Skip to content

Commit

Permalink
Allow /etc/containers/containers.conf to be read by non-root
Browse files Browse the repository at this point in the history
If a root user writes to a config using Write(), and there is not already an /etc/containers/containers.conf, Write() will create it. This config file also needs to be read by non-root podman.

Signed-off-by: Ashley Cui <[email protected]>
  • Loading branch information
ashley-cui authored and vrothberg committed Jun 23, 2021
1 parent 99ee78d commit 9082857
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ func (c *Config) Write() error {
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
return err
}
configFile, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0600)
configFile, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0644)
if err != nil {
return err
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/config/config_local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ var _ = Describe("Config Local", func() {
err = config.Write()
// Then
gomega.Expect(err).To(gomega.BeNil())
fi, err := os.Stat(tmpfile)
gomega.Expect(err).To(gomega.BeNil())
perm := int(fi.Mode().Perm())
// 436 decimal = 644 octal
gomega.Expect(perm).To(gomega.Equal(420))
defer os.Remove(tmpfile)
})
It("Default Umask", func() {
Expand Down

0 comments on commit 9082857

Please sign in to comment.