Skip to content

Commit 2213bb2

Browse files
committed
all: ensure cache files and directories are readable by all
- go.mod: update gocache to commit 6c4617815112 - Fix permissions on cache directories and files.
1 parent ae29fac commit 2213bb2

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

cmd/go-cache-plugin/setup.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func initModProxy(env *command.Env, s3c *s3util.Client) (_ http.Handler, cleanup
102102
}
103103

104104
modCachePath := filepath.Join(flags.CacheDir, "module")
105-
if err := os.MkdirAll(modCachePath, 0700); err != nil {
105+
if err := os.MkdirAll(modCachePath, 0755); err != nil {
106106
return nil, nil, fmt.Errorf("create module cache: %w", err)
107107
}
108108
cacher := &modproxy.S3Cacher{
@@ -146,7 +146,7 @@ func initRevProxy(env *command.Env, s3c *s3util.Client, g *taskgroup.Group) (htt
146146
}
147147

148148
revCachePath := filepath.Join(flags.CacheDir, "revproxy")
149-
if err := os.MkdirAll(revCachePath, 0700); err != nil {
149+
if err := os.MkdirAll(revCachePath, 0755); err != nil {
150150
return nil, fmt.Errorf("create revproxy cache: %w", err)
151151
}
152152
hosts := strings.Split(serveFlags.RevProxy, ",")

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ require (
66
github.com/aws/aws-sdk-go-v2/config v1.27.28
77
github.com/aws/aws-sdk-go-v2/service/s3 v1.59.0
88
github.com/creachadair/atomicfile v0.3.5
9-
github.com/creachadair/command v0.1.13
9+
github.com/creachadair/command v0.1.14
1010
github.com/creachadair/flax v0.0.1
11-
github.com/creachadair/gocache v0.0.0-20240828204135-c17fe2fd53a6
11+
github.com/creachadair/gocache v0.0.0-20240904225701-6c4617815112
1212
github.com/creachadair/mds v0.18.1
1313
github.com/creachadair/mhttp v0.0.0-20240904023549-156b88d21c62
1414
github.com/creachadair/taskgroup v0.9.1

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj
4242
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
4343
github.com/creachadair/atomicfile v0.3.5 h1:i93bxeaH/rQR6XfJslola3XkOM1nEP3eIexuk9SWcSc=
4444
github.com/creachadair/atomicfile v0.3.5/go.mod h1:m7kIY2OUMygtETnMYe141rubsG4b+EusFLinlxxdHYM=
45-
github.com/creachadair/command v0.1.13 h1:UDKPF3QYPRS/quZPVYZ7sW1JLxLLOgiyVSLQ+7wwI2o=
46-
github.com/creachadair/command v0.1.13/go.mod h1:YKwUE49nAi8qxLl8jCQ0GMPvwdxmIBkJW3LqxgZ7ljk=
45+
github.com/creachadair/command v0.1.14 h1:lvAPKPrFU8ECyRQ4MEDCw5UEHhSOIYs5knLLNXvpYyI=
46+
github.com/creachadair/command v0.1.14/go.mod h1:JyiZVgQzhzPWa8DdE6Hfl+IOi7DMpXToBEvQCQoST7c=
4747
github.com/creachadair/flax v0.0.1 h1:it+joEf9aEUalaV7XWll/pk6zA4/FbNvMImW9q/lS8o=
4848
github.com/creachadair/flax v0.0.1/go.mod h1:K8bFvn8hMdAljQkaKNc7I3os5Wk36JxkyCkfdZ7S8d4=
49-
github.com/creachadair/gocache v0.0.0-20240828204135-c17fe2fd53a6 h1:SCF2S1aWvuFD+Vus1HGkbhaP8+ZX0VC8yWyWynlDqTg=
50-
github.com/creachadair/gocache v0.0.0-20240828204135-c17fe2fd53a6/go.mod h1:iqnJUdWeHbNfn8xWEkLWGQnOo3dqjkZPH9Rk0rjVk0U=
49+
github.com/creachadair/gocache v0.0.0-20240904225701-6c4617815112 h1:FSlFO2eztBGGzp67D2z/eeNe5U+AZyj4g/CjKf0AHbo=
50+
github.com/creachadair/gocache v0.0.0-20240904225701-6c4617815112/go.mod h1:vkGW73GdzBPQZJdFlPBZVzFcG7lTxIgDY0+U30mp3xs=
5151
github.com/creachadair/mds v0.18.1 h1:lq2JufNm5Vfkdolf9Z+2shiw7r8XJgLSZniLHUFYJcI=
5252
github.com/creachadair/mds v0.18.1/go.mod h1:4b//mUiL8YldH6TImXjmW45myzTLNS1LLjOmrk888eg=
5353
github.com/creachadair/mhttp v0.0.0-20240904023549-156b88d21c62 h1:6OEfFAgnbvhEDAR83DBUbvImn68DH2NpqcXrwID9Vbs=

lib/modproxy/modproxy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func (c *S3Cacher) putLocal(ctx context.Context, name, path string, data io.Read
183183
if _, err := os.Stat(path); err == nil {
184184
return true, nil
185185
}
186-
nw, err := atomicfile.WriteAll(path, data, 0600)
186+
nw, err := atomicfile.WriteAll(path, data, 0644)
187187
c.putLocalBytes.Add(nw)
188188
if err != nil {
189189
c.putLocalError.Add(1)
@@ -282,7 +282,7 @@ func (c *S3Cacher) makeKey(hash string) string {
282282
func (c *S3Cacher) makePath(name string) (hash, path string, err error) {
283283
hash = hashName(name)
284284
path = filepath.Join(c.Local, hash[:2], hash)
285-
err = os.MkdirAll(filepath.Dir(path), 0700)
285+
err = os.MkdirAll(filepath.Dir(path), 0755)
286286
if err != nil {
287287
c.pathError.Add(1)
288288
}

lib/revproxy/cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ func (s *Server) cacheLoadLocal(hash string) ([]byte, http.Header, error) {
3535
// response headers, followed by "\n\n", followed by the response body.
3636
func (s *Server) cacheStoreLocal(hash string, hdr http.Header, body []byte) error {
3737
path := s.makePath(hash)
38-
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
38+
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
3939
return err
4040
}
41-
return atomicfile.Tx(s.makePath(hash), 0600, func(f *atomicfile.File) error {
41+
return atomicfile.Tx(s.makePath(hash), 0644, func(f *atomicfile.File) error {
4242
return writeCacheObject(f, hdr, body)
4343
})
4444
}

0 commit comments

Comments
 (0)