#!/bin/csh # # /sbin/mount.smbfs # by Greg Galperin, MAR99 # ver 1.1 MAR99 GRG docs update: must escape special chars like $ # ver 1.0 MAR99 GRG original version # # Intent is to allow calls to mount with -t smbfs to work properly # (either manually or from an automounter). # # bugs: # -- possible security hole, as this is a shell script called as root... # -- arguments other than rw and ro which mount might supply are not handled # ########################################################################### # # To use this from autofs: # # have an entry of the form # key -fstype=smbfs,-Uadministrator,-Ppassword ://host/share # in the appropriate /etc/auto.mountpoint file. # # This makes access to /mountpoint/key/ access smb //host/share/ # as administrator (or another user, if you specify such) with the given # password. You may have to supply a -c . # Special characters need to be 'escaped' with a backslash ('\') -- for # instance, if you want to use the default share names with a "$" at the # end (e.g., //host/c$), you must enter ://host/c\$ # # Note that mount/autofs is smart enough to figure out how to unmount # this without any extra work on our part! # ########################################################################### # # I get called as: /sbin/mount.smbfs //host/shr /mnt/tmp -o rw,arg1,arg2 # # It looks like mount tacks on either "rw" or "ro" as the first argument, # so I'm going to count on having exactly 5 arguments. # # This has been developed and tested with mount-2.7 # ########################################################################### # test for correct # args if ( $# != 4 ) then echo $0 does not know how to handle $# arguments: $* exit -1 endif # test for args in the form I expect if ( "$3" != "-o" ) then echo $0 does not know how to handle the 3rd argument not \"-o\" : $3 exit -1 endif setenv COMMAND "/usr/sbin/smbmount $1 $2" foreach arg (`echo $4 | /usr/bin/tr ',' ' '`) if ( "$arg" == "rw" ) then setenv COMMAND "$COMMAND -f777 -d777" else if ( "$arg" == "ro" ) then setenv COMMAND "$COMMAND -f555 -d555" else setenv COMMAND "$COMMAND $arg" endif end $COMMAND