feat: authenticate Windows command launcher and signal helper

This commit is contained in:
2026-09-06 14:38:16 +00:00
parent 158fd8f3aa
commit 0383155b86
13 changed files with 1270 additions and 189 deletions
+17 -2
View File
@@ -41,7 +41,7 @@ func run(args []string, output, diagnostics io.Writer) error {
return errors.New("an internal mode is required (use --help)")
}
if args[0] == "--help" || args[0] == "-h" {
_, err := io.WriteString(output, "usage: rvbox --service|--tray|--check-config|--install-service|--uninstall-service|--configure-service|--start-service|--stop-service|--restart-service --config PATH\n")
_, err := io.WriteString(output, "usage: rvbox --service|--tray|--launcher|--signal-helper|--check-config|--install-service|--uninstall-service|--configure-service|--start-service|--stop-service|--restart-service --config PATH\n")
return err
}
flags := flag.NewFlagSet("rvbox", flag.ContinueOnError)
@@ -49,6 +49,9 @@ func run(args []string, output, diagnostics io.Writer) error {
configPath := flags.String("config", defaultClientConfigPath(), "absolute client TOML configuration path")
serviceMode := flags.Bool("service", false, "run under the Windows Service Control Manager")
trayMode := flags.Bool("tray", false, "run the current user's notification-area frontend")
launcherMode := flags.Bool("launcher", false, "run one private authenticated command launcher")
signalHelperMode := flags.Bool("signal-helper", false, "run one private authenticated signal helper")
channel := flags.String("channel", "", "private launcher channel (internal use only)")
checkConfig := flags.Bool("check-config", false, "validate client configuration and exit")
install := flags.Bool("install-service", false, "install or update the machine-wide service")
uninstall := flags.Bool("uninstall-service", false, "remove the machine-wide service")
@@ -64,7 +67,7 @@ func run(args []string, output, diagnostics io.Writer) error {
return fmt.Errorf("unexpected argument %q", flags.Arg(0))
}
selected := 0
for _, value := range []bool{*serviceMode, *trayMode, *checkConfig, *install, *uninstall, *configure, *start, *stop, *restart} {
for _, value := range []bool{*serviceMode, *trayMode, *launcherMode, *signalHelperMode, *checkConfig, *install, *uninstall, *configure, *start, *stop, *restart} {
if value {
selected++
}
@@ -105,6 +108,18 @@ func run(args []string, output, diagnostics io.Writer) error {
if *trayMode {
return runTray(*configPath, diagnostics)
}
if *launcherMode {
if *channel == "" {
return errors.New("--launcher requires an internal channel")
}
return runLauncher(*channel, diagnostics)
}
if *signalHelperMode {
if *channel == "" {
return errors.New("--signal-helper requires an internal channel")
}
return runSignalHelper(*channel, diagnostics)
}
return runService(*configPath, diagnostics)
}
+8
View File
@@ -16,3 +16,11 @@ func runService(string, io.Writer) error {
func runTray(string, io.Writer) error {
return errors.New("the v1 tray frontend is implemented for Windows only")
}
func runLauncher(string, io.Writer) error {
return errors.New("the v1 command launcher is implemented for Windows only")
}
func runSignalHelper(string, io.Writer) error {
return errors.New("the v1 signal helper is implemented for Windows only")
}
+9
View File
@@ -11,6 +11,7 @@ import (
"path/filepath"
"strings"
clientwindows "github.com/rvbox/rvbox/internal/client/supervisor/windows"
"github.com/rvbox/rvbox/internal/client/windowsservice"
"github.com/rvbox/rvbox/internal/client/windowstray"
"golang.org/x/sys/windows/svc"
@@ -56,6 +57,14 @@ func runTray(configPath string, diagnostics io.Writer) error {
return windowstray.Run(context.Background(), diagnostics)
}
func runLauncher(channel string, _ io.Writer) error {
return clientwindows.RunLauncher(context.Background(), channel)
}
func runSignalHelper(channel string, _ io.Writer) error {
return clientwindows.RunSignalHelper(context.Background(), channel)
}
func handleTrayRequest(ctx context.Context, configPath string, request windowstray.Frame) (windowstray.Frame, error) {
response := windowstray.Frame{Action: windowstray.ActionStatus}
switch request.Action {