diff -urN samba-2.0.7/packaging/RedHat/smbadduser samba-2.0.7.new/packaging/RedHat/smbadduser --- samba-2.0.7/packaging/RedHat/smbadduser Fri Aug 21 16:20:38 1998 +++ samba-2.0.7.new/packaging/RedHat/smbadduser Tue Aug 8 10:23:42 2000 @@ -2,11 +2,17 @@ # # smbadduser - Written by Mike Zakharoff # +# * Sun Aug 6 2000 Philipp Knirsch +# - Bugfix to change file location from /etc to /etc/samba and to use +# smbpasswd -a to add the user entry to the smbpasswd file in case it didn't +# exist before. +# + unalias * set path = ($path) -set smbpasswd = /etc/smbpasswd -set user_map = /etc/smbusers +set smbpasswd = /etc/samba/smbpasswd +set user_map = /etc/samba/smbusers # # Set to site specific passwd command # @@ -46,19 +52,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 +79,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