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 }