Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodefs API: cannot implement chgrp #107

Closed
rfjakob opened this issue May 16, 2016 · 1 comment
Closed

nodefs API: cannot implement chgrp #107

rfjakob opened this issue May 16, 2016 · 1 comment

Comments

@rfjakob
Copy link
Contributor

rfjakob commented May 16, 2016

chgrp(1) actually calls chown(2) with owner set to -1.

Right now, the nodefs code does not handle chgrp at all, but that could be fixed easily. The real problem is that the parameters for Node.Chown() are defined as uint32 instead of int as for syscall.Chown()

How to fix this? Pass 0xFFFFFFFF instead of -1 ?

@rfjakob
Copy link
Contributor Author

rfjakob commented May 16, 2016

This should do it. If you agree I will submit it together with a test case for loopbackfs.

diff --git a/fuse/nodefs/fsops.go b/fuse/nodefs/fsops.go
index 459b75c..4c3120d 100644
--- a/fuse/nodefs/fsops.go
+++ b/fuse/nodefs/fsops.go
@@ -201,7 +201,15 @@ func (c *rawBridge) SetAttr(input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse
                code = node.fsInode.Chmod(f, permissions, &input.Context)
        }
        if code.Ok() && (input.Valid&(fuse.FATTR_UID|fuse.FATTR_GID) != 0) {
-               code = node.fsInode.Chown(f, uint32(input.Uid), uint32(input.Gid), &input.Context)
+               var uid uint32 = ^uint32(0) // means "don't care" in chown(2)
+               var gid uint32 = ^uint32(0)
+               if input.Valid&fuse.FATTR_UID != 0 {
+                       uid = input.Uid
+               }
+               if input.Valid&fuse.FATTR_GID != 0 {
+                       gid = input.Gid
+               }
+               code = node.fsInode.Chown(f, uid, gid, &input.Context)
        }
        if code.Ok() && input.Valid&fuse.FATTR_SIZE != 0 {
                code = node.fsInode.Truncate(f, input.Size, &input.Context)

rfjakob added a commit to rfjakob/go-fuse that referenced this issue May 17, 2016
The special value "-1" for uid or gid means that the value
should not be changed. nodefs incorrectly passed 0 for this
case, leading to chgrp(1) always failing for non-root mounts.

Fixes hanwen#107 .

Change-Id: Idbc5b5da92456278a20a50ccd77183ff391b463f
@hanwen hanwen closed this as completed in 6794332 May 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant