X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Foverlays%2Fppolicy.c;h=b6a833c02bbca690ab0de9bc922cdc0daf37ac56;hb=34f4c2cb97dd6c7851e30298c7e014e170f54665;hp=b8bce27efa590667d3d2bb6a96a26c3226102654;hpb=dbade4ad8c245734443b32c994da9df6b6c62d7b;p=openldap
diff --git a/servers/slapd/overlays/ppolicy.c b/servers/slapd/overlays/ppolicy.c
index b8bce27efa..b6a833c02b 100644
--- a/servers/slapd/overlays/ppolicy.c
+++ b/servers/slapd/overlays/ppolicy.c
@@ -1,7 +1,9 @@
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
- * Copyright 2004 Howard Chu, Symas Corporation.
+ * Copyright 2004-2006 The OpenLDAP Foundation.
+ * Portions Copyright 2004-2005 Howard Chu, Symas Corporation.
+ * Portions Copyright 2004 Hewlett-Packard Company.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -12,26 +14,31 @@
* top-level directory of the distribution or, alternatively, at
* .
*/
+/* ACKNOWLEDGEMENTS:
+ * This work was developed by Howard Chu for inclusion in
+ * OpenLDAP Software, based on prior work by Neil Dunbar (HP).
+ * This work was sponsored by the Hewlett-Packard Company.
+ */
#include "portable.h"
/* This file implements "Password Policy for LDAP Directories",
- * based on draft behera-ldap-password-policy-07
+ * based on draft behera-ldap-password-policy-09
*/
#ifdef SLAPD_OVER_PPOLICY
-#if SLAPD_OVER_PPOLICY == SLAPD_MOD_DYNAMIC
-#define SLAPD_IMPORT
-#endif
-
#include
#include "lutil.h"
#include "slap.h"
+#if SLAPD_MODULES
+#define LIBLTDL_DLL_IMPORT /* Win32: don't re-export libltdl's symbols */
#include
+#endif
#include
#include
#include
+#include
#ifndef MODULE_NAME_SZ
#define MODULE_NAME_SZ 256
@@ -40,18 +47,19 @@
/* Per-instance configuration information */
typedef struct pp_info {
struct berval def_policy; /* DN of default policy subentry */
+ int use_lockout; /* send AccountLocked result? */
+ int hash_passwords; /* transparently hash cleartext pwds */
} pp_info;
/* Our per-connection info - note, it is not per-instance, it is
* used by all instances
*/
typedef struct pw_conn {
- int restrict; /* TRUE if connection is restricted */
+ struct berval dn; /* DN of restricted user */
} pw_conn;
static pw_conn *pwcons;
-
-static long gmtoff; /* Offset of local time from GMT */
+static int ppolicy_cid;
typedef struct pass_policy {
AttributeDescription *ad; /* attribute to which the policy applies */
@@ -63,7 +71,7 @@ typedef struct pass_policy {
int pwdMinLength; /* minimum number of chars in password */
int pwdExpireWarning; /* number of seconds that warning controls are
sent before a password expires */
- int pwdGraceLoginLimit; /* number of times you can log in with an
+ int pwdGraceAuthNLimit; /* number of times you can log in with an
expired password */
int pwdLockout; /* 0 = do not lockout passwords, 1 = lock them out */
int pwdLockoutDuration; /* time in seconds a password is locked out for */
@@ -90,8 +98,8 @@ typedef struct pw_hist {
/* Operational attributes */
static AttributeDescription *ad_pwdChangedTime, *ad_pwdAccountLockedTime,
- *ad_pwdExpirationWarned, *ad_pwdFailureTime, *ad_pwdHistory,
- *ad_pwdGraceUseTime, *ad_pwdReset, *ad_pwdPolicySubentry;
+ *ad_pwdFailureTime, *ad_pwdHistory, *ad_pwdGraceUseTime, *ad_pwdReset,
+ *ad_pwdPolicySubentry;
static struct schema_info {
char *def;
@@ -103,7 +111,7 @@ static struct schema_info {
"EQUALITY generalizedTimeMatch "
"ORDERING generalizedTimeOrderingMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
- "SINGLE-VALUE USAGE directoryOperation )",
+ "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
&ad_pwdChangedTime },
{ "( 1.3.6.1.4.1.42.2.27.8.1.17 "
"NAME ( 'pwdAccountLockedTime' ) "
@@ -111,37 +119,34 @@ static struct schema_info {
"EQUALITY generalizedTimeMatch "
"ORDERING generalizedTimeOrderingMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
- "SINGLE-VALUE USAGE directoryOperation )",
+ "SINGLE-VALUE "
+#if 0
+ /* Not until MANAGEDIT control is released */
+ "NO-USER-MODIFICATION "
+#endif
+ "USAGE directoryOperation )",
&ad_pwdAccountLockedTime },
- { "( 1.3.6.1.4.1.42.2.27.8.1.18 "
- "NAME ( 'pwdExpirationWarned' ) "
- "DESC 'The time the user was first warned about the coming expiration of the password' "
- "EQUALITY generalizedTimeMatch "
- "ORDERING generalizedTimeOrderingMatch "
- "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
- "SINGLE-VALUE USAGE directoryOperation )",
- &ad_pwdExpirationWarned },
{ "( 1.3.6.1.4.1.42.2.27.8.1.19 "
"NAME ( 'pwdFailureTime' ) "
"DESC 'The timestamps of the last consecutive authentication failures' "
"EQUALITY generalizedTimeMatch "
"ORDERING generalizedTimeOrderingMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
- "USAGE directoryOperation )",
+ "NO-USER-MODIFICATION USAGE directoryOperation )",
&ad_pwdFailureTime },
{ "( 1.3.6.1.4.1.42.2.27.8.1.20 "
"NAME ( 'pwdHistory' ) "
"DESC 'The history of users passwords' "
"EQUALITY octetStringMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 "
- "USAGE directoryOperation )",
+ "NO-USER-MODIFICATION USAGE directoryOperation )",
&ad_pwdHistory },
{ "( 1.3.6.1.4.1.42.2.27.8.1.21 "
"NAME ( 'pwdGraceUseTime' ) "
"DESC 'The timestamps of the grace login once the password has expired' "
"EQUALITY generalizedTimeMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
- "USAGE directoryOperation )",
+ "NO-USER-MODIFICATION USAGE directoryOperation )",
&ad_pwdGraceUseTime },
{ "( 1.3.6.1.4.1.42.2.27.8.1.22 "
"NAME ( 'pwdReset' ) "
@@ -155,7 +160,12 @@ static struct schema_info {
"DESC 'The pwdPolicy subentry in effect for this object' "
"EQUALITY distinguishedNameMatch "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
- "SINGLE-VALUE USAGE directoryOperation )",
+ "SINGLE-VALUE "
+#if 0
+ /* Not until MANAGEDIT control is released */
+ "NO-USER-MODIFICATION "
+#endif
+ "USAGE directoryOperation )",
&ad_pwdPolicySubentry },
{ NULL, NULL }
};
@@ -163,7 +173,7 @@ static struct schema_info {
/* User attributes */
static AttributeDescription *ad_pwdMinAge, *ad_pwdMaxAge, *ad_pwdInHistory,
*ad_pwdCheckQuality, *ad_pwdMinLength, *ad_pwdMaxFailure,
- *ad_pwdGraceLoginLimit, *ad_pwdExpireWarning, *ad_pwdLockoutDuration,
+ *ad_pwdGraceAuthNLimit, *ad_pwdExpireWarning, *ad_pwdLockoutDuration,
*ad_pwdFailureCountInterval, *ad_pwdCheckModule, *ad_pwdLockout,
*ad_pwdMustChange, *ad_pwdAllowUserChange, *ad_pwdSafeModify,
*ad_pwdAttribute;
@@ -178,7 +188,7 @@ static struct schema_info pwd_UsSchema[] = {
TAB(pwdCheckQuality),
TAB(pwdMinLength),
TAB(pwdMaxFailure),
- TAB(pwdGraceLoginLimit),
+ TAB(pwdGraceAuthNLimit),
TAB(pwdExpireWarning),
TAB(pwdLockout),
TAB(pwdLockoutDuration),
@@ -195,23 +205,15 @@ static ldap_pvt_thread_mutex_t chk_syntax_mutex;
static time_t
parse_time( char *atm )
{
- struct tm tm;
-
- if (!atm) return (time_t)-1;
+ struct lutil_tm tm;
+ struct lutil_timet tt;
+ time_t ret = (time_t)-1;
- /*
- * special case - if the lowest allowable GeneralizedTime is here, return
- * this is as zero time. Note: this might also be the case if the value stored
- * is equivalent to the start of the epoch (ie, Jan 1, 1970 at midnight.
- */
- if (strcmp(atm, "00000101000000Z") == 0) return (time_t)0;
- /*
- * else parse the time and return it's time_t value. This will be -1 if the
- * text isn't a valid time string.
- */
- strptime( atm, "%Y%m%d%H%M%SZ", &tm );
- tm.tm_isdst = 0;
- return mktime(&tm) - gmtoff;
+ if ( lutil_parsetime( atm, &tm ) == 0) {
+ lutil_tm2time( &tm, &tt );
+ ret = tt.tt_sec;
+ }
+ return ret;
}
static int
@@ -219,10 +221,8 @@ account_locked( Operation *op, Entry *e,
PassPolicy *pp, Modifications **mod )
{
Attribute *la;
- int rc;
- Entry *de;
- assert(mod);
+ assert(mod != NULL);
if ( (la = attr_find( e->e_attrs, ad_pwdAccountLockedTime )) != NULL ) {
BerVarray vals = la->a_nvals;
@@ -233,9 +233,11 @@ account_locked( Operation *op, Entry *e,
*/
if (vals[0].bv_val != NULL) {
time_t then, now;
- struct berval bv;
Modifications *m;
+ if (!pp->pwdLockoutDuration)
+ return 1;
+
if ((then = parse_time( vals[0].bv_val )) == (time_t)0)
return 1;
@@ -246,6 +248,7 @@ account_locked( Operation *op, Entry *e,
m = ch_calloc( sizeof(Modifications), 1 );
m->sml_op = LDAP_MOD_DELETE;
+ m->sml_flags = 0;
m->sml_type = ad_pwdAccountLockedTime->ad_cname;
m->sml_desc = ad_pwdAccountLockedTime;
m->sml_next = *mod;
@@ -256,11 +259,12 @@ account_locked( Operation *op, Entry *e,
return 0;
}
-#define PPOLICY_WARNING 0xa0L
-#define PPOLICY_ERROR 0xa1L
+/* IMPLICIT TAGS, all context-specific */
+#define PPOLICY_WARNING 0xa0L /* constructed + 0 */
+#define PPOLICY_ERROR 0x81L /* primitive + 1 */
-#define PPOLICY_EXPIRE 0xa0L
-#define PPOLICY_GRACE 0xa1L
+#define PPOLICY_EXPIRE 0x80L /* primitive + 0 */
+#define PPOLICY_GRACE 0x81L /* primitive + 1 */
static LDAPControl *
create_passcontrol( int exptime, int grace, LDAPPasswordPolicyError err )
@@ -314,16 +318,19 @@ ppolicy_get( Operation *op, Entry *e, PassPolicy *pp )
pp_info *pi = on->on_bi.bi_private;
Attribute *a;
BerVarray vals;
- int i, rc, nent;
+ int rc;
Entry *pe = NULL;
- AttributeDescription *oca = slap_schema.si_ad_objectClass;
+#if 0
const char *text;
- AttributeDescription *ad;
- struct berval bv;
- void *opr = op->o_private;
+#endif
memset( pp, 0, sizeof(PassPolicy) );
+ pp->ad = slap_schema.si_ad_userPassword;
+
+ /* Users can change their own password by default */
+ pp->pwdAllowUserChange = 1;
+
if ((a = attr_find( e->e_attrs, ad_pwdPolicySubentry )) == NULL) {
/*
* entry has no password policy assigned - use default
@@ -334,19 +341,12 @@ ppolicy_get( Operation *op, Entry *e, PassPolicy *pp )
} else {
vals = a->a_nvals;
if (vals[0].bv_val == NULL) {
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, ERR,
- "ppolicy_get: NULL value for policySubEntry\n", 0, 0, 0 );
-#else
Debug( LDAP_DEBUG_ANY,
"ppolicy_get: NULL value for policySubEntry\n", 0, 0, 0 );
-#endif
goto defaultpol;
}
}
- /* back-bdb stores lock info in o_private */
- op->o_private = NULL;
op->o_bd->bd_info = (BackendInfo *)on->on_info;
rc = be_entry_get_rw( op, vals, NULL, NULL, 0, &pe );
op->o_bd->bd_info = (BackendInfo *)on;
@@ -356,34 +356,42 @@ ppolicy_get( Operation *op, Entry *e, PassPolicy *pp )
#if 0 /* Only worry about userPassword for now */
if ((a = attr_find( pe->e_attrs, ad_pwdAttribute )))
slap_bv2ad( &a->a_vals[0], &pp->ad, &text );
-#else
- pp->ad = slap_schema.si_ad_userPassword;
#endif
- if ((a = attr_find( pe->e_attrs, ad_pwdMinAge )))
- pp->pwdMinAge = atoi(a->a_vals[0].bv_val );
- if ((a = attr_find( pe->e_attrs, ad_pwdMaxAge )))
- pp->pwdMaxAge = atoi(a->a_vals[0].bv_val );
- if ((a = attr_find( pe->e_attrs, ad_pwdInHistory )))
- pp->pwdInHistory = atoi(a->a_vals[0].bv_val );
- if ((a = attr_find( pe->e_attrs, ad_pwdCheckQuality )))
- pp->pwdCheckQuality = atoi(a->a_vals[0].bv_val );
- if ((a = attr_find( pe->e_attrs, ad_pwdMinLength )))
- pp->pwdMinLength = atoi(a->a_vals[0].bv_val );
- if ((a = attr_find( pe->e_attrs, ad_pwdMaxFailure )))
- pp->pwdMaxFailure = atoi(a->a_vals[0].bv_val );
- if ((a = attr_find( pe->e_attrs, ad_pwdGraceLoginLimit )))
- pp->pwdGraceLoginLimit = atoi(a->a_vals[0].bv_val );
- if ((a = attr_find( pe->e_attrs, ad_pwdExpireWarning )))
- pp->pwdExpireWarning = atoi(a->a_vals[0].bv_val );
- if ((a = attr_find( pe->e_attrs, ad_pwdFailureCountInterval )))
- pp->pwdFailureCountInterval = atoi(a->a_vals[0].bv_val );
- if ((a = attr_find( pe->e_attrs, ad_pwdLockoutDuration )))
- pp->pwdLockoutDuration = atoi(a->a_vals[0].bv_val );
-
- if ((a = attr_find( pe->e_attrs, ad_pwdCheckModule ))) {
- strncpy(pp->pwdCheckModule, a->a_vals[0].bv_val,
- sizeof(pp->pwdCheckModule));
+ if ( ( a = attr_find( pe->e_attrs, ad_pwdMinAge ) )
+ && lutil_atoi( &pp->pwdMinAge, a->a_vals[0].bv_val ) != 0 )
+ goto defaultpol;
+ if ( ( a = attr_find( pe->e_attrs, ad_pwdMaxAge ) )
+ && lutil_atoi( &pp->pwdMaxAge, a->a_vals[0].bv_val ) != 0 )
+ goto defaultpol;
+ if ( ( a = attr_find( pe->e_attrs, ad_pwdInHistory ) )
+ && lutil_atoi( &pp->pwdInHistory, a->a_vals[0].bv_val ) != 0 )
+ goto defaultpol;
+ if ( ( a = attr_find( pe->e_attrs, ad_pwdCheckQuality ) )
+ && lutil_atoi( &pp->pwdCheckQuality, a->a_vals[0].bv_val ) != 0 )
+ goto defaultpol;
+ if ( ( a = attr_find( pe->e_attrs, ad_pwdMinLength ) )
+ && lutil_atoi( &pp->pwdMinLength, a->a_vals[0].bv_val ) != 0 )
+ goto defaultpol;
+ if ( ( a = attr_find( pe->e_attrs, ad_pwdMaxFailure ) )
+ && lutil_atoi( &pp->pwdMaxFailure, a->a_vals[0].bv_val ) != 0 )
+ goto defaultpol;
+ if ( ( a = attr_find( pe->e_attrs, ad_pwdGraceAuthNLimit ) )
+ && lutil_atoi( &pp->pwdGraceAuthNLimit, a->a_vals[0].bv_val ) != 0 )
+ goto defaultpol;
+ if ( ( a = attr_find( pe->e_attrs, ad_pwdExpireWarning ) )
+ && lutil_atoi( &pp->pwdExpireWarning, a->a_vals[0].bv_val ) != 0 )
+ goto defaultpol;
+ if ( ( a = attr_find( pe->e_attrs, ad_pwdFailureCountInterval ) )
+ && lutil_atoi( &pp->pwdFailureCountInterval, a->a_vals[0].bv_val ) != 0 )
+ goto defaultpol;
+ if ( ( a = attr_find( pe->e_attrs, ad_pwdLockoutDuration ) )
+ && lutil_atoi( &pp->pwdLockoutDuration, a->a_vals[0].bv_val ) != 0 )
+ goto defaultpol;
+
+ if ( ( a = attr_find( pe->e_attrs, ad_pwdCheckModule ) ) ) {
+ strncpy( pp->pwdCheckModule, a->a_vals[0].bv_val,
+ sizeof(pp->pwdCheckModule) );
pp->pwdCheckModule[sizeof(pp->pwdCheckModule)-1] = '\0';
}
@@ -400,18 +408,11 @@ ppolicy_get( Operation *op, Entry *e, PassPolicy *pp )
be_entry_release_r( op, pe );
op->o_bd->bd_info = (BackendInfo *)on;
- op->o_private = opr;
return;
defaultpol:
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, DETAIL1,
- "ppolicy_get: using default policy\n", 0, 0, 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
+ Debug( LDAP_DEBUG_TRACE,
"ppolicy_get: using default policy\n", 0, 0, 0 );
-#endif
- op->o_private = opr;
return;
}
@@ -432,14 +433,13 @@ password_scheme( struct berval *cred, struct berval *sch )
for(e = 1; cred->bv_val[e] && cred->bv_val[e] != '}'; e++);
if (cred->bv_val[e]) {
- char *sc = ch_calloc( sizeof(char), e + 2);
- sc[e + 1] = '\0'; /* terminate string */
- strncpy( sc, cred->bv_val, e + 1);
- e = lutil_passwd_scheme( sc );
- free( sc );
- if (e && sch) {
- sch->bv_val = cred->bv_val;
- sch->bv_len = e;
+ int rc;
+ rc = lutil_passwd_scheme( cred->bv_val );
+ if (rc) {
+ if (sch) {
+ sch->bv_val = cred->bv_val;
+ sch->bv_len = e;
+ }
return LDAP_SUCCESS;
}
}
@@ -447,11 +447,10 @@ password_scheme( struct berval *cred, struct berval *sch )
}
static int
-check_password_quality( struct berval *cred, PassPolicy *pp, LDAPPasswordPolicyError *err )
+check_password_quality( struct berval *cred, PassPolicy *pp, LDAPPasswordPolicyError *err, Entry *e )
{
int rc = LDAP_SUCCESS, ok = LDAP_SUCCESS;
char *ptr = cred->bv_val;
- char *modpath;
struct berval sch;
assert( cred != NULL );
@@ -493,56 +492,39 @@ check_password_quality( struct berval *cred, PassPolicy *pp, LDAPPasswordPolicyE
}
rc = LDAP_SUCCESS;
-
+
if (pp->pwdCheckModule[0]) {
+#if SLAPD_MODULES
lt_dlhandle mod;
const char *err;
if ((mod = lt_dlopen( pp->pwdCheckModule )) == NULL) {
err = lt_dlerror();
-#ifdef NEW_LOGGING
- LDAP_LOG( SLAPD, CRIT,
- "check_password_quality: lt_dlopen failed: (%s) %s.\n",
- pp->pwdCheckModule, err, 0 );
-#else
Debug(LDAP_DEBUG_ANY,
"check_password_quality: lt_dlopen failed: (%s) %s.\n",
pp->pwdCheckModule, err, 0 );
-#endif
ok = LDAP_OTHER; /* internal error */
} else {
- int (*prog)( char *passwd, char **text, void *arg );
+ int (*prog)( char *passwd, char **text, Entry *ent );
if ((prog = lt_dlsym( mod, "check_password" )) == NULL) {
err = lt_dlerror();
-#ifdef NEW_LOGGING
- LDAP_LOG( SLAPD, CRIT,
- "check_password_quality: lt_dlsym failed: (%s) %s.\n",
- pp->pwdCheckModule, err, 0 );
-#else
Debug(LDAP_DEBUG_ANY,
"check_password_quality: lt_dlsym failed: (%s) %s.\n",
pp->pwdCheckModule, err, 0 );
-#endif
ok = LDAP_OTHER;
} else {
char *txt = NULL;
ldap_pvt_thread_mutex_lock( &chk_syntax_mutex );
- ok = prog( cred->bv_val, &txt, NULL );
+ ok = prog( cred->bv_val, &txt, e );
ldap_pvt_thread_mutex_unlock( &chk_syntax_mutex );
if (txt) {
-#ifdef NEW_LOGGING
- LDAP_LOG( SLAPD, CRIT,
- "check_password_quality: module error (%s) %s[%d].\n",
- pp->pwdCheckModule, txt, ok );
-#else
Debug(LDAP_DEBUG_ANY,
"check_password_quality: module error: (%s) %s.[%d]\n",
pp->pwdCheckModule, txt, ok );
-#endif
free(txt);
} else
ok = LDAP_SUCCESS;
@@ -550,6 +532,10 @@ check_password_quality( struct berval *cred, PassPolicy *pp, LDAPPasswordPolicyE
lt_dlclose( mod );
}
+#else
+ Debug(LDAP_DEBUG_ANY, "check_password_quality: external modules not "
+ "supported. pwdCheckModule ignored.\n", 0, 0, 0);
+#endif /* SLAPD_MODULES */
}
@@ -657,9 +643,9 @@ make_pwd_history_value( char *timebuf, struct berval *bv, Attribute *pa )
int nlen;
snprintf( str, MAX_PWD_HISTORY_SZ,
- "%s#%s#%d#", timebuf,
+ "%s#%s#%lu#", timebuf,
pa->a_desc->ad_type->sat_syntax->ssyn_oid,
- pa->a_nvals[0].bv_len );
+ (unsigned long) pa->a_nvals[0].bv_len );
str[MAX_PWD_HISTORY_SZ-1] = 0;
nlen = strlen(str);
@@ -713,12 +699,11 @@ ppolicy_bind_resp( Operation *op, SlapReply *rs )
slap_overinst *on = ppb->on;
Modifications *mod = ppb->mod, *m;
int pwExpired = 0;
- int ngut = -1, warn = -1, age, rc, i;
+ int ngut = -1, warn = -1, age, rc;
Attribute *a;
- struct tm *tm;
- time_t now, then, pwtime = (time_t)-1;
- const char *txt;
+ time_t now, pwtime = (time_t)-1;
char nowstr[ LDAP_LUTIL_GENTIME_BUFSIZE ];
+ struct berval timestamp;
BackendInfo *bi = op->o_bd->bd_info;
Entry *e;
@@ -736,21 +721,23 @@ ppolicy_bind_resp( Operation *op, SlapReply *rs )
}
now = slap_get_time(); /* stored for later consideration */
- ldap_pvt_thread_mutex_lock( &gmtime_mutex );
- tm = gmtime(&now);
- lutil_gentime( nowstr, sizeof(nowstr), tm );
- ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
+ timestamp.bv_val = nowstr;
+ timestamp.bv_len = sizeof(nowstr);
+ slap_timestamp( &now, ×tamp );
if ( rs->sr_err == LDAP_INVALID_CREDENTIALS ) {
int i = 0, fc = 0;
m = ch_calloc( sizeof(Modifications), 1 );
m->sml_op = LDAP_MOD_ADD;
+ m->sml_flags = 0;
m->sml_type = ad_pwdFailureTime->ad_cname;
m->sml_desc = ad_pwdFailureTime;
m->sml_values = ch_calloc( sizeof(struct berval), 2 );
+ m->sml_nvalues = ch_calloc( sizeof(struct berval), 2 );
- ber_str2bv( nowstr, 0, 1, &m->sml_values[0] );
+ ber_dupbv( &m->sml_values[0], ×tamp );
+ ber_dupbv( &m->sml_nvalues[0], ×tamp );
m->sml_next = mod;
mod = m;
@@ -792,10 +779,13 @@ ppolicy_bind_resp( Operation *op, SlapReply *rs )
*/
m = ch_calloc( sizeof(Modifications), 1 );
m->sml_op = LDAP_MOD_REPLACE;
+ m->sml_flags = 0;
m->sml_type = ad_pwdAccountLockedTime->ad_cname;
m->sml_desc = ad_pwdAccountLockedTime;
m->sml_values = ch_calloc( sizeof(struct berval), 2 );
- ber_str2bv( nowstr, 0, 1, &m->sml_values[0] );
+ m->sml_nvalues = ch_calloc( sizeof(struct berval), 2 );
+ ber_dupbv( &m->sml_values[0], ×tamp );
+ ber_dupbv( &m->sml_nvalues[0], ×tamp );
m->sml_next = mod;
mod = m;
}
@@ -807,6 +797,7 @@ ppolicy_bind_resp( Operation *op, SlapReply *rs )
if ( attr_find( e->e_attrs, ad_pwdFailureTime )) {
m = ch_calloc( sizeof(Modifications), 1 );
m->sml_op = LDAP_MOD_DELETE;
+ m->sml_flags = 0;
m->sml_type = ad_pwdFailureTime->ad_cname;
m->sml_desc = ad_pwdFailureTime;
m->sml_next = mod;
@@ -825,7 +816,8 @@ ppolicy_bind_resp( Operation *op, SlapReply *rs )
* that we are disallowed from doing anything
* other than change password.
*/
- pwcons[op->o_conn->c_conn_idx].restrict = 1;
+ ber_dupbv( &pwcons[op->o_conn->c_conn_idx].dn,
+ &op->o_conn->c_ndn );
ppb->pErr = PP_changeAfterReset;
@@ -849,16 +841,10 @@ ppolicy_bind_resp( Operation *op, SlapReply *rs )
* missing if the DIT was established via
* an import process.
*/
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, ERR,
- "ppolicy_bind: Entry %s does not have valid pwdChangedTime attribute - assuming password expired\n",
- e->e_name.bv_val, 0, 0);
-#else
Debug( LDAP_DEBUG_ANY,
"ppolicy_bind: Entry %s does not have valid pwdChangedTime attribute - assuming password expired\n",
e->e_name.bv_val, 0, 0);
-#endif
pwExpired = 1;
} else {
/*
@@ -874,24 +860,18 @@ grace:
if (!pwExpired) goto check_expiring_password;
if ((a = attr_find( e->e_attrs, ad_pwdGraceUseTime )) == NULL)
- ngut = ppb->pp.pwdGraceLoginLimit;
+ ngut = ppb->pp.pwdGraceAuthNLimit;
else {
for(ngut=0; a->a_nvals[ngut].bv_val; ngut++);
- ngut = ppb->pp.pwdGraceLoginLimit - ngut;
+ ngut = ppb->pp.pwdGraceAuthNLimit - ngut;
}
/*
* ngut is the number of remaining grace logins
*/
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, ERR,
- "ppolicy_bind: Entry %s has an expired password: %d grace logins\n",
- e->e_name.bv_val, ngut, 0);
-#else
Debug( LDAP_DEBUG_ANY,
"ppolicy_bind: Entry %s has an expired password: %d grace logins\n",
e->e_name.bv_val, ngut, 0);
-#endif
if (ngut < 1) {
ppb->pErr = PP_passwordExpired;
@@ -904,10 +884,13 @@ grace:
*/
m = ch_calloc( sizeof(Modifications), 1 );
m->sml_op = LDAP_MOD_ADD;
+ m->sml_flags = 0;
m->sml_type = ad_pwdGraceUseTime->ad_cname;
m->sml_desc = ad_pwdGraceUseTime;
m->sml_values = ch_calloc( sizeof(struct berval), 2 );
- ber_str2bv( nowstr, 0, 1, &m->sml_values[0] );
+ m->sml_nvalues = ch_calloc( sizeof(struct berval), 2 );
+ ber_dupbv( &m->sml_values[0], ×tamp );
+ ber_dupbv( &m->sml_nvalues[0], ×tamp );
m->sml_next = mod;
mod = m;
@@ -935,31 +918,14 @@ check_expiring_password:
*/
if (ppb->pp.pwdMaxAge - age < ppb->pp.pwdExpireWarning ) {
/*
- * Set the warning value, add expiration warned timestamp to the entry.
+ * Set the warning value.
*/
- if ((a = attr_find( e->e_attrs, ad_pwdExpirationWarned )) == NULL) {
- m = ch_calloc( sizeof(Modifications), 1 );
- m->sml_op = LDAP_MOD_ADD;
- m->sml_type = ad_pwdExpirationWarned->ad_cname;
- m->sml_desc = ad_pwdExpirationWarned;
- m->sml_values = ch_calloc( sizeof(struct berval), 2 );
- ber_str2bv( nowstr, 0, 1, &m->sml_values[0] );
- m->sml_next = mod;
- mod = m;
- }
-
warn = ppb->pp.pwdMaxAge - age; /* seconds left until expiry */
if (warn < 0) warn = 0; /* something weird here - why is pwExpired not set? */
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATIONS, DETAIL1,
- "ppolicy_bind: Setting warning for password expiry for %s = %d seconds\n",
- op->o_req_dn.bv_val, warn, 0 );
-#else
Debug( LDAP_DEBUG_ANY,
"ppolicy_bind: Setting warning for password expiry for %s = %d seconds\n",
op->o_req_dn.bv_val, warn, 0 );
-#endif
}
}
@@ -983,12 +949,17 @@ locked:
op2.o_ndn = op->o_bd->be_rootndn;
op2.o_bd->bd_info = (BackendInfo *)on->on_info;
rc = op->o_bd->be_modify( &op2, &r2 );
- slap_mods_free( mod );
+ slap_mods_free( mod, 1 );
}
if ( ppb->send_ctrl ) {
LDAPControl **ctrls = NULL;
+ pp_info *pi = on->on_bi.bi_private;
+ /* Do we really want to tell that the account is locked? */
+ if ( ppb->pErr == PP_accountLocked && !pi->use_lockout ) {
+ ppb->pErr = PP_noError;
+ }
ctrls = ch_calloc( sizeof( LDAPControl *) , 2 );
ctrls[0] = create_passcontrol( warn, ngut, ppb->pErr );
ctrls[1] = NULL;
@@ -1003,10 +974,16 @@ ppolicy_bind( Operation *op, SlapReply *rs )
{
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
+ /* Reset lockout status on all Bind requests */
+ if ( !BER_BVISEMPTY( &pwcons[op->o_conn->c_conn_idx].dn )) {
+ ch_free( pwcons[op->o_conn->c_conn_idx].dn.bv_val );
+ BER_BVZERO( &pwcons[op->o_conn->c_conn_idx].dn );
+ }
+
/* Root bypasses policy */
- if ( !be_isroot( op->o_bd, &op->o_req_ndn )) {
+ if ( !be_isroot_dn( op->o_bd, &op->o_req_ndn )) {
Entry *e;
- int i, rc;
+ int rc;
ppbind *ppb;
slap_callback *cb;
@@ -1031,11 +1008,8 @@ ppolicy_bind( Operation *op, SlapReply *rs )
op->o_callback->sc_next = cb;
/* Did we receive a password policy request control? */
- for ( i=0; op->o_ctrls && op->o_ctrls[i]; i++ ) {
- if ( !strcmp( op->o_ctrls[i]->ldctl_oid, LDAP_CONTROL_PASSWORDPOLICYREQUEST ) ) {
- ppb->send_ctrl = 1;
- break;
- }
+ if ( op->o_ctrlflag[ppolicy_cid] ) {
+ ppb->send_ctrl = 1;
}
op->o_bd->bd_info = (BackendInfo *)on;
@@ -1058,11 +1032,14 @@ ppolicy_bind( Operation *op, SlapReply *rs )
return SLAP_CB_CONTINUE;
}
-/* Reset the restrict flag for the next session on this connection */
+/* Reset the restricted info for the next session on this connection */
static int
-ppolicy_unbind( Operation *op, SlapReply *rs )
+ppolicy_connection_destroy( BackendDB *bd, Connection *conn )
{
- pwcons[op->o_conn->c_conn_idx].restrict = 0;
+ if ( !BER_BVISEMPTY( &pwcons[conn->c_conn_idx].dn )) {
+ ch_free( pwcons[conn->c_conn_idx].dn.bv_val );
+ BER_BVZERO( &pwcons[conn->c_conn_idx].dn );
+ }
return SLAP_CB_CONTINUE;
}
@@ -1073,25 +1050,27 @@ ppolicy_restrict(
SlapReply *rs )
{
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
- int i, send_ctrl = 0;
+ int send_ctrl = 0;
/* Did we receive a password policy request control? */
- for ( i=0; op->o_ctrls && op->o_ctrls[i]; i++ ) {
- if ( !strcmp( op->o_ctrls[i]->ldctl_oid,
- LDAP_CONTROL_PASSWORDPOLICYREQUEST ) ) {
- send_ctrl = 1;
- break;
- }
+ if ( op->o_ctrlflag[ppolicy_cid] ) {
+ send_ctrl = 1;
}
- if ( op->o_conn && pwcons[op->o_conn->c_conn_idx].restrict ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, ENTRY,
- "connection restricted to password changing only\n", 0, 0, 0 );
-#else
+ if ( op->o_conn && !BER_BVISEMPTY( &pwcons[op->o_conn->c_conn_idx].dn )) {
+ /* if the current authcDN doesn't match the one we recorded,
+ * then an intervening Bind has succeeded and the restriction
+ * no longer applies. (ITS#4516)
+ */
+ if ( !dn_match( &op->o_conn->c_ndn,
+ &pwcons[op->o_conn->c_conn_idx].dn )) {
+ ch_free( pwcons[op->o_conn->c_conn_idx].dn.bv_val );
+ BER_BVZERO( &pwcons[op->o_conn->c_conn_idx].dn );
+ return SLAP_CB_CONTINUE;
+ }
+
Debug( LDAP_DEBUG_TRACE,
"connection restricted to password changing only\n", 0, 0, 0);
-#endif
if ( send_ctrl ) {
LDAPControl **ctrls = NULL;
@@ -1101,7 +1080,7 @@ ppolicy_restrict(
rs->sr_ctrls = ctrls;
}
op->o_bd->bd_info = (BackendInfo *)on->on_info;
- send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
+ send_ldap_error( op, rs, LDAP_INSUFFICIENT_ACCESS,
"Operations are restricted to bind/unbind/abandon/StartTLS/modify password" );
return rs->sr_err;
}
@@ -1115,35 +1094,38 @@ ppolicy_add(
SlapReply *rs )
{
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
+ pp_info *pi = on->on_bi.bi_private;
PassPolicy pp;
- int pw;
Attribute *pa;
+ const char *txt;
if ( ppolicy_restrict( op, rs ) != SLAP_CB_CONTINUE )
return rs->sr_err;
+ /* If this is a replica, assume the master checked everything */
+ if ( be_shadow_update( op ))
+ return SLAP_CB_CONTINUE;
+
/* Check for password in entry */
- if ((pa = attr_find( op->oq_add.rs_e->e_attrs, slap_schema.si_ad_userPassword ))) {
+ if ((pa = attr_find( op->oq_add.rs_e->e_attrs,
+ slap_schema.si_ad_userPassword )))
+ {
/*
* new entry contains a password - if we're not the root user
* then we need to check that the password fits in with the
* security policy for the new entry.
*/
- ppolicy_get( op, op->oq_add.rs_e, &pp );
- if (pp.pwdCheckQuality > 0 && !be_isroot( op->o_bd, &op->o_ndn )) {
+ ppolicy_get( op, op->ora_e, &pp );
+ if (pp.pwdCheckQuality > 0 && !be_isroot( op )) {
struct berval *bv = &(pa->a_vals[0]);
- int rc, i, send_ctrl = 0;
+ int rc, send_ctrl = 0;
LDAPPasswordPolicyError pErr = PP_noError;
/* Did we receive a password policy request control? */
- for ( i=0; op->o_ctrls && op->o_ctrls[i]; i++ ) {
- if ( !strcmp( op->o_ctrls[i]->ldctl_oid,
- LDAP_CONTROL_PASSWORDPOLICYREQUEST ) ) {
- send_ctrl = 1;
- break;
- }
+ if ( op->o_ctrlflag[ppolicy_cid] ) {
+ send_ctrl = 1;
}
- rc = check_password_quality( bv, &pp, &pErr );
+ rc = check_password_quality( bv, &pp, &pErr, op->ora_e );
if (rc != LDAP_SUCCESS) {
op->o_bd->bd_info = (BackendInfo *)on->on_info;
if ( send_ctrl ) {
@@ -1158,41 +1140,84 @@ ppolicy_add(
return rs->sr_err;
}
}
+ /*
+ * A controversial bit. We hash cleartext
+ * passwords provided via add and modify operations
+ * You're not really supposed to do this, since
+ * the X.500 model says "store attributes" as they
+ * get provided. By default, this is what we do
+ *
+ * But if the hash_passwords flag is set, we hash
+ * any cleartext password attribute values via the
+ * default password hashing scheme.
+ */
+ if ((pi->hash_passwords) &&
+ (password_scheme( &(pa->a_vals[0]), NULL ) != LDAP_SUCCESS)) {
+ struct berval hpw;
+
+ slap_passwd_hash( &(pa->a_vals[0]), &hpw, &txt );
+ if (hpw.bv_val == NULL) {
+ /*
+ * hashing didn't work. Emit an error.
+ */
+ rs->sr_err = LDAP_OTHER;
+ rs->sr_text = txt;
+ send_ldap_error( op, rs, LDAP_OTHER, "Password hashing failed" );
+ return rs->sr_err;
+ }
+
+ memset( pa->a_vals[0].bv_val, 0, pa->a_vals[0].bv_len);
+ ber_memfree( pa->a_vals[0].bv_val );
+ pa->a_vals[0].bv_val = hpw.bv_val;
+ pa->a_vals[0].bv_len = hpw.bv_len;
+ }
+
/* If password aging is in effect, set the pwdChangedTime */
if ( pp.pwdMaxAge || pp.pwdMinAge ) {
struct berval timestamp;
char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
- struct tm *ltm;
time_t now = slap_get_time();
- ldap_pvt_thread_mutex_lock( &gmtime_mutex );
- ltm = gmtime( &now );
- lutil_gentime( timebuf, sizeof(timebuf), ltm );
- ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
-
timestamp.bv_val = timebuf;
- timestamp.bv_len = strlen(timebuf);
+ timestamp.bv_len = sizeof(timebuf);
+ slap_timestamp( &now, ×tamp );
- attr_merge_one( op->ora_e, ad_pwdChangedTime, ×tamp, NULL );
+ attr_merge_one( op->ora_e, ad_pwdChangedTime, ×tamp, ×tamp );
}
}
return SLAP_CB_CONTINUE;
}
+static int
+ppolicy_mod_cb( Operation *op, SlapReply *rs )
+{
+ slap_callback *sc = op->o_callback;
+ op->o_callback = sc->sc_next;
+ if ( rs->sr_err == LDAP_SUCCESS ) {
+ ch_free( pwcons[op->o_conn->c_conn_idx].dn.bv_val );
+ BER_BVZERO( &pwcons[op->o_conn->c_conn_idx].dn );
+ }
+ op->o_tmpfree( sc, op->o_tmpmemctx );
+ return SLAP_CB_CONTINUE;
+}
+
static int
ppolicy_modify( Operation *op, SlapReply *rs )
{
- slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
- int i, rc, mod_pw_only, pwmod, pwmop, deladd, hsize = 0;
+ slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
+ pp_info *pi = on->on_bi.bi_private;
+ int i, rc, mod_pw_only, pwmod, pwmop = -1, deladd,
+ hsize = 0;
PassPolicy pp;
- Modifications *mods = NULL, *modtail, *ml, *delmod, *addmod;
- Attribute *pa, *ha, *ra, at;
- int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
+ Modifications *mods = NULL, *modtail = NULL,
+ *ml, *delmod, *addmod;
+ Attribute *pa, *ha, at;
const char *txt;
pw_hist *tl = NULL, *p;
- int zapReset, send_ctrl = 0;
+ int zapReset, send_ctrl = 0;
Entry *e;
- struct berval newpw = { 0, NULL }, oldpw = { 0, NULL }, *bv, cr[2];
+ struct berval newpw = BER_BVNULL, oldpw = BER_BVNULL,
+ *bv, cr[2];
LDAPPasswordPolicyError pErr = PP_noError;
op->o_bd->bd_info = (BackendInfo *)on->on_info;
@@ -1201,13 +1226,101 @@ ppolicy_modify( Operation *op, SlapReply *rs )
if ( rc != LDAP_SUCCESS ) return SLAP_CB_CONTINUE;
- /* Did we receive a password policy request control? */
- for ( i=0; op->o_ctrls && op->o_ctrls[i]; i++ ) {
- if ( !strcmp( op->o_ctrls[i]->ldctl_oid,
- LDAP_CONTROL_PASSWORDPOLICYREQUEST ) ) {
- send_ctrl = 1;
- break;
+ /* If this is a replica, we may need to tweak some of the
+ * master's modifications. Otherwise, just pass it through.
+ */
+ if ( be_shadow_update( op )) {
+ Modifications **prev;
+ int got_del_grace = 0, got_del_lock = 0, got_pw = 0, got_del_fail = 0;
+ Attribute *a_grace, *a_lock, *a_fail;
+
+ a_grace = attr_find( e->e_attrs, ad_pwdGraceUseTime );
+ a_lock = attr_find( e->e_attrs, ad_pwdAccountLockedTime );
+ a_fail = attr_find( e->e_attrs, ad_pwdFailureTime );
+
+ for( prev = &op->oq_modify.rs_modlist, ml = *prev; ml; ml = *prev ) {
+
+ if ( ml->sml_desc == slap_schema.si_ad_userPassword )
+ got_pw = 1;
+
+ /* If we're deleting an attr that didn't exist,
+ * drop this delete op
+ */
+ if ( ml->sml_op == LDAP_MOD_DELETE ) {
+ int drop = 0;
+
+ if ( ml->sml_desc == ad_pwdGraceUseTime ) {
+ got_del_grace = 1;
+ if ( !a_grace )
+ drop = 1;
+ } else
+ if ( ml->sml_desc == ad_pwdAccountLockedTime ) {
+ got_del_lock = 1;
+ if ( !a_lock )
+ drop = 1;
+ } else
+ if ( ml->sml_desc == ad_pwdFailureTime ) {
+ got_del_fail = 1;
+ if ( !a_fail )
+ drop = 1;
+ }
+ if ( drop ) {
+ *prev = ml->sml_next;
+ ml->sml_next = NULL;
+ slap_mods_free( ml, 1 );
+ continue;
+ }
+ }
+ prev = &ml->sml_next;
}
+
+ /* If we're resetting the password, make sure grace, accountlock,
+ * and failure also get removed.
+ */
+ if ( got_pw ) {
+ if ( a_grace && !got_del_grace ) {
+ ml = (Modifications *) ch_malloc( sizeof( Modifications ) );
+ ml->sml_op = LDAP_MOD_DELETE;
+ ml->sml_flags = SLAP_MOD_INTERNAL;
+ ml->sml_type.bv_val = NULL;
+ ml->sml_desc = ad_pwdGraceUseTime;
+ ml->sml_values = NULL;
+ ml->sml_nvalues = NULL;
+ ml->sml_next = NULL;
+ *prev = ml;
+ prev = &ml->sml_next;
+ }
+ if ( a_lock && !got_del_lock ) {
+ ml = (Modifications *) ch_malloc( sizeof( Modifications ) );
+ ml->sml_op = LDAP_MOD_DELETE;
+ ml->sml_flags = SLAP_MOD_INTERNAL;
+ ml->sml_type.bv_val = NULL;
+ ml->sml_desc = ad_pwdAccountLockedTime;
+ ml->sml_values = NULL;
+ ml->sml_nvalues = NULL;
+ ml->sml_next = NULL;
+ *prev = ml;
+ }
+ if ( a_fail && !got_del_fail ) {
+ ml = (Modifications *) ch_malloc( sizeof( Modifications ) );
+ ml->sml_op = LDAP_MOD_DELETE;
+ ml->sml_flags = SLAP_MOD_INTERNAL;
+ ml->sml_type.bv_val = NULL;
+ ml->sml_desc = ad_pwdFailureTime;
+ ml->sml_values = NULL;
+ ml->sml_nvalues = NULL;
+ ml->sml_next = NULL;
+ *prev = ml;
+ }
+ }
+ op->o_bd->bd_info = (BackendInfo *)on->on_info;
+ be_entry_release_r( op, e );
+ return SLAP_CB_CONTINUE;
+ }
+
+ /* Did we receive a password policy request control? */
+ if ( op->o_ctrlflag[ppolicy_cid] ) {
+ send_ctrl = 1;
}
/* See if this is a pwdModify exop. If so, we can
@@ -1229,12 +1342,13 @@ ppolicy_modify( Operation *op, SlapReply *rs )
ppolicy_get( op, e, &pp );
- for(ml = op->oq_modify.rs_modlist,
+ for ( ml = op->oq_modify.rs_modlist,
pwmod = 0, mod_pw_only = 1,
deladd = 0, delmod = NULL,
addmod = NULL,
zapReset = 1;
- ml != NULL; modtail = ml, ml = ml->sml_next ) {
+ ml != NULL; modtail = ml, ml = ml->sml_next )
+ {
if ( ml->sml_desc == pp.ad ) {
pwmod = 1;
pwmop = ml->sml_op;
@@ -1273,18 +1387,19 @@ ppolicy_modify( Operation *op, SlapReply *rs )
}
}
- if (pwcons[op->o_conn->c_conn_idx].restrict && !mod_pw_only) {
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, ENTRY,
- "connection restricted to password changing only\n", 0, 0, 0 );
-#else
- Debug( LDAP_DEBUG_TRACE,
- "connection restricted to password changing only\n", 0, 0, 0 );
-#endif
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
- rs->sr_text = "Operations are restricted to bind/unbind/abandon/StartTLS/modify password";
- pErr = PP_changeAfterReset;
- goto return_results;
+ if (!BER_BVISEMPTY( &pwcons[op->o_conn->c_conn_idx].dn ) && !mod_pw_only ) {
+ if ( dn_match( &op->o_conn->c_ndn,
+ &pwcons[op->o_conn->c_conn_idx].dn )) {
+ Debug( LDAP_DEBUG_TRACE,
+ "connection restricted to password changing only\n", 0, 0, 0 );
+ rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+ rs->sr_text = "Operations are restricted to bind/unbind/abandon/StartTLS/modify password";
+ pErr = PP_changeAfterReset;
+ goto return_results;
+ } else {
+ ch_free( pwcons[op->o_conn->c_conn_idx].dn.bv_val );
+ BER_BVZERO( &pwcons[op->o_conn->c_conn_idx].dn );
+ }
}
/*
@@ -1304,13 +1419,8 @@ ppolicy_modify( Operation *op, SlapReply *rs )
if (!addmod) {
rs->sr_err = LDAP_OTHER;
rs->sr_text = "Internal Error";
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, ENTRY,
- "cannot locate modification supplying new password\n", 0, 0, 0 );
-#else
Debug( LDAP_DEBUG_TRACE,
"cannot locate modification supplying new password\n", 0, 0, 0 );
-#endif
goto return_results;
}
@@ -1319,10 +1429,9 @@ ppolicy_modify( Operation *op, SlapReply *rs )
* We need this, even if the user is root, in order to maintain
* the pwdHistory operational attributes properly.
*/
- if (ha = attr_find( e->e_attrs, ad_pwdHistory )) {
+ if (pp.pwdInHistory > 0 && (ha = attr_find( e->e_attrs, ad_pwdHistory ))) {
struct berval oldpw;
time_t oldtime;
- char *oid;
for(i=0; ha->a_nvals[i].bv_val; i++) {
rc = parse_pwdhistory( &(ha->a_nvals[i]), NULL,
@@ -1337,10 +1446,10 @@ ppolicy_modify( Operation *op, SlapReply *rs )
oldpw.bv_len = 0;
}
}
+ for(p=tl; p; p=p->next, hsize++); /* count history size */
}
- for(p=tl, hsize=0; p; p=p->next, hsize++); /* count history size */
- if (be_isroot( op->o_bd, &op->o_ndn)) goto do_modify;
+ if (be_isroot( op )) goto do_modify;
/* This is a pwdModify exop that provided the old pw.
* We need to create a Delete mod for this old pw and
@@ -1349,6 +1458,7 @@ ppolicy_modify( Operation *op, SlapReply *rs )
if (pp.pwdSafeModify && oldpw.bv_val ) {
ml = (Modifications *) ch_malloc( sizeof( Modifications ) );
ml->sml_op = LDAP_MOD_DELETE;
+ ml->sml_flags = SLAP_MOD_INTERNAL;
ml->sml_desc = pp.ad;
ml->sml_type = pp.ad->ad_cname;
ml->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
@@ -1363,23 +1473,17 @@ ppolicy_modify( Operation *op, SlapReply *rs )
}
if (pp.pwdSafeModify && deladd != 2) {
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, ENTRY,
- "change password must use DELETE followed by ADD/REPLACE\n",
- 0, 0, 0 );
-#else
Debug( LDAP_DEBUG_TRACE,
"change password must use DELETE followed by ADD/REPLACE\n",
0, 0, 0 );
-#endif
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+ rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
rs->sr_text = "Must supply old password to be changed as well as new one";
pErr = PP_mustSupplyOldPassword;
goto return_results;
}
if (!pp.pwdAllowUserChange) {
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+ rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
rs->sr_text = "User alteration of password is not allowed";
pErr = PP_passwordModNotAllowed;
goto return_results;
@@ -1394,29 +1498,26 @@ ppolicy_modify( Operation *op, SlapReply *rs )
now = slap_get_time();
age = (int)(now - pwtime);
if ((pwtime != (time_t)-1) && (age < pp.pwdMinAge)) {
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+ rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
rs->sr_text = "Password is too young to change";
pErr = PP_passwordTooYoung;
goto return_results;
}
}
- if (delmod && (pa = attr_find( e->e_attrs, pp.ad )) != NULL) {
+ /* pa is used in password history check below, be sure it's set */
+ if ((pa = attr_find( e->e_attrs, pp.ad )) != NULL && delmod) {
/*
* we have a password to check
*/
const char *txt;
bv = oldpw.bv_val ? &oldpw : delmod->sml_values;
- rc = slap_passwd_check( op->o_conn, pa, bv, &txt );
+ /* FIXME: no access checking? */
+ rc = slap_passwd_check( op, NULL, pa, bv, &txt );
if (rc != LDAP_SUCCESS) {
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, ENTRY,
- "old password check failed: %s\n", txt, 0, 0 );
-#else
Debug( LDAP_DEBUG_TRACE,
"old password check failed: %s\n", txt, 0, 0 );
-#endif
rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
rs->sr_text = "Must supply correct old password to change to new one";
@@ -1445,7 +1546,7 @@ ppolicy_modify( Operation *op, SlapReply *rs )
bv = newpw.bv_val ? &newpw : addmod->sml_values;
if (pp.pwdCheckQuality > 0) {
- rc = check_password_quality( bv, &pp, &pErr );
+ rc = check_password_quality( bv, &pp, &pErr, e );
if (rc != LDAP_SUCCESS) {
rs->sr_err = rc;
rs->sr_text = "Password fails quality checking policy";
@@ -1453,75 +1554,93 @@ ppolicy_modify( Operation *op, SlapReply *rs )
}
}
- /*
- * Last check - the password history.
- */
- if (slap_passwd_check( op->o_conn, pa, bv, &txt ) == LDAP_SUCCESS) {
+ if (pa) {
/*
- * This is bad - it means that the user is attempting
- * to set the password to the same as the old one.
+ * Last check - the password history.
*/
- rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
- rs->sr_text = "Password is not being changed from existing value";
- pErr = PP_passwordInHistory;
- goto return_results;
- }
-
- if (pp.pwdInHistory < 1) goto do_modify;
-
- /*
- * Iterate through the password history, and fail on any
- * password matches.
- */
- at = *pa;
- at.a_vals = cr;
- cr[1].bv_val = NULL;
- for(p=tl; p; p=p->next) {
- cr[0] = p->pw;
- rc = slap_passwd_check( op->o_conn, &at, bv, &txt );
-
- if (rc != LDAP_SUCCESS) continue;
-
- rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
- rs->sr_text = "Password is in history of old passwords";
- pErr = PP_passwordInHistory;
- goto return_results;
+ /* FIXME: no access checking? */
+ if (slap_passwd_check( op, NULL, pa, bv, &txt ) == LDAP_SUCCESS) {
+ /*
+ * This is bad - it means that the user is attempting
+ * to set the password to the same as the old one.
+ */
+ rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
+ rs->sr_text = "Password is not being changed from existing value";
+ pErr = PP_passwordInHistory;
+ goto return_results;
+ }
+
+ if (pp.pwdInHistory < 1) goto do_modify;
+
+ /*
+ * Iterate through the password history, and fail on any
+ * password matches.
+ */
+ at = *pa;
+ at.a_vals = cr;
+ cr[1].bv_val = NULL;
+ for(p=tl; p; p=p->next) {
+ cr[0] = p->pw;
+ /* FIXME: no access checking? */
+ rc = slap_passwd_check( op, NULL, &at, bv, &txt );
+
+ if (rc != LDAP_SUCCESS) continue;
+
+ rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
+ rs->sr_text = "Password is in history of old passwords";
+ pErr = PP_passwordInHistory;
+ goto return_results;
+ }
}
do_modify:
- if ((pwmod) && (!repl_user)) {
+ if (pwmod) {
struct berval timestamp;
char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
- struct tm *ltm;
time_t now = slap_get_time();
- Attribute *ga;
-
+
+ /* If the conn is restricted, set a callback to clear it
+ * if the pwmod succeeds
+ */
+ if (!BER_BVISEMPTY( &pwcons[op->o_conn->c_conn_idx].dn )) {
+ slap_callback *sc = op->o_tmpcalloc( 1, sizeof( slap_callback ),
+ op->o_tmpmemctx );
+ sc->sc_next = op->o_callback;
+ /* Must use sc_response to insure we reset on success, before
+ * the client sees the response. Must use sc_cleanup to insure
+ * that it gets cleaned up if sc_response is not called.
+ */
+ sc->sc_response = ppolicy_mod_cb;
+ sc->sc_cleanup = ppolicy_mod_cb;
+ op->o_callback = sc;
+ }
+
/*
* keep the necessary pwd.. operational attributes
* up to date.
*/
- ldap_pvt_thread_mutex_lock( &gmtime_mutex );
- ltm = gmtime( &now );
- lutil_gentime( timebuf, sizeof(timebuf), ltm );
- ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
-
timestamp.bv_val = timebuf;
- timestamp.bv_len = strlen(timebuf);
+ timestamp.bv_len = sizeof(timebuf);
+ slap_timestamp( &now, ×tamp );
+
mods = (Modifications *) ch_malloc( sizeof( Modifications ) );
mods->sml_type.bv_val = NULL;
mods->sml_desc = ad_pwdChangedTime;
if (pwmop != LDAP_MOD_DELETE) {
mods->sml_op = LDAP_MOD_REPLACE;
mods->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
+ mods->sml_nvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mods->sml_values[0], ×tamp );
+ ber_dupbv( &mods->sml_nvalues[0], ×tamp );
mods->sml_values[1].bv_len = 0;
mods->sml_values[1].bv_val = NULL;
- assert( mods->sml_values[0].bv_val );
+ assert( mods->sml_values[0].bv_val != NULL );
} else {
mods->sml_op = LDAP_MOD_DELETE;
mods->sml_values = NULL;
}
+ mods->sml_flags = SLAP_MOD_INTERNAL;
mods->sml_nvalues = NULL;
mods->sml_next = NULL;
modtail->sml_next = mods;
@@ -1530,6 +1649,7 @@ do_modify:
if (attr_find(e->e_attrs, ad_pwdGraceUseTime )) {
mods = (Modifications *) ch_malloc( sizeof( Modifications ) );
mods->sml_op = LDAP_MOD_DELETE;
+ mods->sml_flags = SLAP_MOD_INTERNAL;
mods->sml_type.bv_val = NULL;
mods->sml_desc = ad_pwdGraceUseTime;
mods->sml_values = NULL;
@@ -1539,11 +1659,12 @@ do_modify:
modtail = mods;
}
- if (attr_find(e->e_attrs, ad_pwdExpirationWarned )) {
+ if (attr_find(e->e_attrs, ad_pwdAccountLockedTime )) {
mods = (Modifications *) ch_malloc( sizeof( Modifications ) );
mods->sml_op = LDAP_MOD_DELETE;
+ mods->sml_flags = SLAP_MOD_INTERNAL;
mods->sml_type.bv_val = NULL;
- mods->sml_desc = ad_pwdExpirationWarned;
+ mods->sml_desc = ad_pwdAccountLockedTime;
mods->sml_values = NULL;
mods->sml_nvalues = NULL;
mods->sml_next = NULL;
@@ -1551,12 +1672,12 @@ do_modify:
modtail = mods;
}
- /* Delete the pwdReset attribute, since it's being reset */
- if ((zapReset) && (attr_find(e->e_attrs, ad_pwdReset ))) {
+ if (attr_find(e->e_attrs, ad_pwdFailureTime )) {
mods = (Modifications *) ch_malloc( sizeof( Modifications ) );
mods->sml_op = LDAP_MOD_DELETE;
+ mods->sml_flags = SLAP_MOD_INTERNAL;
mods->sml_type.bv_val = NULL;
- mods->sml_desc = ad_pwdReset;
+ mods->sml_desc = ad_pwdFailureTime;
mods->sml_values = NULL;
mods->sml_nvalues = NULL;
mods->sml_next = NULL;
@@ -1564,75 +1685,88 @@ do_modify:
modtail = mods;
}
- if (hsize >= pp.pwdInHistory) {
- /*
- * We use the >= operator, since we are going to add a
- * the existing password attribute value into the
- * history - thus the cardinality of history values is
- * about to rise by one.
- *
- * If this would push it over the limit of history
- * values (remembering - the password policy could have
- * changed since the password was last altered), we must
- * delete at least 1 value from the pwdHistory list.
- *
- * In fact, we delete '(#pwdHistory attrs - max pwd
- * history length) + 1' values, starting with the oldest.
- * This is easily evaluated, since the linked list is
- * created in ascending time order.
- */
+ /* Delete the pwdReset attribute, since it's being reset */
+ if ((zapReset) && (attr_find(e->e_attrs, ad_pwdReset ))) {
mods = (Modifications *) ch_malloc( sizeof( Modifications ) );
mods->sml_op = LDAP_MOD_DELETE;
+ mods->sml_flags = SLAP_MOD_INTERNAL;
mods->sml_type.bv_val = NULL;
- mods->sml_desc = ad_pwdHistory;
+ mods->sml_desc = ad_pwdReset;
+ mods->sml_values = NULL;
mods->sml_nvalues = NULL;
- mods->sml_values = ch_calloc( sizeof( struct berval ),
- hsize - pp.pwdInHistory + 2 );
- mods->sml_values[ hsize - pp.pwdInHistory + 1 ].bv_val = NULL;
- mods->sml_values[ hsize - pp.pwdInHistory + 1 ].bv_len = 0;
- for(i=0,p=tl; i < (hsize - pp.pwdInHistory + 1); i++, p=p->next) {
- mods->sml_values[i].bv_val = NULL;
- mods->sml_values[i].bv_len = 0;
- ber_dupbv( &(mods->sml_values[i]), &p->bv );
- }
mods->sml_next = NULL;
modtail->sml_next = mods;
modtail = mods;
}
- free_pwd_history_list( &tl );
- /*
- * Now add the existing password into the history list.
- * This will be executed even if the operation is to delete
- * the password entirely.
- *
- * This isn't in the spec explicitly, but it seems to make
- * sense that the password history list is the list of all
- * previous passwords - even if they were deleted. Thus, if
- * someone tries to add a historical password at some future
- * point, it will fail.
- */
- if ((pa = attr_find( e->e_attrs, pp.ad )) != NULL) {
- mods = (Modifications *) ch_malloc( sizeof( Modifications ) );
- mods->sml_op = LDAP_MOD_ADD;
- mods->sml_type.bv_val = NULL;
- mods->sml_desc = ad_pwdHistory;
- mods->sml_nvalues = NULL;
- mods->sml_values = ch_calloc( sizeof( struct berval ), 2 );
- mods->sml_values[ 1 ].bv_val = NULL;
- mods->sml_values[ 1 ].bv_len = 0;
- make_pwd_history_value( timebuf, &mods->sml_values[0], pa );
- mods->sml_next = NULL;
- modtail->sml_next = mods;
- modtail = mods;
- } else {
-#ifdef NEW_LOGGING
- LDAP_LOG ( OPERATION, ERR,
- "ppolicy_modify: password attr lookup failed\n", 0, 0, 0 );
-#else
- Debug( LDAP_DEBUG_TRACE,
- "ppolicy_modify: password attr lookup failed\n", 0, 0, 0 );
-#endif
+ if (pp.pwdInHistory > 0) {
+ if (hsize >= pp.pwdInHistory) {
+ /*
+ * We use the >= operator, since we are going to add
+ * the existing password attribute value into the
+ * history - thus the cardinality of history values is
+ * about to rise by one.
+ *
+ * If this would push it over the limit of history
+ * values (remembering - the password policy could have
+ * changed since the password was last altered), we must
+ * delete at least 1 value from the pwdHistory list.
+ *
+ * In fact, we delete '(#pwdHistory attrs - max pwd
+ * history length) + 1' values, starting with the oldest.
+ * This is easily evaluated, since the linked list is
+ * created in ascending time order.
+ */
+ mods = (Modifications *) ch_malloc( sizeof( Modifications ) );
+ mods->sml_op = LDAP_MOD_DELETE;
+ mods->sml_flags = SLAP_MOD_INTERNAL;
+ mods->sml_type.bv_val = NULL;
+ mods->sml_desc = ad_pwdHistory;
+ mods->sml_nvalues = NULL;
+ mods->sml_values = ch_calloc( sizeof( struct berval ),
+ hsize - pp.pwdInHistory + 2 );
+ mods->sml_values[ hsize - pp.pwdInHistory + 1 ].bv_val = NULL;
+ mods->sml_values[ hsize - pp.pwdInHistory + 1 ].bv_len = 0;
+ for(i=0,p=tl; i < (hsize - pp.pwdInHistory + 1); i++, p=p->next) {
+ mods->sml_values[i].bv_val = NULL;
+ mods->sml_values[i].bv_len = 0;
+ ber_dupbv( &(mods->sml_values[i]), &p->bv );
+ }
+ mods->sml_next = NULL;
+ modtail->sml_next = mods;
+ modtail = mods;
+ }
+ free_pwd_history_list( &tl );
+
+ /*
+ * Now add the existing password into the history list.
+ * This will be executed even if the operation is to delete
+ * the password entirely.
+ *
+ * This isn't in the spec explicitly, but it seems to make
+ * sense that the password history list is the list of all
+ * previous passwords - even if they were deleted. Thus, if
+ * someone tries to add a historical password at some future
+ * point, it will fail.
+ */
+ if ((pa = attr_find( e->e_attrs, pp.ad )) != NULL) {
+ mods = (Modifications *) ch_malloc( sizeof( Modifications ) );
+ mods->sml_op = LDAP_MOD_ADD;
+ mods->sml_flags = SLAP_MOD_INTERNAL;
+ mods->sml_type.bv_val = NULL;
+ mods->sml_desc = ad_pwdHistory;
+ mods->sml_nvalues = NULL;
+ mods->sml_values = ch_calloc( sizeof( struct berval ), 2 );
+ mods->sml_values[ 1 ].bv_val = NULL;
+ mods->sml_values[ 1 ].bv_len = 0;
+ make_pwd_history_value( timebuf, &mods->sml_values[0], pa );
+ mods->sml_next = NULL;
+ modtail->sml_next = mods;
+ modtail = mods;
+ } else {
+ Debug( LDAP_DEBUG_TRACE,
+ "ppolicy_modify: password attr lookup failed\n", 0, 0, 0 );
+ }
}
/*
@@ -1652,7 +1786,7 @@ do_modify:
* leave it alone.
*/
- if ((addmod) && !newpw.bv_val &&
+ if ((pi->hash_passwords) && (addmod) && !newpw.bv_val &&
(password_scheme( &(addmod->sml_values[0]), NULL ) != LDAP_SUCCESS)) {
struct berval hpw, bv;
@@ -1704,14 +1838,51 @@ ppolicy_parseCtrl(
rs->sr_text = "passwordPolicyRequest control value not empty";
return LDAP_PROTOCOL_ERROR;
}
- if ( ctrl->ldctl_iscritical ) {
- rs->sr_text = "passwordPolicyRequest control invalid criticality";
- return LDAP_PROTOCOL_ERROR;
- }
+ op->o_ctrlflag[ppolicy_cid] = ctrl->ldctl_iscritical
+ ? SLAP_CONTROL_CRITICAL
+ : SLAP_CONTROL_NONCRITICAL;
return LDAP_SUCCESS;
}
+static int
+attrPretty(
+ Syntax *syntax,
+ struct berval *val,
+ struct berval *out,
+ void *ctx )
+{
+ AttributeDescription *ad = NULL;
+ const char *err;
+ int code;
+
+ code = slap_bv2ad( val, &ad, &err );
+ if ( !code ) {
+ ber_dupbv_x( out, &ad->ad_type->sat_cname, ctx );
+ }
+ return code;
+}
+
+static int
+attrNormalize(
+ slap_mask_t use,
+ Syntax *syntax,
+ MatchingRule *mr,
+ struct berval *val,
+ struct berval *out,
+ void *ctx )
+{
+ AttributeDescription *ad = NULL;
+ const char *err;
+ int code;
+
+ code = slap_bv2ad( val, &ad, &err );
+ if ( !code ) {
+ ber_str2bv_x( ad->ad_type->sat_oid, 0, 1, out, ctx );
+ }
+ return code;
+}
+
static int
ppolicy_db_init(
BackendDB *be
@@ -1719,6 +1890,34 @@ ppolicy_db_init(
{
slap_overinst *on = (slap_overinst *) be->bd_info;
+ /* Has User Schema been initialized yet? */
+ if ( !pwd_UsSchema[0].ad[0] ) {
+ const char *err;
+ int i, code;
+
+ for (i=0; pwd_UsSchema[i].def; i++) {
+ code = slap_str2ad( pwd_UsSchema[i].def, pwd_UsSchema[i].ad, &err );
+ if ( code ) {
+ fprintf( stderr, "User Schema Load failed %d: %s\n", code, err );
+ return code;
+ }
+ }
+ {
+ Syntax *syn;
+ MatchingRule *mr;
+
+ syn = ch_malloc( sizeof( Syntax ));
+ *syn = *ad_pwdAttribute->ad_type->sat_syntax;
+ syn->ssyn_pretty = attrPretty;
+ ad_pwdAttribute->ad_type->sat_syntax = syn;
+
+ mr = ch_malloc( sizeof( MatchingRule ));
+ *mr = *ad_pwdAttribute->ad_type->sat_equality;
+ mr->smr_normalize = attrNormalize;
+ ad_pwdAttribute->ad_type->sat_equality = mr;
+ }
+ }
+
on->on_bi.bi_private = ch_calloc( sizeof(pp_info), 1 );
if ( dtblsize && !pwcons )
@@ -1727,6 +1926,14 @@ ppolicy_db_init(
return 0;
}
+static int
+ppolicy_db_open(
+ BackendDB *be
+)
+{
+ return overlay_register_control( be, LDAP_CONTROL_PASSWORDPOLICYREQUEST );
+}
+
static int
ppolicy_close(
BackendDB *be
@@ -1769,6 +1976,23 @@ ppolicy_config(
return 1;
}
return 0;
+
+ } else if ( strcasecmp( argv[0], "ppolicy_use_lockout" ) == 0 ) {
+ if ( argc != 1 ) {
+ fprintf( stderr, "%s: line %d: ppolicy_use_lockout "
+ "takes no arguments\n", fname, lineno );
+ return ( 1 );
+ }
+ pi->use_lockout = 1;
+ return 0;
+ } else if ( strcasecmp( argv[0], "ppolicy_hash_cleartext" ) == 0 ) {
+ if ( argc != 1 ) {
+ fprintf( stderr, "%s: line %d: ppolicy_hash_cleartext "
+ "takes no arguments\n", fname, lineno );
+ return ( 1 );
+ }
+ pi->hash_passwords = 1;
+ return 0;
}
return SLAP_CONF_UNKNOWN;
}
@@ -1780,12 +2004,11 @@ static char *extops[] = {
static slap_overinst ppolicy;
-int ppolicy_init()
+int ppolicy_initialize()
{
LDAPAttributeType *at;
- int code;
const char *err;
- int i;
+ int i, code;
for (i=0; pwd_OpSchema[i].def; i++) {
at = ldap_str2attributetype( pwd_OpSchema[i].def, &code, &err,
@@ -1795,7 +2018,7 @@ int ppolicy_init()
ldap_scherr2str(code), err );
return code;
}
- code = at_add( at, &err );
+ code = at_add( at, 0, NULL, &err );
if ( !code ) {
slap_str2ad( at->at_names[0], pwd_OpSchema[i].ad, &err );
}
@@ -1805,62 +2028,43 @@ int ppolicy_init()
scherr2str(code), err );
return code;
}
- }
-
- for (i=0; pwd_UsSchema[i].def; i++) {
- code = slap_str2ad( pwd_UsSchema[i].def, pwd_UsSchema[i].ad, &err );
- if ( code ) {
- fprintf( stderr, "User Schema Load failed %d: %s\n", code, err );
- return code;
+ /* Allow Manager to set these as needed */
+ if ( is_at_no_user_mod( (*pwd_OpSchema[i].ad)->ad_type )) {
+ (*pwd_OpSchema[i].ad)->ad_type->sat_flags |=
+ SLAP_AT_MANAGEABLE;
}
}
code = register_supported_control( LDAP_CONTROL_PASSWORDPOLICYREQUEST,
- SLAP_CTRL_ADD|SLAP_CTRL_BIND|SLAP_CTRL_MODIFY, extops,
- ppolicy_parseCtrl );
+ SLAP_CTRL_ADD|SLAP_CTRL_BIND|SLAP_CTRL_MODIFY|SLAP_CTRL_HIDE, extops,
+ ppolicy_parseCtrl, &ppolicy_cid );
if ( code != LDAP_SUCCESS ) {
fprintf( stderr, "Failed to register control %d\n", code );
return code;
}
- /* Find out our offset from GMT since mktime() always assumes
- * its input is local time
- */
- {
- time_t gmt, lcl, now = slap_get_time();
- struct tm *tmp;
-
- tmp = gmtime( &now );
- gmt = mktime( tmp );
-
- tmp = localtime( &now );
- tmp->tm_isdst = 0;
- lcl = mktime( tmp );
-
- gmtoff = gmt - lcl;
- }
-
ldap_pvt_thread_mutex_init( &chk_syntax_mutex );
ppolicy.on_bi.bi_type = "ppolicy";
ppolicy.on_bi.bi_db_init = ppolicy_db_init;
+ ppolicy.on_bi.bi_db_open = ppolicy_db_open;
ppolicy.on_bi.bi_db_config = ppolicy_config;
ppolicy.on_bi.bi_db_close = ppolicy_close;
ppolicy.on_bi.bi_op_add = ppolicy_add;
ppolicy.on_bi.bi_op_bind = ppolicy_bind;
- ppolicy.on_bi.bi_op_unbind = ppolicy_unbind;
ppolicy.on_bi.bi_op_compare = ppolicy_restrict;
ppolicy.on_bi.bi_op_delete = ppolicy_restrict;
ppolicy.on_bi.bi_op_modify = ppolicy_modify;
ppolicy.on_bi.bi_op_search = ppolicy_restrict;
+ ppolicy.on_bi.bi_connection_destroy = ppolicy_connection_destroy;
return overlay_register( &ppolicy );
}
#if SLAPD_OVER_PPOLICY == SLAPD_MOD_DYNAMIC
int init_module(int argc, char *argv[]) {
- return ppolicy_init();
+ return ppolicy_initialize();
}
#endif