]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Introduced a new static plugin - password quality validator. It is based on the old...
authorZhanna Tsitkov <tsitkova@mit.edu>
Fri, 28 May 2010 14:58:08 +0000 (14:58 +0000)
committerZhanna Tsitkov <tsitkova@mit.edu>
Fri, 28 May 2010 14:58:08 +0000 (14:58 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/branches/plugins@24108 dc483132-0cff-0310-8789-dd5450dbe970

23 files changed:
src/Makefile.in
src/config-files/krb5.conf
src/config/pre.in
src/configure.in
src/lib/kadm5/srv/Makefile.in
src/lib/kadm5/srv/libkadm5srv_mit.exports
src/lib/kadm5/srv/server_init.c
src/lib/kadm5/srv/server_misc.c
src/lib/krb5/Makefile.in
src/lib/krb5/krb/Makefile.in
src/plugin_core/Makefile.in
src/plugin_core/impl/Makefile.in
src/plugin_core/impl/plugin_default_factory.c
src/plugin_core/impl/plugin_default_factory.h
src/plugins/pwd_qlty/Makefile.in [new file with mode: 0644]
src/plugins/pwd_qlty/deps [new file with mode: 0644]
src/plugins/pwd_qlty/plugin_pwd_qlty.c [new file with mode: 0644]
src/plugins/pwd_qlty/plugin_pwd_qlty.h [new file with mode: 0644]
src/plugins/pwd_qlty/plugin_pwd_qlty_krb/Makefile.in [new file with mode: 0644]
src/plugins/pwd_qlty/plugin_pwd_qlty_krb/deps [new file with mode: 0644]
src/plugins/pwd_qlty/plugin_pwd_qlty_krb/plugin_pwd_qlty_impl.c [new file with mode: 0644]
src/plugins/pwd_qlty/plugin_pwd_qlty_krb/plugin_pwd_qlty_impl.h [new file with mode: 0644]
src/plugins/pwd_qlty/plugin_pwd_qlty_krb/server_dict.c [moved from src/lib/kadm5/srv/server_dict.c with 93% similarity]

index d09f7680cfdfcdfc4f7ee6c4892e6c714fa5c193..2540836ce0d2368965830ef201a81c66d6d12923 100644 (file)
@@ -7,8 +7,9 @@ mydir=.
 #      plugins/preauth/wpse
 #      plugins/preauth/cksum_body
 #      plugins/authdata/greet
-SUBDIRS=util include plugin_core plugin_core/impl   plugins/prng \
+SUBDIRS=util include plugin_core plugin_core/impl    \
        plugins/pa plugins/pa/encrypted_challenge \
+       plugins/pwd_qlty plugins/pwd_qlty/plugin_pwd_qlty_krb   \
        lib \
        @ldap_plugin_dir@ \
        plugins/kdb/db2 \
@@ -19,7 +20,6 @@ SUBDIRS=util include plugin_core plugin_core/impl   plugins/prng \
 BUILDTOP=$(REL)$(C)
 LOCALINCLUDES = -I$(srcdir) 
 
-#      plugins/prng/plugin_yarrow   
 
 SRCS =  
 HDRS = 
index 99a567c124330ab34edfad988a85c0f43bc93722..09387983df154b674a2aa7235eae8b7052abfeed 100644 (file)
                 plugin_name = plugin_encrypted_challenge_pa
                 plugin_type = service
         }
+        plugin_pwd_qlty = {
+                plugin_factory_name = plugin_default_factory
+                plugin_factory_type = static
+                plugin_name = plugin_pwd_qlty_krb
+                plugin_type = service
+        }
 
index 40e2e442503ed7a84d8c45259b4628cbbc90e080..ed7d6202a87e89fdf781a21efcb545b24af4d589 100644 (file)
@@ -326,6 +326,7 @@ KRB5_DEPLIB = $(TOPLIBD)/libkrb5$(DEPLIBEXT)
 CRYPTO_DEPLIB  = $(TOPLIBD)/libk5crypto$(DEPLIBEXT)
 PLUGIN_CORE_DEPLIB     = $(TOPLIBD)/../plugin_core/libplugin_core$(DEPLIBEXT)
 PLUGIN_PRNG_DEPLIB     = $(TOPLIBD)/../plugins/prng/libplugin_prng.a
+PLUGIN_PWD_QLTY_DEPLIB = $(TOPLIBD)/../plugins/pwd_qlty/libplugin_pwd_qlty.a
 LIBS_PROFILE = $(TOPLIBD)/../util/profile/libprofile$(DEPLIBEXT)
 COM_ERR_DEPLIB = $(COM_ERR_DEPLIB-@COM_ERR_VERSION@)
 COM_ERR_DEPLIB-sys = # empty
@@ -340,7 +341,7 @@ SS_DEPLIB-k5        = $(TOPLIBD)/libss.a
 SS_DEPLIB-sys  =
 APPUTILS_DEPLIB        = $(TOPLIBD)/libapputils.a
 
-KRB5_BASE_DEPLIBS      = $(KRB5_DEPLIB)  $(PLUGIN_CORE_DEPLIB) $(LIBS_PROFILE) $(CRYPTO_DEPLIB) $(COM_ERR_DEPLIB) $(SUPPORT_DEPLIB) $(PLUGIN_PRNG_DEPLIB)
+KRB5_BASE_DEPLIBS      = $(KRB5_DEPLIB)  $(PLUGIN_CORE_DEPLIB) $(LIBS_PROFILE) $(CRYPTO_DEPLIB) $(COM_ERR_DEPLIB) $(SUPPORT_DEPLIB) $(PLUGIN_PWD_QLTY_DEPLIB) 
 KDB5_DEPLIBS           = $(KDB5_DEPLIB) $(KDB5_PLUGIN_DEPLIBS)
 GSS_DEPLIBS            = $(GSS_DEPLIB)
 GSSRPC_DEPLIBS         = $(GSSRPC_DEPLIB) $(GSS_DEPLIBS)
@@ -382,7 +383,7 @@ SUPPORT_LIB                 = -l$(SUPPORT_LIBNAME)
 # HESIOD_LIBS is -lhesiod...
 HESIOD_LIBS    = @HESIOD_LIBS@
 
-KRB5_BASE_LIBS = $(KRB5_LIB) $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(GEN_LIB) $(LIBS) $(DL_LIB)  $(LIBS_PROFILE) $(PLUGIN_CORE_DEPLIB) $(PLUGIN_PRNG_DEPLIB)
+KRB5_BASE_LIBS = $(KRB5_LIB) $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(GEN_LIB) $(LIBS) $(DL_LIB)  $(LIBS_PROFILE) $(PLUGIN_CORE_DEPLIB) $(PLUGIN_PWD_QLTY_DEPLIB)
 KDB5_LIBS      = $(KDB5_LIB) $(GSSRPC_LIBS)
 GSS_LIBS       = $(GSS_KRB5_LIB)
 # needs fixing if ever used on Mac OS X!
index 4e4d9d6e3daeeabfbb58f2014744fae0fc4a068e..6d1ddad60a9d35373eadbf78dc42985563f3c7f1 100644 (file)
@@ -1116,7 +1116,8 @@ dnl       ccapi ccapi/lib ccapi/lib/unix ccapi/server ccapi/server/unix ccapi/test
        plugins/authdata/greet_client
        plugins/authdata/greet_server
 
-       plugins/prng
+       plugins/pwd_qlty
+       plugins/pwd_qlty/plugin_pwd_qlty_krb
        plugin_core/impl
        plugins/pa
        plugins/pa/encrypted_challenge
index 9e8b26f833da100bff5984f372be8da86aeba3db..dfc20c6973877b0b00f9064bf13f379bb58db26a 100644 (file)
@@ -1,8 +1,10 @@
 mydir=lib/kadm5/srv
 BUILDTOP=$(REL)..$(S)..$(S)..
 LOCALINCLUDES = -I$(BUILDTOP)/include/kadm5 \
-       -I$(top_srcdir)/lib/gssapi/krb5 -I$(top_srcdir)/lib/gssapi/generic \
-       -I$(BUILDTOP)/lib/gssapi/krb5 -I$(BUILDTOP)/lib/gssapi/generic
+       -I$(top_srcdir)/lib/gssapi/krb5 -I$(top_srcdir)/lib/gssapi/generic      \
+       -I$(BUILDTOP)/lib/gssapi/krb5 -I$(BUILDTOP)/lib/gssapi/generic          \
+       -I$(BUILDTOP)/plugin_core/ -I$(BUILDTOP)/../../../plugin_core/impl      \
+       -I$(BUILDTOP)/plugins/pwd_qlty/
 DEFINES = @HESIOD_DEFS@
 DEFS=
 
@@ -22,7 +24,8 @@ SHLIB_EXPDEPS=\
        $(TOPLIBD)/libk5crypto$(SHLIBEXT) \
        $(COM_ERR_DEPLIB) $(SUPPORT_LIBDEP)
 SHLIB_EXPLIBS =        -lgssrpc -lgssapi_krb5 -lkdb5 $(KDB5_DB_LIB) \
-               -lkrb5 -lk5crypto $(SUPPORT_LIB) -lcom_err @GEN_LIB@
+               -lkrb5 -lk5crypto $(SUPPORT_LIB) -lcom_err \
+               $(PLUGIN_CORE_DEPLIB) $(PLUGIN_PWD_QLTY_DEPLIB) @GEN_LIB@ 
 SHLIB_DIRS=-L$(TOPLIBD)
 SHLIB_RDIRS=$(KRB5_LIBDIR)
 RELDIR=kadm5/srv
@@ -33,7 +36,6 @@ SRCS =        $(srcdir)/svr_policy.c \
        $(srcdir)/server_kdb.c \
        $(srcdir)/server_misc.c \
        $(srcdir)/server_init.c \
-       $(srcdir)/server_dict.c \
        $(srcdir)/svr_iters.c \
        $(srcdir)/svr_chpass_util.c \
        $(srcdir)/adb_xdr.c 
@@ -44,7 +46,6 @@ OBJS =        svr_policy.$(OBJEXT) \
        server_kdb.$(OBJEXT) \
        server_misc.$(OBJEXT) \
        server_init.$(OBJEXT) \
-       server_dict.$(OBJEXT) \
        svr_iters.$(OBJEXT) \
        svr_chpass_util.$(OBJEXT) \
        adb_xdr.$(OBJEXT) 
@@ -56,7 +57,6 @@ STLIBOBJS = \
        server_kdb.o \
        server_misc.o \
        server_init.o \
-       server_dict.o \
        svr_iters.o \
        svr_chpass_util.o \
        adb_xdr.o
index 7ba5c1a91c3cc517f0170ea8764e1e8e2771031e..8e675c74e3f43c6e2c62f34183511c86d1a1d978 100644 (file)
@@ -7,10 +7,7 @@ kadm5int_acl_impose_restrictions
 kadm5int_acl_init
 adb_policy_close
 adb_policy_init
-destroy_dict
-find_word
 hist_princ
-init_dict
 kadm5_set_use_password_server
 kadm5_chpass_principal
 kadm5_chpass_principal_3
index 557ef0ad46839ea68aa575bc10b59e8a50cb85d8..8b1fc8dee456a19583750ea370175e3f8bb0192e 100644 (file)
@@ -316,7 +316,8 @@ kadm5_ret_t kadm5_init(krb5_context context, char *client_name, char *pass,
         free(handle);
         return ret;
     }
-
+#if 0
+// Should happen in plugin
     ret = init_dict(&handle->params);
     if (ret) {
         krb5_db_fini(handle->context);
@@ -325,6 +326,8 @@ kadm5_ret_t kadm5_init(krb5_context context, char *client_name, char *pass,
         free(handle);
         return ret;
     }
+#endif
+
 
     *server_handle = (void *) handle;
 
@@ -337,8 +340,10 @@ kadm5_ret_t kadm5_destroy(void *server_handle)
 
     CHECK_HANDLE(server_handle);
 
+#if 0
+// Should happen in plugin
     destroy_dict();
-
+#endif
     adb_policy_close(handle);
     krb5_db_fini(handle->context);
     krb5_free_principal(handle->context, handle->current_caller);
index 1faeb86b16f7d6ba42f235ae66fb7617bbc537dc..3f51c0d7d3027ce3d9ac357c98ebf868e2725801 100644 (file)
@@ -19,6 +19,10 @@ static char *rcsid = "$Header$";
 
 #include    "server_internal.h"
 
+#include <plugin_manager.h>
+#include <plugin_pwd_qlty.h>
+
+
 kadm5_ret_t
 adb_policy_init(kadm5_server_handle_t handle)
 {
@@ -37,147 +41,19 @@ adb_policy_close(kadm5_server_handle_t handle)
     return KADM5_OK;
 }
 
-#ifdef HESIOD
-/* stolen from v4sever/kadm_funcs.c */
-static char *
-reverse(str)
-    char    *str;
-{
-    static char newstr[80];
-    char    *p, *q;
-    int     i;
-
-    i = strlen(str);
-    if (i >= sizeof(newstr))
-        i = sizeof(newstr)-1;
-    p = str+i-1;
-    q = newstr;
-    q[i]='\0';
-    for(; i > 0; i--)
-        *q++ = *p--;
-
-    return(newstr);
-}
-#endif /* HESIOD */
-
-#if 0
-static int
-lower(str)
-    char    *str;
-{
-    register char   *cp;
-    int     effect=0;
-
-    for (cp = str; *cp; cp++) {
-        if (isupper(*cp)) {
-            *cp = tolower(*cp);
-            effect++;
-        }
-    }
-    return(effect);
-}
-#endif
-
-#ifdef HESIOD
-static int
-str_check_gecos(gecos, pwstr)
-    char    *gecos;
-    char    *pwstr;
-{
-    char            *cp, *ncp, *tcp;
-
-    for (cp = gecos; *cp; ) {
-        /* Skip past punctuation */
-        for (; *cp; cp++)
-            if (isalnum(*cp))
-                break;
-        /* Skip to the end of the word */
-        for (ncp = cp; *ncp; ncp++)
-            if (!isalnum(*ncp) && *ncp != '\'')
-                break;
-        /* Delimit end of word */
-        if (*ncp)
-            *ncp++ = '\0';
-        /* Check word to see if it's the password */
-        if (*cp) {
-            if (!strcasecmp(pwstr, cp))
-                return 1;
-            tcp = reverse(cp);
-            if (!strcasecmp(pwstr, tcp))
-                return 1;
-            cp = ncp;
-        } else
-            break;
-    }
-    return 0;
-}
-#endif /* HESIOD */
-
 /* some of this is stolen from gatekeeper ... */
+/* passwd_check -  returns KADM5_OK if password passes the validation.*/
 kadm5_ret_t
-passwd_check(kadm5_server_handle_t handle,
+passwd_check(kadm5_server_handle_t srv_handle,
              char *password, int use_policy, kadm5_policy_ent_t pol,
              krb5_principal principal)
 {
-    int     nupper = 0,
-        nlower = 0,
-        ndigit = 0,
-        npunct = 0,
-        nspec = 0;
-    char    c, *s, *cp;
-#ifdef HESIOD
-    extern  struct passwd *hes_getpwnam();
-    struct  passwd *ent;
-#endif
 
-    if(use_policy) {
-        if(strlen(password) < pol->pw_min_length)
-            return KADM5_PASS_Q_TOOSHORT;
-        s = password;
-        while ((c = *s++)) {
-            if (islower((unsigned char) c)) {
-                nlower = 1;
-                continue;
-            }
-            else if (isupper((unsigned char) c)) {
-                nupper = 1;
-                continue;
-            } else if (isdigit((unsigned char) c)) {
-                ndigit = 1;
-                continue;
-            } else if (ispunct((unsigned char) c)) {
-                npunct = 1;
-                continue;
-            } else {
-                nspec = 1;
-                continue;
-            }
-        }
-        if ((nupper + nlower + ndigit + npunct + nspec) < pol->pw_min_classes)
-            return KADM5_PASS_Q_CLASS;
-        if((find_word(password) == KADM5_OK))
-            return KADM5_PASS_Q_DICT;
-        else {
-            int i, n = krb5_princ_size(handle->context, principal);
-            cp = krb5_princ_realm(handle->context, principal)->data;
-            if (strcasecmp(cp, password) == 0)
-                return KADM5_PASS_Q_DICT;
-            for (i = 0; i < n ; i++) {
-                cp = krb5_princ_component(handle->context, principal, i)->data;
-                if (strcasecmp(cp, password) == 0)
-                    return KADM5_PASS_Q_DICT;
-#ifdef HESIOD
-                ent = hes_getpwnam(cp);
-                if (ent && ent->pw_gecos)
-                    if (str_check_gecos(ent->pw_gecos, password))
-                        return KADM5_PASS_Q_DICT; /* XXX new error code? */
-#endif
-            }
-            return KADM5_OK;
-        }
-    } else {
-        if (strlen(password) < 1)
-            return KADM5_PASS_Q_TOOSHORT;
-    }
-    return KADM5_OK;
+    int ret = 0;
+
+    plhandle plugin_handle = plugin_manager_get_service(srv_handle->context->pl_handle, "plugin_pwd_qlty");
+
+    ret = plugin_pwd_qlty_check(plugin_handle, srv_handle, password, use_policy, pol, principal);
+
+    return ret;
 }
index bc690481c7f60c63c4218634c08c685ea16818b8..0e3a047a8d14f2e2c89b4018f8ab26782cc59070 100644 (file)
@@ -9,7 +9,8 @@ DEFS=
 
 PLUGINS_LIBS = \
        ../../plugin_core/impl/libplugin_impl.a $(PLUGIN_CORE_DEPLIB)   \
-       ../../plugins/pa/encrypted_challenge/libencrypted_challenge.a   
+       ../../plugins/pa/encrypted_challenge/libencrypted_challenge.a   \
+       ../../plugins/pwd_qlty/plugin_pwd_qlty_krb/libplugin_pwd_qlty_krb.a     
 
 
 ##DOSBUILDTOP = ..\..
index 0e2f2ad7c94deab52e85783b81dff91c1d71c71d..40add8bf87090a24ad10fc61df171ae7a65ef245 100644 (file)
@@ -13,8 +13,6 @@ DEFS=-DLIBDIR=\"$(KRB5_LIBDIR)\"
 ##DOS##OBJFILE=..\$(OUTPRE)$(PREFIXDIR).lst
 
 PLUGINS_LIBS =   $(srcdir)/../../libplugin_impl.a $(srcdir)/../../libencrypted_challenge.a 
-# PLUGINS_LIBS =   $(srcdir)/../../libplugin_impl.a $(srcdir)/../../libplugin_yarrow.a $(srcdir)/../../libencrypted_challenge.a 
-
 
 STLIBOBJS= \
        addr_comp.o     \
index c16725efbf489deb94e2dd435acfb1367a5dde9c..d523f4e5b7928587a599b6e68aa3191742b417b5 100644 (file)
@@ -5,7 +5,7 @@ PROG_LIBPATH=-L$(TOPLIBD)
 PROG_RPATH=$(KRB5_LIBDIR)
 DEFS=
 
-LOCALINCLUDES = -I$(srcdir)/../include/krb5  -I$(srcdir)/. -I$(srcdir)/../plugins/prng -I$(srcdir)/../util/profile
+LOCALINCLUDES = -I$(srcdir)/../include/krb5  -I$(srcdir)/. -I$(srcdir)/../plugins/pwd_qlty -I$(srcdir)/../util/profile
 
 LIBBASE= plugin_core
 LIBMAJOR=0
index 84f077b15a1582f273f27457e8742a1264ad41f0..2d292d86ddaa3e6531b91f06dcbd2c769d1111ed 100644 (file)
@@ -6,9 +6,9 @@ PROG_RPATH=$(KRB5_LIBDIR)
 DEFS=
 
 LOCALINCLUDES = -I$(srcdir)/../../include/krb5  -I$(srcdir)/.  \
-               -I$(srcdir)/../../plugins/prng  \
+               -I$(srcdir)/../../plugins/pwd_qlty -I$(srcdir)/../../plugins/pwd_qlty/plugin_pwd_qlty_krb       \
                -I$(srcdir)/../../plugins/pa -I$(srcdir)/../../plugins/pa/encrypted_challenge   \
-               -I$(srcdir)/..
+               -I$(srcdir)/..  -I$(srcdir)/../../lib/kadm5
 
 LIBBASE=plugin_impl
 
@@ -18,11 +18,8 @@ SRCS= plugin_default_factory.c plugin_default_manager.c
 
 STOBJLISTS=OBJS.ST
 
-LIBS_UTILS = ../plugin_core$(SO_EXT) 
-
-#      ../../plugins/prng/plugin_yarrow/plugin_prng_impl$(SO_EXT)      \
-#      ../../plugins/prng/plugin_yarrow/ycipher$(SO_EXT)               \
-#      ../../plugins/prng/plugin_yarrow/yarrow$(SO_EXT) 
+LIBS_UTILS = ../plugin_core$(SO_EXT) \
+       ../../plugins/pwd_qlty/plugin_pwd_qlty_krb/plugin_pwd_qlty_impl$(SO_EXT)        
 
 SHLIB_EXPLIBS=  $(LIBS_UTILS) $(CRYPTO_DEPLIB) $(SUPPORT_DEPLIB)
 
index 1814ae2895b2c3c799f1786e0bf0a1200aca8efe..a006cabd7eaae6439020458f8efc2659ee891b96 100644 (file)
 #include "plugin_factory.h"
 //#include "plugin_prng_impl.h"
 #include "plugin_pa_impl.h"
+#include "plugin_pwd_qlty_impl.h"
 #include "plugin_default_factory.h"
 
 static plugin_factory* _default_factory_instance = NULL;
 
 static plugin_descr  plugin_default_factory_table[] = {
 //        {"plugin_yarrow_prng", plugin_yarrow_prng_create},
+        {"plugin_pwd_qlty_krb", plugin_pwd_qlty_krb_create},
         {"plugin_encrypted_challenge_pa", plugin_encrypted_challenge_pa_create},
         {"plugin_ldap_audit", NULL},
         {NULL,NULL}
index 8b92b10bacd9525d418a1889c2d33e932bacfa7a..04e8e318ab637f4b8f3abc3fc5bf11e5de0fbf28 100644 (file)
@@ -7,7 +7,7 @@
 #define PLUGIN_DEFAULT_FACTORY_H_
 
 #include <plugin_factory.h>
-//#include "plugin_prng_impl.h"
+#include "plugin_pwd_qlty_impl.h"
 
 
 factory_handle plugin_default_factory_get_instance(void);
diff --git a/src/plugins/pwd_qlty/Makefile.in b/src/plugins/pwd_qlty/Makefile.in
new file mode 100644 (file)
index 0000000..a70c166
--- /dev/null
@@ -0,0 +1,22 @@
+mydir=plugins/pwd_qlty
+BUILDTOP=$(REL)../..
+RELDIR=../plugins/pwd_qlty
+PROG_LIBPATH=-L$(TOPLIBD)
+PROG_RPATH=$(KRB5_LIBDIR)
+DEFS=
+
+LOCALINCLUDES = -I../../include/krb5 -I. -I../../plugin_core -I../../lib/kadm5/
+
+LIBBASE=plugin_pwd_qlty
+
+STLIBOBJS= plugin_pwd_qlty.o  
+SRCS= plugin_pwd_qlty.c  
+STOBJLISTS=OBJS.ST
+
+all-unix:: all-liblinks
+clean-unix:: clean-liblinks clean-libs clean-libobjs
+install-unix:: install-libs
+
+@libpriv_frag@
+@lib_frag@
+@libobj_frag@
diff --git a/src/plugins/pwd_qlty/deps b/src/plugins/pwd_qlty/deps
new file mode 100644 (file)
index 0000000..7b7a879
--- /dev/null
@@ -0,0 +1,15 @@
+# 
+# Generated makefile dependencies follow.
+#
+plugin_pwd_qlty.so plugin_pwd_qlty.po $(OUTPRE)plugin_pwd_qlty.$(OBJEXT): \
+  $(BUILDTOP)/include/krb5/krb5.h $(COM_ERR_DEPS) $(top_srcdir)/plugins/pwd_qlty/plugin_pwd_qlty.h \
+  $(top_srcdir)/plugin_core/plugin_manager.h \
+  $(top_srcdir)/plugin_core/plugin_factory.h \
+  $(top_srcdir)/lib/kadm5/admin.h \
+  plugin_pwd_qlty.c
+plugin_pwd_qlty_impl.so plugin_pwd_qlty_impl.po $(OUTPRE)plugin_pwd_qlty_impl.$(OBJEXT): \
+  $(BUILDTOP)/include/krb5/krb5.h $(COM_ERR_DEPS) $(top_srcdir)/plugins/pwd_qlty/plugin_pwd_qlty_impl.h \
+  $(top_srcdir)/plugin_core/plugin_manager.h \
+  $(top_srcdir)/plugin_core/plugin_factory.h \
+  $(top_srcdir)/lib/kadm5/admin.h \
+  plugin_pwd_qlty_impl.c
diff --git a/src/plugins/pwd_qlty/plugin_pwd_qlty.c b/src/plugins/pwd_qlty/plugin_pwd_qlty.c
new file mode 100644 (file)
index 0000000..2306be5
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * plugin_pwd_qlty.c
+ *
+ */
+#include <plugin_manager.h>
+#include "plugin_pwd_qlty.h"
+
+kadm5_ret_t
+plugin_pwd_qlty_check(plhandle handle, kadm5_server_handle_t srv_handle,
+                      char *password, int use_policy, kadm5_policy_ent_t pol,
+                      krb5_principal principal)
+{
+    kadm5_ret_t ret = KADM5_OK;
+    plugin_pwd_qlty* api = (plugin_pwd_qlty*) handle.api;
+    ret = api->pwd_qlty_check(srv_handle, password, use_policy, pol, principal);
+
+    return ret;
+}
+
+
+kadm5_ret_t
+plugin_pwd_qlty_init(plhandle handle, kadm5_server_handle_t srv_handle)
+{
+    kadm5_ret_t ret = KADM5_OK;
+    plugin_pwd_qlty* api = (plugin_pwd_qlty*) handle.api;
+    ret = api->pwd_qlty_init(srv_handle);
+
+    return ret;
+}
+
+void
+plugin_pwd_qlty_cleanup(plhandle handle)
+{
+    return;
+}
diff --git a/src/plugins/pwd_qlty/plugin_pwd_qlty.h b/src/plugins/pwd_qlty/plugin_pwd_qlty.h
new file mode 100644 (file)
index 0000000..4921be8
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * plugin_pwd_qlty.h
+ *
+ */
+
+#ifndef PLUGIN_PWD_QLTY_H_
+#define PLUGIN_PWD_QLTY_H_
+
+#include <plugin_manager.h>
+#include <k5-int.h>
+#include <admin.h>
+#include <server_internal.h>
+
+/* PWD_QLTY API */
+typedef struct {
+       int version;
+       kadm5_ret_t (*pwd_qlty_init)(kadm5_server_handle_t);
+       void (*pwd_qlty_cleanup)();
+       kadm5_ret_t (*pwd_qlty_check)(kadm5_server_handle_t, char*,
+                                      int, kadm5_policy_ent_t, krb5_principal);
+} plugin_pwd_qlty;
+
+/* Utility functions */
+kadm5_ret_t plugin_pwd_qlty_init(plhandle, kadm5_server_handle_t);
+void plugin_pwd_qlty_cleanup(plhandle);
+kadm5_ret_t plugin_pwd_qlty_check(plhandle, kadm5_server_handle_t, char*,
+                                  int,  kadm5_policy_ent_t, krb5_principal);
+
+#endif /* PLUGIN_PWD_QLTY_H_ */
diff --git a/src/plugins/pwd_qlty/plugin_pwd_qlty_krb/Makefile.in b/src/plugins/pwd_qlty/plugin_pwd_qlty_krb/Makefile.in
new file mode 100644 (file)
index 0000000..f00cf9e
--- /dev/null
@@ -0,0 +1,25 @@
+mydir=plugins/pwd_qlty/plugin_pwd_qlty_krb
+BUILDTOP=$(REL)../../..
+RELDIR=../plugins/pwd_qlty/plugin_pwd_qlty_krb
+PROG_LIBPATH=-L$(TOPLIBD)
+PROG_RPATH=$(KRB5_LIBDIR)
+DEFS=
+
+LOCALINCLUDES = -I../../../include/krb5 -I. -I../../../plugin_core -I..  -I$(srcdir)/..        \
+               -I../../../lib/kadm5
+
+LIBBASE=plugin_pwd_qlty_krb
+
+STLIBOBJS= plugin_pwd_qlty_impl.o server_dict.o
+SRCS= $(srcdir)/plugin_pwd_qlty_impl.c  $(srcdir)/server_dict.c
+
+STOBJLISTS=OBJS.ST
+
+all-unix:: all-liblinks
+clean-unix:: clean-liblinks clean-libs clean-libobjs
+install-unix:: install-libs
+
+
+@libpriv_frag@
+@lib_frag@
+@libobj_frag@
diff --git a/src/plugins/pwd_qlty/plugin_pwd_qlty_krb/deps b/src/plugins/pwd_qlty/plugin_pwd_qlty_krb/deps
new file mode 100644 (file)
index 0000000..d2990c7
--- /dev/null
@@ -0,0 +1,11 @@
+# 
+# Generated makefile dependencies follow.
+#
+plugin_pwd_qlty_impl.so plugin_pwd_qlty_impl.po $(OUTPRE)plugin_pwd_qlty_impl.$(OBJEXT): \
+  $(BUILDTOP)/include/krb5/krb5.h $(COM_ERR_DEPS) \
+  $(top_srcdir)/plugins/pwd_qlty/plugin_pwd_qlty_krb/plugin_pwd_qlty_impl.h \
+  $(top_srcdir)/lib/kadm5/admin.h \
+  $(top_srcdir)/plugin_core/plugin_manager.h \
+  $(top_srcdir)/plugin_core/plugin_factory.h \
+  plugin_pwd_qlty_impl.c
+
diff --git a/src/plugins/pwd_qlty/plugin_pwd_qlty_krb/plugin_pwd_qlty_impl.c b/src/plugins/pwd_qlty/plugin_pwd_qlty_krb/plugin_pwd_qlty_impl.c
new file mode 100644 (file)
index 0000000..941a165
--- /dev/null
@@ -0,0 +1,166 @@
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+
+#include "k5-int.h"
+
+#include <plugin_manager.h>
+#include <plugin_pwd_qlty.h>
+#include "plugin_pwd_qlty_impl.h"
+#include    <string.h>
+#include    <ctype.h>
+
+
+#ifdef HESIOD
+/* stolen from v4sever/kadm_funcs.c */
+static char *
+reverse(str)
+    char    *str;
+{
+    static char newstr[80];
+    char    *p, *q;
+    int     i;
+
+    i = strlen(str);
+    if (i >= sizeof(newstr))
+        i = sizeof(newstr)-1;
+    p = str+i-1;
+    q = newstr;
+    q[i]='\0';
+    for(; i > 0; i--)
+        *q++ = *p--;
+
+    return(newstr);
+}
+
+static int
+str_check_gecos(gecos, pwstr)
+    char    *gecos;
+    char    *pwstr;
+{
+    char            *cp, *ncp, *tcp;
+
+    for (cp = gecos; *cp; ) {
+        /* Skip past punctuation */
+        for (; *cp; cp++)
+            if (isalnum(*cp))
+                break;
+        /* Skip to the end of the word */
+        for (ncp = cp; *ncp; ncp++)
+            if (!isalnum(*ncp) && *ncp != '\'')
+                break;
+        /* Delimit end of word */
+        if (*ncp)
+            *ncp++ = '\0';
+        /* Check word to see if it's the password */
+        if (*cp) {
+            if (!strcasecmp(pwstr, cp))
+                return 1;
+            tcp = reverse(cp);
+            if (!strcasecmp(pwstr, tcp))
+                return 1;
+            cp = ncp;
+        } else
+            break;
+    }
+    return 0;
+}
+#endif /* HESIOD */
+
+
+static kadm5_ret_t
+_plugin_pwd_qlty_check(kadm5_server_handle_t srv_handle,
+             char *password, int use_policy, kadm5_policy_ent_t pol,
+             krb5_principal principal)
+{
+    int     nupper = 0,
+        nlower = 0,
+        ndigit = 0,
+        npunct = 0,
+        nspec = 0;
+    char    c, *s, *cp;
+
+#ifdef HESIOD
+    extern  struct passwd *hes_getpwnam();
+    struct  passwd *ent;
+#endif
+    if(use_policy) {
+        if(strlen(password) < (unsigned int)pol->pw_min_length)
+            return KADM5_PASS_Q_TOOSHORT;
+        s = password;
+        while ((c = *s++)) {
+            if (islower((unsigned char) c)) {
+                nlower = 1;
+                continue;
+            }
+            else if (isupper((unsigned char) c)) {
+                nupper = 1;
+                continue;
+            } else if (isdigit((unsigned char) c)) {
+                ndigit = 1;
+                continue;
+            } else if (ispunct((unsigned char) c)) {
+                npunct = 1;
+                continue;
+            } else {
+                nspec = 1;
+                continue;
+            }
+        }
+        if ((nupper + nlower + ndigit + npunct + nspec) < pol->pw_min_classes)
+            return KADM5_PASS_Q_CLASS;
+        if((find_word(password) == KADM5_OK))
+            return KADM5_PASS_Q_DICT;
+        else {
+            int i, n = krb5_princ_size(handle->context, principal);
+            cp = krb5_princ_realm(handle->context, principal)->data;
+            if (strcasecmp(cp, password) == 0)
+                return KADM5_PASS_Q_DICT;
+            for (i = 0; i < n ; i++) {
+                cp = krb5_princ_component(handle->context, principal, i)->data;
+                if (strcasecmp(cp, password) == 0)
+                    return KADM5_PASS_Q_DICT;
+#ifdef HESIOD
+                ent = hes_getpwnam(cp);
+                if (ent && ent->pw_gecos)
+                    if (str_check_gecos(ent->pw_gecos, password))
+                        return KADM5_PASS_Q_DICT; /* XXX new error code? */
+#endif
+            }
+            return KADM5_OK;
+        }
+    } else {
+        if (strlen(password) < 1)
+            return KADM5_PASS_Q_TOOSHORT;
+    }
+    return KADM5_OK;
+
+}
+
+static kadm5_ret_t
+_plugin_pwd_qlty_init(kadm5_server_handle_t handle)
+{
+    init_dict(&handle->params);
+    return 0;
+}
+
+static void
+_plugin_pwd_qlty_clean()
+{
+    destroy_dict();
+    return;
+}
+
+plhandle
+plugin_pwd_qlty_krb_create()
+{
+        plhandle handle;
+        plugin_pwd_qlty* api = malloc(sizeof(plugin_pwd_qlty));
+
+        memset(api, 0, sizeof(plugin_pwd_qlty));
+        api->version = 1;
+        api->pwd_qlty_init    = _plugin_pwd_qlty_init;
+        api->pwd_qlty_check   = _plugin_pwd_qlty_check;
+        api->pwd_qlty_cleanup = _plugin_pwd_qlty_clean;
+        handle.api = api;
+
+        return handle;
+}
diff --git a/src/plugins/pwd_qlty/plugin_pwd_qlty_krb/plugin_pwd_qlty_impl.h b/src/plugins/pwd_qlty/plugin_pwd_qlty_krb/plugin_pwd_qlty_impl.h
new file mode 100644 (file)
index 0000000..b8bf206
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * plugin_pwd_qlty_impl.h
+ *
+ */
+
+#ifndef PLUGIN_PWD_QLTY_IMPL_H_
+#define PLUGIN_PWD_QLTY_IMPL_H_
+
+#include <plugin_manager.h>
+#include <plugin_pwd_qlty.h>
+
+plhandle plugin_pwd_qlty_krb_create(void);
+
+#endif /* PLUGIN_PWD_QLTY_IMPL_H_ */
similarity index 93%
rename from src/lib/kadm5/srv/server_dict.c
rename to src/plugins/pwd_qlty/plugin_pwd_qlty_krb/server_dict.c
index 81cc5f99709c2433e14bac2996514622a2019189..46a30f1b6ba30acb9f8ec88372bbaea90f7563eb 100644 (file)
@@ -91,15 +91,10 @@ int init_dict(kadm5_config_params *params)
     if(word_list != NULL && word_block != NULL)
         return KADM5_OK;
     if (! (params->mask & KADM5_CONFIG_DICT_FILE)) {
-        krb5_klog_syslog(LOG_INFO, "No dictionary file specified, continuing "
-                         "without one.");
         return KADM5_OK;
     }
     if ((fd = open(params->dict_file, O_RDONLY)) == -1) {
         if (errno == ENOENT) {
-            krb5_klog_syslog(LOG_ERR,
-                             "WARNING!  Cannot find dictionary file %s, "
-                             "continuing without one.", params->dict_file);
             return KADM5_OK;
         } else
             return errno;