[vhffs-dev] [1623] fixing various stuff on vhffsfs (long train trips do that, usually) |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1623
Author: gradator
Date: 2010-09-06 21:50:23 +0200 (Mon, 06 Sep 2010)
Log Message:
-----------
fixing various stuff on vhffsfs (long train trips do that, usually)
Modified Paths:
--------------
trunk/vhffs-fs/vhffsfs.c
Modified: trunk/vhffs-fs/vhffsfs.c
===================================================================
--- trunk/vhffs-fs/vhffsfs.c 2010-08-30 20:00:42 UTC (rev 1622)
+++ trunk/vhffs-fs/vhffsfs.c 2010-09-06 19:50:23 UTC (rev 1623)
@@ -1,7 +1,7 @@
/*
* VHFFSFS: Virtual chroot for your users, using FUSE !
*
- * Copyright 2007-2008 Sylvain Rochet <gradator@xxxxxxxxxxxx>
+ * Copyright 2007-2010 Sylvain Rochet <gradator@xxxxxxxxxxxx>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -441,7 +441,7 @@
for(cur = group ; *cur ; cur++)
if(! ( (*cur >= 'a' && *cur <= 'z') || (*cur >= '0' && *cur <= '9') ) ) return 0;
- snprintf(query, 256, "SELECT g.gid FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id=g.object_id WHERE o.state=6 AND g.groupname='%s' ", group);
+ snprintf(query, 256, "SELECT g.gid FROM vhffs_groups g INNER JOIN vhffs_user_group ug ON ug.gid=g.gid INNER JOIN vhffs_object o ON o.object_id=g.object_id WHERE ug.uid = %d AND o.state=6 AND g.groupname='%s' ", fuse_get_context()->uid, group);
res=vhffsfs_PGQuery(query);
if(!res) return 0;
@@ -646,8 +646,6 @@
// set uid and gid
if(uid) *uid = fuse_get_context()->uid;
if(gid) *gid = fuse_get_context()->gid;
- // path relative
- if(*(path+0) == '.') return strdup(path);
// fetch homedir
homedir = vhffsfs_gethomedir();
if(!homedir) return strdup(VHFFSFS_EMPTYDIR);
@@ -752,22 +750,27 @@
char **vhffsfs_virtualdirs(const char *path) {
- char *groupname=NULL;
- char **vdirs=NULL;
+ char *groupname;
+ char *cur;
+ gid_t gid;
// path empty
- if(*(path+0) == '\0') return NULL;
+ if(*path == '\0') return NULL;
+
// get groupname
- if(*(path+1) != '\0') groupname = (char*)path+1;
+ groupname = (char*)path+1;
+ if(!groupname)
+ return vhffsfs_getusergroups(fuse_get_context()->uid);
- if(!groupname) vdirs = vhffsfs_getusergroups(fuse_get_context()->uid);
+ // don't do group lookup if the path is not a group directory
+ for(cur = groupname ; *cur ; cur++)
+ if( *cur == '/' ) return NULL;
- else {
- gid_t gid = vhffsfs_getgroupgid(groupname);
- if(gid > 0) vdirs = vhffsfs_getgroupservices(gid);
- }
+ gid = vhffsfs_getgroupgid(groupname);
+ if(gid > 0)
+ return vhffsfs_getgroupservices(gid);
- return vdirs;
+ return NULL;
}