[vhffs-dev] [1597] add two new options, clearmodefile and clearmodedir, so that you can clear modes when chmod()ing (eg.

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1597
Author:   gradator
Date:     2010-04-13 00:35:55 +0200 (Tue, 13 Apr 2010)
Log Message:
-----------
add two new options, clearmodefile and clearmodedir, so that you can clear modes when chmod()ing (eg. clearing o+w, ...), renamed minimalright... options to forcemode... options

Modified Paths:
--------------
    trunk/vhffs-fs/config.h.in
    trunk/vhffs-fs/vhffsfs.c
    trunk/vhffs-fs/vhffsfs.conf.dist

Modified: trunk/vhffs-fs/config.h.in
===================================================================
--- trunk/vhffs-fs/config.h.in	2010-04-12 22:10:01 UTC (rev 1596)
+++ trunk/vhffs-fs/config.h.in	2010-04-12 22:35:55 UTC (rev 1597)
@@ -158,6 +158,9 @@
 /* Define to the one symbol short name of this package. */
 #undef PACKAGE_TARNAME
 
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
@@ -210,7 +213,7 @@
 #undef _REENTRANT
 
 /* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
-   <pthread.h>, or <semaphore.h> is not used. If the typedef was allowed, the
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
    #define below would cause a syntax error. */
 #undef _UINT32_T
 

Modified: trunk/vhffs-fs/vhffsfs.c
===================================================================
--- trunk/vhffs-fs/vhffsfs.c	2010-04-12 22:10:01 UTC (rev 1596)
+++ trunk/vhffs-fs/vhffsfs.c	2010-04-12 22:35:55 UTC (rev 1597)
@@ -104,8 +104,10 @@
 	char *dbname;
 	int dbtimeout;
 	char *dbconninfo;
-	mode_t minimumrightfile;
-	mode_t minimumrightdir;
+	mode_t forcemodefile;
+	mode_t forcemodedir;
+	mode_t clearmodefile;
+	mode_t clearmodedir;
 #ifdef WITH_CACHE
 	GHashTable *cachequeries;
 	GPtrArray* cachekeys;
@@ -1361,7 +1363,9 @@
 		struct stat st;
 		lchown(rpath, uid, gid);
 		stat(rpath, &st);
-		chmod(rpath, st.st_mode | vhffsfs.minimumrightdir);
+		st.st_mode &= vhffsfs.clearmodedir;
+		st.st_mode |= vhffsfs.forcemodedir;
+		chmod(rpath, st.st_mode);
 	}
 	free(rpath);
 
@@ -1505,7 +1509,14 @@
 	if(!rpath) return -ENOENT;
 
 	stat(rpath, &st);
-	res = chmod(rpath, mode | (S_ISDIR(st.st_mode) ? vhffsfs.minimumrightdir : vhffsfs.minimumrightfile) );
+	if( S_ISDIR(st.st_mode) ) {
+		mode &= vhffsfs.clearmodedir;
+		mode |= vhffsfs.forcemodedir;
+	} else {
+		mode &= vhffsfs.clearmodefile;
+		mode |= vhffsfs.forcemodefile;
+	}
+	res = chmod(rpath, mode);
 	free(rpath);
 
 	if(res == -1) return -errno;
@@ -1597,7 +1608,9 @@
 		struct stat st;
 		lchown(rpath, uid, gid);
 		stat(rpath, &st);
-		chmod(rpath, st.st_mode | vhffsfs.minimumrightfile);
+		st.st_mode &= vhffsfs.clearmodefile;
+		st.st_mode |= vhffsfs.forcemodefile;
+		chmod(rpath, st.st_mode);
 	}
 	free(rpath);
 
@@ -1846,12 +1859,18 @@
 		else if(!strncmp("dbtimeout ", line, 10))  {
 			vhffsfs.dbtimeout = atoi(line+10);
 		}
-		else if(!strncmp("minimumrightfile ", line, 17))  {
-                     vhffsfs.minimumrightfile = strtoul(line+17, NULL, 8);
+		else if(!strncmp("forcemodefile ", line, 14))  {
+                     vhffsfs.forcemodefile = strtoul(line+14, NULL, 8);
 		}
-		else if(!strncmp("minimumrightdir ", line, 16))  {
-                     vhffsfs.minimumrightdir = strtoul(line+16, NULL, 8);
+		else if(!strncmp("forcemodedir ", line, 13))  {
+                     vhffsfs.forcemodedir = strtoul(line+13, NULL, 8);
 		}
+		else if(!strncmp("clearmodefile ", line, 14))  {
+                     vhffsfs.clearmodefile = ~strtoul(line+14, NULL, 8);
+		}
+		else if(!strncmp("clearmodedir ", line, 13))  {
+                     vhffsfs.clearmodedir = ~strtoul(line+13, NULL, 8);
+		}
 #ifdef WITH_CHECKQUOTA
 		else if(!strncmp("datablockdev ", line, 13))  {
                      vhffsfs.datablockdev = strdup(line+13);
@@ -1917,8 +1936,10 @@
 	vhffsfs.dbtimeout = 30;
 //	vhffsfs.defaultrightfile = 00664;
 //	vhffsfs.defaultrightdir = 02775;
-	vhffsfs.minimumrightfile = 00400;
-	vhffsfs.minimumrightdir = 02700;
+	vhffsfs.forcemodefile = 00400;
+	vhffsfs.forcemodedir = 02700;
+	vhffsfs.clearmodefile = ~07002;
+	vhffsfs.clearmodedir = ~05002;
 #ifdef WITH_CACHE
 	vhffsfs.cachequeries = g_hash_table_new(g_str_hash, g_str_equal);
 	vhffsfs.cachekeys = g_ptr_array_sized_new(4096);

Modified: trunk/vhffs-fs/vhffsfs.conf.dist
===================================================================
--- trunk/vhffs-fs/vhffsfs.conf.dist	2010-04-12 22:10:01 UTC (rev 1596)
+++ trunk/vhffs-fs/vhffsfs.conf.dist	2010-04-12 22:35:55 UTC (rev 1597)
@@ -7,8 +7,12 @@
 dbpass mypass
 dbname vhffs
 dbtimeout 10
-minimumrightfile 00400
-minimumrightdir 02700
+# bits to enforce when chmoding files
+forcemodefile 00400
+forcemodedir 02700
+# bits to clear when chmoding files
+clearmodefile 07002
+clearmodedir 05002
 # -- set this value to your blockdev which contain the /data if you want to check stats locally
 #datablockdev /dev/sda5
 # -- set these values to your rpcserver IP or host and path which contain the /data if your want to remotely check stats


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/