Commit Graph

124 Commits

Author SHA1 Message Date
Ophestra Umiker 1038af98f0
dbus: add tests
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-28 00:06:16 +09:00
Ophestra Umiker aa2be18f47
dbus/config: implement file loading functions
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-27 23:53:08 +09:00
Ophestra Umiker 84d8c27b5f
dbus: return exported error for nil config
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-27 23:52:38 +09:00
Ophestra Umiker ee2f5ed6ac
dbus/config: remove unused method
Null checking is replaced by helper/args while string building is no longer required.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-27 12:04:28 +09:00
Ophestra Umiker 8492239cba
helper/args: simplify argument parsing and eliminate excess memory copies
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-25 14:00:30 +09:00
Ophestra Umiker a8b4b3634b
dbus: use generalised helper.Helper for xdg-dbus-proxy
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-25 01:17:38 +09:00
Ophestra Umiker 97bab6c406
helper: clean up and separate helper process management from dbus
The previous code was poorly documented and made little sense in some parts. This is a generalised and cleaned up implementation in the helper package making use of the Args interface.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-25 01:16:06 +09:00
Ophestra Umiker 831b1aad6f
helper/args: hold a read lock in WriteTo
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-24 20:22:37 +09:00
Ophestra Umiker be83ad838c
dbus: assert fmt.Stringer instead of helper.Args on argument seal
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-24 19:37:50 +09:00
Ophestra Umiker b722adc4dd
dbus: seal as io.WriterTo interface
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-24 18:03:05 +09:00
Ophestra Umiker 000607da5f
helper: separate helper args fd builder from dbus
This method of passing arguments is used in bubblewrap as well as other tools, this commit separates the argument builder/writer to the helper package and generalise it as an interface.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-24 16:11:08 +09:00
Ophestra Umiker 1cb90c0840
app: improve dbus proxy verbose messages
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-24 13:44:42 +09:00
Ophestra Umiker a75229991c
nix: make bubblewrap available in PATH
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-23 18:21:12 +09:00
Ophestra Umiker ced31a7257
state: round printed uptime to the second
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-22 16:15:21 +09:00
Ophestra Umiker 61628dabb7
nix: remove obnoxious shell hook
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-22 16:08:11 +09:00
Ophestra Umiker 9a9fcdb9ec
release: 0.0.0-beta.4
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-22 01:18:47 +09:00
Ophestra Umiker 62cb8a91b6
app: clean up interactions and handle all application state and setup/teardown
There was an earlier attempt of cleaning up the app package however it ended up creating even more of a mess and the code structure largely still looked like Ego with state setup scattered everywhere and a bunch of ugly hacks had to be implemented to keep track of all of them. In this commit the entire app package is rewritten to track everything that has to do with an app in one thread safe value.

In anticipation of the client/server split also made changes:
- Console messages are cleaned up to be consistent
- State tracking is fully rewritten to be cleaner and usable for multiple process and client/server
- Encapsulate errors to easier identify type of action causing the error as well as additional info
- System-level setup operations is grouped in a way that can be collectively committed/reverted
  and gracefully handles errors returned by each operation
- Resource sharing is made more fine-grained with PID-scoped resources whenever possible,
  a few remnants (X11, Wayland, PulseAudio) will be addressed when a generic proxy is available
