Fix bug #6154 - zfs does not honor admin users.
[Samba/gbeck.git] / source3 / smbadduser.in
blob4b9671319a3f76c115f29c9ecc65c0311b04abb4
1 #!/bin/csh
3 # smbadduser - Written by Mike Zakharoff
6 prefix=@prefix@
7 exec_prefix=@exec_prefix@
8 LIBDIR=@libdir@
9 PRIVATEDIR=@privatedir@
10 CONFIGDIR=@configdir@
12 unalias *
13 set path = ($path /usr/bin)
15 set smbpasswd = $PRIVATEDIR/smbpasswd
16 set user_map = $CONFIGDIR/smbusers
19 # Set to site specific passwd command
21 set passwd = "getent passwd"
22 #set passwd = "niscat passwd.org_dir"
23 #set passwd = "ypcat passwd"
25 set line = "----------------------------------------------------------"
26 if ($#argv == 0) then
27 echo $line
28 echo "Written: Mike Zakharoff email: michael.j.zakharoff@boeing.com"
29 echo ""
30 echo " 1) Updates $smbpasswd"
31 echo " 2) Updates $user_map"
32 echo " 3) Executes smbpasswd for each new user"
33 echo ""
34 echo "smbadduser unixid:ntid unixid:ntid ..."
35 echo ""
36 echo "Example: smbadduser zak:zakharoffm johns:smithj"
37 echo $line
38 exit 1
39 endif
41 touch $smbpasswd $user_map
42 set new = ()
43 foreach one ($argv)
44 echo $one | grep ':' >& /dev/null
45 if ($status != 0) then
46 echo "ERROR: Must use unixid:ntid like -> zak:zakharoffm"
47 continue
48 endif
49 set unix = `echo $one | awk -F: '{print $1}'`
50 set ntid = `echo $one | awk -F: '{print $2}'`
52 set usr = `eval $passwd | awk -F: '$1==USR {print $1}' USR=$unix`
53 if ($#usr != 1) then
54 echo "ERROR: $unix Not in passwd database SKIPPING..."
55 continue
56 endif
57 set tmp = `cat $smbpasswd | awk -F: '$1==USR {print $1}' USR=$unix`
58 if ($#tmp != 0) then
59 echo "ERROR: $unix is already in $smbpasswd SKIPPING..."
60 continue
61 endif
63 echo "Adding: $unix to $smbpasswd"
64 /usr/bin/smbpasswd -a -n $unix
65 if ($unix != $ntid) then
66 echo "Adding: {$unix = $ntid} to $user_map"
67 echo "$unix = $ntid" >> $user_map
68 endif
69 set new = ($new $unix)
70 end
73 # Enter password for new users
75 foreach one ($new)
76 echo $line
77 echo "ENTER password for $one"
78 smbpasswd $one
79 end