On Wed, 11 Mar 1998, Wesley W. Owen wrote:
> Is there a way to get RHL5 to generate a random password when I create a
> new user? Or, is it somewhere in passwd? Thanks for the help!
>
> Wes
>
It's pretty trivial in just about any language to write something to read
bytes from /dev/random or /dev/urandom (faster, but less random) until
you've collected 8 alphanumeric characters (the max normal password
length, IIRC).
A quick example in C:
#include <stdio.h>
#include <ctype.h>
void main()
{
char passwd[9], c;
int i=0;
FILE *random;
random=fopen("/dev/urandom","r");
while(i != 8)
{
c=fgetc(random);
if(isalnum(c))
passwd[i++]=c;
}
passwd[9]='\0';
printf("%s\n",passwd);
fclose(random);
}
Hope this helps...
Ryan
----------------------------------------------------------------------------
Ryan McCowan
[EMAIL PROTECTED] --> http://www.cookeville.com/users/ryan
[EMAIL PROTECTED] Linux: The Choice of a GNU Generation.
----------------------------------------------------------------------------
--
PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com/RedHat-FAQ /RedHat-Errata /RedHat-Tips /mailing-lists
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject.