summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2013-01-04 22:38:33 +0100
committerArthur de Jong <arthur@arthurdejong.org>2013-03-03 11:40:04 +0100
commit5fce062a92b4838d976a412f88781ca12168ff77 (patch)
tree4e6a434ea7fc990a0f934dafab644540d2d5bc5c /compat
parent37151df22e5cdf31c92b15157fe8a18e061ee2fb (diff)
provide a basic replacement implementation of ldap_passwordpolicy_err2txt() for systems that don't have it
Diffstat (limited to 'compat')
-rw-r--r--compat/Makefile.am2
-rw-r--r--compat/ldap_compat.h4
-rw-r--r--compat/ldap_passwordpolicy_err2txt.c48
3 files changed, 53 insertions, 1 deletions
diff --git a/compat/Makefile.am b/compat/Makefile.am
index 5c8ec76..7391fee 100644
--- a/compat/Makefile.am
+++ b/compat/Makefile.am
@@ -28,7 +28,7 @@ EXTRA_DIST = getopt_long.c getopt_long.h \
strndup.c strndup.h \
nss_compat.h socket.h \
ldap_compat.h pagectrl.c ldap_passwd_s.c ldap_initialize.c \
- ldap_parse_passwordpolicy_control.c \
+ ldap_parse_passwordpolicy_control.c ldap_passwordpolicy_err2txt.c \
pam_compat.h pam_get_authtok.c pam_prompt.c
libcompat_a_SOURCES = getpeercred.c getpeercred.h
diff --git a/compat/ldap_compat.h b/compat/ldap_compat.h
index cf460d1..6e9c6b1 100644
--- a/compat/ldap_compat.h
+++ b/compat/ldap_compat.h
@@ -76,6 +76,10 @@ int ldap_parse_passwordpolicy_control(LDAP *ld, LDAPControl *ctrl,
LDAPPasswordPolicyError *errorp);
#endif /* HAVE_LDAP_PARSE_PASSWORDPOLICY_CONTROL */
+#ifndef HAVE_LDAP_PASSWORDPOLICY_ERR2TXT
+const char *ldap_passwordpolicy_err2txt(LDAPPasswordPolicyError error);
+#endif /* HAVE_LDAP_PASSWORDPOLICY_ERR2TXT */
+
/* compatibility definition */
#ifndef LDAP_SASL_QUIET
#define LDAP_SASL_QUIET 2U
diff --git a/compat/ldap_passwordpolicy_err2txt.c b/compat/ldap_passwordpolicy_err2txt.c
new file mode 100644
index 0000000..09bd0ea
--- /dev/null
+++ b/compat/ldap_passwordpolicy_err2txt.c
@@ -0,0 +1,48 @@
+/*
+ ldap_passwordpolicy_err2txt.c - replacement function
+
+ Copyright (C) 2013 Arthur de Jong
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA
+*/
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <lber.h>
+#include <ldap.h>
+#include <string.h>
+
+#include "compat/ldap_compat.h"
+#include "compat/attrs.h"
+
+const char *ldap_passwordpolicy_err2txt(LDAPPasswordPolicyError error)
+{
+ switch (error)
+ {
+ case PP_passwordExpired: return "Password expired";
+ case PP_accountLocked: return "Account locked";
+ case PP_changeAfterReset: return "Change after reset";
+ case PP_passwordModNotAllowed: return "Password modification not allowed";
+ case PP_mustSupplyOldPassword: return "Must supply old password";
+ case PP_insufficientPasswordQuality: return "Insufficient password quality";
+ case PP_passwordTooShort: return "Password too short";
+ case PP_passwordTooYoung: return "Password too young";
+ case PP_passwordInHistory: return "Password in history";
+ case PP_noError: return "No error";
+ default: return "Unknown error";
+ }
+}