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

windows root directory fallback #1742

Merged
merged 6 commits into from
Jun 7, 2024
Merged

Conversation

zackattack01
Copy link
Contributor

@zackattack01 zackattack01 commented Jun 7, 2024

These changes are to allow a windows device to fallback to a historical (or current) root directory location. When an MSI with a different root directory is freshly installed over another, launcher cannot see the existing DB and triggers a new enrollment.
To avoid this, svc_windows will override the root_directory set by the MSI if a populated database exists in another known root directory location

Copy link
Contributor

@directionless directionless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking out loud... What are the cases:

db[s] on disk option desired outcome
old location old location old location
new location new location new location
new location old location new location
old location new location old location
anywhere developer developer specified

@@ -51,6 +51,18 @@ func runWindowsSvc(systemSlogger *multislogger.MultiSlogger, args []string) erro

// Create a local logger. This logs to a known path, and aims to help diagnostics
if opts.RootDirectory != "" {
// check for old root directories before creating DB in case we've stomped over with windows MSI install
updatedRootDirectory := determineRootDirectory(opts.RootDirectory, systemSlogger.Logger)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use the local/debug slogger, not the system one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I guess this is happening before we know where to write debug.json. Tricky

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah my first pass at this failed to notice that and the logs end up being split across RootDirs, I thought maybe safer to just do this until we get it set up

cmd/launcher/svc_windows.go Show resolved Hide resolved
cmd/launcher/svc_windows.go Outdated Show resolved Hide resolved
cmd/launcher/svc_windows.go Outdated Show resolved Hide resolved
Copy link
Contributor

@directionless directionless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels pretty good

cmd/launcher/svc_windows.go Outdated Show resolved Hide resolved
cmd/launcher/svc_windows.go Outdated Show resolved Hide resolved
Comment on lines +33 to +34
"C:\\ProgramData\\Kolide\\Launcher-kolide-k2\\data",
"C:\\Program Files\\Kolide\\Launcher-kolide-k2\\data",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the correct order? It means that if there's a new db path, we should prefer it. And I think that's likely to be true if someone got themselves into this situation. (They'll have already done the pain of it, and going back to the old db will be worse)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was my thinking as well. I think for most (upgrade) cases moving forward we'll get ProgramData via opts anyway and check that first before we even iterate these

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly talking through my assumptions here.

@zackattack01 zackattack01 marked this pull request as ready for review June 7, 2024 17:55
James-Pickett
James-Pickett previously approved these changes Jun 7, 2024
RebeccaMahany
RebeccaMahany previously approved these changes Jun 7, 2024
Copy link
Contributor

@RebeccaMahany RebeccaMahany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense!

cmd/launcher/svc_windows.go Show resolved Hide resolved
Copy link
Contributor

@directionless directionless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is okay to try. We'll need to figure out some really good testing

@zackattack01 zackattack01 added this pull request to the merge queue Jun 7, 2024
Merged via the queue into main with commit 081e66b Jun 7, 2024
31 checks passed
@zackattack01 zackattack01 deleted the zack/windows_find_rootdir branch June 7, 2024 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants