Fix Fleet Desktop opening of URL on Ubuntu 21/22 (#6314)

* Fix Fleet Desktop opening URL on Ubuntu 21/22

* Fine tunning: fix for Ubuntu 18
This commit is contained in:
Lucas Manuel Rodriguez
2022-06-21 16:26:14 -03:00
committed by GitHub
parent 9b210fc6bd
commit c90e3012d2
2 changed files with 13 additions and 1 deletions
+8 -1
View File
@@ -24,10 +24,13 @@ func run(path string, opts eopts) error {
Int64("id", user.id).
Msg("running sudo")
arg := []string{"-u", user.name, "-H"}
// Flag `-i` is needed to run the command with the user's context, from `man sudo`:
// "The command is run with an environment similar to the one a user would receive at log in"
arg := []string{"-i", "-u", user.name, "-H"}
for _, nv := range opts.env {
arg = append(arg, fmt.Sprintf("%s=%s", nv[0], nv[1]))
}
arg = append(arg,
// TODO(lucas): Default to display 0, revisit when working on
// multi-user/multi-session support. This assumes there's only
@@ -36,7 +39,11 @@ func run(path string, opts eopts) error {
// DBUS_SESSION_BUS_ADDRESS sets the location of the user login session bus.
// Required by the libayatana-appindicator3 library to display a tray icon
// on the desktop session.
//
// This is required for Ubuntu 18, and not required for Ubuntu 21/22
// (because it's already part of the user).
fmt.Sprintf("DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%d/bus", user.id),
// Append the packaged libayatana-appindicator3 libraries path to LD_LIBRARY_PATH.
fmt.Sprintf("LD_LIBRARY_PATH=%s:%s", filepath.Dir(path), os.ExpandEnv("$LD_LIBRARY_PATH")),
path,
)
+5
View File
@@ -307,10 +307,15 @@ func writePreRemove(opt Options, path string) error {
// We add `|| true` in case the service is not running
// or has been manually disabled already. Otherwise,
// uninstallation fails.
//
// "pkill fleet-desktop" is required because the application
// runs as user (separate from sudo command that launched it),
// so on some systems it's not killed properly.
if err := ioutil.WriteFile(path, []byte(`#!/bin/sh
systemctl stop orbit.service || true
systemctl disable orbit.service || true
pkill fleet-desktop || true
`), constant.DefaultFileMode); err != nil {
return fmt.Errorf("write file: %w", err)
}