9 void usage(char *command
) {
13 while ((c
= strrchr(comm
, '/')) != NULL
) {
17 fprintf(stderr
, "Usage: %s [-c] [-s] [-d <dictionary>]\n\n", comm
);
18 fprintf(stderr
, " -c enables NT like complexity checks\n");
19 fprintf(stderr
, " -d <dictionary file> for cracklib\n");
20 fprintf(stderr
, " -s simple check use NT like checks ONLY\n\n");
21 fprintf(stderr
, "The password is read via stdin.\n\n");
25 int complexity(char* passwd
)
28 * check password for complexity like MS Windows NT
38 if (!passwd
) goto fail
;
41 for (i
= 0; i
< len
; i
++) {
43 if (c_tot
>= 3) break;
45 if (isupper(passwd
[i
])) {
52 if (islower(passwd
[i
])) {
59 if (isdigit(passwd
[i
])) {
66 if (ispunct(passwd
[i
])) {
75 if ((c_tot
) < 3) goto fail
;
79 fprintf(stderr
, "ERR Complexity check failed\n\n");
83 int main(int argc
, char **argv
) {
85 int c
, ret
, complex_check
= 0, simplex_check
= 0;
88 char *dictionary
= NULL
;
92 while ( (c
= getopt(argc
, argv
, "d:cs")) != EOF
){
95 dictionary
= strdup(optarg
);
109 if (!simplex_check
&& dictionary
== NULL
) {
110 fprintf(stderr
, "ERR - Missing cracklib dictionary\n\n");
115 password
= fgets(f
, sizeof(f
), stdin
);
117 if (password
== NULL
) {
118 fprintf(stderr
, "ERR - Failed to read password\n\n");
123 ret
= complexity(password
);
133 reply
= FascistCheck(password
, dictionary
);
135 fprintf(stderr
, "ERR - %s\n\n", reply
);