Skip to content

Commit

Permalink
chown dirs when migrating ephemeral_disk data
Browse files Browse the repository at this point in the history
Fixes #3702

Added missing chown call and made it conditional on running as root and
not on Windows as we do with files.
  • Loading branch information
schmichael committed Jan 8, 2018
1 parent 3c57705 commit a010d4b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ BUG FIXES:
* core: Fix search endpoint forwarding for multi-region clusters [[GH-3680](https://github.com/hashicorp/nomad/issues/3680)]
* core: Fix an issue in which batch jobs with queued placements and lost
allocations could result in improper placement counts [[GH-3717](https://github.com/hashicorp/nomad/issues/3717)]
* client: Migrated ephemeral_disk's maintain directory permissions [[GH-3723](https://github.com/hashicorp/nomad/issues/3723)]
* config: Revert minimum CPU limit back to 20 from 100.

## 0.7.1 (December 19, 2017)
Expand Down
13 changes: 10 additions & 3 deletions client/alloc_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,15 @@ func (p *remotePrevAlloc) streamAllocDir(ctx context.Context, resp io.ReadCloser

// If the header is for a directory we create the directory
if hdr.Typeflag == tar.TypeDir {
os.MkdirAll(filepath.Join(dest, hdr.Name), os.FileMode(hdr.Mode))
name := filepath.Join(dest, hdr.Name)
os.MkdirAll(name, os.FileMode(hdr.Mode))

// Can't change owner if not root or on Windows.
if euid == 0 {
if err := os.Chown(name, hdr.Uid, hdr.Gid); err != nil {
return fmt.Errorf("error chowning directory %v", err)
}
}
continue
}
// If the header is for a symlink we create the symlink
Expand All @@ -522,8 +530,7 @@ func (p *remotePrevAlloc) streamAllocDir(ctx context.Context, resp io.ReadCloser
return fmt.Errorf("error chmoding file %v", err)
}

// Can't change owner if not root. Returns false on
// Windows as Chown always errors there.
// Can't change owner if not root or on Windows.
if euid == 0 {
if err := f.Chown(hdr.Uid, hdr.Gid); err != nil {
f.Close()
Expand Down

0 comments on commit a010d4b

Please sign in to comment.