Skip to contentSkip to conversation

CIFS: make sec=none force an anonymous mount

PATCH In review Jeff Layton 2 participants 2 messages May 3, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CIFS: make sec=none force an anonymous mount

We had a customer report that attempting to make CIFS mount with a null username (i.e. doing an anonymous mount) doesn't work. Looking through the code, it looks like CIFS expects a NULL username from userspace in order to trigger an anonymous mount. The mount.cifs code doesn't seem to ever pass a null username to the kernel, however.

It looks also like the kernel can take a sec=none option, but it only seems to look at it if the username is already NULL. This seems redundant and effectively makes sec=none useless.

The following patch makes sec=none force an anonymous mount. I've briefly tested it and it seems to work. I suppose we could alternately do some stuff in userspace to make mount.cifs force a null username instead, but this seems more straightforward to me.

fs/cifs/connect.c +4 -3
index cf40e24..330e290 100644
@@ -1721,12 +1721,13 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
 		return -EINVAL;
 	}
 
-	if (volume_info.username) {
+	if (volume_info.nullauth) {
+		cFYI(1,("null user"));
+		volume_info.username = NULL;
+	} else if (volume_info.username) {
 		/* BB fixme parse for domain name here */
 		cFYI(1, ("Username: %s ", volume_info.username));
 
-	} else if (volume_info.nullauth) {
-		cFYI(1,("null user"));
 	} else {
 		cifserror("No username specified");
         /* In userspace mount helper we can get user name from alternate
#1 lore raw
Quoted 6 lines · Jeff Layton

We had a customer report that attempting to make CIFS mount with a null username (i.e. doing an anonymous mount) doesn't work. Looking through the code, it looks like CIFS expects a NULL username from userspace in order to trigger an anonymous mount. The mount.cifs code doesn't seem to ever pass a null username to the kernel, however.

Quoted 8 lines

It looks also like the kernel can take a sec=none option, but it only seems to look at it if the username is already NULL. This seems redundant and effectively makes sec=none useless.

The following patch makes sec=none force an anonymous mount. I've briefly tested it and it seems to work. I suppose we could alternately do some stuff in userspace to make mount.cifs force a null username instead, but this seems more straightforward to me.

Looks useful. In case you have some spare time at your hand it would be really nice to convert cifs option parsing to the lib/parser.c code and move all validation of the arguments into one place, so it's easily understanable and better to maintain.