Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!email!vmars!hp From: hp@vmars.tuwien.ac.at (Peter Holzer) Newsgroups: comp.unix.wizards Subject: Re: opening accounts from a non-root account .. Message-ID: <1991Jun13.162234.9602@email.tuwien.ac.at> Date: 13 Jun 91 16:22:34 GMT References: Sender: news@email.tuwien.ac.at Distribution: comp.unix.wizards Organization: Technical University Vienna, Dept. for Realtime Systems, AUSTRIA Lines: 41 Nntp-Posting-Host: nowhere.vmars.tuwien.ac.at lubkt@spectrum.CC.Lehigh.EDU (Binod K. Taterway) writes: >All of this works fine for root; but -F option of passwd(1) does not >work with non-root. So, I thought I might get around by generating >encrypted password in the first place. Good idea. >Here begins my journey to the wonderous land of crypt(3), login(1), >DES, and a host of other programs. I realize crypt cannot generate >initial encrypted password because it doesn't have the right seed. Let >EPW be the encrypted password of the clear-text password, PW. Then, > EPW = crypt(PW, EPW) >The second parameter of crypt is the seed: if the seed is same as EPW, >then the result of crypt is same EPW. This is what is presumably used >by login programs to validate a user. >But, my problem is to generate EPW without initial seed. The manual [crypt(3), makekey(8)] states that the salt are two characters from the set [A-Za-z0-9./]. The salt is stored together with the password so we can just use some random salt: [...] char saltchars [] = "AB...YZab...yz0123456789./"; char salt[2]; srand ((int)(time ((time_t *)0) + getpid())); salt[0] = saltchars[rand() % 64]; salt[1] = saltchars[rand() % 64]; epw = crypt(pw, salt); [...] -- | _ | Peter J. Holzer | Think of it | | |_|_) | Technical University Vienna | as evolution | | | | | Dept. for Real-Time Systems | in action! | | __/ | hp@vmars.tuwien.ac.at | Tony Rand |