fix: don't attempt to launch fleet desktop until the user is logged into GUI (#16090)

> 📜 Related issue: https://github.com/fleetdm/fleet/issues/14698

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Manual QA for all new/changed functionality
  - For Orbit and Fleet Desktop changes:
- [x] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [x] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
This commit is contained in:
Jahziel Villasana-Espinoza
2024-01-17 10:00:28 -05:00
committed by GitHub
parent 29b7c8e44e
commit d7d55f0e56
4 changed files with 57 additions and 0 deletions
+14
View File
@@ -33,6 +33,7 @@ import (
"github.com/fleetdm/fleet/v4/orbit/pkg/token"
"github.com/fleetdm/fleet/v4/orbit/pkg/update"
"github.com/fleetdm/fleet/v4/orbit/pkg/update/filestore"
"github.com/fleetdm/fleet/v4/orbit/pkg/user"
"github.com/fleetdm/fleet/v4/pkg/certificate"
"github.com/fleetdm/fleet/v4/pkg/file"
retrypkg "github.com/fleetdm/fleet/v4/pkg/retry"
@@ -1307,6 +1308,19 @@ func (d *desktopRunner) execute() error {
for {
// First retry logic to start fleet-desktop.
if done := retry(30*time.Second, false, d.interruptCh, func() bool {
// On MacOS, if we attempt to run Fleet Desktop while the user is not logged in through
// the GUI, MacOS returns an error. See https://github.com/fleetdm/fleet/issues/14698
// for more details.
loggedInGui, err := user.IsUserLoggedInViaGui()
if err != nil {
log.Debug().Err(err).Msg("desktop.IsUserLoggedInGui")
return true
}
if !loggedInGui {
return true
}
// Orbit runs as root user on Unix and as SYSTEM (Windows Service) user on Windows.
// To be able to run the desktop application (mostly to register the icon in the system tray)
// we need to run the application as the login user.