svn commit: samba r2330 - in trunk/examples/auth: . crackcheck

idra at samba.org idra at samba.org
Tue Sep 14 00:19:34 GMT 2004


Author: idra
Date: 2004-09-14 00:19:33 +0000 (Tue, 14 Sep 2004)
New Revision: 2330

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/trunk/examples/auth&rev=2330&nolog=1

Log:

sample external program to check password complexity via cracklib


Added:
   trunk/examples/auth/crackcheck/
   trunk/examples/auth/crackcheck/Makefile
   trunk/examples/auth/crackcheck/crackcheck.c


Changeset:
Added: trunk/examples/auth/crackcheck/Makefile
===================================================================
--- trunk/examples/auth/crackcheck/Makefile	2004-09-14 00:18:14 UTC (rev 2329)
+++ trunk/examples/auth/crackcheck/Makefile	2004-09-14 00:19:33 UTC (rev 2330)
@@ -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
+

Added: trunk/examples/auth/crackcheck/crackcheck.c
===================================================================
--- trunk/examples/auth/crackcheck/crackcheck.c	2004-09-14 00:18:14 UTC (rev 2329)
+++ trunk/examples/auth/crackcheck/crackcheck.c	2004-09-14 00:19:33 UTC (rev 2330)
@@ -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);
+
+}
+



More information about the samba-cvs mailing list