-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BACKPORT 2.18.4][PLAT-9990] Allowing YBA-installer to work with arbi…
…trary umask Summary: Previously our implementation for making directories simply called go's os module which set permissions before umask, so any umask settings on the operating system would result in non deterministic behavior. This diff changes our common Mkdir implementation to explicitly set the permissions to whatever we desire. Original diff: d2df3ad / D27912 Test Plan: Validate diff fixes installation on a box with umask 027. More test cases for making directories since the function is more complicated. Reviewers: muthu, sanketh Reviewed By: muthu Subscribers: yugaware Tags: #jenkins-ready Differential Revision: https://phorge.dev.yugabyte.com/D29980
- Loading branch information
Showing
8 changed files
with
156 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package common | ||
|
||
import ( | ||
"testing" | ||
"os" | ||
) | ||
|
||
const CustomDirPerms = 0700 + os.ModeDir | ||
|
||
func TestCreateNestedDirectory(t *testing.T) { | ||
tmpDir := t.TempDir() | ||
testdir := tmpDir + "/food/bar/baz" | ||
err := MkdirAll(testdir, CustomDirPerms) | ||
if err != nil { | ||
t.Fatalf("error making directory %s: %s", testdir, err.Error()) | ||
} | ||
ValidateDirectory(t, testdir, CustomDirPerms) | ||
} | ||
|
||
func TestCreateDirectory(t *testing.T) { | ||
tmpDir := t.TempDir() | ||
testdir := tmpDir + "/test" | ||
err := MkdirAll(testdir, CustomDirPerms) | ||
if err != nil { | ||
t.Fatalf("error making directory %s: %s", testdir, err.Error()) | ||
} | ||
ValidateDirectory(t, testdir, CustomDirPerms) | ||
} | ||
|
||
func TestCreateExistingDirectory(t *testing.T) { | ||
testdir := t.TempDir() | ||
testDirInfo, _ := os.Stat(testdir) | ||
testDirPerms := testDirInfo.Mode() | ||
err := MkdirAll(testdir, CustomDirPerms) | ||
if err != nil { | ||
t.Fatalf("error making directory %s: %s", testdir, err.Error()) | ||
} | ||
ValidateDirectory(t, testdir, testDirPerms) | ||
} | ||
|
||
func ValidateDirectory(t *testing.T, testdir string, perm os.FileMode) { | ||
fileInfo, err := os.Stat(testdir) | ||
if err != nil { | ||
t.Fatalf("error locating directory %s: %s", testdir, err.Error()) | ||
} | ||
if fileInfo.Mode() != perm { | ||
t.Fatalf("directory %s has incorrect permissions. expected: %s actual: %s", | ||
testdir, perm, fileInfo.Mode()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters