diff options
author | Gerald Carter <jerry@samba.org> | 2004-09-23 12:21:10 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2004-09-23 12:21:10 +0000 |
commit | 3cf617a8c779ef153080bd00d20bfaa349603096 (patch) | |
tree | 8950e518321f034d21006ebe087a8cd4a80d1ca8 /examples/auth/crackcheck/crackcheck.c | |
parent | f36cd948f0006d177ff67ab5bb2636d32493ce28 (diff) | |
download | samba-3cf617a8c779ef153080bd00d20bfaa349603096.tar.gz |
r2565: syncing up for 3.0.8pre1
Diffstat (limited to 'examples/auth/crackcheck/crackcheck.c')
-rw-r--r-- | examples/auth/crackcheck/crackcheck.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/examples/auth/crackcheck/crackcheck.c b/examples/auth/crackcheck/crackcheck.c new file mode 100644 index 00000000000..338433779b0 --- /dev/null +++ b/examples/auth/crackcheck/crackcheck.c @@ -0,0 +1,62 @@ +#include <memory.h> +#include <string.h> +#include <stdlib.h> +#include <stdio.h> +#include <ctype.h> +#include <crack.h> + +void usage(char *command) { + char *c, *comm; + + comm = command; + while ((c = strrchr(comm, '/')) != NULL) { + comm = c + 1; + } + + fprintf(stderr, "Usage: %s -d dictionary\n\n", comm); + fprintf(stderr, " -d dictionary file for cracklib\n\n"); + fprintf(stderr, " The password is expected to be given via stdin.\n\n"); + exit(-1); +} + +int main(int argc, char **argv) { + extern char *optarg; + int c; + + char f[256]; + char *dictionary = NULL; + char *password; + char *reply; + + while ( (c = getopt(argc, argv, "d:")) != EOF){ + switch(c) { + case 'd': + dictionary = strdup(optarg); + break; + default: + usage(argv[0]); + } + } + + if (dictionary == NULL) { + fprintf(stderr, "ERR - Wrong Command Line\n\n"); + usage(argv[0]); + } + + password = fgets(f, sizeof(f), stdin); + + if (password == NULL) { + fprintf(stderr, "ERR - Failed to read password\n\n"); + exit(-2); + } + + reply = FascistCheck(password, dictionary); + if (reply != NULL) { + fprintf(stderr, "ERR - %s\n\n", reply); + exit(-3); + } + + exit(0); + +} + |