diff -urN samba-2.2.0.org/source/smbadduser samba-2.2.0/source/smbadduser --- samba-2.2.0.org/source/smbadduser Wed Apr 18 01:27:35 2001 +++ samba-2.2.0/source/smbadduser Wed Apr 18 01:33:08 2001 @@ -3,10 +3,10 @@ # smbadduser - Written by Mike Zakharoff # unalias * -set path = ($path /usr/local/samba/bin) +set path = ($path /usr/bin) -set smbpasswd = /usr/local/samba/private/smbpasswd -set user_map = /usr/local/samba/lib/users.map +set smbpasswd = /etc/samba/smbpasswd +set user_map = /etc/samba/users.map # # Set to site specific passwd command # @@ -46,19 +46,23 @@ echo "ERROR: $unix Not in passwd database SKIPPING..." continue endif - set tmp = `cat $smbpasswd | awk -F: '$1==USR {print $1}' USR=$unix` - if ($#tmp != 0) then - echo "ERROR: $unix is already in $smbpasswd SKIPPING..." - continue - endif - echo "Adding: $unix to $smbpasswd" - eval $passwd | \ - awk -F: '$1==USR { \ - printf( "%s:%s:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:%s:%s:%s\n", $1, $3, $5, $6, $7) }' USR=$unix >> $smbpasswd + # Fix 8/7/2000 Phil Knirsch: Removed the smbpasswd stuff here and fixed + # the way the usermap gets updated as that one was really wrong: If a + # user was added twice the usermap would contain 2 entries! We now + # first select the existing entry, remove it from the usermap and add + # a new one with the new ntid. If something goes wrong the new entry + # will as before simply be added to the file (for manual fixing later). + set usr = `eval cat $user_map | awk -F= '{if(match($1, USR" *") != 0) print $2}' USR=$unix` + if ($unix != $ntid) then - echo "Adding: {$unix = $ntid} to $user_map" - echo "$unix = $ntid" >> $user_map + echo "Adding: {$unix = $usr $ntid} to $user_map" + cat $user_map | sed /"$unix.*"/d > $user_map.new + if (-e $user_map.new) then + cp $user_map.new $user_map + endif + rm $user_map.new + echo "$unix = $usr $ntid" >> $user_map endif set new = ($new $unix) end @@ -69,5 +73,9 @@ foreach one ($new) echo $line echo "ENTER password for $one" - smbpasswd $one + + # Fix Phil Knirsch 8/6/2000: Use the -a option to create the user + # entry in case it didn't exist before. This way we get rid of the + # file format dependent awk replacement in the previous version. + smbpasswd -a $one end