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

Ensure that the root directory is 0755 #1265

Merged
merged 4 commits into from
Jul 27, 2023
Merged
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
16 changes: 15 additions & 1 deletion cmd/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/apache/thrift/lib/go/thrift"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/kolide/kit/fsutil"
"github.com/kolide/kit/logutil"
"github.com/kolide/kit/ulid"
"github.com/kolide/kit/version"
Expand Down Expand Up @@ -110,9 +111,22 @@ func runLauncher(ctx context.Context, cancel func(), opts *launcher.Options) err
)
}

if err := os.MkdirAll(rootDirectory, 0700); err != nil {
if err := os.MkdirAll(rootDirectory, fsutil.DirMode); err != nil {
return fmt.Errorf("creating root directory: %w", err)
}
// Ensure permissions are correct, regardless of umask settings -- we use
// DirMode (0755) because the desktop processes that run as the user
// must be able to access the root directory as well.
if err := os.Chmod(rootDirectory, fsutil.DirMode); err != nil {
return fmt.Errorf("chmodding root directory: %w", err)
}
if filepath.Dir(rootDirectory) == "/var/kolide-k2" {
// We need to ensure the same for the parent of the root directory, but we only
// want to do the same for Kolide-created directories.
if err := os.Chmod(filepath.Dir(rootDirectory), fsutil.DirMode); err != nil {
return fmt.Errorf("chmodding root directory parent: %w", err)
}
}

if _, err := osquery.DetectPlatform(); err != nil {
return fmt.Errorf("detecting platform: %w", err)
Expand Down