From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,bcbf1c84bf8f804b X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2002-06-26 06:09:09 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.uchicago.edu!vixen.cso.uiuc.edu!howland.erols.net!nntp.abs.net!uunet!dca.uu.net!prodigy.com!news.cc.ukans.edu!sloane From: sloane@ukans.edu (Bob Sloane) Newsgroups: comp.unix.tru64 Subject: Re: npasswd Date: 26 Jun 2002 08:09:05 CDT Organization: University of Kansas Academic Computing Services Message-ID: References: <110fcff.0206251503.63ac5cc5@posting.google.com> NNTP-Posting-Host: kuhub.cc.ku.edu Xref: archiver1.google.com comp.unix.tru64:8004 In article <110fcff.0206251503.63ac5cc5@posting.google.com>, pdioquino@yahoo.com (Priscilla) writes: > 2. Are there other tools I've overlooked that can do this? Take a look at "man prpasswd" in the section on u_policy. When this is set, the file /tcb/bin/pwpolicy is run to check the password. I have attached a simple example of how this works. You will probably want to write something a little more robust for production work. :-) This just checks to see that the password doesn't equal the username and that it is mixed case. -- USmail: Bob Sloane, University of Kansas Computer Center, Lawrence, KS, 66045 E-mail: sloane@ukans.edu http://www.ukans.edu/home/sloane Phone:(785)864-0444 #include #include #define UPPERCASE 1 #define LOWERCASE 2 #define NUMERIC 4 #define OTHER 8 main() { char func[64]; char pass[64]; char user[64]; int ch; int i; /* * first thing should be a function number. Currently, only "1" is defined */ if ( fgets(func,63,stdin) == 0 ) exit(0); /* be generous and allow protocol errors */ /* * Second thing should be the username */ if ( fgets(user,63,stdin) == 0 ) exit(0); /* be generous and allow protocol errors */ /* * delete the trailing newline that fgets appends */ if ( user[strlen(user)-1] == '\n' ) user[strlen(user)-1] = '\0'; /* * next should be the password */ if ( fgets(pass,63,stdin) == 0 ) exit(0); /* be generous and allow protocol errors */ /* * delete the trailing newline that fgets appends */ if ( pass[strlen(pass)-1] == '\n' ) pass[strlen(pass)-1] = '\0'; /* * Don't allow password == username */ if ( strcmp(user,pass) == 0 ) exit(1); /* * Make sure it isn't all the same case or all numeric */ for ( i=ch=0; i < strlen(pass); ++i ) { if ( pass[i] >= 'a' && pass[i] <= 'z' ) ch |= LOWERCASE; else if ( pass[i] >= 'A' && pass[i] <= 'Z' ) ch |= UPPERCASE; else if ( pass[i] >= '0' && pass[i] <= '9' ) ch |= NUMERIC; else ch |= OTHER; } /* * if password is all upper case, *all lower case or all numeric it fails. */ if ( ch == LOWERCASE || ch == UPPERCASE || ch == NUMERIC ) exit(1); /* * password is OK. */ exit(0); }