Finish adding cracklib support - this adds the configure test to enable
authorAndrew Bartlett <abartlet@samba.org>
Wed, 14 Jan 2004 01:14:22 +0000 (01:14 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 14 Jan 2004 01:14:22 +0000 (01:14 +0000)
it, on machines that actually have a working cracklib, for which we have
the correct path to the dictionary.

Andrew Bartlett

source/configure.in
source/tests/crack.c

index 7a844c337d4d4ccaf0daf83a140b8e0853212b3e..375eed06abe4de6a6cc1033746001cbcce320ee2 100644 (file)
@@ -2961,6 +2961,64 @@ if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
 fi
 fi
 
+
+dictpath="/usr/lib/cracklib_dict"
+
+###############################################
+# test for where we get FaciestCheck from
+AC_MSG_CHECKING(where to use cracklib from (default=$dictpath))
+AC_ARG_WITH(cracklib,
+[  --with-cracklib[=DIR]     Look for cracklib dictionary in this location ],
+[  case "$withval" in
+  yes)
+    AC_MSG_RESULT(${dictpath})
+    ;;
+  no)
+    AC_MSG_RESULT(no)
+      dictpath=""
+    ;;
+  *)
+      dictpath="$withval"
+    AC_MSG_RESULT(${dictpath})
+    ;;
+  esac ],
+  dictpath=""
+  AC_MSG_RESULT(no)
+)
+
+if test x$dictpath != x""; then
+     AC_SEARCH_LIBS(FascistCheck, [crack],
+                    [test "$ac_cv_search_crack" = "none required" || samba_cv_found_crack="yes"
+                    AC_DEFINE(HAVE_CRACK,1,[Whether the system has the FaciestCheck function from cracklib])])
+
+     crack_saved_libs=$LIBS;
+
+     if test x$samba_cv_found_crack=x"yes"; then
+        AC_SEARCH_LIBS(CRACKLIB_DICTPATH, [crypt],
+            AC_DEFINE(HAVE_CRACKLIB_DICTPATH, 1, [Whether we have given a CRACKLIB_DICTPATH in our headers])
+        )
+
+       AC_DEFINE_UNQUOTED(SAMBA_CRACKLIB_DICTPATH, "$dictpath", [Where the cracklib dictionay is])
+        AC_MSG_CHECKING(Whether we have a working cracklib)
+        AC_TRY_RUN([
+               #include "${srcdir-.}/tests/crack.c"],
+              AC_MSG_RESULT(yes)
+              AC_DEFINE(HAVE_WORKING_CRACKLIB,1,[Whether we have a working cracklib])
+             AUTH_LIBS="-lcrack $AUTH_LIBS",
+
+              AC_MSG_RESULT(no)
+             AC_MSG_WARN(cracklib exists - but does not function correctly),
+
+              AC_MSG_RESULT(no)
+             AC_MSG_WARN(cannot test-run when cross-compiling)
+             )
+    else
+        AC_MSG_CHECKING(Whether we have cracklib)
+        AC_MSG_RESULT(no)
+    fi
+    LIBS=$crack_saved_libs
+fi
+
 ########################################################################################
 ##
 ## TESTS FOR SAM BACKENDS.  KEEP THESE GROUPED TOGETHER
index 1342887852974929092f01e289d3dc7bbd46391a..36119b3bbc672e2ab4fa38e53586ef4557bd769b 100644 (file)
@@ -1,3 +1,10 @@
+#include <crack.h>
+
+#ifndef HAVE_CRACKLIB_DICTPATH
+#ifndef CRACKLIB_DICTPATH
+#define CRACKLIB_DICTPATH SAMBA_CRACKLIB_DICTPATH
+#endif
+#endif
 
 int main(int argc, char **argv) {
        FascistCheck("Foo", CRACKLIB_DICTPATH);