Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!sri-unix!teknowledge-vaxc!mkhaw From: mkhaw@teknowledge-vaxc.ARPA (Mike Khaw) Newsgroups: comp.unix.questions Subject: Re: can i read new passwords from a file? Message-ID: <17618@teknowledge-vaxc.ARPA> Date: Mon, 5-Oct-87 14:18:08 EDT Article-I.D.: teknowle.17618 Posted: Mon Oct 5 14:18:08 1987 Date-Received: Thu, 8-Oct-87 03:45:03 EDT References: <731@bingvaxu.cc.binghamton.edu> Reply-To: mkhaw@teknowledge-vaxc.UUCP (Mike Khaw) Organization: Teknowledge, Inc., Palo Alto CA Lines: 39 Keywords: passwd Sorry to post to the net, we couldn't mail to bingvaxu.cc.binghamton.edu: > Is there a simple way that I can read a set of userids & passwords from > a file and have them change in /etc/passwd. I'm trying to automate > setting up accounts. I've looked at the source for passwd.c which calls I assume you mean that you have a list of usernames that are already in /etc/passwd, paired up with unencrypted passwords, and you want to use the list to change these users' passwords in /etc/passwd. You can convert the unencrypted passwords to encrypted ones by using /usr/lib/makekey. It reads 10 characters from standard input (8 characters to encrypt, plus a 2 character "salt" suffix from the set [0-9A-Za-z/.]), and writes a 13 character encrypted result on standard output whose first 2 characters are the encryption salt. So, you can write a shell script that reads your list and returns effectively a list of commands for ex (or ed). Feed these commands to ex via a pipe to modify the passwd file: sh_script < cleartext_list | ex /etc/passwd Of course, you ought to be a little more elaborate and use the same file locking convention that vipw, chfn, and passwd obey: check that /etc/ptmp doesn't exist, create /etc/ptmp, modify /etc/passwd, remove /etc/ptmp. You might also consider that keeping a list with cleartext passwords is risky, even if the file is readable only to root. DEC supplies Ultrix with an /etc/adduser shell script that you can customize for your site. I don't recall what they do about setting passwords (probably nothing), but you can easily add that feature using makekey. Mike Khaw -- internet: mkhaw@teknowledge-vaxc.arpa usenet: {uunet|sun|ucbvax|decwrl|uw-beaver}!mkhaw%teknowledge-vaxc.arpa USnail: Teknowledge Inc, 1850 Embarcadero Rd, POB 10119, Palo Alto, CA 94303