Package: autofs
Version: 4.1.4-7

I modified the auto.smb to handle the password that the server may require. When I try to access the server //loki,
my script output these lines(the password is masked, of course):

-fstype=smbfs,username=gg,password='AaAaaaa 12' \
         /E$ ://loki/E$ \
         /write ://loki/write \
         /I$ ://loki/I$ \
         /opencpu ://loki/opencpu \
         /G$ ://loki/G$ \
         /smtsim ://loki/smtsim \
         /read ://loki/read \
         /rain ://loki/rain \
         /ADMIN$ ://loki/ADMIN$ \
         /C$ ://loki/C$ \
         /gems ://loki/gems

Then I find theses in /var/log/daemon.log(debug turned on):


Jun  2 01:24:11 Adam automount[9465]: lookup(program): loki -> -fstype=smbfs,username=gg,password='AaAaaaa 12'  ^I /E$ ://loki/E$  ^I /write ://loki/write  ^I /I$ ://loki/I$  ^I /opencpu ://loki/opencpu  ^I /G$ ://loki/G$  ^I /smtsim ://loki/smtsim ^I /read ://loki/read  ^I /rain ://loki/rain  ^I /ADMIN$ ://loki/ADMIN$  ^I /C$ ://loki/C$  ^I /gems ://loki/gems
Jun  2 01:24:11 Adam automount[9465]: parse(sun): expanded entry: -fstype=smbfs,username=gg,password='AaAaaaa 12'  ^I /E ://loki/E  ^I /write ://loki/write  ^I /I ://loki/I  ^I /opencpu ://loki/opencpu  ^I /G ://loki/G  ^I /smtsim ://loki/smtsim  ^I /read ://loki/read  ^I /rain ://loki/rain  ^I /ADMIN ://loki/ADMIN  ^I /C ://loki/C  ^I /gems ://loki/gems
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("fstype=smbfs,username=gg,password='AaAaaaa") -> fstype=smbfs,username=gg,password='AaAaaaa
Jun  2 01:24:11 Adam automount[9465]: parse(sun): gathered options: fstype=smbfs,username=gg,password='AaAaaaa
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("/") -> /
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("12'") -> 12'
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("/E") -> /E
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("//loki/E") -> //loki/E
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("/write") -> /write
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("//loki/write") -> //loki/write
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("/I") -> /I
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("//loki/I") -> //loki/I
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("/opencpu") -> /opencpu
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("//loki/opencpu") -> //loki/opencpu
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("/G") -> /G
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("//loki/G") -> //loki/G
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("/smtsim") -> /smtsim
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("//loki/smtsim") -> //loki/smtsim
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("/read") -> /read
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("//loki/read") -> //loki/read
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("/rain") -> /rain
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("//loki/rain") -> //loki/rain
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("/ADMIN") -> /ADMIN
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("//loki/ADMIN") -> //loki/ADMIN
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("/C") -> /C
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("//loki/C") -> //loki/C
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("/gems") -> /gems
Jun  2 01:24:11 Adam automount[9465]: parse(sun): dequote("//loki/gems") -> //loki/gems
Jun  2 01:24:11 Adam automount[9465]: parse(sun): multimount: 12' on / with options fstype=smbfs,username=gg,password='AaAaaaa
Jun  2 01:24:11 Adam automount[9465]: parse(sun): mounting root /opt/loki, mountpoint , what 12', fstype smbfs, options username=gg,password='AaAaaaa

I found that:
1) the '$'es in the share names are lost during the 'dequote' processing in 'parse(sun)' module
2) the password is cut into two pieces by the space, even the quote or double-quote cannot protect the password.
I see these as bugs of the package, so I decide to report to you. At the time of posting, the latest version of autofs package
would be 4.1.4-10. I didn't try this, but the changelog doesn't suggest that these bugs have been fixed

kernel version 2.6.12-10, build by myself.
libc6 2.3.6-7



something that maybe less relevant
======================
Configured Mount Points:
------------------------
/usr/sbin/automount --timeout=300 --ghost /mnt file /etc/auto.local user umask=0 utf8
/usr/sbin/automount --timeout=60 /media program /etc/auto.usb
/usr/sbin/automount --timeout=300 /opt program /etc/auto.smb

Active Mount Points:
--------------------
/usr/sbin/automount --pid-file=/var/run/autofs/_etc_auto.local.pid --timeout=300 --ghost /mnt file /etc/auto.local user umask=0 utf8
/usr/sbin/automount --pid-file=/var/run/autofs/_media.pid --timeout=60 /media program /etc/auto.usb
/usr/sbin/automount --pid-file=/var/run/autofs/_opt.pid --timeout=300 /opt program /etc/auto.smb



The auto.smb file
==================================
key="$1"
opts="-fstype=smbfs"

auth()
{
        AUTHFILE="/etc/autosmb.pwd/$1"
        if [ -r "$AUTHFILE" ]; then
          { local IFS='= '
            read NOUSE USER
            read NOUSE PASSWD
          } < "$AUTHFILE"

          opts="$opts,username=$USER,password=\"$PASSWD\""

          SMBCLIENT="$SMBCLIENT -U \"$USER%$PASSWD\" "
        else
          SMBCLIENT="$SMBCLIENT -N "
        fi
}


for SMBCLIENT in /{,usr/}{,s}bin/smbclient
do
        if [ -x $SMBCLIENT ]
        then
                break
        fi
done

[ -x $SMBCLIENT ] || exit 1

auth $key

IFS='|'
FIRST=1
eval "$SMBCLIENT -gL $key 2>/dev/null"| while read TYPE NAME COMMENT
        do
        if [ "$TYPE" == "Disk" ]; then
                if eval "$SMBCLIENT //$key/$NAME -c quit >/dev/null 2>/dev/null"; then
                        if [ "$FIRST" == "1" ]; then
                                echo -n "$opts"
                                FIRST=0
                        fi
                        echo -en " \\\\\n\t /$NAME ://$key/$NAME"
                fi
        fi
        done

Reply via email to