#include <ac/stdlib.h>
#include <ac/string.h>
+#ifdef SLAPD_SPASSWD
+# include <sasl.h>
+#endif
+
#ifdef SLAPD_KPASSWD
# include <ac/krb.h>
# include <ac/krb5.h>
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
+#ifdef HAVE_AIX_SECURITY
+# include <userpw.h>
+#endif
#include <lber.h>
const struct berval *passwd,
const struct berval *cred );
+#ifdef SLAPD_SPASSWD
+static int chk_sasl(
+ const struct pw_scheme *scheme,
+ const struct berval *passwd,
+ const struct berval *cred );
+#endif
+
+#ifdef SLAPD_KPASSWD
static int chk_kerberos(
const struct pw_scheme *scheme,
const struct berval *passwd,
const struct berval *cred );
+#endif
+#ifdef SLAPD_CRYPT
static int chk_crypt(
const struct pw_scheme *scheme,
const struct berval *passwd,
const struct berval *cred );
+#if defined( HAVE_GETPWNAM ) && defined( HAVE_PW_PASSWD )
static int chk_unix(
const struct pw_scheme *scheme,
const struct berval *passwd,
const struct berval *cred );
+#endif
+#endif
/* password hash routines */
const struct pw_scheme *scheme,
const struct berval *passwd );
+#ifdef SLAPD_CRYPT
static struct berval *hash_crypt(
const struct pw_scheme *scheme,
const struct berval *passwd );
+#endif
static const struct pw_scheme pw_schemes[] =
{ {sizeof("{SMD5}")-1, "{SMD5}"}, chk_smd5, hash_smd5 },
{ {sizeof("{MD5}")-1, "{MD5}"}, chk_md5, hash_md5 },
+#ifdef SLAPD_SPASSWD
+ { {sizeof("{SASL}")-1, "{SASL}"}, chk_sasl, NULL },
+#endif
+
#ifdef SLAPD_KPASSWD
{ {sizeof("{KERBEROS}")-1, "{KERBEROS}"}, chk_kerberos, NULL },
#endif
#ifdef SLAPD_CRYPT
{ {sizeof("{CRYPT}")-1, "{CRYPT}"}, chk_crypt, hash_crypt },
-#endif
-# if defined( HAVE_GETSPNAM ) \
- || ( defined( HAVE_GETPWNAM ) && defined( HAVE_PW_PASSWD ) )
+# if defined( HAVE_GETPWNAM ) && defined( HAVE_PW_PASSWD )
{ {sizeof("{UNIX}")-1, "{UNIX}"}, chk_unix, NULL },
+# endif
#endif
#ifdef SLAPD_CLEARTEXT
return rc ? 1 : 0;
}
+#ifdef SLAPD_SPASSWD
+#ifdef HAVE_CYRUS_SASL
+sasl_conn_t *lutil_passwd_sasl_conn = NULL;
+#endif
+
+static int chk_sasl(
+ const struct pw_scheme *sc,
+ const struct berval * passwd,
+ const struct berval * cred )
+{
+ int i;
+ int rtn;
+
+ for( i=0; i<cred->bv_len; i++) {
+ if(cred->bv_val[i] == '\0') {
+ return 1; /* NUL character in password */
+ }
+ }
+
+ if( cred->bv_val[i] != '\0' ) {
+ return 1; /* cred must behave like a string */
+ }
+
+ for( i=0; i<passwd->bv_len; i++) {
+ if(passwd->bv_val[i] == '\0') {
+ return 1; /* NUL character in password */
+ }
+ }
+
+ if( passwd->bv_val[i] != '\0' ) {
+ return 1; /* passwd must behave like a string */
+ }
+
+ rtn = 1;
+
+#ifdef HAVE_CYRUS_SASL
+ if( lutil_passwd_sasl_conn != NULL ) {
+ const char *errstr = NULL;
+ int sc;
+
+ sc = sasl_checkpass( lutil_passwd_sasl_conn,
+ passwd->bv_val, passwd->bv_len,
+ cred->bv_val, cred->bv_len,
+ &errstr );
+
+ rtn = ( sc != SASL_OK );
+ }
+#endif
+
+ return rtn;
+}
+#endif
+
#ifdef SLAPD_KPASSWD
static int chk_kerberos(
const struct pw_scheme *sc,
return strcmp( passwd->bv_val, cr ) ? 1 : 0;
}
-# if defined( HAVE_GETSPNAM ) \
- || ( defined( HAVE_GETPWNAM ) && defined( HAVE_PW_PASSWD ) )
+# if defined( HAVE_GETPWNAM ) && defined( HAVE_PW_PASSWD )
static int chk_unix(
const struct pw_scheme *sc,
const struct berval * passwd,
return -1; /* passwd must behave like a string */
}
-# ifdef HAVE_GETSPNAM
{
- struct spwd *spwd = getspnam(passwd->bv_val);
+ struct passwd *pwd = getpwnam(passwd->bv_val);
- if(spwd == NULL) {
+ if(pwd == NULL) {
return -1; /* not found */
}
- pw = spwd->sp_pwdp;
+ pw = pwd->pw_passwd;
}
-
-# else
+# ifdef HAVE_GETSPNAM
{
- struct passwd *pwd = getpwnam(passwd->bv_val);
+ struct spwd *spwd = getspnam(passwd->bv_val);
- if(pwd == NULL) {
- return -1; /* not found */
+ if(spwd != NULL) {
+ pw = spwd->sp_pwdp;
}
+ }
+# endif
+# ifdef HAVE_AIX_SECURITY
+ {
+ struct userpw *upw = getuserpw(passwd->bv_val);
- pw = pwd->pw_passwd;
+ if (upw != NULL) {
+ pw = upw->upw_passwd;
+ }
}
# endif