aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-03-25 04:42:30 +0900
committerOphestra <cat@gensokyo.uk>2025-03-25 04:42:30 +0900
commitec5e91b8c97f02707a70a789ba4af84d51394ea5 (patch)
tree45f05e1315063936741ddafde8b5f95338315b54 /main.go
parentee51320abfeafabecd42659a88af9dfd44308a3a (diff)
system: optimise string formatting
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'main.go')
-rw-r--r--main.go39
1 files changed, 23 insertions, 16 deletions
diff --git a/main.go b/main.go
index cd9489ae..9890b529 100644
--- a/main.go
+++ b/main.go
@@ -96,12 +96,13 @@ func buildCommand(out io.Writer) command.Command {
mpris bool
dbusVerbose bool
- fid string
- aid int
- groups command.RepeatableFlag
- homeDir string
- userName string
- enablements [system.ELen]bool
+ fid string
+ aid int
+ groups command.RepeatableFlag
+ homeDir string
+ userName string
+
+ wayland, x11, dBus, pulse bool
)
c.NewCommand("run", "Configure and start a permissive default sandbox", func(args []string) error {
@@ -158,15 +159,21 @@ func buildCommand(out io.Writer) command.Command {
config.Confinement.Outer = homeDir
config.Confinement.Username = userName
- // enablements from flags
- for i := system.Enablement(0); i < system.Enablement(system.ELen); i++ {
- if enablements[i] {
- config.Confinement.Enablements.Set(i)
- }
+ if wayland {
+ config.Confinement.Enablements |= system.EWayland
+ }
+ if x11 {
+ config.Confinement.Enablements |= system.EX11
+ }
+ if dBus {
+ config.Confinement.Enablements |= system.EDBus
+ }
+ if pulse {
+ config.Confinement.Enablements |= system.EPulse
}
// parse D-Bus config file from flags if applicable
- if enablements[system.EDBus] {
+ if dBus {
if dbusConfigSession == "builtin" {
config.Confinement.SessionBus = dbus.NewConfig(fid, true, mpris)
} else {
@@ -215,13 +222,13 @@ func buildCommand(out io.Writer) command.Command {
"Application home directory").
Flag(&userName, "u", command.StringFlag("chronos"),
"Passwd name within sandbox").
- Flag(&enablements[system.EWayland], "wayland", command.BoolFlag(false),
+ Flag(&wayland, "wayland", command.BoolFlag(false),
"Allow Wayland connections").
- Flag(&enablements[system.EX11], "X", command.BoolFlag(false),
+ Flag(&x11, "X", command.BoolFlag(false),
"Share X11 socket and allow connection").
- Flag(&enablements[system.EDBus], "dbus", command.BoolFlag(false),
+ Flag(&dBus, "dbus", command.BoolFlag(false),
"Proxy D-Bus connection").
- Flag(&enablements[system.EPulse], "pulse", command.BoolFlag(false),
+ Flag(&pulse, "pulse", command.BoolFlag(false),
"Share PulseAudio socket and cookie")
}