Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete Fleet Desktop auth token when we detect a migrated host #23658

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions orbit/changes/23164-delete-migrated-identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Fixed stale Fleet Desktop token UUID after a macOS host completes Migration Assistant.
7 changes: 5 additions & 2 deletions orbit/cmd/orbit/orbit.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,10 +719,13 @@ func main() {
return fmt.Errorf("removing old osquery.db: %w", err)
}

// We can remove this because we want it to be regenerated during the re-enrollment.
// We can remove these because we want them to be regenerated during the re-enrollment.
if err := os.RemoveAll(filepath.Join(c.String("root-dir"), constant.OrbitNodeKeyFileName)); err != nil {
return fmt.Errorf("removing old orbit node key file: %w", err)
}
if err := os.RemoveAll(filepath.Join(c.String("root-dir"), constant.DesktopTokenFileName)); err != nil {
return fmt.Errorf("removing old Fleet Desktop identifier file: %w", err)
}

return errors.New("found a new hardware uuid, restarting")
}
Expand Down Expand Up @@ -1017,7 +1020,7 @@ func main() {
var trw *token.ReadWriter
var deviceClient *service.DeviceClient
if c.Bool("fleet-desktop") {
trw = token.NewReadWriter(filepath.Join(c.String("root-dir"), "identifier"))
trw = token.NewReadWriter(filepath.Join(c.String("root-dir"), constant.DesktopTokenFileName))
if err := trw.LoadOrGenerate(); err != nil {
return fmt.Errorf("initializing token read writer: %w", err)
}
Expand Down
2 changes: 2 additions & 0 deletions orbit/pkg/constant/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const (
// We use fleet-desktop as name to properly identify the process when listing
// running processes/tasks.
DesktopAppExecName = "fleet-desktop"
// DesktopTokenFileName is the filename on disk (in the orbit base dir) where we store the Fleet Desktop auth token
DesktopTokenFileName = "identifier"
// OrbitNodeKeyFileName is the filename on disk where we write the orbit node key to
OrbitNodeKeyFileName = "secret-orbit-node-key.txt"
// OrbitEnrollMaxRetries is the max number of retries when doing an enroll request.
Expand Down
Loading