mirror of
https://github.com/kemko/nomad.git
synced 2026-01-03 00:45:43 +03:00
chown dirs when migrating ephemeral_disk data
Fixes #3702 Added missing chown call and made it conditional on running as root and not on Windows as we do with files.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user