Skip to content

Commit

Permalink
syscall: Rename NetServiceAttr to NetPortAttr
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gnoack committed Jul 4, 2024
1 parent 83b9c6e commit 2ff0359
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions landlock/net_opt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions landlock/syscall/landlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 4 additions & 4 deletions landlock/syscall/syscall_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion landlock/syscall/syscall_nonlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Check failure on line 26 in landlock/syscall/syscall_nonlinux.go

View workflow job for this annotation

GitHub Actions / Go Tests (macos-latest, 1.20)

undefined: NetServiceAttr
return syscall.ENOSYS
}

Expand Down

0 comments on commit 2ff0359

Please sign in to comment.