fleet/orbit
Scott Gress f4cc1a2e5f
Run fleet desktop with user SELinux context when applicable (#30882)
For #29793 

# Details

This PR changes the way that Orbit launches processes such as the
desktop app on Linux, in order to ensure that on SELinux-enabled systems
the correct user context is set when running the command.

Previously, `sudo -u` was used to launch commands on Linux. This PR
switches to use `runuser` instead, which is recommended in situations
where the root user wants to execute a command as a user with reduced
privileges (see [the blog post by one of the creators of
runuser](https://danwalsh.livejournal.com/55588.html)). This avoids
certain errors that can come from interacting with PAM modules as the
system user.

Additionally, if we detect that SELinux is set up on a system, we now
use `runcon` to force the command to run using the logged-in user's
SELinux context. It's possible that on some systems they may have
configuration where `sudo` will switch to the user's SELinux context
automatically, but this is not guaranteed. Using `runuser` + `runcon` is
our best bet for ensuring that the desktop app (and anything that it
spawns) runs under the correct context.

This PR also does some refactoring so that the three `run` methods for
Linux (`run`, `runWithOutput` and `runWithStdin`) all use the same base
code to create the command with the correct args and env vars, and
differ only in how they handle the i/o.

# 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/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.
- For Orbit and Fleet Desktop changes:
- [x] Make sure fleetd is compatible with the latest released version of
Fleet (see [Must
rule](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/workflows/fleetd-development-and-release-strategy.md)).
- [x] Orbit runs on macOS, Linux and Windows. Check if the orbit
feature/bugfix should only apply to one platform (`runtime.GOOS`).
- [x] ~Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.~ (n/a, code is linux only)
- [x] ~Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).~ n/a

# Testing

- [x] Ubuntu with SELinux on
- [x] Ubuntu with SELinux off
- [ ] Fedora with SELinux on
- [ ] Fedora with SELinux off
- [ ] Debian with SELinux on
- [x] Debian with SELinux off
- [x] `runWithOutput` still works (tested with `go run
./tools/dialog/main.go --dialog=zenity`)
- [ ] ~`runWithStdin` still works~ (this isn't currently used by Linux)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved security and user context handling when launching the fleet
desktop application on Linux systems.

* **Refactor**
* Enhanced process launch mechanism to use proper SELinux context and
user session, ensuring processes start under the correct user and
security environment.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-07-25 08:44:13 -05:00
..
changes Run fleet desktop with user SELinux context when applicable (#30882) 2025-07-25 08:44:13 -05:00
cmd Show 'About Fleet' menu item when host becomes online (#31255) 2025-07-25 05:37:08 -04:00
pkg Run fleet desktop with user SELinux context when applicable (#30882) 2025-07-25 08:44:13 -05:00
tools Orbit for Windows ARM64 (#27882) 2025-04-11 10:18:28 -04:00
.gitattributes Add 'orbit/' from commit 'ab3047bb39f1e2be331d1ff18b4eb768619033c4' 2021-08-04 16:58:25 -03:00
.gitignore Add 'orbit/' from commit 'ab3047bb39f1e2be331d1ff18b4eb768619033c4' 2021-08-04 16:58:25 -03:00
.gon.hcl Build universal macOS binaries for Orbit (#6208) 2022-06-13 19:43:47 -03:00
CHANGELOG.md Update orbit CHANGELOG.md with 1.45.1 release date to stable (#30991) 2025-07-17 15:29:18 -03:00
goreleaser-linux-arm64.yml Use goreleaser v2 in CI (#23748) 2024-12-03 16:15:31 -06:00
goreleaser-linux.yml Update changelog for fleetd 1.42.0 release (#29186) 2025-05-19 08:22:30 -03:00
goreleaser-macos.yml Use goreleaser v2 in CI (#23748) 2024-12-03 16:15:31 -06:00
goreleaser-windows-arm64.yml Orbit for Windows ARM64 (#27882) 2025-04-11 10:18:28 -04:00
goreleaser-windows.yml Use goreleaser v2 in CI (#23748) 2024-12-03 16:15:31 -06:00
LICENSE Add 'orbit/' from commit 'ab3047bb39f1e2be331d1ff18b4eb768619033c4' 2021-08-04 16:58:25 -03:00
old-TUF.md Update tools/tuf-status for windows-arm64 (#28232) 2025-04-15 19:04:46 -03:00
README.md Clean up "click here" and "here" link anchors - part 1 (#29731) 2025-06-04 13:54:34 -06:00
TUF.md Update versions of fleetd components in Fleet's TUF [automated] (#30912) 2025-07-15 17:49:00 -03:00

Fleet logo, landscape, dark text, transparent background

Orbit is a lightweight osquery installer and autoupdater. With Orbit, it's easy to deploy osquery, manage configurations, and keep things up-to-date. Orbit eases the deployment of osquery connected with a Fleet server, and is a (near) drop-in replacement for osquery in a variety of deployment scenarios.

Orbit is the recommended agent for Fleet. But Orbit can be used with or without Fleet, and Fleet can be used with or without Orbit.

How to build from source

To build orbit we use goreleaser.

For reference, here are the build configuration files:

Following are the commands to build in case you can't use goreleaser.

IMPORTANT: We recommend you build orbit natively and not cross compile to avoid any build or runtime errors.

macOS

CGO_ENABLED=1 \
CODESIGN_IDENTITY=$CODESIGN_IDENTITY \
ORBIT_VERSION=$VERSION \
ORBIT_BINARY_PATH=./orbit-macos \
go run ./orbit/tools/build/build.go

Windows

CGO_ENABLED=0 \
GOOS=windows \
GOARCH=amd64 \
go build \
-trimpath \
-ldflags="-X github.com/fleetdm/fleet/v4/orbit/pkg/build.Version=$VERSION \
-X github.com/fleetdm/fleet/v4/orbit/pkg/build.Commit=$COMMIT \
-X github.com/fleetdm/fleet/v4/orbit/pkg/build.Date=$DATE" \
-o ./orbit.exe ./orbit/cmd/orbit

Linux

CGO_ENABLED=1 \
GOOS=linux \
GOARCH=amd64 \
go build \
-trimpath \
-ldflags="-X github.com/fleetdm/fleet/v4/orbit/pkg/build.Version=$VERSION \
-X github.com/fleetdm/fleet/v4/orbit/pkg/build.Commit=$COMMIT \
-X github.com/fleetdm/fleet/v4/orbit/pkg/build.Date=$DATE" \
-o ./orbit-linux ./orbit/cmd/orbit

Bugs

To report a bug or request a feature, create an issue in the fleet GitHub repository.

Orbit Development

Run Orbit From Source

To execute orbit from source, use the following commands:

Connect to a Fleet server

Modify the fleet-url and enroll-secret as appropriate:

go run github.com/fleetdm/fleet/v4/orbit/cmd/orbit \
    --dev-mode \
    --disable-updates \
    --root-dir /tmp/orbit \
    --fleet-url https://localhost:8080 \
    --insecure \
    --enroll-secret Pz3zC0NMDdZfb3FtqiLgwoexItojrYh/ \
    -- --verbose

Using a custom flagfile

With a flagfile.txt for osqueryd:

go run github.com/fleetdm/fleet/v4/orbit/cmd/orbit \
    --dev-mode \
    --disable-updates \
    --root-dir /tmp/orbit \
    -- --flagfile=flagfile.txt --verbose

Open an interactive shell to run SQL

This can be useful for building/testing extension tables:

go run github.com/fleetdm/fleet/v4/orbit/cmd/orbit \
    --dev-mode \
    --disable-updates \
    --root-dir /tmp/orbit \
    shell

Generate Installer Packages from Orbit Source

The fleetctl package command generates installers by fetching the targets/executables from a TUF repository. To generate an installer that contains an Orbit built from source you need to setup a local TUF repository. The following document explains how you can generate a TUF repository, and installers that use it tools/tuf/test.

FAQs

How does Orbit compare with Kolide Launcher?

Orbit is inspired by the success of Kolide Launcher, and approaches a similar problem domain with new strategies informed by the challenges encountered in real world deployments. Orbit does not share any code with Launcher.

  • Both Orbit and Launcher use The Update Framework specification for managing updates. Orbit utilizes the official go-tuf library, while Launcher has it's own implementation of the specification.
  • Orbit can be deployed as a (near) drop-in replacement for osquery, supporting full customization of the osquery flags. Launcher heavily manages the osquery flags making deployment outside of Fleet or Kolide's SaaS difficult.
  • Orbit prefers the battle-tested plugins of osquery. Orbit uses the built-in logging, configuration, and live query plugins, while Launcher uses custom implementations.
  • Orbit prefers the built-in osquery remote APIs. Launcher utilizes a custom gRPC API that has led to issues with character encoding, load balancers/proxies, and request size limits.
  • Orbit encourages use of the osquery performance Watchdog, while Launcher disables the Watchdog.

Additionally, Orbit aims to tackle problems out of scope for Launcher:

  • Configure updates via release channels, providing more granular control over agent versioning.
  • Manage osquery startup flags from a remote (Fleet) server.
  • Support for deploying and updating osquery extensions.
  • Manage osquery versions from a remote (Fleet) server.

Is Orbit Free?

Yes! Orbit is licensed under an MIT license and all uses are encouraged.

How does orbit update osquery? And how do the stable and edge channels get triggered to update osquery on a self hosted Fleet instance?

Orbit uses a configurable update server. We expect that many folks will just use the update server we manage (similar to what Kolide does with Launcher's update server). We are also offering tooling for self-managing an update server as part of Fleet Premium (the subscription offering).

Community

Chat

Please join us in the #fleet channel on osquery Slack.

Banner featuring a futuristic cloud city with the Fleet logo