opening accounts from a non-root account ..
John Quillen
quillen at orion.fccc.edu
Fri Jun 14 23:58:23 AEST 1991
>lubkt at spectrum.CC.Lehigh.EDU (Binod K. Taterway) writes...
>
>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)
Crypt can, in fact, generate the right password. The "seed" is better known as
the salt (man 3 crypt for an explanation). The salt appears as the first two
characters of the encrypted string. That is how multiple users can have the
same password and unique encrypted passwords.
Here's a code fragment you may find useful...
John
#include <stdio.h>
/* call once before making getrand calls */
#define seedrand() srand( (int) time( 0 ) + getpid() )
/* generate random number in given range */
#define getrand( lo, hi ) (( rand() % ( hi - lo )) + lo )
/*
* mk_pass - generate encrypted string passwd
*/
char *
mk_pass( pass )
char *pass; /* unencrypted passwd */
{
extern char *crypt();
char salt[ 3 ];
salt[ 0 ] = (char) getrand( 'a', 'z' );
salt[ 1 ] = (char) getrand( 'A', 'Z' );
salt[ 2 ] = (char) NULL;
return( crypt( pass, salt ));
}
--
--------------------------------------------------------------------------
John W. Quillen, Jr. Phone: (215) 728-3660
Research Computing Services FAX: (215) 728-3574
The Fox Chase Cancer Center internet: JW_Quillen at fccc.edu
7701 Burholme Avenue /-----------------------------------------
Philadelphia, PA 19111 / "No matter where you go, there you are."
USA / - B. Banzai
--------------------------------------------------------------------------
More information about the Comp.unix.wizards
mailing list