strict file permissions of repository.yaml

Fixes #11451

Signed-off-by: shankeerthan-kasilingam <shankeerthan1995@gmail.com>
(cherry picked from commit 33121a80ff)
release-3.12
shankeerthan-kasilingam 2 years ago committed by Joe Julian
parent 4f32150a3f
commit dee1fde4e8
No known key found for this signature in database
GPG Key ID: FAB12BE0575D999B

@ -212,7 +212,7 @@ func (o *repoAddOptions) run(out io.Writer) error {
f.Update(&c) f.Update(&c)
if err := f.WriteFile(o.repoFile, 0644); err != nil { if err := f.WriteFile(o.repoFile, 0600); err != nil {
return err return err
} }
fmt.Fprintf(out, "%q has been added to your repositories\n", o.name) fmt.Fprintf(out, "%q has been added to your repositories\n", o.name)

@ -67,7 +67,7 @@ func (o *repoRemoveOptions) run(out io.Writer) error {
if !r.Remove(name) { if !r.Remove(name) {
return errors.Errorf("no repo named %q found", name) return errors.Errorf("no repo named %q found", name)
} }
if err := r.WriteFile(o.repoFile, 0644); err != nil { if err := r.WriteFile(o.repoFile, 0600); err != nil {
return err return err
} }

@ -202,7 +202,7 @@ func TestWriteFile(t *testing.T) {
t.Errorf("failed to create test-file (%v)", err) t.Errorf("failed to create test-file (%v)", err)
} }
defer os.Remove(file.Name()) defer os.Remove(file.Name())
if err := sampleRepository.WriteFile(file.Name(), 0644); err != nil { if err := sampleRepository.WriteFile(file.Name(), 0600); err != nil {
t.Errorf("failed to write file (%v)", err) t.Errorf("failed to write file (%v)", err)
} }

@ -385,7 +385,7 @@ func (s *Server) StartTLS() {
CAFile: filepath.Join("../../testdata", "rootca.crt"), CAFile: filepath.Join("../../testdata", "rootca.crt"),
}) })
if err := r.WriteFile(repoConfig, 0644); err != nil { if err := r.WriteFile(repoConfig, 0600); err != nil {
panic(err) panic(err)
} }
} }
@ -422,5 +422,5 @@ func setTestingRepository(url, fname string) error {
Name: "test", Name: "test",
URL: url, URL: url,
}) })
return r.WriteFile(fname, 0644) return r.WriteFile(fname, 0640)
} }

Loading…
Cancel
Save