Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sticky bit to temp directory #2519

Merged
merged 1 commit into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/allocdir/alloc_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var (
TaskSecrets = "secrets"

// TaskDirs is the set of directories created in each tasks directory.
TaskDirs = []string{"tmp"}
TaskDirs = map[string]os.FileMode{"tmp": os.ModeSticky | 0777}
)

type AllocDir struct {
Expand Down Expand Up @@ -250,7 +250,7 @@ func (d *AllocDir) Build() error {
}

// Make the shared directory have non-root permissions.
if err := dropDirPermissions(d.SharedDir); err != nil {
if err := dropDirPermissions(d.SharedDir, os.ModePerm); err != nil {
return err
}

Expand All @@ -260,7 +260,7 @@ func (d *AllocDir) Build() error {
if err := os.MkdirAll(p, 0777); err != nil {
return err
}
if err := dropDirPermissions(p); err != nil {
if err := dropDirPermissions(p, os.ModePerm); err != nil {
return err
}
}
Expand Down
4 changes: 2 additions & 2 deletions client/allocdir/fs_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ var (

// dropDirPermissions gives full access to a directory to all users and sets
// the owner to nobody.
func dropDirPermissions(path string) error {
if err := os.Chmod(path, 0777); err != nil {
func dropDirPermissions(path string, desired os.FileMode) error {
if err := os.Chmod(path, desired|0777); err != nil {
return fmt.Errorf("Chmod(%v) failed: %v", path, err)
}

Expand Down
2 changes: 1 addition & 1 deletion client/allocdir/fs_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func removeSecretDir(dir string) error {
}

// The windows version does nothing currently.
func dropDirPermissions(path string) error {
func dropDirPermissions(path string, desired os.FileMode) error {
return nil
}

Expand Down
12 changes: 6 additions & 6 deletions client/allocdir/task_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (t *TaskDir) Build(chrootCreated bool, chroot map[string]string, fsi cstruc
}

// Make the task directory have non-root permissions.
if err := dropDirPermissions(t.Dir); err != nil {
if err := dropDirPermissions(t.Dir, os.ModePerm); err != nil {
return err
}

Expand All @@ -75,18 +75,18 @@ func (t *TaskDir) Build(chrootCreated bool, chroot map[string]string, fsi cstruc
return err
}

if err := dropDirPermissions(t.LocalDir); err != nil {
if err := dropDirPermissions(t.LocalDir, os.ModePerm); err != nil {
return err
}

// Create the directories that should be in every task.
for _, dir := range TaskDirs {
for dir, perms := range TaskDirs {
absdir := filepath.Join(t.Dir, dir)
if err := os.MkdirAll(absdir, 0777); err != nil {
if err := os.MkdirAll(absdir, perms); err != nil {
return err
}

if err := dropDirPermissions(absdir); err != nil {
if err := dropDirPermissions(absdir, perms); err != nil {
return err
}
}
Expand All @@ -110,7 +110,7 @@ func (t *TaskDir) Build(chrootCreated bool, chroot map[string]string, fsi cstruc
return err
}

if err := dropDirPermissions(t.SecretsDir); err != nil {
if err := dropDirPermissions(t.SecretsDir, os.ModePerm); err != nil {
return err
}

Expand Down