X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fcontrols.c;h=7c26ff1c38fb4876cf072298de6dfbda2dcc92e7;hb=27cb98d28d60b1f258ea12852b22bfdfec6380f6;hp=d0da95c2bb04a8ff1914038c7af0ddd048c91186;hpb=4b48c05a8e1b9ed776a4bee10ee91986941105de;p=openldap diff --git a/servers/slapd/controls.c b/servers/slapd/controls.c index d0da95c2bb..7c26ff1c38 100644 --- a/servers/slapd/controls.c +++ b/servers/slapd/controls.c @@ -90,7 +90,7 @@ static struct slap_control { { LDAP_CONTROL_CLIENT_UPDATE, SLAP_CTRL_SEARCH, NULL, parseClientUpdate }, -#endif +#endif /* LDAP_CLIENT_UPDATE */ { NULL } }; @@ -126,10 +126,6 @@ int get_ctrls( int rc = LDAP_SUCCESS; const char *errmsg = NULL; -#ifdef LDAP_CLIENT_UPDATE - op->o_clientupdatetype = -1; -#endif - len = ber_pvt_ber_remaining(ber); if( len == 0) { @@ -624,7 +620,7 @@ static int parseClientUpdate ( struct berval scheme = { 0, NULL }; struct berval cookie = { 0, NULL }; - if ( op->o_noop != SLAP_NO_CONTROL ) { + if ( op->o_clientupdate != SLAP_NO_CONTROL ) { *text = "LCUP client update control specified multiple times"; return LDAP_PROTOCOL_ERROR; } @@ -656,9 +652,17 @@ static int parseClientUpdate ( return LDAP_PROTOCOL_ERROR; } - if ( type != SYNCHRONIZE_ONLY && - type != SYNCHRONIZE_AND_PERSIST && - type != PERSIST_ONLY ) { + switch( type ) { + case LDAP_CUP_SYNC_ONLY: + type = SLAP_LCUP_SYNC; + break; + case LDAP_CUP_SYNC_AND_PERSIST: + type = SLAP_LCUP_SYNC_AND_PERSIST; + break; + case LDAP_CUP_PERSIST_ONLY: + type = SLAP_LCUP_PERSIST; + break; + default: *text = "LCUP client update control : unknown update type"; return LDAP_PROTOCOL_ERROR; } @@ -676,12 +680,12 @@ static int parseClientUpdate ( if ( interval <= 0 ) { /* server chooses interval */ - interval = LDAP_LCUP_DEFAULT_SEND_COOKIE_INTERVAL; + interval = LDAP_CUP_DEFAULT_SEND_COOKIE_INTERVAL; } - } - else { + + } else { /* server chooses interval */ - interval = LDAP_LCUP_DEFAULT_SEND_COOKIE_INTERVAL; + interval = LDAP_CUP_DEFAULT_SEND_COOKIE_INTERVAL; } if ( (tag = ber_peek_tag( ber, &len )) == LBER_DEFAULT ) { @@ -699,23 +703,23 @@ static int parseClientUpdate ( /* TODO : Cookie Scheme Validation */ #if 0 - if ( lcup_cookie_validate(scheme, cookie) != LDAP_SUCCESS ) { - *text = "Invalid LCUP cookie"; - return LCUP_INVALID_COOKIE; - } - if ( lcup_cookie_scheme_validate(scheme) != LDAP_SUCCESS ) { *text = "Unsupported LCUP cookie scheme"; return LCUP_UNSUPPORTED_SCHEME; } + + if ( lcup_cookie_validate(scheme, cookie) != LDAP_SUCCESS ) { + *text = "Invalid LCUP cookie"; + return LCUP_INVALID_COOKIE; + } #endif - op->o_clientupdatestate = ber_dupbv(NULL, &cookie); + ber_dupbv( &op->o_clientupdate_state, &cookie ); (void) ber_free( ber, 1 ); - op->o_clientupdatetype = type; - op->o_clientupdateinterval = interval; + op->o_clientupdate_type = (char) type; + op->o_clientupdate_interval = interval; op->o_clientupdate = ctrl->ldctl_iscritical ? SLAP_CRITICAL_CONTROL @@ -723,4 +727,4 @@ static int parseClientUpdate ( return LDAP_SUCCESS; } -#endif +#endif /* LDAP_CLIENT_UPDATE */