summaryrefslogtreecommitdiffstats
path: root/mount/mount.smbfs
blob: 990b69540ce89c910579f384d33a5abc23de7f9b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/csh
#
# /sbin/mount.smbfs
# by Greg Galperin, MAR99 <grg@ai.mit.edu>
# 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 <unqualified-localhostname>.
# 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