You are not logged in.

#1 2016-06-05 13:27:40

yktor
Member
Registered: 2016-06-05
Posts: 7

Auto mounting of smb shares with dollar sign

I expirience the problem with automounting of smb shares with dollar sign (Ex: //hostname/C$).

I'm using default auto.smb. It escapes dollars, netherless I can't access such shares.

    $SMBCLIENT $smbopts -gL "$key" 2>/dev/null| awk -v "key=$key" -v "opts=$opts" -F '|' -- '
	BEGIN	{ ORS=""; first=1 }
	/Disk/	{
		  if (first)
			print opts; first=0
		  dir = $2
		  loc = $2
		  # Enclose mount dir and location in quotes
		  # Double quote "$" in location as it is special
		  gsub(/\$$/, "\\$", loc);
		  gsub(/\&/,"\\\\&",loc)
		  print " \\\n\t \"/" dir "\"", "\"://" key "/" loc "\""
		}
	END 	{ if (!first) print "\n"; else exit 1 }
	'

For example when I do `ls /smb/10.250.79.126/C\$`, I get such error from automount:

    attempting to mount entry /smb/10.250.79.126/C$
    lookup_mount: lookup(program): /smb/10.250.79.126/C$ -> -fstype=cifs,uid=1000,gid=1000,credentials=/etc/creds/10.250.79.126 ://10.250.79.126/C\$
    parse_mount: parse(sun): expanded entry: -fstype=cifs,uid=1000,gid=1000,credentials=/etc/creds/10.250.79.126 ://10.250.79.126/C\$
    parse_mount: parse(sun): gathered options: fstype=cifs,uid=1000,gid=1000,credentials=/etc/creds/10.250.79.126
    sun_mount: parse(sun): mounting root /smb/10.250.79.126/C$, mountpoint /smb/10.250.79.126/C$, what //10.250.79.126/C\$, fstype cifs, options uid=1000,gid=1000,credentials=/etc/creds/10.250.79.126
    do_mount: //10.250.79.126/C\$ /smb/10.250.79.126/C$ type cifs options uid=1000,gid=1000,credentials=/etc/creds/10.250.79.126 using module generic
    mount_mount: mount(generic): calling mkdir_path /smb/10.250.79.126/C$
    mount_mount: mount(generic): calling mount -t cifs -o uid=1000,gid=1000,credentials=/etc/creds/10.250.79.126 //10.250.79.126/C\$ /smb/10.250.79.126/C$
    >> Retrying with upper case share name
    >> mount error(6): No such device or address
    >> Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
    mount(generic): failed to mount //10.250.79.126/C\$ (type cifs) on /smb/10.250.79.126/C$
    dev_ioctl_send_fail: token = 156
    failed to mount /smb/10.250.79.126/C$

But when I try `mount -t cifs -o uid=1000,gid=1000,credentials=/etc/creds/10.250.79.126 //10.250.79.126/C\$ /smb/10.250.79.126/C$`, it works.

Can you give me advise what to do? It looks for me now as an bug in distribution.

Offline

#2 2016-06-30 09:47:11

yktor
Member
Registered: 2016-06-05
Posts: 7

Re: Auto mounting of smb shares with dollar sign

I finally found the time to investigate this problem. It happend because two facts:
1. Autofs reads '$' as a special symbol (variable name) and expands it to variable value
2. mount.cifs reads '\\' as a delimiter, so you can actually pass "\\\\hostname\\sharename" as mount src argument

So in my case if I returns "//hostname/C$" from auto.smb, then automount daemon replace '$' to '' and if I returns "//hostname/C\\$" then mount.cifs crops "\\$" and uses '$' as a prefixpath mount option.

I made simple fix in automount, that drops back slash after arguments parsing.

--- modules/parse_sun.c.orig    2016-06-30 12:25:24.303171405 +0300
+++ modules/parse_sun.c 2016-06-30 12:27:17.269833151 +0300
@@ -177,13 +177,10 @@
                        }
                        break;
 
                case '\\':
                        len++;
-                       if (dst)
-                               *dst++ = ch;
-
                        if (*src) {
                                len++;
                                if (dst)
                                        *dst++ = *src;
                                src++;

Will write to developers

Offline

Board footer

Powered by FluxBB