return ret;
}
+static int cfs_fuse_chmod(const char *path, mode_t mode)
+{
+ int ret = -EPERM;
+
+ cfs_debug("enter cfs_fuse_chmod %s", path);
+
+ mode_t allowed_mode = (S_IRUSR | S_IWUSR);
+ if (!path_is_private(path))
+ allowed_mode |= (S_IRGRP);
+
+ // allow only setting our supported modes (0600 for priv, 0640 for rest)
+ // mode has additional bits set, which we ignore; see stat(2)
+ if ((mode & ALLPERMS) == allowed_mode)
+ ret = 0;
+
+ cfs_debug("leave cfs_fuse_chmod %s (%d) mode: %o", path, ret, (int)mode);
+
+ return ret;
+}
+
+static int cfs_fuse_chown(const char *path, uid_t user, gid_t group)
+{
+ int ret = -EPERM;
+
+ cfs_debug("enter cfs_fuse_chown %s", path);
+
+ // we get -1 if no change should be made
+ if ((user == 0 || user == -1) && (group == cfs.gid || group == -1))
+ ret = 0;
+
+ cfs_debug("leave cfs_fuse_chown %s (%d) (uid: %d; gid: %d)", path, ret, user, group);
+
+ return ret;
+}
+
static int cfs_fuse_mkdir(const char *path, mode_t mode)
{
cfs_debug("enter cfs_fuse_mkdir %s", path);
{
(void) fi;
- cfs_debug("enter cfs_fuse_read %s %lu %ld", path, size, offset);
+ cfs_debug("enter cfs_fuse_read %s %zu %jd", path, size, offset);
int ret = -EACCES;
{
(void) fi;
- cfs_debug("enter cfs_fuse_write %s %lu %ld", path, size, offset);
+ cfs_debug("enter cfs_fuse_write %s %zu %jd", path, size, offset);
int ret = -EACCES;
static int cfs_fuse_truncate(const char *path, off_t size)
{
- cfs_debug("enter cfs_fuse_truncate %s %ld", path, size);
+ cfs_debug("enter cfs_fuse_truncate %s %jd", path, size);
int ret = -EACCES;
.readlink = cfs_fuse_readlink,
.utimens = cfs_fuse_utimens,
.statfs = cfs_fuse_statfs,
- .init = cfs_fuse_init
+ .init = cfs_fuse_init,
+ .chown = cfs_fuse_chown,
+ .chmod = cfs_fuse_chmod
};
static char *
exit (-1);
}
- for (int i=0; i < sizeof(utsname.nodename); i++) {
- if (utsname.nodename[i] =='.') utsname.nodename[i] = 0;
- }
+ char *dot = strchr(utsname.nodename, '.');
+ if (dot)
+ *dot = 0;
cfs.nodename = g_strdup(utsname.nodename);