[linux-cifs-client] mount.cifs.c and passwords with ',' in them

Jay Fenlason fenlason at redhat.com
Thu Jan 13 20:35:54 GMT 2005


The attached patch closes
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=144198
and
https://bugzilla.samba.org/show_bug.cgi?id=899

by using \001 (Control-A) as the separator character between
mount.cifs and the kernel.  This will work until someone opens a bug
rport saying that their password with ^A in it doesn't work.

IMAO, the correct way to fix it is to use \0 as the paramater
separator (so everyone's passwords will work), but that requires
fixing the kernel side code to allow it.

			-- JF
-------------- next part --------------
--- samba-3.0.10/source/client/mount.cifs.c	2004-10-25 17:05:11.000000000 -0400
+++ mount.cifs.c	2005-01-12 16:27:21.000000000 -0500
@@ -297,10 +297,10 @@
 						printf("\nskipping empty user mount parameter\n");
 					/* remove the parm since it would otherwise be confusing
 					to the kernel code which would think it was a real username */
-						data[0] = ',';
-						data[1] = ',';
-						data[2] = ',';
-						data[3] = ',';
+						data[0] = '\001';
+						data[1] = '\001';
+						data[2] = '\001';
+						data[3] = '\001';
 					/* BB remove it from mount line so as not to confuse kernel code */
 				} else {
 					printf("username specified with no parameter\n");
@@ -311,7 +311,7 @@
 					got_user=1;
 					percent_char = strchr(value,'%');
 					if(percent_char) {
-						*percent_char = ',';
+						*percent_char = '\001';
 						if(mountpassword == NULL)
 							mountpassword = calloc(65,1);
 						if(mountpassword) {
@@ -322,7 +322,7 @@
 							strncpy(mountpassword, percent_char,64);
 						/*  remove password from username */
 							while(*percent_char != 0) {
-								*percent_char = ',';
+								*percent_char = '\001';
 								percent_char++;
 							}
 						}
@@ -468,11 +468,11 @@
 		} else if (strncmp(data, "guest", 5) == 0) {
 			got_password=1;
                         /* remove the parm since it would otherwise be logged by kern */
- 			data[0] = ',';
-                        data[1] = ',';
-                        data[2] = ',';
- 			data[3] = ',';
-			data[4] = ',';
+ 			data[0] = '\001';
+                        data[1] = '\001';
+                        data[2] = '\001';
+ 			data[3] = '\001';
+			data[4] = '\001';
 		} else if (strncmp(data, "ro", 2) == 0) {
 			*filesys_flags |= MS_RDONLY;
 		} else if (strncmp(data, "rw", 2) == 0) {
@@ -509,7 +509,7 @@
 	
 		/* put previous overwritten comma back */
 		if(next_keyword)
-			*next_keyword = ',';
+			*next_keyword = '\001';
 		else
 			data = NULL;
 	}
@@ -525,7 +525,6 @@
 	char * ipaddress_string = NULL;
 	struct hostent * host_entry;
 	struct in_addr server_ipaddr;
-	int rc;
 
 	if(length > 1023) {
 		printf("mount error: UNC name too long");
@@ -569,7 +568,8 @@
 				share += 1;
 				if(got_ip == 0) {
 					host_entry = gethostbyname(unc_name);
-				}
+				} else
+					host_entry = NULL;
 				*(share - 1) = '/'; /* put the slash back */
 				if(got_ip) {
 					if(verboseflag)
@@ -578,7 +578,6 @@
 				}
 				if(host_entry == NULL) {
 					printf("mount error: could not find target server. TCP name %s not found ", unc_name);
-					printf(" rc = %d\n",rc);
 					return NULL;
 				} else {
 					/* BB should we pass an alternate version of the share name as Unicode */
@@ -855,7 +854,7 @@
 		optlen += strlen(ipaddr) + 4;
 	if(mountpassword)
 		optlen += strlen(mountpassword) + 6;
-	options = malloc(optlen + 10);
+	options = malloc(optlen + 15);
 
 	if(options == NULL) {
 		printf("Could not allocate memory for mount options\n");
@@ -863,7 +862,7 @@
 	}
 		
 
-	options[0] = 0;
+	strcpy ( options, "sep=\001" );
 	strncat(options,"unc=",4);
 	strcat(options,share_name);
 	/* scan backwards and reverse direction of slash */
@@ -871,22 +870,22 @@
 	if(temp > options + 6)
 		*temp = '\\';
 	if(ipaddr) {
-		strncat(options,",ip=",4);
+		strncat(options,"\001ip=",4);
 		strcat(options,ipaddr);
 	} 
 	if(user_name) {
-		strncat(options,",user=",6);
+		strncat(options,"\001user=",6);
 		strcat(options,user_name);
 	} 
 	if(mountpassword) {
-		strncat(options,",pass=",6);
+		strncat(options,"\001pass=",6);
 		strcat(options,mountpassword);
 	}
-	strncat(options,",ver=",5);
+	strncat(options,"\001ver=",5);
 	strcat(options,MOUNT_CIFS_VERSION_MAJOR);
 
 	if(orgoptions) {
-		strcat(options,",");
+		strcat(options,"\001");
 		strcat(options,orgoptions);
 	}
 	if(verboseflag)


More information about the linux-cifs-client mailing list