Skip to content

Commit

Permalink
Neither the singularity sif file nor the module file should be execut…
Browse files Browse the repository at this point in the history
…able (#35)
  • Loading branch information
mjkw31 authored Dec 12, 2024
1 parent 8c1597d commit 99099a7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
16 changes: 12 additions & 4 deletions build/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,18 @@ Stage: final
So(err, ShouldBeNil)

perm := info.Mode().Perm()
So(perm.String(), ShouldEqual, "-rwxr-xr-x")
So(perm.String(), ShouldEqual, "-rw-r--r--")

dir := modulePath
for dir != conf.Module.ModuleInstallDir {
info, err = os.Stat(dir)
So(err, ShouldBeNil)
perm = info.Mode().Perm()
So(perm&0755, ShouldEqual, 0755)
if info.IsDir() {
So(perm&0755, ShouldEqual, 0755)
} else {
So(perm&0755, ShouldEqual, 0644)
}

dir = filepath.Dir(dir)
}
Expand All @@ -278,7 +282,11 @@ Stage: final
info, err = os.Stat(dir)
So(err, ShouldBeNil)
perm = info.Mode().Perm()
So(perm&0755, ShouldEqual, 0755)
if info.IsDir() {
So(perm&0755, ShouldEqual, 0755)
} else {
So(perm&0755, ShouldEqual, 0644)
}

dir = filepath.Dir(dir)
}
Expand All @@ -287,7 +295,7 @@ Stage: final
So(err, ShouldBeNil)

perm = info.Mode().Perm()
So(perm.String(), ShouldEqual, "-rwxr-xr-x")
So(perm.String(), ShouldEqual, "-rw-r--r--")

f, err := os.Open(imagePath)
So(err, ShouldBeNil)
Expand Down
9 changes: 5 additions & 4 deletions build/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ const (
ScriptsDirSuffix = "-scripts"
ErrMakeDirectory = internal.Error("base not parent of leaf")

perms = 0755
flags = os.O_EXCL | os.O_CREATE | os.O_WRONLY
perms = 0644
dirPerms = 0755
flags = os.O_EXCL | os.O_CREATE | os.O_WRONLY
)

func installModule(scriptInstallBase, moduleInstallBase string, def *Definition, module,
Expand Down Expand Up @@ -114,12 +115,12 @@ func makeDirectory(leafDir, baseDir string) error {
return ErrMakeDirectory
}

if err = os.MkdirAll(leafDir, perms); err != nil {
if err = os.MkdirAll(leafDir, dirPerms); err != nil {
return err
}

for leafDir != baseDir {
if err := os.Chmod(leafDir, perms); err != nil {
if err := os.Chmod(leafDir, dirPerms); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion build/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestInstall(t *testing.T) {
So(err, ShouldBeNil)

baseDir := filepath.Join(tmpDir, "base")
err = os.MkdirAll(baseDir, perms)
err = os.MkdirAll(baseDir, dirPerms)
So(err, ShouldBeNil)

leafDir := filepath.Join("base", "sub1", "sub2")
Expand Down

0 comments on commit 99099a7

Please sign in to comment.