Shell script

Brian Densmore DensmoreB at ctbsonline.com
Wed Nov 12 15:24:51 CST 2003


> -----Original Message-----
> From: Jason Clinton
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Charles Steinkuehler wrote:
> |>> /usr/sbin/useradd -c "$1 Account Whatever Comment Here" $1
> |>> echo $2 | /usr/bin/passwd --stdin $1
> |>> done
> |>>
> |>>
> |>> You may have to tweak around with this a touch..  But it should do
> |>> the job for
> |>> you.  The script creates the account with default 
> settings and then
> |>> puts the
> |>> password in for you using the passwd command.  The 
> --stdin option to
> |>> passwd is
> |>> generally not documented well, if at all, but it's there in every
> |>> distribution
> |>> I've used.
> |
> |
> |  From "man passwd" on RHEL-3:
> | <quote>
> | --stdin
> |     This option is used to indicate that passwd should read the  new
> |     password from standard input, which can be a pipe.
> | </quote>
> |
> 
> This is not standard at all. This is why Samba has a password changing
> communications section in its config file -- it's different in every
> distro. In Gentoo, passwd comes from the 'shadow' package and does not
> accept STDIN. This package also contains /usr/sbin/chpasswd which can
> only be run by root and accepts a file from STDIN in the form of
> "username:password" in which case you would want to do 
> something like this:
> 
> # ruby -neW0 'puts "#$1:#$2" if /(.*)t(.*)/' sourcefile | chpasswd -e
I can't speak to the scripting, but this is news to me. I have used
passwd to change my password in gentoo. passwd is smart enough to know
whether the password is a shadowed password or not. So it is irrelevant
as to where the password is stored. In fact, I thought it was pretty
standard anymore for Linux distros to use shadow passwords by default. 
I am not sure why Samba 'needs' to have an elaborate section for password
changing. Correct me if I am wrong.

Brian




More information about the Kclug mailing list