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

Change folder permission event when not root #1888

Merged
merged 2 commits into from
Oct 29, 2016
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ BUG FIXES:
[GH-1802]
* cli: `alloc-status` does not query for allocation statistics if node is down
[GH-1844]
* client: Folder permissions are dropped even when not running as root [GH-1888]
* client: Prevent race when persisting state file [GH-1682]
* client: Artifact download failures will be retried before failing tasks
[GH-1558]
Expand Down
10 changes: 5 additions & 5 deletions client/allocdir/alloc_dir_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ func (d *AllocDir) linkOrCopy(src, dst string, perm os.FileMode) error {
}

func (d *AllocDir) dropDirPermissions(path string) error {
// Can't do anything if not root.
if err := os.Chmod(path, 0777); err != nil {
return fmt.Errorf("Chmod(%v) failed: %v", path, err)
}

// Can't change owner if not root.
if unix.Geteuid() != 0 {
return nil
}
Expand All @@ -67,10 +71,6 @@ func (d *AllocDir) dropDirPermissions(path string) error {
return fmt.Errorf("Couldn't change owner/group of %v to (uid: %v, gid: %v): %v", path, uid, gid, err)
}

if err := os.Chmod(path, 0777); err != nil {
return fmt.Errorf("Chmod(%v) failed: %v", path, err)
}

return nil
}

Expand Down