diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2007-09-14 18:30:40 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2007-09-14 18:30:40 +0200 |
commit | c5fde824853997d98807b9a51585e4544e86d048 (patch) | |
tree | 2400bccaea77dbc279fc30cd872e0ce6037248b0 /nslcd/shadow.c | |
parent | b79a013d8b44fbd008019ed8b212a24f66ea2069 (diff) |
get rid of global session and instead pass the session as a parameter with every request and allocate a session per thread
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@391 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nslcd/shadow.c')
-rw-r--r-- | nslcd/shadow.c | 47 |
1 files changed, 16 insertions, 31 deletions
diff --git a/nslcd/shadow.c b/nslcd/shadow.c index 1e79a04..9d4f02a 100644 --- a/nslcd/shadow.c +++ b/nslcd/shadow.c @@ -150,56 +150,41 @@ _nss_ldap_shadow_handle_flag (struct spwd *sp) } } -static enum nss_status _nss_ldap_parse_sp(LDAPMessage *e, - struct ldap_state UNUSED(*pvt), - void *result,char *buffer,size_t buflen) +static enum nss_status _nss_ldap_parse_sp( + MYLDAP_SESSION *session,LDAPMessage *e,struct ldap_state UNUSED(*state), + void *result,char *buffer,size_t buflen) { struct spwd *sp = (struct spwd *) result; enum nss_status stat; char *tmp = NULL; - stat = - _nss_ldap_assign_userpassword (e, attmap_shadow_userPassword, - &sp->sp_pwdp, &buffer, &buflen); + stat=_nss_ldap_assign_userpassword(session,e,attmap_shadow_userPassword,&sp->sp_pwdp,&buffer,&buflen); if (stat != NSS_STATUS_SUCCESS) return stat; - stat = - _nss_ldap_assign_attrval (e, attmap_shadow_uid, &sp->sp_namp, &buffer, - &buflen); + stat=_nss_ldap_assign_attrval(session,e,attmap_shadow_uid,&sp->sp_namp,&buffer,&buflen); if (stat != NSS_STATUS_SUCCESS) return stat; - stat = - _nss_ldap_assign_attrval (e, attmap_shadow_shadowLastChange, &tmp, &buffer, - &buflen); + stat=_nss_ldap_assign_attrval(session,e,attmap_shadow_shadowLastChange,&tmp,&buffer,&buflen); sp->sp_lstchg = (stat == NSS_STATUS_SUCCESS) ? _nss_ldap_shadow_date (tmp) : -1; - stat = - _nss_ldap_assign_attrval (e, attmap_shadow_shadowMax, &tmp, &buffer, &buflen); + stat=_nss_ldap_assign_attrval(session,e,attmap_shadow_shadowMax,&tmp,&buffer,&buflen); sp->sp_max = (stat == NSS_STATUS_SUCCESS) ? atol (tmp) : -1; - stat = - _nss_ldap_assign_attrval (e, attmap_shadow_shadowMin, &tmp, &buffer, &buflen); + stat=_nss_ldap_assign_attrval(session,e,attmap_shadow_shadowMin,&tmp,&buffer,&buflen); sp->sp_min = (stat == NSS_STATUS_SUCCESS) ? atol (tmp) : -1; - stat = - _nss_ldap_assign_attrval (e, attmap_shadow_shadowWarning, &tmp, &buffer, - &buflen); + stat=_nss_ldap_assign_attrval(session,e,attmap_shadow_shadowWarning,&tmp,&buffer,&buflen); sp->sp_warn = (stat == NSS_STATUS_SUCCESS) ? atol (tmp) : -1; - stat = - _nss_ldap_assign_attrval (e, attmap_shadow_shadowInactive, &tmp, &buffer, - &buflen); + stat=_nss_ldap_assign_attrval(session,e,attmap_shadow_shadowInactive,&tmp,&buffer,&buflen); sp->sp_inact = (stat == NSS_STATUS_SUCCESS) ? atol (tmp) : -1; - stat = - _nss_ldap_assign_attrval (e, attmap_shadow_shadowExpire, &tmp, &buffer, - &buflen); + stat=_nss_ldap_assign_attrval(session,e,attmap_shadow_shadowExpire,&tmp,&buffer,&buflen); sp->sp_expire = (stat == NSS_STATUS_SUCCESS) ? _nss_ldap_shadow_date (tmp) : -1; - stat = - _nss_ldap_assign_attrval (e, attmap_shadow_shadowFlag, &tmp, &buffer, &buflen); + stat=_nss_ldap_assign_attrval(session,e,attmap_shadow_shadowFlag,&tmp,&buffer,&buflen); sp->sp_flag = (stat == NSS_STATUS_SUCCESS) ? atol (tmp) : 0; _nss_ldap_shadow_handle_flag(sp); @@ -220,7 +205,7 @@ static enum nss_status _nss_ldap_parse_sp(LDAPMessage *e, #define SHADOW_EXPIRE result.sp_expire #define SHADOW_FLAG result.sp_flag -int nslcd_shadow_byname(TFILE *fp) +int nslcd_shadow_byname(TFILE *fp,MYLDAP_SESSION *session) { int32_t tmpint32; char name[256]; @@ -239,7 +224,7 @@ int nslcd_shadow_byname(TFILE *fp) /* do the LDAP request */ mkfilter_shadow_byname(name,filter,sizeof(filter)); shadow_init(); - retv=_nss_ldap_getbyname(&result,buffer,1024,&errnop, + retv=_nss_ldap_getbyname(session,&result,buffer,1024,&errnop, shadow_base,shadow_scope,filter,shadow_attrs, _nss_ldap_parse_sp); /* write the response */ @@ -253,7 +238,7 @@ int nslcd_shadow_byname(TFILE *fp) return 0; } -int nslcd_shadow_all(TFILE *fp) +int nslcd_shadow_all(TFILE *fp,MYLDAP_SESSION *session) { int32_t tmpint32; struct ent_context context; @@ -268,7 +253,7 @@ int nslcd_shadow_all(TFILE *fp) WRITE_INT32(fp,NSLCD_VERSION); WRITE_INT32(fp,NSLCD_ACTION_SHADOW_ALL); /* initialize context */ - _nss_ldap_ent_context_init(&context); + _nss_ldap_ent_context_init(&context,session); /* loop over all results */ shadow_init(); while ((retv=_nss_ldap_getent(&context,&result,buffer,sizeof(buffer),&errnop, |