Submitted By: Randy McMurchy (LFS-User_AT_mcmurchy_DOT_com)
Date: 2004-05-03
Initial Package Version: 2.7
Origin: Randy McMurchy and ftp://ftp.pdc.kth.se/pub/krb/src/cracklib.patch 
Description: Patches cracklib to work with Heimdal Kerberos 5
             Requires heimdal-0.6.3-cracklib-1.patch applied to the Heimdal
             source code. Patch is available at:
             http://www.linuxfromscratch.org/patches/blfs/cvs/

$LastChangedBy: randy $
$Date: 2005-01-27 08:36:13 -0700 (Thu, 27 Jan 2005) $

diff -Naur cracklib,2.7-orig/Makefile cracklib,2.7/Makefile
--- cracklib,2.7-orig/Makefile	2004-05-01 00:41:30.000000000 +0000
+++ cracklib,2.7/Makefile	2004-05-01 01:07:16.000000000 +0000
@@ -32,18 +32,21 @@
 
 all:
 	( cd cracklib && make && exit $$? )
+	( cd cracklib_krb5 && make && exit $$? )
 	( cd util && make DICTPATH=$(DICTPATH) && exit $$? )
 ###	( cd passwd && make DICTPATH=$(DICTPATH) passwd && exit $$? )
 ###	touch all
 
 clean:
 	-( cd cracklib && make clean && exit $$? )
+	-( cd cracklib_krb5 && make clean && exit $$? )
 	-( cd util && make clean && exit $$? )
 ###	-( cd passwd && make clean && exit $$? )
 	-rm -f all installed Part* *.BAK *.bak *~
 
 install: all
 	( cd cracklib && make install && exit $$? )
+	( cd cracklib_krb5 && make install && exit $$? )
 	( cd util && make install && exit $$? )
 	@echo 'if "sort" dies from lack of space, see "util/mkdict"'
 	util/mkdict $(SRCDICTS) | LD_LIBRARY_PATH=cracklib util/packer $(DESTDIR)$(DICTPATH)

diff -Naur cracklib,2.7-orig/cracklib_krb5/Makefile cracklib,2.7/cracklib_krb5/Makefile
--- cracklib,2.7-orig/cracklib_krb5/Makefile	2004-05-01 01:02:47.000000000 +0000
+++ cracklib,2.7/cracklib_krb5/Makefile	2004-05-01 02:03:26.000000000 +0000
@@ -6,9 +6,9 @@
 # and upwards.
 ###
 
-LIB	= libcrack.so
+LIB	= libcrack_krb5.so
 OBJ	= fascist.o packlib.o rules.o stringlib.o
-CFLAGS += -g -I../cracklib -DIN_CRACKLIB -fPIC
+CFLAGS += -g -I../cracklib_krb5 -DIN_CRACKLIB_KRB5 -fPIC
 LD	= ld
 
 $(LIB):	$(OBJ) Makefile
@@ -20,10 +20,9 @@
 clean:
 	-rm -f $(OBJ) $(LIB) $(LIB).$(VERSION) *~
 
-install: $(LIB) crack.h
-	install -m 755 $(LIB).$(VERSION) $(DESTDIR)/lib
-	ln -sf $(LIB).$(VERSION) $(DESTDIR)/lib/$(LIB)
-	ln -sf $(DESTDIR)/lib/$(LIB).$(VERSION) $(DESTDIR)/lib/$(LIB).$(MAJOR)
+install: $(LIB) crack_krb5.h
+	install -m 755 $(LIB).$(VERSION) $(DESTDIR)/usr/lib
+	ln -sf $(LIB).$(VERSION) $(DESTDIR)/usr/lib/$(LIB)
+	ln -sf $(LIB).$(VERSION) $(DESTDIR)/usr/lib/$(LIB).$(MAJOR)
 
-	install -m 644 packer.h $(DESTDIR)/usr/include
-	install -m 644 crack.h $(DESTDIR)/usr/include
+	install -m 644 crack_krb5.h $(DESTDIR)/usr/include

