Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!gatech!uflorida!haven!adm!xadmx!danl@midget.towson.edu From: danl@midget.towson.edu Newsgroups: comp.unix.questions Subject: Re: How can I pipe input into passwd? Message-ID: <20719@adm.BRL.MIL> Date: 28 Aug 89 13:25:59 GMT Sender: news@adm.BRL.MIL Lines: 40 >I've been doing OK so far, but I'm stumped on one thing. Each quarter I >have to generate 500 user IDs for students. I build a script that >does this (by piping into sysadm) from student registration data from >our administrative mainframe (Unisys A5). > >THE PROBLEM! How can I easily enter passwords for each account auto- >magically. I can't pipe into passwd cause he goes after /dev/tty. I'd >use makekey, but Prime (in their infinite wisdom) doesn't include it >with their unix (or crypt). > >Ken Weaverling >Delaware Technical & Community College >+1 302 573 5460 I have the same problem more or less. You can't pipe to passwd because it flushes the buffer before reading. I solved it by writing a C program to do the complete generation of user accounts - creation of the directory, password file entry, null mailbox, and copying of a skeleton .login, .cshrc, and .profile. The trick with the password is with the crypt() function. I assume from your message that you are missing the crypt command and not the crypt function. The password field of the password entry is generated via crypt(). I generate random passwords, and random two character salts for the crypt function, and feed crypt() these salts and a random password. The returned string is the password field of the password entry. A log is generated containing the user names and passwords for distribution to classes. The program is four years old and needs some cleaning up (I've learned much since then), but it still works. Anyone who wants it, let me know and i'll send you a copy. If I get enough response, I'll make it available via ftp and VMSserv (BITNET). +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Dan Gosner Internet: danl@midget.towson.edu Operations Manager DGosner@TOE.TOWSON.EDU Towson State University Bitnet: DGosner@TOWSONVX Towson, Maryland 21204 %% VMS pays the bills, but Unix is where my real work gets done. %% ***************************************************************************