diff options
Diffstat (limited to 'internal/system')
| -rw-r--r-- | internal/system/acl.go | 9 | ||||
| -rw-r--r-- | internal/system/dbus.go | 6 | ||||
| -rw-r--r-- | internal/system/dispatcher.go | 10 | ||||
| -rw-r--r-- | internal/system/dispatcher_test.go | 4 | ||||
| -rw-r--r-- | internal/system/link.go | 8 | ||||
| -rw-r--r-- | internal/system/mkdir.go | 9 | ||||
| -rw-r--r-- | internal/system/pipewire.go | 7 | ||||
| -rw-r--r-- | internal/system/system.go | 16 | ||||
| -rw-r--r-- | internal/system/system_test.go | 6 | ||||
| -rw-r--r-- | internal/system/wayland.go | 7 | ||||
| -rw-r--r-- | internal/system/xhost.go | 5 |
11 files changed, 50 insertions, 37 deletions
diff --git a/internal/system/acl.go b/internal/system/acl.go index 4df0d9c1..e91f4eb7 100644 --- a/internal/system/acl.go +++ b/internal/system/acl.go @@ -17,20 +17,21 @@ func (sys *I) UpdatePerm(path *check.Absolute, perms ...acl.Perm) *I { return sys } -// UpdatePermType maintains [acl.Perms] on a file until its [Enablement] is no longer satisfied. -func (sys *I) UpdatePermType(et hst.Enablement, path *check.Absolute, perms ...acl.Perm) *I { +// UpdatePermType maintains [acl.Perms] on a file until its [hst.Enablements] is +// no longer satisfied. +func (sys *I) UpdatePermType(et hst.Enablements, path *check.Absolute, perms ...acl.Perm) *I { sys.ops = append(sys.ops, &aclUpdateOp{et, path.String(), perms}) return sys } // aclUpdateOp implements [I.UpdatePermType]. type aclUpdateOp struct { - et hst.Enablement + et hst.Enablements path string perms acl.Perms } -func (a *aclUpdateOp) Type() hst.Enablement { return a.et } +func (a *aclUpdateOp) Type() hst.Enablements { return a.et } func (a *aclUpdateOp) apply(sys *I) error { sys.msg.Verbose("applying ACL", a) diff --git a/internal/system/dbus.go b/internal/system/dbus.go index 8e2a7ec7..70acdbdb 100644 --- a/internal/system/dbus.go +++ b/internal/system/dbus.go @@ -31,7 +31,9 @@ func (sys *I) MustProxyDBus( } } -// ProxyDBus finalises configuration ahead of time and starts xdg-dbus-proxy via [dbus] and terminates it on revert. +// ProxyDBus finalises configuration ahead of time and starts xdg-dbus-proxy via +// [dbus] and terminates it on revert. +// // This [Op] is always [Process] scoped. func (sys *I) ProxyDBus( session, system *hst.BusConfig, @@ -84,7 +86,7 @@ type dbusProxyOp struct { system bool } -func (d *dbusProxyOp) Type() hst.Enablement { return Process } +func (d *dbusProxyOp) Type() hst.Enablements { return Process } func (d *dbusProxyOp) apply(sys *I) error { sys.msg.Verbosef("session bus proxy on %q for upstream %q", d.final.Session[1], d.final.Session[0]) diff --git a/internal/system/dispatcher.go b/internal/system/dispatcher.go index d9a9fdb9..8f70b0c0 100644 --- a/internal/system/dispatcher.go +++ b/internal/system/dispatcher.go @@ -21,12 +21,16 @@ type osFile interface { fs.File } -// syscallDispatcher provides methods that make state-dependent system calls as part of their behaviour. +// syscallDispatcher provides methods that make state-dependent system calls as +// part of their behaviour. +// // syscallDispatcher is embedded in [I], so all methods must be unexported. type syscallDispatcher interface { // new starts a goroutine with a new instance of syscallDispatcher. - // A syscallDispatcher must never be used in any goroutine other than the one owning it, - // just synchronising access is not enough, as this is for test instrumentation. + // + // A syscallDispatcher must never be used in any goroutine other than the + // one owning it, just synchronising access is not enough, as this is for + // test instrumentation. new(f func(k syscallDispatcher)) // stat provides os.Stat. diff --git a/internal/system/dispatcher_test.go b/internal/system/dispatcher_test.go index 977140ec..3bf14e75 100644 --- a/internal/system/dispatcher_test.go +++ b/internal/system/dispatcher_test.go @@ -27,7 +27,7 @@ func call(name string, args stub.ExpectArgs, ret any, err error) stub.Call { type opBehaviourTestCase struct { name string uid int - ec hst.Enablement + ec hst.Enablements op Op apply []stub.Call @@ -158,7 +158,7 @@ type opMetaTestCase struct { name string op Op - wantType hst.Enablement + wantType hst.Enablements wantPath string wantString string } diff --git a/internal/system/link.go b/internal/system/link.go index 872ac80a..1bf3a1c2 100644 --- a/internal/system/link.go +++ b/internal/system/link.go @@ -12,19 +12,19 @@ func (sys *I) Link(oldname, newname *check.Absolute) *I { return sys.LinkFileType(Process, oldname, newname) } -// LinkFileType maintains a hardlink until its [Enablement] is no longer satisfied. -func (sys *I) LinkFileType(et hst.Enablement, oldname, newname *check.Absolute) *I { +// LinkFileType maintains a hardlink until its [hst.Enablements] is no longer satisfied. +func (sys *I) LinkFileType(et hst.Enablements, oldname, newname *check.Absolute) *I { sys.ops = append(sys.ops, &hardlinkOp{et, newname.String(), oldname.String()}) return sys } // hardlinkOp implements [I.LinkFileType]. type hardlinkOp struct { - et hst.Enablement + et hst.Enablements dst, src string } -func (l *hardlinkOp) Type() hst.Enablement { return l.et } +func (l *hardlinkOp) Type() hst.Enablements { return l.et } func (l *hardlinkOp) apply(sys *I) error { sys.msg.Verbose("linking", l) diff --git a/internal/system/mkdir.go b/internal/system/mkdir.go index cff5d662..81b89d58 100644 --- a/internal/system/mkdir.go +++ b/internal/system/mkdir.go @@ -15,21 +15,22 @@ func (sys *I) Ensure(name *check.Absolute, perm os.FileMode) *I { return sys } -// Ephemeral ensures the existence of a directory until its [Enablement] is no longer satisfied. -func (sys *I) Ephemeral(et hst.Enablement, name *check.Absolute, perm os.FileMode) *I { +// Ephemeral ensures the existence of a directory until its [hst.Enablements] is +// no longer satisfied. +func (sys *I) Ephemeral(et hst.Enablements, name *check.Absolute, perm os.FileMode) *I { sys.ops = append(sys.ops, &mkdirOp{et, name.String(), perm, true}) return sys } // mkdirOp implements [I.Ensure] and [I.Ephemeral]. type mkdirOp struct { - et hst.Enablement + et hst.Enablements path string perm os.FileMode ephemeral bool } -func (m *mkdirOp) Type() hst.Enablement { return m.et } +func (m *mkdirOp) Type() hst.Enablements { return m.et } func (m *mkdirOp) apply(sys *I) error { sys.msg.Verbose("ensuring directory", m) diff --git a/internal/system/pipewire.go b/internal/system/pipewire.go index a78cee26..c2d7b396 100644 --- a/internal/system/pipewire.go +++ b/internal/system/pipewire.go @@ -12,8 +12,9 @@ import ( ) // PipeWire maintains a pipewire socket with SecurityContext attached via [pipewire]. -// The socket stops accepting connections once the pipe referred to by sync is closed. -// The socket is pathname only and is destroyed on revert. +// +// The socket stops accepting connections once the pipe referred to by sync is +// closed. The socket is pathname only and is destroyed on revert. func (sys *I) PipeWire(dst *check.Absolute, appID, instanceID string) *I { sys.ops = append(sys.ops, &pipewireOp{nil, dst, appID, instanceID}) return sys @@ -27,7 +28,7 @@ type pipewireOp struct { appID, instanceID string } -func (p *pipewireOp) Type() hst.Enablement { return Process } +func (p *pipewireOp) Type() hst.Enablements { return Process } func (p *pipewireOp) apply(sys *I) (err error) { var ctx *pipewire.Context diff --git a/internal/system/system.go b/internal/system/system.go index f518975c..1462f818 100644 --- a/internal/system/system.go +++ b/internal/system/system.go @@ -20,21 +20,21 @@ const ( ) // Criteria specifies types of Op to revert. -type Criteria hst.Enablement +type Criteria hst.Enablements -func (ec *Criteria) hasType(t hst.Enablement) bool { +func (ec *Criteria) hasType(t hst.Enablements) bool { // nil criteria: revert everything except User if ec == nil { return t != User } - return hst.Enablement(*ec)&t != 0 + return hst.Enablements(*ec)&t != 0 } // Op is a reversible system operation. type Op interface { // Type returns [Op]'s enablement type, for matching a revert criteria. - Type() hst.Enablement + Type() hst.Enablements apply(sys *I) error revert(sys *I, ec *Criteria) error @@ -44,8 +44,8 @@ type Op interface { String() string } -// TypeString extends [hst.Enablement.String] to support [User] and [Process]. -func TypeString(e hst.Enablement) string { +// TypeString extends [hst.Enablements] to support [User] and [Process]. +func TypeString(e hst.Enablements) string { switch e { case User: return "user" @@ -110,7 +110,9 @@ func (sys *I) Equal(target *I) bool { return true } -// Commit applies all [Op] held by [I] and reverts all successful [Op] on first error encountered. +// Commit applies all [Op] held by [I] and reverts all successful [Op] on first +// error encountered. +// // Commit must not be called more than once. func (sys *I) Commit() error { if sys.committed { diff --git a/internal/system/system_test.go b/internal/system/system_test.go index d0b1154e..b5dec992 100644 --- a/internal/system/system_test.go +++ b/internal/system/system_test.go @@ -20,7 +20,7 @@ func TestCriteria(t *testing.T) { testCases := []struct { name string - ec, t hst.Enablement + ec, t hst.Enablements want bool }{ {"nil", 0xff, hst.EWayland, true}, @@ -47,7 +47,7 @@ func TestTypeString(t *testing.T) { t.Parallel() testCases := []struct { - e hst.Enablement + e hst.Enablements want string }{ {hst.EWayland, hst.EWayland.String()}, @@ -190,7 +190,7 @@ func TestCommitRevert(t *testing.T) { testCases := []struct { name string f func(sys *I) - ec hst.Enablement + ec hst.Enablements commit []stub.Call wantErrCommit error diff --git a/internal/system/wayland.go b/internal/system/wayland.go index ada91167..c22c3fdf 100644 --- a/internal/system/wayland.go +++ b/internal/system/wayland.go @@ -11,8 +11,9 @@ import ( ) // Wayland maintains a wayland socket with security-context-v1 attached via [wayland]. -// The socket stops accepting connections once the pipe referred to by sync is closed. -// The socket is pathname only and is destroyed on revert. +// +// The socket stops accepting connections once the pipe referred to by sync is +// closed. The socket is pathname only and is destroyed on revert. func (sys *I) Wayland(dst, src *check.Absolute, appID, instanceID string) *I { sys.ops = append(sys.ops, &waylandOp{nil, dst, src, appID, instanceID}) @@ -26,7 +27,7 @@ type waylandOp struct { appID, instanceID string } -func (w *waylandOp) Type() hst.Enablement { return Process } +func (w *waylandOp) Type() hst.Enablements { return Process } func (w *waylandOp) apply(sys *I) (err error) { if w.ctx, err = sys.waylandNew(w.src, w.dst, w.appID, w.instanceID); err != nil { diff --git a/internal/system/xhost.go b/internal/system/xhost.go index be44ce1a..f4a520ea 100644 --- a/internal/system/xhost.go +++ b/internal/system/xhost.go @@ -5,7 +5,8 @@ import ( "hakurei.app/internal/xcb" ) -// ChangeHosts inserts the target user into X11 hosts and deletes it once its [Enablement] is no longer satisfied. +// ChangeHosts inserts the target user into X11 hosts and deletes it once its +// [hst.Enablements] is no longer satisfied. func (sys *I) ChangeHosts(username string) *I { sys.ops = append(sys.ops, xhostOp(username)) return sys @@ -14,7 +15,7 @@ func (sys *I) ChangeHosts(username string) *I { // xhostOp implements [I.ChangeHosts]. type xhostOp string -func (x xhostOp) Type() hst.Enablement { return hst.EX11 } +func (x xhostOp) Type() hst.Enablements { return hst.EX11 } func (x xhostOp) apply(sys *I) error { sys.msg.Verbosef("inserting entry %s to X11", x) |
