summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2004-09-14 00:21:11 +0000
committerSimo Sorce <idra@samba.org>2004-09-14 00:21:11 +0000
commit395461d3679d11732f979f60134b65c1e8bb7b92 (patch)
tree9cfab7fe569ab297cc93a2264a267340feb44c10 /examples
parentb59cda5176c0c7e9a1da466eecd80959dd282c85 (diff)
downloadsamba-395461d3679d11732f979f60134b65c1e8bb7b92.tar.gz
samba-395461d3679d11732f979f60134b65c1e8bb7b92.tar.xz
samba-395461d3679d11732f979f60134b65c1e8bb7b92.zip
r2331: check password script code and example from trunk
Diffstat (limited to 'examples')
-rw-r--r--examples/auth/crackcheck/Makefile25
-rw-r--r--examples/auth/crackcheck/crackcheck.c62
2 files changed, 87 insertions, 0 deletions
diff --git a/examples/auth/crackcheck/Makefile b/examples/auth/crackcheck/Makefile
new file mode 100644
index 00000000000..84377aafefe
--- /dev/null
+++ b/examples/auth/crackcheck/Makefile
@@ -0,0 +1,25 @@
+# C compiler
+#CC=cc
+CC=gcc
+
+# Uncomment the following to add symbols to the code for debugging
+#DEBUG=-g -Wall
+
+# Optimization for the compiler
+#OPTIMIZE=
+OPTIMIZE=-O2
+
+CFLAGS= $(DEBUG) $(OPTIMIZE)
+
+OBJS = crackcheck.o
+LIBS = -lcrack
+
+crackcheck: $(OBJS)
+ $(CC) $(CFLAGS) $(LIBS) -o crackcheck $(OBJS)
+
+clean:
+ rm -f core *.o crackcheck
+
+install: crackcheck
+ install -m 555 crackcheck $(PREFIX)/sbin/crackcheck
+
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);
+
+}
+