-
Notifications
You must be signed in to change notification settings - Fork 103
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
add func to exclude launcher db from time machine #1531
Merged
James-Pickett
merged 11 commits into
kolide:main
from
James-Pickett:james/exclude-launcher-db-from-time-machine
Jan 12, 2024
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
61b255c
add func to exclude launcher db from time machine
James-Pickett 9d7cda6
Merge branch 'main' into james/exclude-launcher-db-from-time-machine
James-Pickett 96fd2e8
move timemachine to ee/agent
James-Pickett 7b5be2d
better error message wording
James-Pickett 0f77084
Merge branch 'main' into james/exclude-launcher-db-from-time-machine
James-Pickett 9aae794
pass slogger instead of logger
James-Pickett e35d272
glob for files paths, add test
James-Pickett 6150318
lint
James-Pickett 89cb5e3
update var names
James-Pickett 7c19fba
remove else statement
James-Pickett 49c3b2c
Merge branch 'main' into james/exclude-launcher-db-from-time-machine
James-Pickett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//go:build darwin | ||
// +build darwin | ||
|
||
package timemachine | ||
|
||
import ( | ||
"context" | ||
"log/slog" | ||
|
||
"github.com/kolide/launcher/ee/agent/types" | ||
"github.com/kolide/launcher/ee/allowedcmd" | ||
) | ||
|
||
// ExcludeLauncherDB adds the launcher db to the time machine exclusions for | ||
// darwin and is noop for other oses | ||
func ExcludeLauncherDB(ctx context.Context, k types.Knapsack) { | ||
dbPath := k.BboltDB().Path() | ||
cmd, err := allowedcmd.Tmutil(ctx, "addexclusion", dbPath) | ||
if err != nil { | ||
k.Slogger().Log(ctx, slog.LevelError, | ||
"could not create tmutil command to add launcher db to time machine exclusions", | ||
"err", err, | ||
"path", dbPath, | ||
) | ||
return | ||
} | ||
|
||
if err := cmd.Run(); err != nil { | ||
k.Slogger().Log(ctx, slog.LevelError, | ||
"running command to add launcher db to time machine exclusions", | ||
"err", err, | ||
"path", dbPath, | ||
) | ||
return | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//go:build !darwin | ||
// +build !darwin | ||
|
||
package timemachine | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/kolide/launcher/ee/agent/types" | ||
) | ||
|
||
// ExcludeLauncherDB adds the launcher db to the time machine exclusions for | ||
// darwin and is noop for other oses | ||
func ExcludeLauncherDB(_ context.Context, _ types.Knapsack) { | ||
// do nothing, no time machine on non darwin | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should exclude the whole root directory. Maybe the secret too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually keep the secret. But probably ignore the whole root directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that, but if I understand correctly, that would mean we would also not bring along all the updates. So after a time machine restore / backup the user would be back on the very first version of launcher they downloaded and would need to update again. Maybe that's okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grabbing the updates, and the TUF db, is a great counterpoint. I think you're right, it's good to carry those.
Maybe we should drop some more stuff though. Can we go by wildcard? Or do we need to do own globbing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can wild card, you thinking
*.db
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json, json.gz, the metadata, the menu, most of the osquery files, desktop, the pid files, sockets...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wildcards did not work as expected, ended up globbing