From 2ff03591fef8f1412c39963ac5afb1694cc2067e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Noack?= Date: Thu, 4 Jul 2024 19:14:13 +0200 Subject: [PATCH] syscall: Rename NetServiceAttr to NetPortAttr This was originally named in line with an earlier, unstable version of the networking support, and I missed to update it. We do not give backwards compatibility guarantees on the syscall module, but I was unable to find direct dependencies on it on the internet. If this breaks you, please reach out with a Github issue. --- landlock/net_opt.go | 4 ++-- landlock/syscall/landlock.go | 4 ++-- landlock/syscall/syscall_linux.go | 8 ++++---- landlock/syscall/syscall_nonlinux.go | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/landlock/net_opt.go b/landlock/net_opt.go index 5598ee2..0de167d 100644 --- a/landlock/net_opt.go +++ b/landlock/net_opt.go @@ -45,11 +45,11 @@ func (n NetRule) compatibleWithConfig(c Config) bool { func (n NetRule) addToRuleset(rulesetFD int, c Config) error { flags := 0 - attr := &ll.NetServiceAttr{ + attr := &ll.NetPortAttr{ AllowedAccess: uint64(n.access), Port: n.port, } - return ll.LandlockAddNetServiceRule(rulesetFD, attr, flags) + return ll.LandlockAddNetPortRule(rulesetFD, attr, flags) } func (n NetRule) downgrade(c Config) (out Rule, ok bool) { diff --git a/landlock/syscall/landlock.go b/landlock/syscall/landlock.go index 48bc657..f12dad6 100644 --- a/landlock/syscall/landlock.go +++ b/landlock/syscall/landlock.go @@ -72,8 +72,8 @@ type PathBeneathAttr struct { ParentFd int } -// NetServiceAttr specifies which ports can be used for what. -type NetServiceAttr struct { +// NetPortAttr specifies which ports can be used for what. +type NetPortAttr struct { AllowedAccess uint64 Port uint16 } diff --git a/landlock/syscall/syscall_linux.go b/landlock/syscall/syscall_linux.go index 8a78980..5cb271d 100644 --- a/landlock/syscall/syscall_linux.go +++ b/landlock/syscall/syscall_linux.go @@ -34,7 +34,7 @@ func LandlockGetABIVersion() (version int, err error) { // Landlock rule types. const ( RuleTypePathBeneath = unix.LANDLOCK_RULE_PATH_BENEATH - RuleTypeNetService = 2 // TODO: Use it from sys/unix when available. + RuleTypeNetPort = 2 // TODO: Use it from sys/unix when available. ) // LandlockAddPathBeneathRule adds a rule of type "path beneath" to @@ -44,10 +44,10 @@ func LandlockAddPathBeneathRule(rulesetFd int, attr *PathBeneathAttr, flags int) return LandlockAddRule(rulesetFd, RuleTypePathBeneath, unsafe.Pointer(attr), flags) } -// LandlockAddNetServiceRule adds a rule of type "net service" to the given ruleset FD. +// LandlockAddNetPortRule adds a rule of type "net port" to the given ruleset FD. // attr defines the rule parameters. flags must currently be 0. -func LandlockAddNetServiceRule(rulesetFD int, attr *NetServiceAttr, flags int) error { - return LandlockAddRule(rulesetFD, RuleTypeNetService, unsafe.Pointer(attr), flags) +func LandlockAddNetPortRule(rulesetFD int, attr *NetPortAttr, flags int) error { + return LandlockAddRule(rulesetFD, RuleTypeNetPort, unsafe.Pointer(attr), flags) } // LandlockAddRule is the generic landlock_add_rule syscall. diff --git a/landlock/syscall/syscall_nonlinux.go b/landlock/syscall/syscall_nonlinux.go index c8ec3ff..c3830c1 100644 --- a/landlock/syscall/syscall_nonlinux.go +++ b/landlock/syscall/syscall_nonlinux.go @@ -23,7 +23,7 @@ func LandlockAddPathBeneathRule(rulesetFd int, attr *PathBeneathAttr, flags int) return syscall.ENOSYS } -func LandlockAddNetServiceRule(rulesetFD int, attr *NetServiceAttr, flags int) error { +func LandlockAddNetPortRule(rulesetFD int, attr *NetServiceAttr, flags int) error { return syscall.ENOSYS }