Skip to content

Commit 3a4d9e1

Browse files
authored
cache: fixup pogreb db permissions (#1317)
Signed-off-by: Joe Lanford <[email protected]>
1 parent e7ca8e3 commit 3a4d9e1

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

pkg/cache/pogrebv1.go

+20-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ func newPogrebV1Backend(baseDir string) *pogrebV1Backend {
3131
}
3232

3333
const (
34-
pogrebV1CacheModeDir = 0750
35-
pogrebV1CacheModeFile = 0640
34+
pogrebV1CacheModeDir = 0770
35+
pogrebV1CacheModeFile = 0660
3636

3737
pograbV1CacheDir = "pogreb.v1"
3838
pogrebDigestFile = pograbV1CacheDir + "/digest"
@@ -86,7 +86,24 @@ func (q *pogrebV1Backend) Close() error {
8686
if q.db == nil {
8787
return nil
8888
}
89-
return q.db.Close()
89+
if err := q.db.Close(); err != nil {
90+
return err
91+
}
92+
93+
// Recursively fixup permissions on the DB directory.
94+
return filepath.Walk(filepath.Join(q.baseDir, pogrebDbDir), func(path string, info os.FileInfo, err error) error {
95+
if err != nil {
96+
return err
97+
}
98+
switch info.Mode().Type() {
99+
case os.ModeDir:
100+
return os.Chmod(path, pogrebV1CacheModeDir)
101+
case 0:
102+
return os.Chmod(path, pogrebV1CacheModeFile)
103+
default:
104+
return nil
105+
}
106+
})
90107
}
91108

92109
func (q *pogrebV1Backend) GetPackageIndex(_ context.Context) (packageIndex, error) {

0 commit comments

Comments
 (0)