diff -Naur cracklib,2.7-orig/cracklib_krb5/crack_krb5.h cracklib,2.7/cracklib_krb5/crack_krb5.h
--- cracklib,2.7-orig/cracklib_krb5/crack_krb5.h	2004-05-01 01:03:13.000000000 +0000
+++ cracklib,2.7/cracklib_krb5/crack_krb5.h	2004-05-01 01:01:08.000000000 +0000
@@ -0,0 +1,16 @@
+#ifndef CRACKLIB_KRB5_H
+#define CRACKLIB_KRB5_H
+
+/* This header file is required for using cracklib with
+ * the Heimdal Kerberos 5 package. This file differs from
+ * the original cracklib header as Heimdal requires a third
+ * parameter passed to the FascistCheck function.
+ *
+ * You must link with -lcrack_krb5
+ */
+
+extern char *FascistCheck(char *pw, char *dictpath, char *strings);
+
+#define CRACKLIB_DICTPATH "/lib/cracklib_dict"
+
+#endif

diff -Naur cracklib,2.7-orig/cracklib_krb5/fascist.c cracklib,2.7/cracklib_krb5/fascist.c
--- cracklib,2.7-orig/cracklib_krb5/fascist.c	2004-05-01 01:02:47.000000000 +0000
+++ cracklib,2.7/cracklib_krb5/fascist.c	2004-05-01 01:35:59.000000000 +0000
@@ -478,6 +478,23 @@
 }
 
 char *
+FascistStrings(password, strings)
+    char *password;
+    char **strings;
+{
+    char *p;
+
+    while(p = *strings++)
+    {
+	if(GTry(p, password))
+	{
+	    return ("it is based on your name");
+	}
+    }
+    return ((char *) 0);
+}
+
+char *
 FascistGecos(password, uid)
     char *password;
     int uid;
@@ -614,9 +631,10 @@
 }
 
 char *
-FascistLook(pwp, instring)
+FascistLook(pwp, instring, strings)
     PWDICT *pwp;
     char *instring;
+    char **strings;
 {
     int i;
     char *ptr;
@@ -695,10 +713,16 @@
 	return ("it looks like a National Insurance number.");
     }
 
+#if 0
     if (ptr = FascistGecos(password, getuid()))
     {
 	return (ptr);
     }
+#endif
+    if (ptr = FascistStrings(password, strings))
+    {
+	return (ptr);
+    }
 
     /* it should be safe to use Mangle with its reliance on STRINGSIZE
        since password cannot be longer than TRUNCSTRINGSIZE;
@@ -746,9 +770,10 @@
 }
 
 char *
-FascistCheck(password, path)
+FascistCheck(password, path, strings)
     char *password;
     char *path;
+    char **strings;
 {
     static char lastpath[STRINGSIZE];
     static PWDICT *pwp;
@@ -781,5 +806,5 @@
 	strncpy(lastpath, path, STRINGSIZE);
     }
 
-    return (FascistLook(pwp, pwtrunced));
+    return (FascistLook(pwp, pwtrunced, strings));
 }

diff -Naur cracklib,2.7-orig/cracklib_krb5/packlib.c cracklib,2.7/cracklib_krb5/packlib.c
--- cracklib,2.7-orig/cracklib_krb5/packlib.c	2004-05-01 01:02:47.000000000 +0000
+++ cracklib,2.7/cracklib_krb5/packlib.c	2004-05-01 01:34:10.000000000 +0000
@@ -329,6 +329,13 @@
 #ifdef DEBUG
 	printf("%lu, %lu\n", lwm, hwm);
 #endif
+	if (lwm > hwm) {
+	     register int32 tmp;
+
+	     tmp = hwm;
+	     hwm = lwm;
+	     lwm = tmp;
+	}
 
 	middle = lwm + ((hwm - lwm + 1) / 2);
 

diff -Naur cracklib,2.7-orig/cracklib_krb5/rules.c cracklib,2.7/cracklib_krb5/rules.c
--- cracklib,2.7-orig/cracklib_krb5/rules.c	2004-05-01 01:02:47.000000000 +0000
+++ cracklib,2.7/cracklib_krb5/rules.c	2004-05-01 01:57:58.000000000 +0000
@@ -8,9 +8,9 @@
 
 static char vers_id[] = "rules.c : v5.0p3 Alec Muffett 20 May 1993";
 
-#ifndef IN_CRACKLIB
+#ifndef IN_CRACKLIB_KRB5
 
-#include "crack.h"
+#include "crack_krb5.h"
 
 #else
 
