[Pkg-samba-maint] r1476 - in trunk/samba/debian: . patches

vorlon at alioth.debian.org vorlon at alioth.debian.org
Thu Jul 12 06:20:17 UTC 2007


Author: vorlon
Date: 2007-07-12 06:20:17 +0000 (Thu, 12 Jul 2007)
New Revision: 1476

Added:
   trunk/samba/debian/patches/linux-cifs-user-perms.patch
Modified:
   trunk/samba/debian/changelog
   trunk/samba/debian/patches/series
Log:
support setting a default uid and gid value when mount.cifs is called as
non-root 



Modified: trunk/samba/debian/changelog
===================================================================
--- trunk/samba/debian/changelog	2007-07-10 05:54:17 UTC (rev 1475)
+++ trunk/samba/debian/changelog	2007-07-12 06:20:17 UTC (rev 1476)
@@ -13,8 +13,10 @@
     - move the ADS "gpo" cache directory to /var/cache/samba
     - move idmap_cache.tdb to /var/cache/samba, and fix up the path on
       winbind upgrade
+  * linux-cifs-user-perms.patch: also support setting a default uid and gid
+    value when mount.cifs is called as non-root
 
- -- Steve Langasek <vorlon at debian.org>  Mon, 09 Jul 2007 22:49:42 -0700
+ -- Steve Langasek <vorlon at debian.org>  Wed, 11 Jul 2007 23:18:55 -0700
 
 samba (3.0.25b-1) unstable; urgency=low
 

Added: trunk/samba/debian/patches/linux-cifs-user-perms.patch
===================================================================
--- trunk/samba/debian/patches/linux-cifs-user-perms.patch	                        (rev 0)
+++ trunk/samba/debian/patches/linux-cifs-user-perms.patch	2007-07-12 06:20:17 UTC (rev 1476)
@@ -0,0 +1,112 @@
+Goal: when mount.cifs is called by a non-root user, provide default uid= and
+gid= options matching the current process
+
+Upstream status: submitted as bugzilla bug #4780
+
+Index: samba-3.0.25b/source/client/mount.cifs.c
+===================================================================
+--- samba-3.0.25b.orig/source/client/mount.cifs.c	2007-07-11 19:54:30.000000000 -0700
++++ samba-3.0.25b/source/client/mount.cifs.c	2007-07-11 20:17:40.000000000 -0700
+@@ -321,6 +321,8 @@
+ 	int out_len = 0;
+ 	int word_len;
+ 	int rc = 0;
++	char user[32];
++	char group[32];
+ 
+ 	if (!optionsp || !*optionsp)
+ 		return 1;
+@@ -331,6 +333,13 @@
+ 
+ 	/* BB fixme check for separator override BB */
+ 
++	if (getuid()) {
++		got_uid = 1;
++		sprintf(user,"%u",getuid());
++		got_gid = 1;
++		sprintf(group,"%u",getgid());
++	}
++
+ /* while ((data = strsep(&options, ",")) != NULL) { */
+ 	while(data != NULL) {
+ 		/*  check if ends with trailing comma */
+@@ -493,33 +502,35 @@
+ 				got_uid = 1;
+ 				if (!isdigit(*value)) {
+ 					struct passwd *pw;
+-					static char temp[32];
+ 
+ 					if (!(pw = getpwnam(value))) {
+ 						printf("bad user name \"%s\"\n", value);
+ 						exit(1);
+ 					}
+-					sprintf(temp, "%u", pw->pw_uid);
+-					value = temp;
++					sprintf(user, "%u", pw->pw_uid);
+ 					endpwent();
++				} else {
++					strcpy(user,value);
+ 				}
+ 			}
++			goto nocopy;
+ 		} else if (strncmp(data, "gid", 3) == 0) {
+ 			if (value && *value) {
+ 				got_gid = 1;
+ 				if (!isdigit(*value)) {
+ 					struct group *gr;
+-					static char temp[32];
+ 
+ 					if (!(gr = getgrnam(value))) {
+ 						printf("bad group name \"%s\"\n", value);
+ 						exit(1);
+ 					}
+-					sprintf(temp, "%u", gr->gr_gid);
+-					value = temp;
++					sprintf(group, "%u", gr->gr_gid);
+ 					endpwent();
++				} else {
++					strcpy(group,value);
+ 				}
+ 			}
++			goto nocopy;
+        /* fmask and dmask synonyms for people used to smbfs syntax */
+ 		} else if (strcmp(data, "file_mode") == 0 || strcmp(data, "fmask")==0) {
+ 			if (!value || !*value) {
+@@ -621,6 +632,37 @@
+ nocopy:
+ 		data = next_keyword;
+ 	}
++
++	// special-case the uid and gid
++	if (got_uid) {
++		word_len = strlen(user);
++
++		out = (char *)realloc(out, out_len + word_len + 6);
++		if (out == NULL) {
++			perror("malloc");
++			exit(1);
++		}
++
++		if (out_len)
++			out[out_len++] = ',';
++		sprintf(out + out_len, "uid=%s", user);
++		out_len = strlen(out);
++	}
++	if (got_gid) {
++		word_len = strlen(group);
++
++		out = (char *)realloc(out, out_len + word_len + 6);
++		if (out == NULL) {
++			perror("malloc");
++			exit(1);
++		}
++
++		if (out_len)
++			out[out_len++] = ',';
++		sprintf(out + out_len, "gid=%s", group);
++		out_len = strlen(out);
++	}
++
+ 	free(*optionsp);
+ 	*optionsp = out;
+ 	return 0;

Modified: trunk/samba/debian/patches/series
===================================================================
--- trunk/samba/debian/patches/series	2007-07-10 05:54:17 UTC (rev 1475)
+++ trunk/samba/debian/patches/series	2007-07-12 06:20:17 UTC (rev 1476)
@@ -17,3 +17,4 @@
 autoconf.patch
 python-examples.patch
 missing_userspace_bugzilla999.patch
+linux-cifs-user-perms.patch




More information about the Pkg-samba-maint mailing list