gluster-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gluster-devel] Problem with with fuse_setattr()


From: Filipe Maia
Subject: [Gluster-devel] Problem with with fuse_setattr()
Date: Fri, 23 Jan 2009 16:48:08 +0100

Hi,

There is a problem with fuse_setattr() when the valid flag matches
more than one condition.
Imagine the following situation:

A file is created by the root and it's mode changed to 6555. Then the
owner is change to someone else.
When  this happens the setuid and setgid bits are removed at the same
as the owner is changed.
In this case valid == FUSE_SET_ATTR_MODE|FUSE_SET_ATTR_UID | FUSE_SET_ATTR_GID.

Due to the if else structure of the code the chown call will only
change the permissions it will not actually change the owner. Only the
second chown call will change the owner.
Changing the if else to a bunch of ifs causes problem which I think
are related to double freeing of some variables. It seems to me that
with the current code it's difficult to do
two fops from the same setattr.

The best solution I found for now was to use the following patch:

--- fuse-bridge.c.old   2009-01-23 16:39:32.000000000 +0100
+++ fuse-bridge.c       2009-01-23 16:38:43.000000000 +0100
@@ -858,11 +858,10 @@
               int valid,
               struct fuse_file_info *fi)
 {
-
-        if (valid & FUSE_SET_ATTR_MODE)
-                do_chmod (req, ino, attr, fi);
-        else if (valid & (FUSE_SET_ATTR_UID | FUSE_SET_ATTR_GID))
+        if (valid & (FUSE_SET_ATTR_UID | FUSE_SET_ATTR_GID))
                 do_chown (req, ino, attr, valid, fi);
+        else if (valid & FUSE_SET_ATTR_MODE)
+                do_chmod (req, ino, attr, fi);
         else if (valid & FUSE_SET_ATTR_SIZE)
                 do_truncate (req, ino, attr, fi);
         else if (valid & (FUSE_SET_ATTR_ATIME | FUSE_SET_ATTR_MTIME))

Having the USE_SET_ATTR_UID | FUSE_SET_ATTR_GID tested before
FUSE_SET_ATTR_MOD will cause the correct behaviour with the chown on
my machine.
But hardly seems like a proper solution. The best way I think would be
to test all possible flags one at a time, but I didn't manage to get
that working.

Filipe




reply via email to

[Prev in Thread] Current Thread [Next in Thread]