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

cache: fixup pogreb db permissions #1317

Merged
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
23 changes: 20 additions & 3 deletions pkg/cache/pogrebv1.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func newPogrebV1Backend(baseDir string) *pogrebV1Backend {
}

const (
pogrebV1CacheModeDir = 0750
pogrebV1CacheModeFile = 0640
pogrebV1CacheModeDir = 0770
pogrebV1CacheModeFile = 0660

pograbV1CacheDir = "pogreb.v1"
pogrebDigestFile = pograbV1CacheDir + "/digest"
Expand Down Expand Up @@ -86,7 +86,24 @@ func (q *pogrebV1Backend) Close() error {
if q.db == nil {
return nil
}
return q.db.Close()
if err := q.db.Close(); err != nil {
return err
}

// Recursively fixup permissions on the DB directory.
return filepath.Walk(filepath.Join(q.baseDir, pogrebDbDir), func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
switch info.Mode().Type() {
case os.ModeDir:
return os.Chmod(path, pogrebV1CacheModeDir)
case 0:
return os.Chmod(path, pogrebV1CacheModeFile)
default:
return nil
}
})
}

func (q *pogrebV1Backend) GetPackageIndex(_ context.Context) (packageIndex, error) {
Expand Down
Loading