Skip to content

Commit

Permalink
fix: Set local directory perms to 774 (#462)
Browse files Browse the repository at this point in the history
In order to support using securityContext.fsGroup to RW charts to a filesystem, we can create the directories with 774 permissions. We have to use os.Chmod in order to set the correct perms
  • Loading branch information
cbuto authored Jan 24, 2022
1 parent 37fadf0 commit c8bcede
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions local.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (b LocalFilesystemBackend) ListObjects(prefix string) ([]Object, error) {
var objects []Object
files, err := ioutil.ReadDir(pathutil.Join(b.RootDirectory, prefix))
if err != nil {
if os.IsNotExist(err) { // OK if the directory doesnt exist yet
if os.IsNotExist(err) { // OK if the directory doesnt exist yet
err = nil
}
return objects, err
Expand Down Expand Up @@ -84,7 +84,14 @@ func (b LocalFilesystemBackend) PutObject(path string, content []byte) error {
_, err := os.Stat(folderPath)
if err != nil {
if os.IsNotExist(err) {
err := os.MkdirAll(folderPath, 0777)
err := os.MkdirAll(folderPath, 0774)
if err != nil {
return err
}
// os.MkdirAll set the dir permissions before the umask
// we need to use os.Chmod to ensure the permissions of the created directory are 774
// because the default umask will prevent that and cause the permissions to be 755
err = os.Chmod(folderPath, 0774)
if err != nil {
return err
}
Expand Down

0 comments on commit c8bcede

Please sign in to comment.