fusefrontend: Also preserve the owner in Mkdir
This already worked for files but was missing for dirs.
This commit is contained in:
parent
40420cb4cd
commit
828f718483
|
@ -153,10 +153,11 @@ func (fs *FS) Create(path string, flags uint32, mode uint32, context *fuse.Conte
|
||||||
return nil, fuse.ToStatus(err)
|
return nil, fuse.ToStatus(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Set owner
|
||||||
if fs.args.PreserveOwner {
|
if fs.args.PreserveOwner {
|
||||||
err = fd.Chown(int(context.Owner.Uid), int(context.Owner.Gid))
|
err = fd.Chown(int(context.Owner.Uid), int(context.Owner.Gid))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tlog.Warn.Printf("PreserveOwner: Chown failed: %v", err)
|
tlog.Warn.Printf("Create: Chown failed: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NewFile(fd, writeOnly, fs.contentEnc)
|
return NewFile(fd, writeOnly, fs.contentEnc)
|
||||||
|
|
|
@ -20,7 +20,8 @@ import (
|
||||||
|
|
||||||
func (fs *FS) mkdirWithIv(cPath string, mode uint32) error {
|
func (fs *FS) mkdirWithIv(cPath string, mode uint32) error {
|
||||||
// Between the creation of the directory and the creation of gocryptfs.diriv
|
// Between the creation of the directory and the creation of gocryptfs.diriv
|
||||||
// the directory is inconsistent. Take the lock to prevent other readers.
|
// the directory is inconsistent. Take the lock to prevent other readers
|
||||||
|
// from seeing it.
|
||||||
fs.dirIVLock.Lock()
|
fs.dirIVLock.Lock()
|
||||||
// The new directory may take the place of an older one that is still in the cache
|
// The new directory may take the place of an older one that is still in the cache
|
||||||
fs.nameTransform.DirIVCache.Clear()
|
fs.nameTransform.DirIVCache.Clear()
|
||||||
|
@ -51,6 +52,13 @@ func (fs *FS) Mkdir(newPath string, mode uint32, context *fuse.Context) (code fu
|
||||||
}
|
}
|
||||||
if fs.args.PlaintextNames {
|
if fs.args.PlaintextNames {
|
||||||
err = os.Mkdir(cPath, os.FileMode(mode))
|
err = os.Mkdir(cPath, os.FileMode(mode))
|
||||||
|
// Set owner
|
||||||
|
if fs.args.PreserveOwner {
|
||||||
|
err = os.Chown(cPath, int(context.Owner.Uid), int(context.Owner.Gid))
|
||||||
|
if err != nil {
|
||||||
|
tlog.Warn.Printf("Mkdir: Chown failed: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
return fuse.ToStatus(err)
|
return fuse.ToStatus(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +102,17 @@ func (fs *FS) Mkdir(newPath string, mode uint32, context *fuse.Context) (code fu
|
||||||
tlog.Warn.Printf("Mkdir: Chmod failed: %v", err)
|
tlog.Warn.Printf("Mkdir: Chmod failed: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Set owner
|
||||||
|
if fs.args.PreserveOwner {
|
||||||
|
err = os.Chown(cPath, int(context.Owner.Uid), int(context.Owner.Gid))
|
||||||
|
if err != nil {
|
||||||
|
tlog.Warn.Printf("Mkdir: Chown failed: %v", err)
|
||||||
|
}
|
||||||
|
err = os.Chown(filepath.Join(cPath, nametransform.DirIVFilename), int(context.Owner.Uid), int(context.Owner.Gid))
|
||||||
|
if err != nil {
|
||||||
|
tlog.Warn.Printf("Mkdir: Chown failed: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
return fuse.OK
|
return fuse.OK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue