graphdriver/fuse-overlayfs: Remove redundant dir chown#53134
Conversation
Init already creates the driver home with the required ownership. Avoid calling MkdirAllAndChown on it again during every layer creation. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
There was a problem hiding this comment.
Pull request overview
This PR removes a per-layer MkdirAllAndChown(path.Dir(dir), ...) call in the fuse-overlayfs graphdriver’s create() path, relying on Init() to have already created and chowned the driver home directory. The intent is to avoid repeated ownership work on every layer creation.
Changes:
- Remove redundant
MkdirAllAndChown()of the driver home directory from(*Driver).create(). - Keep per-layer directory creation (
MkdirAndChown(dir, ...)) unchanged.
| dir := d.dir(id) | ||
| uid, gid := d.idMap.RootPair() | ||
|
|
||
| if err := user.MkdirAllAndChown(path.Dir(dir), 0o710, uid, gid); err != nil { | ||
| return err | ||
| } | ||
| if err := user.MkdirAndChown(dir, 0o710, uid, gid); err != nil { | ||
| return err |
There was a problem hiding this comment.
The path is created in the driver's init function
moby/daemon/graphdriver/fuse-overlayfs/fuseoverlayfs.go
Lines 76 to 92 in b780867
Which is registered as the init function for the driver, so executed at startup;
|
Had another look at this, and probably needs a follow-up; looks like the same is the case for overlay2 (maybe others) moby/daemon/graphdriver/overlay2/overlay.go Lines 346 to 356 in c77c96e Some notes there; Looks like this MkdirAllAndChown for the drivers' home because redundant after 03f1c3d That was a security fix, to make sure the driver's home had the right permissions, and that added the MkdirAllAndChown in the
03f1c3d#diff-ed0b7987eccdde1bd70dc1ca9191f0ac2601e8f187024db5e3f968d755b9e47c From the above, it looks to be intentional to overwrite existing mode for the directory BUT it may be too wide; moby/vendor/github.com/moby/sys/user/idtools.go Lines 15 to 17 in c77c96e
Which means that any missing parent path would also be chown-ed and chmod-ed (the comment looks wrong because existing paths are handled earlier); moby/vendor/github.com/moby/sys/user/idtools_unix.go Lines 60 to 66 in c77c96e |
Init already creates the driver home with the required ownership. Avoid calling MkdirAllAndChown on it again during every layer creation.
Summary
Release notes (optional)
A picture of a cute animal (not mandatory but encouraged)