- Application setup takes a JSON-friendly config struct and deterministically generates system setup operations

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-22 01:15:39 +09:00
Ophestra Umiker 11832a9379
acl: define Go type alias for acl_perm_t
Define exported type alias for C.acl_perm_t and accept that for UpdatePerm. This makes representing its function signature significantly less cumbersome.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-21 22:25:03 +09:00
Ophestra Umiker 2763ec730e
release: 0.0.0-beta.3
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-17 23:17:39 +09:00
Ophestra Umiker 3d963b9f67
nix: include package buildInputs in devShells
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-17 23:15:33 +09:00
Ophestra Umiker 4b7d616862
exit: move final and early code to internal package
Exit cleanup state information is now stored in a dedicated struct and built up using methods of that struct.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-17 13:48:42 +09:00
Ophestra Umiker 6a6f62efa6
release: 0.0.0-beta.2
This project started as a Go implementation of https://github.com/intgr/ego. That is clearly no longer what it is anymore and the tagged releases no longer made sense, so we're going back to v0.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-16 20:41:02 +09:00
Ophestra Umiker 03c24c5122
move acl and xcb binding packages to top level
These packages are reasonably clean and do not interact with other packages.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-16 20:32:07 +09:00
Ophestra Umiker 8bdae74ebe
final: refactor for removal of system package and reduction of interactions to state package
State query command has been moved to main where it belongs, "system" information are now fetched in app.New and stored in *App with accessors for relevant values. Exit (cleanup-related) functions are separated into its dedicated "final" package.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-16 20:31:35 +09:00
Ophestra Umiker d49b97b1d4
nix: pass method string directly
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-13 11:58:45 +09:00
Ophestra Umiker 40d0550ad3
flag: move method flag from main
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-13 11:49:10 +09:00
Ophestra Umiker da6d238d8a
verbose: remove system package interaction
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-12 21:07:05 +09:00
Ophestra Umiker b0aff89166
app: handle launch method in New function
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-12 20:53:33 +09:00
Ophestra Umiker 8223a9ee66
enable filter in README example
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-11 16:35:23 +09:00
Ophestra Umiker 88ac05be6d
nix: fix typo in nixos module implementation previously missed due to lazy eval
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 23:29:16 +09:00
Ophestra Umiker 0ef321ad6f
update README document
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 23:22:07 +09:00
Ophestra Umiker 52f986559c
app/run: empty launcher environment
The launcher process should not receive the child's environment.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 22:24:58 +09:00
Ophestra Umiker 396066de7b
nix: implement dbus-system option in nixos module
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 21:26:14 +09:00
Ophestra Umiker 44301cd979
app/dbus: accept system bus config
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 21:19:12 +09:00
Ophestra Umiker 20c0e66d8f
dbus/config: seal with session and system bus proxy
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 21:13:00 +09:00
Ophestra Umiker e5918ba3b3
dbus/config: fix builtin defaults
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 19:20:37 +09:00
Ophestra Umiker 35d040590b
dbus/config: document fields and add --call and --broadcast
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 13:27:31 +09:00
Ophestra Umiker c1bfe2cd74
release: 1.1.0
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 05:14:53 +09:00
Ophestra Umiker d813f8e44e
update README document
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 05:14:14 +09:00
Ophestra Umiker 0e5b85fd42
nix: implement new dbus options in nixos module
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 04:58:25 +09:00
Ophestra Umiker cdc08817a7
nix: add xdg-dbus-proxy to PATH via wrapProgram
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 04:37:12 +09:00
Ophestra Umiker e5b3fa02f9
flag: rename cli to flag
Yet another leftover from Ego. The cli name made no sense and this file only contains flag declarations now hence the rename.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 04:21:13 +09:00
Ophestra Umiker 8e848366cd
app/dbus: set dbusAddress early
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 03:46:46 +09:00
Ophestra Umiker 38ef2b4d0c
app/dbus: manage dbus proxy and pass address to child
This commit adds code that starts and registers the D-Bus proxy, as well as cleanup code that tracks and closes the daemon once our child exits. A few more flags were added to pass D-Bus config to xdg-dbus-proxy.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 03:16:54 +09:00
Ophestra Umiker 357cc4ce4d
dbus: implement xdg-dbus-proxy wrapper
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 03:11:50 +09:00
Ophestra Umiker 3242ce3406
app: treat display server variable unset as fatal
This is yet another remnant of Ego, as Ego unconditionally shares these resources and the absence of them are ignored and warned about in verbose logging. In our case they are individually opt-in so silently dropping them while the enablement is still set makes very little sense.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 00:35:16 +09:00
Ophestra Umiker 7450b0b0bb
app/run: remove bare launch option
This flag serves no use and is only a leftover from Ego.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-09 00:32:17 +09:00
Ophestra Umiker 83af555c97
state/print: collect and output state information of all users
The -state flag now outputs state of all users. The old behaviour can be accessed via the -state-current flag, user is selected via -u.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-08 13:19:48 +09:00
Ophestra Umiker 60e4846542
nix: provide options for capability flags
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-08 02:45:00 +09:00
Ophestra Umiker 1906853382
clean up setup/launcher code and enable better control over shares
In the past Wayland, X and PulseAudio are shared unconditionally. This can unnecessarily increase attack surface as some of these resources might not be needed at all. This commit moves all environment preparation code to the internal app package and selectively call them based on flags.

An "enablements" bitfield is introduced tracking all enabled shares. This value is registered after successful child process launch and stored in launcher states.

Code responsible for running the child process is isolated to its own app/run file and cleaned up. Launch method selection is also extensively cleaned up.

The internal state/track readLaunchers function now takes uid as an argument. Launcher state is now printed using text/tabwriter and argv is only emitted when verbose.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-08 02:24:01 +09:00