2 # Debian mount.smbfs compatibility wrapper
3 # Copyright 2007, Steve Langasek <vorlon at debian.org>
4 # Licensed under the GNU General Public License, version 2. See the
5 # file /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
7 # This script accepts all documented mount options for mount.smbfs,
8 # passing through those that are also recognized by mount.cifs,
9 # converting those that are not recognized but map to available cifs
10 # options, and warning about the use of options for which no equivalent
13 # known bugs: quoted spaces in arguments are not passed intact
17 # reverse the order of username and password in a "username" parameter,
18 # taking care to leave any "%password" bit intact
20 reverse_username_workgroup
() {
21 local workgroup password username
25 *%*) password
="${username#*%}"
26 username
="${username%%%*}"
31 */*) workgroup
="${username#*/}"
32 username
="${username%%/*}"
36 if [ -n "$workgroup" ]; then
37 username
="$workgroup\\$username"
39 if [ -n "$password" ]; then
40 username
="$username%$password"
46 # parse out the mount options that have been specified using -o, and if
47 # necessary, convert them for use by mount.cifs
49 parse_mount_options
() {
50 local OLD_IFS IFS options option username
59 sockopt
=* | scope
=* | codepage
=* | ttl
=* | debug
=*)
60 echo "Warning: ignoring deprecated smbfs option '$option'" >&2
64 options
="$options${options:+,}sec=krb5"
68 echo "Warning: mapping 'guest' to 'guest,sec=none'" >&2
69 options
="$options${options:+,}guest,sec=none"
72 # username and workgroup are reversed in username= arguments,
73 # so need to be parsed out
76 username
="${option#username=}"
77 username
="$(reverse_username_workgroup "$username")"
79 options
="$options${options:+,}username=$username"
83 options
="$options${options:+,}$option"
92 while [ "$#" -gt 0 ]; do
97 if [ -z "$arg" ]; then
101 arg
="$(parse_mount_options "$arg")"
102 if [ -n "$arg" ]; then
103 args
=("${args[@]}" "-o" "$arg")
107 args
=("${args[@]}" "$1")
113 USER
="$(reverse_username_workgroup "$USER")"
115 exec /sbin
/mount.cifs
"${args[@]}"