mirror of
https://github.com/moby/moby.git
synced 2026-08-08 17:11:38 +00:00
daemon/graphdriver: Avoid recursive driver home ownership changes
The daemon root exists before graphdriver initialization, so recursively creating driver homes can apply the driver's ownership and mode to missing parent directories. Create each driver-owned directory directly during initialization, including the VFS layer parent. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
committed by
Sebastiaan van Stijn
parent
7a4a06cc89
commit
4d64f0249d
@@ -78,7 +78,7 @@ func Init(home string, options []string, idMap user.IdentityMapping) (graphdrive
|
||||
}
|
||||
|
||||
_, gid := idMap.RootPair()
|
||||
if err := user.MkdirAllAndChown(home, 0o710, os.Getuid(), gid); err != nil {
|
||||
if err := user.MkdirAndChown(home, 0o710, os.Getuid(), gid); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@@ -84,10 +84,10 @@ func Init(home string, options []string, idMap user.IdentityMapping) (graphdrive
|
||||
|
||||
cuid := os.Getuid()
|
||||
_, gid := idMap.RootPair()
|
||||
if err := user.MkdirAllAndChown(home, 0o710, cuid, gid); err != nil {
|
||||
if err := user.MkdirAndChown(home, 0o710, cuid, gid); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := user.MkdirAllAndChown(path.Join(home, linkDir), 0o700, cuid, os.Getegid()); err != nil {
|
||||
if err := user.MkdirAndChown(path.Join(home, linkDir), 0o700, cuid, os.Getegid()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@@ -167,10 +167,10 @@ func Init(home string, options []string, idMap user.IdentityMapping) (graphdrive
|
||||
|
||||
cuid := os.Getuid()
|
||||
_, gid := idMap.RootPair()
|
||||
if err := user.MkdirAllAndChown(home, 0o710, cuid, gid); err != nil {
|
||||
if err := user.MkdirAndChown(home, 0o710, cuid, gid); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := user.MkdirAllAndChown(path.Join(home, linkDir), 0o700, cuid, os.Getegid()); err != nil {
|
||||
if err := user.MkdirAndChown(path.Join(home, linkDir), 0o700, cuid, os.Getegid()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,10 @@ func Init(home string, options []string, idMap user.IdentityMapping) (graphdrive
|
||||
}
|
||||
|
||||
_, gid := d.idMapping.RootPair()
|
||||
if err := user.MkdirAllAndChown(home, 0o710, os.Getuid(), gid); err != nil {
|
||||
if err := user.MkdirAndChown(home, 0o710, os.Getuid(), gid); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := user.MkdirAndChown(filepath.Join(home, "dir"), 0o710, os.Getuid(), gid); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ func Init(base string, opt []string, idMap user.IdentityMapping) (graphdriver.Dr
|
||||
}
|
||||
|
||||
_, gid := idMap.RootPair()
|
||||
if err := user.MkdirAllAndChown(base, 0o710, os.Getuid(), gid); err != nil {
|
||||
if err := user.MkdirAndChown(base, 0o710, os.Getuid(), gid); err != nil {
|
||||
return nil, fmt.Errorf("Failed to create '%s': %v", base, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ func TestLayerMigrationNoTarsplit(t *testing.T) {
|
||||
newTestFile("/root/.bashrc", []byte("# Updated configuration"), 0o644),
|
||||
}
|
||||
|
||||
graph, err := newVFSGraphDriver(filepath.Join(tempDir, "graphdriver-"))
|
||||
graph, err := newVFSGraphDriver(tempDir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user