[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [K12OSN] Password file



* Chris Hobbs <chris clanhobbs org> [030402 17:26]:
> IMO, the better way to do this is not to modify these files directly. Their 
> are utilities on your system to handle adding users without going through 
> the hassle of directly modifying those files. Automating those utilities is 
> the key. Attached please find a perl script that I use to add users in 
> bulk. It uses the newusers command to add linux users, and smbpasswd to add 
> samba users. The input file is their username (we use their student IDs), a 
> tab, and then their real name ("Bob Jones").

Chris' script seems very useful for the purpose of this thread.
However, we have been using a slightly less ambitious script to add
passwords.  This snippet seems to work, and seems like it could
replace a lot of the work that is done manually in the script Chris
attached (this is also in Perl, and works on a Mandrake 9.0 system):

if( `echo "$password" | passwd --stdin $user` ){
    print "Password added successfully\n";
}
else{
    die "Error while adding password for $user ";
}

By using the regular 'passwd' command in a subshell, it automatically
adds to the 'shadow' file.  You would still need to add the smbpasswd
as in Chris' script, but this might also work with LDAP ... I haven't
gotten around to that yet.

-- 
Jan Wilson, SysAdmin     _/*];          corocom btl net
Corozal Junior College   |  |:'  corozal.com corozal.bz
Corozal Town, Belize     |  /'  chetumal.com & linux.bz
Reg. Linux user #151611  |_/   Network, PHP, Perl, HTML





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]