diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-11-13 01:15:19 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-11-13 01:17:47 +0900 |
| commit | 4e7aab07d5b175345fdf3ea08868dab1e6d90126 (patch) | |
| tree | a625cca0e8cdf576313fe2d9ab07a22d1839ee7c | |
| parent | 15a66a2b314e7a674c9445e25ffb2451ec73b55e (diff) | |
internal/system: relocate from system
These packages are highly specific to hakurei and are difficult to use safely from other pieces of code.
Their exported symbols are made available until v0.4.0 where they will be removed for #24.
Signed-off-by: Ophestra <cat@gensokyo.uk>
| -rw-r--r-- | internal/system/acl.go (renamed from system/acl.go) | 2 | ||||
| -rw-r--r-- | internal/system/acl/acl.go (renamed from system/acl/acl.go) | 0 | ||||
| -rw-r--r-- | internal/system/acl/acl_test.go (renamed from system/acl/acl_test.go) | 2 | ||||
| -rw-r--r-- | internal/system/acl/libacl-helper.c (renamed from system/acl/libacl-helper.c) | 0 | ||||
| -rw-r--r-- | internal/system/acl/libacl-helper.go (renamed from system/acl/libacl-helper.go) | 0 | ||||
| -rw-r--r-- | internal/system/acl/libacl-helper.h (renamed from system/acl/libacl-helper.h) | 0 | ||||
| -rw-r--r-- | internal/system/acl/libacl-helper_test.go (renamed from system/acl/libacl-helper_test.go) | 0 | ||||
| -rw-r--r-- | internal/system/acl/perms.go (renamed from system/acl/perms.go) | 0 | ||||
| -rw-r--r-- | internal/system/acl/perms_test.go (renamed from system/acl/perms_test.go) | 2 | ||||
| -rw-r--r-- | internal/system/acl_test.go (renamed from system/acl_test.go) | 2 | ||||
| -rw-r--r-- | internal/system/dbus.go (renamed from system/dbus.go) | 2 | ||||
| -rw-r--r-- | internal/system/dbus/address.go (renamed from system/dbus/address.go) | 0 | ||||
| -rw-r--r-- | internal/system/dbus/address_escape_test.go (renamed from system/dbus/address_escape_test.go) | 0 | ||||
| -rw-r--r-- | internal/system/dbus/address_test.go (renamed from system/dbus/address_test.go) | 2 | ||||
| -rw-r--r-- | internal/system/dbus/config.go (renamed from system/dbus/config.go) | 0 | ||||
| -rw-r--r-- | internal/system/dbus/config_test.go (renamed from system/dbus/config_test.go) | 2 | ||||
| -rw-r--r-- | internal/system/dbus/dbus.go (renamed from system/dbus/dbus.go) | 0 | ||||
| -rw-r--r-- | internal/system/dbus/dbus_test.go (renamed from system/dbus/dbus_test.go) | 2 | ||||
| -rw-r--r-- | internal/system/dbus/export_test.go (renamed from system/dbus/export_test.go) | 0 | ||||
| -rw-r--r-- | internal/system/dbus/proc.go (renamed from system/dbus/proc.go) | 0 | ||||
| -rw-r--r-- | internal/system/dbus/proc_test.go (renamed from system/dbus/proc_test.go) | 0 | ||||
| -rw-r--r-- | internal/system/dbus/proxy.go (renamed from system/dbus/proxy.go) | 0 | ||||
| -rw-r--r-- | internal/system/dbus/samples_test.go (renamed from system/dbus/samples_test.go) | 0 | ||||
| -rw-r--r-- | internal/system/dbus/testdata/dev.vencord.Vesktop.json (renamed from system/dbus/testdata/dev.vencord.Vesktop.json) | 0 | ||||
| -rw-r--r-- | internal/system/dbus/testdata/org.chromium.Chromium+.json (renamed from system/dbus/testdata/org.chromium.Chromium+.json) | 0 | ||||
| -rw-r--r-- | internal/system/dbus/testdata/org.chromium.Chromium.json (renamed from system/dbus/testdata/org.chromium.Chromium.json) | 0 | ||||
| -rw-r--r-- | internal/system/dbus/testdata/uk.gensokyo.CrashTestDummy.json (renamed from system/dbus/testdata/uk.gensokyo.CrashTestDummy.json) | 0 | ||||
| -rw-r--r-- | internal/system/dbus_test.go (renamed from system/dbus_test.go) | 2 | ||||
| -rw-r--r-- | internal/system/dispatcher.go (renamed from system/dispatcher.go) | 6 | ||||
| -rw-r--r-- | internal/system/dispatcher_test.go (renamed from system/dispatcher_test.go) | 6 | ||||
| -rw-r--r-- | internal/system/link.go (renamed from system/link.go) | 0 | ||||
| -rw-r--r-- | internal/system/link_test.go (renamed from system/link_test.go) | 0 | ||||
| -rw-r--r-- | internal/system/mkdir.go (renamed from system/mkdir.go) | 0 | ||||
| -rw-r--r-- | internal/system/mkdir_test.go (renamed from system/mkdir_test.go) | 0 | ||||
| -rw-r--r-- | internal/system/output.go (renamed from system/output.go) | 0 | ||||
| -rw-r--r-- | internal/system/output_test.go (renamed from system/output_test.go) | 0 | ||||
| -rw-r--r-- | internal/system/system.go (renamed from system/system.go) | 2 | ||||
| -rw-r--r-- | internal/system/system_test.go (renamed from system/system_test.go) | 2 | ||||
| -rw-r--r-- | internal/system/wayland.go (renamed from system/wayland.go) | 4 | ||||
| -rw-r--r-- | internal/system/wayland/conn.go (renamed from system/wayland/conn.go) | 1 | ||||
| -rw-r--r-- | internal/system/wayland/security-context-v1-protocol.c (renamed from system/wayland/security-context-v1-protocol.c) | 0 | ||||
| -rw-r--r-- | internal/system/wayland/security-context-v1-protocol.h (renamed from system/wayland/security-context-v1-protocol.h) | 0 | ||||
| -rw-r--r-- | internal/system/wayland/wayland-client-helper.c (renamed from system/wayland/wayland-client-helper.c) | 0 | ||||
| -rw-r--r-- | internal/system/wayland/wayland-client-helper.h (renamed from system/wayland/wayland-client-helper.h) | 0 | ||||
| -rw-r--r-- | internal/system/wayland/wayland.go (renamed from system/wayland/wayland.go) | 20 | ||||
| -rw-r--r-- | internal/system/wayland_test.go (renamed from system/wayland_test.go) | 4 | ||||
| -rw-r--r-- | internal/system/xcb/changehosts.go (renamed from system/internal/xcb/changehosts.go) | 0 | ||||
| -rw-r--r-- | internal/system/xcb/xcb.go (renamed from system/internal/xcb/xcb.go) | 0 | ||||
| -rw-r--r-- | internal/system/xhost.go (renamed from system/xhost.go) | 2 | ||||
| -rw-r--r-- | internal/system/xhost_test.go (renamed from system/xhost_test.go) | 2 | ||||
| -rw-r--r-- | system/acl/deprecated.go | 25 | ||||
| -rw-r--r-- | system/dbus/deprecated.go | 115 | ||||
| -rw-r--r-- | system/deprecated.go | 50 | ||||
| -rw-r--r-- | system/wayland/deprecated.go (renamed from system/wayland/consts.go) | 16 |
54 files changed, 243 insertions, 30 deletions
diff --git a/system/acl.go b/internal/system/acl.go index c89a4780..854e812b 100644 --- a/system/acl.go +++ b/internal/system/acl.go @@ -8,7 +8,7 @@ import ( "hakurei.app/container/check" "hakurei.app/hst" - "hakurei.app/system/acl" + "hakurei.app/internal/system/acl" ) // UpdatePerm calls UpdatePermType with the [Process] criteria. diff --git a/system/acl/acl.go b/internal/system/acl/acl.go index 366ad533..366ad533 100644 --- a/system/acl/acl.go +++ b/internal/system/acl/acl.go diff --git a/system/acl/acl_test.go b/internal/system/acl/acl_test.go index c6c3e562..b0dd58d7 100644 --- a/system/acl/acl_test.go +++ b/internal/system/acl/acl_test.go @@ -13,7 +13,7 @@ import ( "strconv" "testing" - "hakurei.app/system/acl" + "hakurei.app/internal/system/acl" ) const testFileName = "acl.test" diff --git a/system/acl/libacl-helper.c b/internal/system/acl/libacl-helper.c index d1df8167..d1df8167 100644 --- a/system/acl/libacl-helper.c +++ b/internal/system/acl/libacl-helper.c diff --git a/system/acl/libacl-helper.go b/internal/system/acl/libacl-helper.go index 22575296..22575296 100644 --- a/system/acl/libacl-helper.go +++ b/internal/system/acl/libacl-helper.go diff --git a/system/acl/libacl-helper.h b/internal/system/acl/libacl-helper.h index b86eb170..b86eb170 100644 --- a/system/acl/libacl-helper.h +++ b/internal/system/acl/libacl-helper.h diff --git a/system/acl/libacl-helper_test.go b/internal/system/acl/libacl-helper_test.go index 13d23a3c..13d23a3c 100644 --- a/system/acl/libacl-helper_test.go +++ b/internal/system/acl/libacl-helper_test.go diff --git a/system/acl/perms.go b/internal/system/acl/perms.go index fbc99e82..fbc99e82 100644 --- a/system/acl/perms.go +++ b/internal/system/acl/perms.go diff --git a/system/acl/perms_test.go b/internal/system/acl/perms_test.go index 16b282a7..3d5e3df5 100644 --- a/system/acl/perms_test.go +++ b/internal/system/acl/perms_test.go @@ -3,7 +3,7 @@ package acl_test import ( "testing" - "hakurei.app/system/acl" + "hakurei.app/internal/system/acl" ) func TestPerms(t *testing.T) { diff --git a/system/acl_test.go b/internal/system/acl_test.go index 2202d957..1fc3b1a2 100644 --- a/system/acl_test.go +++ b/internal/system/acl_test.go @@ -7,7 +7,7 @@ import ( "hakurei.app/container/stub" "hakurei.app/hst" - "hakurei.app/system/acl" + "hakurei.app/internal/system/acl" ) func TestACLUpdateOp(t *testing.T) { diff --git a/system/dbus.go b/internal/system/dbus.go index 424f9dfa..b9021b81 100644 --- a/system/dbus.go +++ b/internal/system/dbus.go @@ -13,7 +13,7 @@ import ( "hakurei.app/container" "hakurei.app/hst" - "hakurei.app/system/dbus" + "hakurei.app/internal/system/dbus" ) // ErrDBusConfig is returned when a required [hst.BusConfig] argument is nil. diff --git a/system/dbus/address.go b/internal/system/dbus/address.go index edee7e20..edee7e20 100644 --- a/system/dbus/address.go +++ b/internal/system/dbus/address.go diff --git a/system/dbus/address_escape_test.go b/internal/system/dbus/address_escape_test.go index 4ef48f8b..4ef48f8b 100644 --- a/system/dbus/address_escape_test.go +++ b/internal/system/dbus/address_escape_test.go diff --git a/system/dbus/address_test.go b/internal/system/dbus/address_test.go index 5de90535..9ed48214 100644 --- a/system/dbus/address_test.go +++ b/internal/system/dbus/address_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "hakurei.app/system/dbus" + "hakurei.app/internal/system/dbus" ) func TestParse(t *testing.T) { diff --git a/system/dbus/config.go b/internal/system/dbus/config.go index 2a09ee90..2a09ee90 100644 --- a/system/dbus/config.go +++ b/internal/system/dbus/config.go diff --git a/system/dbus/config_test.go b/internal/system/dbus/config_test.go index 644c766f..dec4cb16 100644 --- a/system/dbus/config_test.go +++ b/internal/system/dbus/config_test.go @@ -7,7 +7,7 @@ import ( "testing" "hakurei.app/hst" - "hakurei.app/system/dbus" + "hakurei.app/internal/system/dbus" ) func TestConfigArgs(t *testing.T) { diff --git a/system/dbus/dbus.go b/internal/system/dbus/dbus.go index 9ea89f51..9ea89f51 100644 --- a/system/dbus/dbus.go +++ b/internal/system/dbus/dbus.go diff --git a/system/dbus/dbus_test.go b/internal/system/dbus/dbus_test.go index 3a9af578..9fc2b539 100644 --- a/system/dbus/dbus_test.go +++ b/internal/system/dbus/dbus_test.go @@ -12,8 +12,8 @@ import ( "time" "hakurei.app/internal/helper" + "hakurei.app/internal/system/dbus" "hakurei.app/message" - "hakurei.app/system/dbus" ) func TestFinalise(t *testing.T) { diff --git a/system/dbus/export_test.go b/internal/system/dbus/export_test.go index bc24f3f3..bc24f3f3 100644 --- a/system/dbus/export_test.go +++ b/internal/system/dbus/export_test.go diff --git a/system/dbus/proc.go b/internal/system/dbus/proc.go index 0bd9c6b3..0bd9c6b3 100644 --- a/system/dbus/proc.go +++ b/internal/system/dbus/proc.go diff --git a/system/dbus/proc_test.go b/internal/system/dbus/proc_test.go index 544856ed..544856ed 100644 --- a/system/dbus/proc_test.go +++ b/internal/system/dbus/proc_test.go diff --git a/system/dbus/proxy.go b/internal/system/dbus/proxy.go index 9de49c41..9de49c41 100644 --- a/system/dbus/proxy.go +++ b/internal/system/dbus/proxy.go diff --git a/system/dbus/samples_test.go b/internal/system/dbus/samples_test.go index 7db3d6b9..7db3d6b9 100644 --- a/system/dbus/samples_test.go +++ b/internal/system/dbus/samples_test.go diff --git a/system/dbus/testdata/dev.vencord.Vesktop.json b/internal/system/dbus/testdata/dev.vencord.Vesktop.json index 05259774..05259774 100644 --- a/system/dbus/testdata/dev.vencord.Vesktop.json +++ b/internal/system/dbus/testdata/dev.vencord.Vesktop.json diff --git a/system/dbus/testdata/org.chromium.Chromium+.json b/internal/system/dbus/testdata/org.chromium.Chromium+.json index 0a27d719..0a27d719 100644 --- a/system/dbus/testdata/org.chromium.Chromium+.json +++ b/internal/system/dbus/testdata/org.chromium.Chromium+.json diff --git a/system/dbus/testdata/org.chromium.Chromium.json b/internal/system/dbus/testdata/org.chromium.Chromium.json index be027f39..be027f39 100644 --- a/system/dbus/testdata/org.chromium.Chromium.json +++ b/internal/system/dbus/testdata/org.chromium.Chromium.json diff --git a/system/dbus/testdata/uk.gensokyo.CrashTestDummy.json b/internal/system/dbus/testdata/uk.gensokyo.CrashTestDummy.json index 43272f67..43272f67 100644 --- a/system/dbus/testdata/uk.gensokyo.CrashTestDummy.json +++ b/internal/system/dbus/testdata/uk.gensokyo.CrashTestDummy.json diff --git a/system/dbus_test.go b/internal/system/dbus_test.go index eedb2335..f79c8482 100644 --- a/system/dbus_test.go +++ b/internal/system/dbus_test.go @@ -12,7 +12,7 @@ import ( "hakurei.app/container/stub" "hakurei.app/hst" "hakurei.app/internal/helper" - "hakurei.app/system/dbus" + "hakurei.app/internal/system/dbus" ) func TestDBusProxyOp(t *testing.T) { diff --git a/system/dispatcher.go b/internal/system/dispatcher.go index cdc95072..86aebcaa 100644 --- a/system/dispatcher.go +++ b/internal/system/dispatcher.go @@ -7,9 +7,9 @@ import ( "os" "hakurei.app/hst" - "hakurei.app/system/acl" - "hakurei.app/system/dbus" - "hakurei.app/system/internal/xcb" + "hakurei.app/internal/system/acl" + "hakurei.app/internal/system/dbus" + "hakurei.app/internal/system/xcb" ) type osFile interface { diff --git a/system/dispatcher_test.go b/internal/system/dispatcher_test.go index fd6e5d09..8000f0c7 100644 --- a/system/dispatcher_test.go +++ b/internal/system/dispatcher_test.go @@ -10,9 +10,9 @@ import ( "hakurei.app/container/stub" "hakurei.app/hst" - "hakurei.app/system/acl" - "hakurei.app/system/dbus" - "hakurei.app/system/internal/xcb" + "hakurei.app/internal/system/acl" + "hakurei.app/internal/system/dbus" + "hakurei.app/internal/system/xcb" ) // call initialises a [stub.Call]. diff --git a/system/link.go b/internal/system/link.go index a13adaae..a13adaae 100644 --- a/system/link.go +++ b/internal/system/link.go diff --git a/system/link_test.go b/internal/system/link_test.go index d719931f..d719931f 100644 --- a/system/link_test.go +++ b/internal/system/link_test.go diff --git a/system/mkdir.go b/internal/system/mkdir.go index f375579c..f375579c 100644 --- a/system/mkdir.go +++ b/internal/system/mkdir.go diff --git a/system/mkdir_test.go b/internal/system/mkdir_test.go index e8ffde2a..e8ffde2a 100644 --- a/system/mkdir_test.go +++ b/internal/system/mkdir_test.go diff --git a/system/output.go b/internal/system/output.go index 71acace4..71acace4 100644 --- a/system/output.go +++ b/internal/system/output.go diff --git a/system/output_test.go b/internal/system/output_test.go index c0cbfdfe..c0cbfdfe 100644 --- a/system/output_test.go +++ b/internal/system/output_test.go diff --git a/system/system.go b/internal/system/system.go index cadaab04..f518975c 100644 --- a/system/system.go +++ b/internal/system/system.go @@ -44,7 +44,7 @@ type Op interface { String() string } -// TypeString extends [Enablement.String] to support [User] and [Process]. +// TypeString extends [hst.Enablement.String] to support [User] and [Process]. func TypeString(e hst.Enablement) string { switch e { case User: diff --git a/system/system_test.go b/internal/system/system_test.go index 83df9dee..b0773b0f 100644 --- a/system/system_test.go +++ b/internal/system/system_test.go @@ -11,8 +11,8 @@ import ( "hakurei.app/container/check" "hakurei.app/container/stub" "hakurei.app/hst" + "hakurei.app/internal/system/xcb" "hakurei.app/message" - "hakurei.app/system/internal/xcb" ) func TestCriteria(t *testing.T) { diff --git a/system/wayland.go b/internal/system/wayland.go index bb144d8c..8883148e 100644 --- a/system/wayland.go +++ b/internal/system/wayland.go @@ -7,8 +7,8 @@ import ( "hakurei.app/container/check" "hakurei.app/hst" - "hakurei.app/system/acl" - "hakurei.app/system/wayland" + "hakurei.app/internal/system/acl" + "hakurei.app/internal/system/wayland" ) type waylandConn interface { diff --git a/system/wayland/conn.go b/internal/system/wayland/conn.go index 86e0a288..c55fe704 100644 --- a/system/wayland/conn.go +++ b/internal/system/wayland/conn.go @@ -1,4 +1,3 @@ -// Package wayland implements Wayland security_context_v1 protocol. package wayland import ( diff --git a/system/wayland/security-context-v1-protocol.c b/internal/system/wayland/security-context-v1-protocol.c index 5b15b1b4..5b15b1b4 100644 --- a/system/wayland/security-context-v1-protocol.c +++ b/internal/system/wayland/security-context-v1-protocol.c diff --git a/system/wayland/security-context-v1-protocol.h b/internal/system/wayland/security-context-v1-protocol.h index f973619e..f973619e 100644 --- a/system/wayland/security-context-v1-protocol.h +++ b/internal/system/wayland/security-context-v1-protocol.h diff --git a/system/wayland/wayland-client-helper.c b/internal/system/wayland/wayland-client-helper.c index 5a2c9a01..5a2c9a01 100644 --- a/system/wayland/wayland-client-helper.c +++ b/internal/system/wayland/wayland-client-helper.c diff --git a/system/wayland/wayland-client-helper.h b/internal/system/wayland/wayland-client-helper.h index eae8936d..eae8936d 100644 --- a/system/wayland/wayland-client-helper.h +++ b/internal/system/wayland/wayland-client-helper.h diff --git a/system/wayland/wayland.go b/internal/system/wayland/wayland.go index 2aa1fe15..7a8694cd 100644 --- a/system/wayland/wayland.go +++ b/internal/system/wayland/wayland.go @@ -1,3 +1,4 @@ +// Package wayland implements Wayland security_context_v1 protocol. package wayland //go:generate sh -c "wayland-scanner client-header `pkg-config --variable=datarootdir wayland-protocols`/wayland-protocols/staging/security-context/security-context-v1.xml security-context-v1-protocol.h" @@ -13,10 +14,21 @@ import "C" import ( "errors" "strings" + "syscall" ) -var ( - ErrContainsNull = errors.New("string contains null character") +const ( + // Display contains the name of the server socket + // (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1147) + // which is concatenated with XDG_RUNTIME_DIR + // (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1171) + // or used as-is if absolute + // (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1176). + Display = "WAYLAND_DISPLAY" + + // FallbackName is used as the wayland socket name if WAYLAND_DISPLAY is unset + // (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1149). + FallbackName = "wayland-0" ) var resErr = [...]error{ @@ -27,10 +39,10 @@ var resErr = [...]error{ func bindWaylandFd(socketPath string, fd uintptr, appID, instanceID string, syncFd uintptr) error { if hasNull(appID) || hasNull(instanceID) { - return ErrContainsNull + return syscall.EINVAL } res := C.hakurei_bind_wayland_fd(C.CString(socketPath), C.int(fd), C.CString(appID), C.CString(instanceID), C.int(syncFd)) return resErr[int32(res)] } -func hasNull(s string) bool { return strings.IndexByte(s, '\x00') > -1 } +func hasNull(s string) bool { return strings.IndexByte(s, 0) > -1 } diff --git a/system/wayland_test.go b/internal/system/wayland_test.go index 6805b0c2..083c8ba7 100644 --- a/system/wayland_test.go +++ b/internal/system/wayland_test.go @@ -6,8 +6,8 @@ import ( "testing" "hakurei.app/container/stub" - "hakurei.app/system/acl" - "hakurei.app/system/wayland" + "hakurei.app/internal/system/acl" + "hakurei.app/internal/system/wayland" ) type stubWaylandConn struct { diff --git a/system/internal/xcb/changehosts.go b/internal/system/xcb/changehosts.go index 8b05614b..8b05614b 100644 --- a/system/internal/xcb/changehosts.go +++ b/internal/system/xcb/changehosts.go diff --git a/system/internal/xcb/xcb.go b/internal/system/xcb/xcb.go index 3dc62c3f..3dc62c3f 100644 --- a/system/internal/xcb/xcb.go +++ b/internal/system/xcb/xcb.go diff --git a/system/xhost.go b/internal/system/xhost.go index 9a547f43..27e60c2b 100644 --- a/system/xhost.go +++ b/internal/system/xhost.go @@ -2,7 +2,7 @@ package system import ( "hakurei.app/hst" - "hakurei.app/system/internal/xcb" + "hakurei.app/internal/system/xcb" ) // ChangeHosts inserts the target user into X11 hosts and deletes it once its [Enablement] is no longer satisfied. diff --git a/system/xhost_test.go b/internal/system/xhost_test.go index 759f7536..853da651 100644 --- a/system/xhost_test.go +++ b/internal/system/xhost_test.go @@ -5,7 +5,7 @@ import ( "hakurei.app/container/stub" "hakurei.app/hst" - "hakurei.app/system/internal/xcb" + "hakurei.app/internal/system/xcb" ) func TestXHostOp(t *testing.T) { diff --git a/system/acl/deprecated.go b/system/acl/deprecated.go new file mode 100644 index 00000000..4119057b --- /dev/null +++ b/system/acl/deprecated.go @@ -0,0 +1,25 @@ +// Package acl exposes the internal/system/acl package. +// +// Deprecated: This package will be removed in 0.4. +package acl + +import ( + _ "unsafe" // for go:linkname + + "hakurei.app/internal/system/acl" +) + +type Perm = acl.Perm + +const ( + Read = acl.Read + Write = acl.Write + Execute = acl.Execute +) + +// Update replaces ACL_USER entry with qualifier uid. +// +//go:linkname Update hakurei.app/internal/system/acl.Update +func Update(name string, uid int, perms ...Perm) error + +type Perms = acl.Perms diff --git a/system/dbus/deprecated.go b/system/dbus/deprecated.go new file mode 100644 index 00000000..67a309c2 --- /dev/null +++ b/system/dbus/deprecated.go @@ -0,0 +1,115 @@ +// Package dbus exposes the internal/system/dbus package. +// +// Deprecated: This package will be removed in 0.4. +package dbus + +import ( + "context" + "io" + _ "unsafe" // for go:linkname + + "hakurei.app/hst" + "hakurei.app/internal/system/dbus" + "hakurei.app/message" +) + +type AddrEntry = dbus.AddrEntry + +// EqualAddrEntries returns whether two slices of [AddrEntry] are equal. +// +//go:linkname EqualAddrEntries hakurei.app/internal/system/dbus.EqualAddrEntries +func EqualAddrEntries(entries, target []AddrEntry) bool + +// Parse parses D-Bus address according to +// https://dbus.freedesktop.org/doc/dbus-specification.html#addresses +// +//go:linkname Parse hakurei.app/internal/system/dbus.Parse +func Parse(addr []byte) ([]AddrEntry, error) + +type ParseError = dbus.ParseError + +const ( + ErrNoColon = dbus.ErrNoColon + ErrBadPairSep = dbus.ErrBadPairSep + ErrBadPairKey = dbus.ErrBadPairKey + ErrBadPairVal = dbus.ErrBadPairVal + ErrBadValLength = dbus.ErrBadValLength + ErrBadValByte = dbus.ErrBadValByte + ErrBadValHexLength = dbus.ErrBadValHexLength + ErrBadValHexByte = dbus.ErrBadValHexByte +) + +type BadAddressError = dbus.BadAddressError + +// ProxyPair is an upstream dbus address and a downstream socket path. +type ProxyPair = dbus.ProxyPair + +// Args returns the xdg-dbus-proxy arguments equivalent of [hst.BusConfig]. +// +//go:linkname Args hakurei.app/internal/system/dbus.Args +func Args(c *hst.BusConfig, bus ProxyPair) (args []string) + +// NewConfig returns the address of a new [hst.BusConfig] with optional defaults. +// +//go:linkname NewConfig hakurei.app/internal/system/dbus.NewConfig +func NewConfig(id string, defaults, mpris bool) *hst.BusConfig + +const ( + /* + SessionBusAddress is the name of the environment variable where the address of the login session message bus is given in. + + If that variable is not set, applications may also try to read the address from the X Window System root window property _DBUS_SESSION_BUS_ADDRESS. + The root window property must have type STRING. The environment variable should have precedence over the root window property. + + The address of the login session message bus is given in the DBUS_SESSION_BUS_ADDRESS environment variable. + If DBUS_SESSION_BUS_ADDRESS is not set, or if it's set to the string "autolaunch:", + the system should use platform-specific methods of locating a running D-Bus session server, + or starting one if a running instance cannot be found. + Note that this mechanism is not recommended for attempting to determine if a daemon is running. + It is inherently racy to attempt to make this determination, since the bus daemon may be started just before or just after the determination is made. + Therefore, it is recommended that applications do not try to make this determination for their functionality purposes, and instead they should attempt to start the server. + + This package diverges from the specification, as the caller is unlikely to be an X client, or be in a position to autolaunch a dbus server. + So a fallback address with a socket located in the well-known default XDG_RUNTIME_DIR formatting is used. + */ + SessionBusAddress = dbus.SessionBusAddress + + /* + SystemBusAddress is the name of the environment variable where the address of the system message bus is given in. + + If that variable is not set, applications should try to connect to the well-known address unix:path=/var/run/dbus/system_bus_socket. + Implementations of the well-known system bus should listen on an address that will result in that connection being successful. + */ + SystemBusAddress = dbus.SystemBusAddress + + // FallbackSystemBusAddress is used when [SystemBusAddress] is not set. + FallbackSystemBusAddress = dbus.FallbackSystemBusAddress +) + +// Address returns the session and system bus addresses copied from environment, +// or appropriate fallback values if they are not set. +// +//go:linkname Address hakurei.app/internal/system/dbus.Address +func Address() (session, system string) + +// ProxyName is the file name or path to the proxy program. +// Overriding ProxyName will only affect Proxy instance created after the change. +// +//go:linkname ProxyName hakurei.app/internal/system/dbus.ProxyName +var ProxyName string + +// Proxy holds the state of a xdg-dbus-proxy process, and should never be copied. +type Proxy = dbus.Proxy + +// Final describes the outcome of a proxy configuration. +type Final = dbus.Final + +// Finalise creates a checked argument writer for [Proxy]. +// +//go:linkname Finalise hakurei.app/internal/system/dbus.Finalise +func Finalise(sessionBus, systemBus ProxyPair, session, system *hst.BusConfig) (final *Final, err error) + +// New returns a new instance of [Proxy]. +// +//go:linkname New hakurei.app/internal/system/dbus.New +func New(ctx context.Context, msg message.Msg, final *Final, output io.Writer) *Proxy diff --git a/system/deprecated.go b/system/deprecated.go new file mode 100644 index 00000000..3f0a423d --- /dev/null +++ b/system/deprecated.go @@ -0,0 +1,50 @@ +// Package system exposes the internal/system package. +// +// Deprecated: This package will be removed in 0.4. +package system + +import ( + "context" + _ "unsafe" // for go:linkname + + "hakurei.app/hst" + "hakurei.app/internal/system" + "hakurei.app/message" +) + +// ErrDBusConfig is returned when a required hst.BusConfig argument is nil. +// +//go:linkname ErrDBusConfig hakurei.app/internal/system.ErrDBusConfig +var ErrDBusConfig error + +// OpError is returned by [I.Commit] and [I.Revert]. +type OpError = system.OpError + +const ( + // User type is reverted at final instance exit. + User = system.User + // Process type is unconditionally reverted on exit. + Process = system.Process + + CM = system.CM +) + +// Criteria specifies types of Op to revert. +type Criteria = system.Criteria + +// Op is a reversible system operation. +type Op = system.Op + +// TypeString extends [Enablement.String] to support [User] and [Process]. +// +//go:linkname TypeString hakurei.app/internal/system.TypeString +func TypeString(e hst.Enablement) string + +// New returns the address of a new [I] targeting uid. +// +//go:linkname New hakurei.app/internal/system.New +func New(ctx context.Context, msg message.Msg, uid int) (sys *I) + +// An I provides deferred operating system interaction. [I] must not be copied. +// Methods of [I] must not be used concurrently. +type I = system.I diff --git a/system/wayland/consts.go b/system/wayland/deprecated.go index 672e6392..bf364d9a 100644 --- a/system/wayland/consts.go +++ b/system/wayland/deprecated.go @@ -1,5 +1,17 @@ +// Package wayland exposes the internal/system/wayland package. +// +// Deprecated: This package will be removed in 0.4. package wayland +import ( + _ "unsafe" // for go:linkname + + "hakurei.app/internal/system/wayland" +) + +// Conn represents a connection to the wayland display server. +type Conn = wayland.Conn + const ( // WaylandDisplay contains the name of the server socket // (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1147) @@ -7,9 +19,9 @@ const ( // (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1171) // or used as-is if absolute // (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1176). - WaylandDisplay = "WAYLAND_DISPLAY" + WaylandDisplay = wayland.Display // FallbackName is used as the wayland socket name if WAYLAND_DISPLAY is unset // (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1149). - FallbackName = "wayland-0" + FallbackName = wayland.FallbackName ) |
