--- loncom/lcpasswd 2002/08/30 13:37:59 1.16 +++ loncom/lcpasswd 2002/09/16 13:27:40 1.17 @@ -14,7 +14,7 @@ # YEAR=2002 # 02/19 Matthew Hall # -# $Id: lcpasswd,v 1.16 2002/08/30 13:37:59 matthew Exp $ +# $Id: lcpasswd,v 1.17 2002/09/16 13:27:40 foxr Exp $ ### ############################################################################### @@ -158,12 +158,16 @@ unless(getpwnam($safeusername)) { &enable_root_capability; ($>,$<)=(0,0); +print "Now root, -invoking pwchange with $safeusername $password1" + unless $noprint; open OUT,"|pwchange $safeusername"; print OUT $password1; print OUT "\n"; close OUT; ($>,$<)=(0,500); +print "pwchange done, back to uid 500" unless $noprint; + if ($?) { exit 8; } @@ -173,34 +177,22 @@ if (-e '/usr/bin/smbpasswd') { ($>,$<)=(0,0); # fool smbpasswd here to think this is not a setuid # environment - unless (-e '/etc/smbpasswd') { - open (OUT,'>/etc/smbpasswd'); close OUT; - } - - my $smbexist=0; - open (IN, '; - close IN; - for my $l (@lines) { - chop $l; - my @F=split(/\:/,$l); - if ($F[0] eq $username) {$smbexist=1;} - } - unless ($smbexist) { - open(OUT,'>>/etc/smbpasswd'); - print OUT join(':',($safeusername,$userid, - 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXX'. - 'XXXXXXXXXXXXXXXXXX','','/home/'.$safeusername, - '/bin/bash')) . "\n"; - close OUT; - } - open(OUT,"|/usr/bin/smbpasswd -s $safeusername>/dev/null") or +# If the -a swithc is put on the smbpasswd +# command line, either a new entry will be created or the old one +# will be used. +# Therefore the old strategy of looking for and adding a dummy entry is +# not needed... Finally, the smbpasswd file is in /etc/samba not +# /etc/smbpasswd as older versions of the script implied. + + print "Running smbpasswd" unless $noprint; + open(OUT,"|/usr/bin/smbpasswd -s -a $safeusername>/dev/null") or die('cannot run smbpasswd'); print OUT $password2; print OUT "\n"; print OUT $password2; print OUT "\n"; close OUT; $<=$wwwid; # unfool the program + print "smbpasswd done" unless $noprint; } &disable_root_capability;