diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2007-07-28 16:20:06 +0000 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2007-07-28 16:20:06 +0000 |
commit | 9e68b31911052fd5270c036366d2875f02ec3280 (patch) | |
tree | ec6d37e7cb09ab75dc94747d6da7ae94879dc421 | |
parent | c8fa7714097214ca7efd94ed69d27ffaacb59a07 (diff) |
define the list of attributes to look up in searches in the service modules instead of in ldap-schema
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@337 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r-- | nslcd/alias.c | 16 | ||||
-rw-r--r-- | nslcd/cfg.h | 2 | ||||
-rw-r--r-- | nslcd/ether.c | 38 | ||||
-rw-r--r-- | nslcd/group.c | 33 | ||||
-rw-r--r-- | nslcd/host.c | 18 | ||||
-rw-r--r-- | nslcd/ldap-nss.c | 46 | ||||
-rw-r--r-- | nslcd/ldap-nss.h | 12 | ||||
-rw-r--r-- | nslcd/ldap-schema.c | 176 | ||||
-rw-r--r-- | nslcd/ldap-schema.h | 1 | ||||
-rw-r--r-- | nslcd/netgroup.c | 14 | ||||
-rw-r--r-- | nslcd/network.c | 19 | ||||
-rw-r--r-- | nslcd/passwd.c | 25 | ||||
-rw-r--r-- | nslcd/protocol.c | 19 | ||||
-rw-r--r-- | nslcd/rpc.c | 19 | ||||
-rw-r--r-- | nslcd/service.c | 20 | ||||
-rw-r--r-- | nslcd/shadow.c | 23 |
16 files changed, 211 insertions, 270 deletions
diff --git a/nslcd/alias.c b/nslcd/alias.c index a19ac70..dc9bc89 100644 --- a/nslcd/alias.c +++ b/nslcd/alias.c @@ -45,6 +45,16 @@ #include "attmap.h" #include "ldap-schema.h" +/* the attributes to request with searches */ +static const char *attlst[3]; + +static void attlst_init(void) +{ + attlst[0] = attmap_alias_cn; + attlst[1] = attmap_alias_rfc822MailMember; + attlst[2] = NULL; +} + static enum nss_status _nss_ldap_parse_alias( LDAPMessage *e,struct ldap_state UNUSED(*pvt),void *result, char *buffer,size_t buflen) @@ -98,7 +108,8 @@ int nslcd_alias_byname(TFILE *fp) LA_INIT(a); LA_STRING(a)=name; LA_TYPE(a)=LA_TYPE_STRING; - _nss_ldap_searchbyname(&a,_nss_ldap_filt_getaliasbyname,LM_ALIASES,fp,write_alias); + attlst_init(); + _nss_ldap_searchbyname(&a,_nss_ldap_filt_getaliasbyname,LM_ALIASES,attlst,fp,write_alias); WRITE_FLUSH(fp); /* we're done */ return 0; @@ -122,7 +133,8 @@ int nslcd_alias_all(TFILE *fp) if (_nss_ldap_ent_context_init(&alias_context)==NULL) return -1; /* loop over all results */ - while ((retv=nss2nslcd(_nss_ldap_getent(&alias_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getaliasent,LM_ALIASES,_nss_ldap_parse_alias)))==NSLCD_RESULT_SUCCESS) + attlst_init(); + while ((retv=nss2nslcd(_nss_ldap_getent(&alias_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getaliasent,LM_ALIASES,attlst,_nss_ldap_parse_alias)))==NSLCD_RESULT_SUCCESS) { /* write the result */ WRITE_INT32(fp,retv); diff --git a/nslcd/cfg.h b/nslcd/cfg.h index f23e05f..bf0689d 100644 --- a/nslcd/cfg.h +++ b/nslcd/cfg.h @@ -136,8 +136,6 @@ struct ldap_config enum ldap_userpassword_selector ldc_password_type; /* Use active directory time offsets? */ enum ldap_shadow_selector ldc_shadow_type; - /* attribute table for ldap search requensts */ - const char **ldc_attrtab[LM_NONE + 1]; unsigned int ldc_flags; char **ldc_initgroups_ignoreusers; }; diff --git a/nslcd/ether.c b/nslcd/ether.c index 7d12166..9cc9705 100644 --- a/nslcd/ether.c +++ b/nslcd/ether.c @@ -74,30 +74,15 @@ struct ether struct ether_addr e_addr; }; -#ifdef NEW -static int write_ether(LDAPMessage *e,struct ldap_state *pvt,TFILE *fp) -{ - /* FIXME: fix following problem: - if the entry has multiple cn fields we may end up - sending the wrong cn, we should return the requested - CN instead, otherwise write an entry for each cn */ - int stat; - char buffer[1024]; - /* write NSLCD_STRING(ETHER_NAME) */ - stat=_nss_ldap_write_attrval(fp,e,attmap_ether_cn); - if (stat!=NSLCD_RESULT_SUCCESS) - return stat; - /* write NSLCD_TYPE(ETHER_ADDR,u_int8_t[6]) */ - stat=_nss_ldap_write_attrval_ether(fp,e,attmap_ether_macAddress); +/* the attributes to request with searches */ +static const char *attlst[3]; - stat = _nss_ldap_assign_attrval (e, attmap_ether_macAddress, &saddr, - &buffer, &buflen); - if (stat != NSS_STATUS_SUCCESS || ((addr = ether_aton (saddr)) == NULL)) - return NSS_STATUS_NOTFOUND; - memcpy (ðer->e_addr, addr, sizeof (*addr)); - return NSLCD_RESULT_SUCCESS; +static void attlst_init(void) +{ + attlst[0] = attmap_ether_cn; + attlst[1] = attmap_ether_macAddress; + attlst[2] = NULL; } -#endif /* NEW */ static enum nss_status _nss_ldap_parse_ether (LDAPMessage * e, @@ -152,7 +137,8 @@ int nslcd_ether_byname(TFILE *fp) LA_INIT(a); LA_STRING(a)=name; LA_TYPE(a)=LA_TYPE_STRING; - retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_gethostton,LM_ETHERS,_nss_ldap_parse_ether)); + attlst_init(); + retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_gethostton,LM_ETHERS,attlst,_nss_ldap_parse_ether)); /* write the response */ WRITE_INT32(fp,retv); if (retv==NSLCD_RESULT_SUCCESS) @@ -187,7 +173,8 @@ int nslcd_ether_byether(TFILE *fp) and we're looking for 1:0:e:... (leading zeros) */ LA_STRING(a)=ether_ntoa(&addr); LA_TYPE(a)=LA_TYPE_STRING; - retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getntohost,LM_ETHERS,_nss_ldap_parse_ether)); + attlst_init(); + retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getntohost,LM_ETHERS,attlst,_nss_ldap_parse_ether)); /* write the response */ WRITE_INT32(fp,retv); if (retv==NSLCD_RESULT_SUCCESS) @@ -217,7 +204,8 @@ int nslcd_ether_all(TFILE *fp) if (_nss_ldap_ent_context_init(ðer_context)==NULL) return -1; /* loop over all results */ - while ((retv=nss2nslcd(_nss_ldap_getent(ðer_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getetherent,LM_ETHERS,_nss_ldap_parse_ether)))==NSLCD_RESULT_SUCCESS) + attlst_init(); + while ((retv=nss2nslcd(_nss_ldap_getent(ðer_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getetherent,LM_ETHERS,attlst,_nss_ldap_parse_ether)))==NSLCD_RESULT_SUCCESS) { /* write the result */ WRITE_INT32(fp,retv); diff --git a/nslcd/group.c b/nslcd/group.c index c677568..534ef30 100644 --- a/nslcd/group.c +++ b/nslcd/group.c @@ -112,6 +112,18 @@ static enum nss_status ng_chase (const char *dn, ldap_initgroups_args_t * lia); static enum nss_status ng_chase_backlink (const char ** membersOf, ldap_initgroups_args_t * lia); +/* the attributes to request with searches */ +static const char *attlst[6]; + +static void attlst_init(void) +{ + attlst[0] = attmap_group_cn; + attlst[1] = attmap_group_userPassword; + attlst[2] = attmap_group_memberUid; + attlst[3] = attmap_group_uniqueMember; + attlst[4] = attmap_group_gidNumber; + attlst[5] = NULL; +} /* * Add a nested netgroup or group to the namelist @@ -383,16 +395,12 @@ do_parse_group_members (LDAPMessage * e, char **groupMembers; size_t groupMembersCount, i; char **valiter; - /* support for range retrieval */ - const char *uniquemember_attr; const char *uniquemember_attrs[2]; LDAPMessage *res = NULL; int start, end = 0; char *groupdn = NULL; - uniquemember_attr = attmap_group_uniqueMember; - - uniquemember_attrs[0] = uniquemember_attr; + uniquemember_attrs[0] = attmap_group_uniqueMember; uniquemember_attrs[1] = NULL; if (*depth > LDAP_NSS_MAXGR_DEPTH) @@ -433,7 +441,7 @@ do_parse_group_members (LDAPMessage * e, groupMembersCount = 0; /* number of members in this group */ - (void) do_get_range_values (e, uniquemember_attrs[0], &start, &end, &dnValues); + (void) do_get_range_values (e, attmap_group_uniqueMember, &start, &end, &dnValues); if (dnValues != NULL) { groupMembersCount += ldap_count_values (dnValues); @@ -562,12 +570,12 @@ do_parse_group_members (LDAPMessage * e, /* Get next range for Active Directory compat */ if (end != -1) { - stat = do_construct_range_attribute (uniquemember_attr, + stat = do_construct_range_attribute (attmap_group_uniqueMember, end + 1, -1, buffer, buflen, - &uniquemember_attrs[0]); + uniquemember_attrs); if (stat == NSS_STATUS_SUCCESS) { if (dnValues != NULL) @@ -1188,7 +1196,8 @@ int nslcd_group_byname(TFILE *fp) LA_INIT(a); LA_STRING(a)=name; LA_TYPE(a)=LA_TYPE_STRING; - retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getgrnam,LM_GROUP,_nss_ldap_parse_gr)); + attlst_init(); + retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getgrnam,LM_GROUP,attlst,_nss_ldap_parse_gr)); /* write the response */ WRITE_INT32(fp,NSLCD_VERSION); WRITE_INT32(fp,NSLCD_ACTION_GROUP_BYNAME); @@ -1226,7 +1235,8 @@ int nslcd_group_bygid(TFILE *fp) LA_INIT(a); LA_NUMBER(a)=gid; LA_TYPE(a)=LA_TYPE_NUMBER; - retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getgrgid,LM_GROUP,_nss_ldap_parse_gr)); + attlst_init(); + retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getgrgid,LM_GROUP,attlst,_nss_ldap_parse_gr)); /* write the response */ WRITE_INT32(fp,NSLCD_VERSION); WRITE_INT32(fp,NSLCD_ACTION_GROUP_BYGID); @@ -1314,7 +1324,8 @@ int nslcd_group_all(TFILE *fp) if (_nss_ldap_ent_context_init(&gr_context)==NULL) return -1; /* loop over all results */ - while ((retv=nss2nslcd(_nss_ldap_getent(&gr_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getgrent,LM_GROUP,_nss_ldap_parse_gr)))==NSLCD_RESULT_SUCCESS) + attlst_init(); + while ((retv=nss2nslcd(_nss_ldap_getent(&gr_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getgrent,LM_GROUP,attlst,_nss_ldap_parse_gr)))==NSLCD_RESULT_SUCCESS) { /* write the result */ WRITE_INT32(fp,retv); diff --git a/nslcd/host.c b/nslcd/host.c index 35531ac..c8105d3 100644 --- a/nslcd/host.c +++ b/nslcd/host.c @@ -60,6 +60,16 @@ #define MAXALIASES 35 #endif +/* the attributes to request with searches */ +static const char *attlst[3]; + +static void attlst_init(void) +{ + attlst[0] = attmap_host_cn; + attlst[1] = attmap_host_ipHostNumber; + attlst[2] = NULL; +} + /* write a single host entry to the stream */ static int write_hostent(TFILE *fp,struct hostent *result) { @@ -266,7 +276,8 @@ int nslcd_host_byname(TFILE *fp) LA_INIT(a); LA_STRING(a)=name; LA_TYPE(a)=LA_TYPE_STRING; - retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_gethostbyname,LM_HOSTS, + attlst_init(); + retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_gethostbyname,LM_HOSTS,attlst, #ifdef INET6 (af == AF_INET6)?_nss_ldap_parse_hostv6:_nss_ldap_parse_hostv4)); #else @@ -323,7 +334,8 @@ int nslcd_host_byaddr(TFILE *fp) LA_INIT(a); LA_STRING(a)=name; LA_TYPE(a)=LA_TYPE_STRING; - retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_gethostbyaddr,LM_HOSTS, + attlst_init(); + retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_gethostbyaddr,LM_HOSTS,attlst, #ifdef INET6 (af == AF_INET6)?_nss_ldap_parse_hostv6:_nss_ldap_parse_hostv4)); #else @@ -356,7 +368,9 @@ int nslcd_host_all(TFILE *fp) if (_nss_ldap_ent_context_init(&host_context)==NULL) return -1; /* loop over all results */ + attlst_init(); while ((retv=nss2nslcd(_nss_ldap_getent(&host_context,&result,buffer,1024,&errnop,_nss_ldap_filt_gethostent,LM_HOSTS, + attlst, #ifdef INET6 (_res.options&RES_USE_INET6)?_nss_ldap_parse_hostv6:_nss_ldap_parse_hostv4 #else diff --git a/nslcd/ldap-nss.c b/nslcd/ldap-nss.c index b61f55d..0c5e561 100644 --- a/nslcd/ldap-nss.c +++ b/nslcd/ldap-nss.c @@ -820,7 +820,6 @@ do_init (void) __session.ls_timestamp = 0; __session.ls_state = LS_UNINITIALIZED; - _nss_ldap_init_attributes (nslcd_cfg->ldc_attrtab); _nss_ldap_init_filters (); #ifdef HAVE_LDAP_SET_OPTION @@ -2112,12 +2111,12 @@ _nss_ldap_next_attribute (LDAPMessage * entry, BerElement * ber) enum nss_status _nss_ldap_search_s( const struct ldap_args *args, const char *filterprot,enum ldap_map_selector sel, - const char **user_attrs,int sizelimit,LDAPMessage **res) + const char **attrs,int sizelimit,LDAPMessage **res) { char sdBase[LDAP_FILT_MAXSIZ]; const char *base=NULL; char filterBuf[LDAP_FILT_MAXSIZ],*dynamicFilterBuf=NULL; - const char **attrs,*filter; + const char *filter; int scope; enum nss_status stat; struct ldap_service_search_descriptor *sd=NULL; @@ -2131,7 +2130,6 @@ enum nss_status _nss_ldap_search_s( /* Set some reasonable defaults. */ base=nslcd_cfg->ldc_base; scope=nslcd_cfg->ldc_scope; - attrs=NULL; /* if args includes a base, use that */ if (args!=NULL&&args->la_base!=NULL) { @@ -2160,14 +2158,13 @@ next: scope=sd->lsd_scope; } } - attrs=nslcd_cfg->ldc_attrtab[sel]; } /* this may allocate dynamicFilterBuf */ stat=do_filter(args,filterprot,sd,filterBuf,sizeof(filterBuf),&dynamicFilterBuf,&filter); if (stat!=NSS_STATUS_SUCCESS) return stat; stat=do_with_reconnect( - base,scope,filter,(user_attrs!=NULL)?user_attrs:attrs, + base,scope,filter,attrs, sizelimit,res,(search_func_t)do_search_s); if (dynamicFilterBuf!=NULL) { @@ -2195,13 +2192,13 @@ next: static enum nss_status _nss_ldap_search (const struct ldap_args * args, const char *filterprot, enum ldap_map_selector sel, - const char **user_attrs, int sizelimit, int *msgid, + const char **attrs, int sizelimit, int *msgid, struct ldap_service_search_descriptor ** csd) { char sdBase[LDAP_FILT_MAXSIZ]; const char *base = NULL; char filterBuf[LDAP_FILT_MAXSIZ], *dynamicFilterBuf = NULL; - const char **attrs, *filter; + const char *filter; int scope; enum nss_status stat; struct ldap_service_search_descriptor *sd = NULL; @@ -2220,7 +2217,6 @@ _nss_ldap_search (const struct ldap_args * args, /* Set some reasonable defaults. */ base = nslcd_cfg->ldc_base; scope = nslcd_cfg->ldc_scope; - attrs = NULL; if (args != NULL && args->la_base != NULL) { @@ -2267,7 +2263,6 @@ _nss_ldap_search (const struct ldap_args * args, scope = sd->lsd_scope; } } - attrs = nslcd_cfg->ldc_attrtab[sel]; } stat = @@ -2276,8 +2271,7 @@ _nss_ldap_search (const struct ldap_args * args, if (stat != NSS_STATUS_SUCCESS) return stat; - stat = do_with_reconnect (base, scope, filter, - (user_attrs != NULL) ? user_attrs : attrs, + stat = do_with_reconnect (base, scope, filter, attrs, sizelimit, msgid, (search_func_t) do_search); if (dynamicFilterBuf != NULL) @@ -2291,13 +2285,14 @@ _nss_ldap_search (const struct ldap_args * args, #ifdef HAVE_LDAP_SEARCH_EXT static enum nss_status do_next_page (const struct ldap_args * args, - const char *filterprot, enum ldap_map_selector sel, int - sizelimit, int *msgid, struct berval *pCookie) + const char *filterprot, enum ldap_map_selector sel, + const char **attrs, int sizelimit, int *msgid, + struct berval *pCookie) { char sdBase[LDAP_FILT_MAXSIZ]; const char *base = NULL; char filterBuf[LDAP_FILT_MAXSIZ], *dynamicFilterBuf = NULL; - const char **attrs, *filter; + const char *filter; int scope; enum nss_status stat; struct ldap_service_search_descriptor *sd = NULL; @@ -2308,7 +2303,6 @@ do_next_page (const struct ldap_args * args, /* Set some reasonable defaults. */ base = nslcd_cfg->ldc_base; scope = nslcd_cfg->ldc_scope; - attrs = NULL; if (args != NULL && args->la_base != NULL) { @@ -2338,7 +2332,6 @@ do_next_page (const struct ldap_args * args, scope = sd->lsd_scope; } } - attrs = nslcd_cfg->ldc_attrtab[sel]; } stat = @@ -2386,7 +2379,7 @@ enum nss_status _nss_ldap_getent (struct ent_context ** ctx, void *result, char *buffer, size_t buflen, int *errnop, const char *filterprot, - enum ldap_map_selector sel, parser_t parser) + enum ldap_map_selector sel, const char **attrs, parser_t parser) { enum nss_status status; @@ -2399,7 +2392,7 @@ _nss_ldap_getent (struct ent_context ** ctx, _nss_ldap_enter (); status = _nss_ldap_getent_ex (NULL, ctx, result, buffer, buflen, - errnop, filterprot, sel, NULL, parser); + errnop, filterprot, sel, attrs, parser); _nss_ldap_leave (); return status; @@ -2415,7 +2408,7 @@ _nss_ldap_getent_ex (struct ldap_args * args, char *buffer, size_t buflen, int *errnop, const char *filterprot, enum ldap_map_selector sel, - const char **user_attrs, parser_t parser) + const char **attrs, parser_t parser) { enum nss_status stat = NSS_STATUS_SUCCESS; @@ -2442,7 +2435,7 @@ next: { int msgid; - stat = _nss_ldap_search (args, filterprot, sel, user_attrs, + stat = _nss_ldap_search (args, filterprot, sel, attrs, LDAP_NO_LIMIT, &msgid, &(*ctx)->ec_sd); if (stat != NSS_STATUS_SUCCESS) { @@ -2464,7 +2457,7 @@ next: int msgid; stat = - do_next_page (NULL, filterprot, sel, LDAP_NO_LIMIT, &msgid, + do_next_page (NULL, filterprot, sel, attrs, LDAP_NO_LIMIT, &msgid, (*ctx)->ec_cookie); if (stat != NSS_STATUS_SUCCESS) { @@ -2496,7 +2489,8 @@ enum nss_status _nss_ldap_getbyname (struct ldap_args * args, void *result, char *buffer, size_t buflen, int *errnop, const char *filterprot, - enum ldap_map_selector sel, parser_t parser) + enum ldap_map_selector sel, const char **attrs, + parser_t parser) { enum nss_status stat = NSS_STATUS_NOTFOUND; struct ent_context ctx; @@ -2508,7 +2502,7 @@ _nss_ldap_getbyname (struct ldap_args * args, ctx.ec_msgid = -1; ctx.ec_cookie = NULL; - stat = _nss_ldap_search_s (args, filterprot, sel, NULL, 1, &ctx.ec_res); + stat = _nss_ldap_search_s (args, filterprot, sel, attrs, 1, &ctx.ec_res); if (stat != NSS_STATUS_SUCCESS) { _nss_ldap_leave (); @@ -2586,7 +2580,7 @@ static int NEW_do_parse_s(struct ent_context *ctx,TFILE *fp,NEWparser_t parser) int _nss_ldap_searchbyname( struct ldap_args *args,const char *filterprot, - enum ldap_map_selector sel,TFILE *fp,NEWparser_t parser) + enum ldap_map_selector sel,const char **attrs,TFILE *fp,NEWparser_t parser) { int stat; struct ent_context ctx; @@ -2597,7 +2591,7 @@ int _nss_ldap_searchbyname( ctx.ec_msgid=-1; ctx.ec_cookie=NULL; - stat=nss2nslcd(_nss_ldap_search_s(args,filterprot,sel,NULL,1,&ctx.ec_res)); + stat=nss2nslcd(_nss_ldap_search_s(args,filterprot,sel,attrs,1,&ctx.ec_res)); /* write the result code */ WRITE_INT32(fp,stat); /* bail on nothing found */ diff --git a/nslcd/ldap-nss.h b/nslcd/ldap-nss.h index 28c9c59..8c8fe9f 100644 --- a/nslcd/ldap-nss.h +++ b/nslcd/ldap-nss.h @@ -296,14 +296,14 @@ char *_nss_ldap_next_attribute (LDAPMessage * entry, BerElement *ber); enum nss_status _nss_ldap_search_s (const struct ldap_args * args, /* IN */ const char *filterprot, /* IN */ enum ldap_map_selector sel, /* IN */ - const char **user_attrs, /* IN */ + const char **attrs, /* IN */ int sizelimit, /* IN */ LDAPMessage ** res /* OUT */ ); int _nss_ldap_searchbyname( struct ldap_args *args,const char *filterprot, - enum ldap_map_selector sel,TFILE *fp,NEWparser_t parser); + enum ldap_map_selector sel,const char **attrs,TFILE *fp,NEWparser_t parser); /* @@ -325,7 +325,7 @@ enum nss_status _nss_ldap_getent_ex (struct ldap_args * args, /* IN */ int *errnop, /* OUT */ const char *filterprot, /* IN */ enum ldap_map_selector sel, /* IN */ - const char **user_attrs, /* IN */ + const char **attrs, /* IN */ parser_t parser /* IN */ ); /* @@ -339,6 +339,7 @@ enum nss_status _nss_ldap_getent (struct ent_context ** ctx, /* IN/OUT */ int *errnop, /* OUT */ const char *filterprot, /* IN */ enum ldap_map_selector sel, /* IN */ + const char **attrs, /* IN */ parser_t parser /* IN */ ); /* @@ -351,6 +352,7 @@ enum nss_status _nss_ldap_getbyname (struct ldap_args * args, /* IN/OUT * int *errnop, /* OUT */ const char *filterprot, /* IN */ enum ldap_map_selector sel, /* IN */ + const char **attrs, /* IN */ parser_t parser /* IN */ ); @@ -381,10 +383,6 @@ enum nss_status _nss_ldap_assign_userpassword (LDAPMessage * e, /* IN */ return 0 for false, not-0 for true */ int has_objectclass(LDAPMessage *entry,const char *objectclass); -const char *_nss_ldap_map_at (enum ldap_map_selector sel, const char *attribute); - -const char *_nss_ldap_map_oc (enum ldap_map_selector sel, const char *objectclass); - enum nss_status _nss_ldap_init (void); #endif /* _LDAP_NSS_LDAP_LDAP_NSS_H */ diff --git a/nslcd/ldap-schema.c b/nslcd/ldap-schema.c index e4ba186..5d316fa 100644 --- a/nslcd/ldap-schema.c +++ b/nslcd/ldap-schema.c @@ -239,179 +239,3 @@ _nss_ldap_init_filters () } -static void -init_pwd_attributes (const char ***pwd_attrs) -{ - int i = 0; - static const char *__pwd_attrs[ATTRTAB_SIZE + 1]; - - (*pwd_attrs) = __pwd_attrs; - - (*pwd_attrs)[i++] = attmap_passwd_uid; - (*pwd_attrs)[i++] = attmap_passwd_userPassword; - (*pwd_attrs)[i++] = attmap_passwd_uidNumber; - (*pwd_attrs)[i++] = attmap_passwd_gidNumber; - (*pwd_attrs)[i++] = attmap_passwd_cn; - (*pwd_attrs)[i++] = attmap_passwd_homeDirectory; - (*pwd_attrs)[i++] = attmap_passwd_loginShell; - (*pwd_attrs)[i++] = attmap_passwd_gecos; - (*pwd_attrs)[i++] = attmap_objectClass; - (*pwd_attrs)[i] = NULL; -} - -static void -init_sp_attributes (const char ***sp_attrs) -{ - static const char *__sp_attrs[ATTRTAB_SIZE + 1]; - - (*sp_attrs) = __sp_attrs; - - (*sp_attrs)[0] = attmap_shadow_uid; - (*sp_attrs)[1] = attmap_shadow_userPassword; - (*sp_attrs)[2] = attmap_shadow_shadowLastChange; - (*sp_attrs)[3] = attmap_shadow_shadowMax; - (*sp_attrs)[4] = attmap_shadow_shadowMin; - (*sp_attrs)[5] = attmap_shadow_shadowWarning; - (*sp_attrs)[6] = attmap_shadow_shadowInactive; - (*sp_attrs)[7] = attmap_shadow_shadowExpire; - (*sp_attrs)[8] = attmap_shadow_shadowFlag; - (*sp_attrs)[9] = NULL; -} - -static void -init_grp_attributes (const char ***grp_attrs) -{ - int i = 0; - static const char *__grp_attrs[ATTRTAB_SIZE + 1]; - - (*grp_attrs) = __grp_attrs; - - (*grp_attrs)[i++] = attmap_group_cn; - (*grp_attrs)[i++] = attmap_group_userPassword; - (*grp_attrs)[i++] = attmap_group_memberUid; - if (_nss_ldap_test_config_flag (NSS_LDAP_FLAGS_RFC2307BIS)) - (*grp_attrs)[i++] = attmap_group_uniqueMember; - (*grp_attrs)[i++] = attmap_group_gidNumber; - (*grp_attrs)[i] = NULL; -} - -static void -init_hosts_attributes (const char ***hosts_attrs) -{ - static const char *__hosts_attrs[ATTRTAB_SIZE + 1]; - - (*hosts_attrs) = __hosts_attrs; - - (*hosts_attrs)[0] = attmap_host_cn; - (*hosts_attrs)[1] = attmap_host_ipHostNumber; - (*hosts_attrs)[2] = NULL; -} - -static void -init_services_attributes (const char ***services_attrs) -{ - static const char *__services_attrs[ATTRTAB_SIZE + 1]; - - (*services_attrs) = __services_attrs; - - (*services_attrs)[0] = attmap_service_cn; - (*services_attrs)[1] = attmap_service_ipServicePort; - (*services_attrs)[2] = attmap_service_ipServiceProtocol; - (*services_attrs)[3] = NULL; -} - -static void -init_network_attributes (const char ***network_attrs) -{ - static const char *__network_attrs[ATTRTAB_SIZE + 1]; - - (*network_attrs) = __network_attrs; - - (*network_attrs)[0] = attmap_network_cn; - (*network_attrs)[1] = attmap_network_ipNetworkNumber; - (*network_attrs)[2] = NULL; -} - -static void -init_proto_attributes (const char ***proto_attrs) -{ - static const char *__proto_attrs[ATTRTAB_SIZE + 1]; - - (*proto_attrs) = __proto_attrs; - - (*proto_attrs)[0] = attmap_protocol_cn; - (*proto_attrs)[1] = attmap_protocol_ipProtocolNumber; - (*proto_attrs)[2] = NULL; -} - -static void -init_rpc_attributes (const char ***rpc_attrs) -{ - static const char *__rpc_attrs[ATTRTAB_SIZE + 1]; - - (*rpc_attrs) = __rpc_attrs; - - (*rpc_attrs)[0] = attmap_rpc_cn; - (*rpc_attrs)[1] = attmap_rpc_oncRpcNumber; - (*rpc_attrs)[2] = NULL; -} - -static void -init_ethers_attributes (const char ***ethers_attrs) -{ - static const char *__ethers_attrs[ATTRTAB_SIZE + 1]; - - (*ethers_attrs) = __ethers_attrs; - - (*ethers_attrs)[0] = attmap_ether_cn; - (*ethers_attrs)[1] = attmap_ether_macAddress; - (*ethers_attrs)[2] = NULL; -} - -static void -init_alias_attributes (const char ***alias_attrs) -{ - static const char *__alias_attrs[ATTRTAB_SIZE + 1]; - - (*alias_attrs) = __alias_attrs; - - (*alias_attrs)[0] = attmap_alias_cn; - (*alias_attrs)[1] = attmap_alias_rfc822MailMember; - (*alias_attrs)[2] = NULL; -} - -static void -init_netgrp_attributes (const char ***netgrp_attrs) -{ - static const char *__netgrp_attrs[ATTRTAB_SIZE + 1]; - - (*netgrp_attrs) = __netgrp_attrs; - - (*netgrp_attrs)[0] = attmap_netgroup_cn; - (*netgrp_attrs)[1] = attmap_netgroup_nisNetgroupTriple; - (*netgrp_attrs)[2] = attmap_netgroup_memberNisNetgroup; - (*netgrp_attrs)[3] = NULL; -} - -/** - * attribute table initialization routines - */ -void -_nss_ldap_init_attributes (const char ***attrtab) -{ - init_pwd_attributes (&attrtab[LM_PASSWD]); - init_sp_attributes (&attrtab[LM_SHADOW]); - init_grp_attributes (&attrtab[LM_GROUP]); - init_hosts_attributes (&attrtab[LM_HOSTS]); - init_services_attributes (&attrtab[LM_SERVICES]); - init_network_attributes (&attrtab[LM_NETWORKS]); - init_proto_attributes (&attrtab[LM_PROTOCOLS]); - init_rpc_attributes (&attrtab[LM_RPC]); - init_ethers_attributes (&attrtab[LM_ETHERS]); - init_alias_attributes (&attrtab[LM_ALIASES]); - init_netgrp_attributes (&attrtab[LM_NETGROUP]); - - attrtab[LM_NONE] = NULL; -} - - diff --git a/nslcd/ldap-schema.h b/nslcd/ldap-schema.h index 60bb0e7..aeb6c34 100644 --- a/nslcd/ldap-schema.h +++ b/nslcd/ldap-schema.h @@ -30,7 +30,6 @@ * function to initialize global lookup filters. */ void _nss_ldap_init_filters(void); -void _nss_ldap_init_attributes(const char ***attrtab); /** * make filters formerly declared in ldap-*.h globally available. diff --git a/nslcd/netgroup.c b/nslcd/netgroup.c index 13007ce..339b2d3 100644 --- a/nslcd/netgroup.c +++ b/nslcd/netgroup.c @@ -114,6 +114,17 @@ struct mynetgrent } \ while (0) +/* the attributes to request with searches */ +static const char *attlst[4]; + +static void attlst_init(void) +{ + attlst[0] = attmap_netgroup_cn; + attlst[1] = attmap_netgroup_nisNetgroupTriple; + attlst[2] = attmap_netgroup_memberNisNetgroup; + attlst[3] = NULL; +} + static char * strip_whitespace (char *str) { @@ -311,7 +322,8 @@ int nslcd_netgroup_byname(TFILE *fp) LA_INIT(a); LA_STRING(a)=name; LA_TYPE(a)=LA_TYPE_STRING; - stat=_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getnetgrent,LM_NETGROUP,_nss_ldap_load_netgr); + attlst_init(); + stat=_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getnetgrent,LM_NETGROUP,attlst,_nss_ldap_load_netgr); if (_nss_ldap_ent_context_init(&netgroup_context)==NULL) return -1; /* loop over all results */ diff --git a/nslcd/network.c b/nslcd/network.c index b45fbbf..c3a9149 100644 --- a/nslcd/network.c +++ b/nslcd/network.c @@ -58,6 +58,16 @@ #define MAXADDRSIZE 4 #endif /* HAVE_USERSEC_H */ +/* the attributes to request with searches */ +static const char *attlst[3]; + +static void attlst_init(void) +{ + attlst[0] = attmap_network_cn; + attlst[1] = attmap_network_ipNetworkNumber; + attlst[2] = NULL; +} + /* write a single network entry to the stream */ static int write_netent(TFILE *fp,struct netent *result) { @@ -130,7 +140,8 @@ int nslcd_network_byname(TFILE *fp) LA_INIT(a); LA_STRING(a)=name; LA_TYPE(a)=LA_TYPE_STRING; - retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getnetbyname,LM_NETWORKS,_nss_ldap_parse_net)); + attlst_init(); + retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getnetbyname,LM_NETWORKS,attlst,_nss_ldap_parse_net)); /* write the response */ WRITE_INT32(fp,retv); if (retv==NSLCD_RESULT_SUCCESS) @@ -187,7 +198,8 @@ int nslcd_network_byaddr(TFILE *fp) while (retv==456) { /* do the request */ - retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getnetbyaddr,LM_NETWORKS,_nss_ldap_parse_net)); + attlst_init(); + retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getnetbyaddr,LM_NETWORKS,attlst,_nss_ldap_parse_net)); /* if no entry was found, retry with .0 stripped from the end */ if ((retv==NSLCD_RESULT_NOTFOUND) && (strlen(name)>2) && @@ -225,7 +237,8 @@ int nslcd_network_all(TFILE *fp) if (_nss_ldap_ent_context_init(&net_context)==NULL) return -1; /* loop over all results */ - while ((retv=nss2nslcd(_nss_ldap_getent(&net_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getnetent,LM_NETWORKS,_nss_ldap_parse_net)))==NSLCD_RESULT_SUCCESS) + attlst_init(); + while ((retv=nss2nslcd(_nss_ldap_getent(&net_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getnetent,LM_NETWORKS,attlst,_nss_ldap_parse_net)))==NSLCD_RESULT_SUCCESS) { /* write the result */ WRITE_INT32(fp,retv); diff --git a/nslcd/passwd.c b/nslcd/passwd.c index a564156..0f0b4b2 100644 --- a/nslcd/passwd.c +++ b/nslcd/passwd.c @@ -59,6 +59,22 @@ #define GID_NOBODY UID_NOBODY #endif +/* the attributes to request with searches */ +static const char *attlst[10]; + +static void attlst_init(void) +{ + attlst[0] = attmap_passwd_uid; + attlst[1] = attmap_passwd_userPassword; + attlst[2] = attmap_passwd_uidNumber; + attlst[3] = attmap_passwd_gidNumber; + attlst[4] = attmap_passwd_cn; + attlst[5] = attmap_passwd_homeDirectory; + attlst[6] = attmap_passwd_loginShell; + attlst[7] = attmap_passwd_gecos; + attlst[8] = attmap_objectClass; + attlst[9] = NULL; +} static inline enum nss_status _nss_ldap_assign_emptystring( char **valptr, char **buffer, size_t * buflen) @@ -195,7 +211,8 @@ int nslcd_passwd_byname(TFILE *fp) LA_INIT(a); LA_STRING(a)=name; LA_TYPE(a)=LA_TYPE_STRING; - retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getpwnam,LM_PASSWD,_nss_ldap_parse_pw)); + attlst_init(); + retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getpwnam,LM_PASSWD,attlst,_nss_ldap_parse_pw)); /* write the response */ WRITE_INT32(fp,NSLCD_VERSION); WRITE_INT32(fp,NSLCD_ACTION_PASSWD_BYNAME); @@ -227,7 +244,8 @@ int nslcd_passwd_byuid(TFILE *fp) LA_INIT(a); LA_NUMBER(a)=uid; LA_TYPE(a)=LA_TYPE_NUMBER; - retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getpwuid,LM_PASSWD,_nss_ldap_parse_pw)); + attlst_init(); + retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getpwuid,LM_PASSWD,attlst,_nss_ldap_parse_pw)); /* write the response */ WRITE_INT32(fp,NSLCD_VERSION); WRITE_INT32(fp,NSLCD_ACTION_PASSWD_BYUID); @@ -259,7 +277,8 @@ int nslcd_passwd_all(TFILE *fp) if (_nss_ldap_ent_context_init(&pw_context)==NULL) return -1; /* go over results */ - while ((retv=nss2nslcd(_nss_ldap_getent(&pw_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getpwent,LM_PASSWD,_nss_ldap_parse_pw)))==NSLCD_RESULT_SUCCESS) + attlst_init(); + while ((retv=nss2nslcd(_nss_ldap_getent(&pw_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getpwent,LM_PASSWD,attlst,_nss_ldap_parse_pw)))==NSLCD_RESULT_SUCCESS) { /* write the result */ WRITE_INT32(fp,retv); diff --git a/nslcd/protocol.c b/nslcd/protocol.c index 98873c4..035697d 100644 --- a/nslcd/protocol.c +++ b/nslcd/protocol.c @@ -55,6 +55,16 @@ #include "attmap.h" #include "ldap-schema.h" +/* the attributes to request with searches */ +static const char *attlst[3]; + +static void attlst_init(void) +{ + attlst[0] = attmap_protocol_cn; + attlst[1] = attmap_protocol_ipProtocolNumber; + attlst[2] = NULL; +} + static enum nss_status _nss_ldap_parse_proto (LDAPMessage *e, struct ldap_state UNUSED(*pvt), void *result, char *buffer, size_t buflen) @@ -116,7 +126,8 @@ int nslcd_protocol_byname(TFILE *fp) LA_INIT(a); LA_STRING(a)=name; LA_TYPE(a)=LA_TYPE_STRING; - retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getprotobyname,LM_PROTOCOLS,_nss_ldap_parse_proto)); + attlst_init(); + retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getprotobyname,LM_PROTOCOLS,attlst,_nss_ldap_parse_proto)); /* write the response */ WRITE_INT32(fp,retv); if (retv==NSLCD_RESULT_SUCCESS) @@ -149,7 +160,8 @@ int nslcd_protocol_bynumber(TFILE *fp) LA_INIT(a); LA_NUMBER(a)=protocol; LA_TYPE(a)=LA_TYPE_NUMBER; - retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getprotobynumber,LM_PROTOCOLS,_nss_ldap_parse_proto)); + attlst_init(); + retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getprotobynumber,LM_PROTOCOLS,attlst,_nss_ldap_parse_proto)); /* write the response */ WRITE_INT32(fp,retv); if (retv==NSLCD_RESULT_SUCCESS) @@ -179,7 +191,8 @@ int nslcd_protocol_all(TFILE *fp) if (_nss_ldap_ent_context_init(&protocol_context)==NULL) return -1; /* loop over all results */ - while ((retv=nss2nslcd(_nss_ldap_getent(&protocol_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getprotoent,LM_PROTOCOLS,_nss_ldap_parse_proto)))==NSLCD_RESULT_SUCCESS) + attlst_init(); + while ((retv=nss2nslcd(_nss_ldap_getent(&protocol_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getprotoent,LM_PROTOCOLS,attlst,_nss_ldap_parse_proto)))==NSLCD_RESULT_SUCCESS) { /* write the result code */ WRITE_INT32(fp,retv); diff --git a/nslcd/rpc.c b/nslcd/rpc.c index 5c886b3..ad92541 100644 --- a/nslcd/rpc.c +++ b/nslcd/rpc.c @@ -67,6 +67,16 @@ #define RPC_ALIASES result->r_aliases #define RPC_NUMBER result->r_number +/* the attributes to request with searches */ +static const char *attlst[3]; + +static void attlst_init(void) +{ + attlst[0] = attmap_rpc_cn; + attlst[1] = attmap_rpc_oncRpcNumber; + attlst[2] = NULL; +} + /* write a single rpc entry to the stream */ static int write_rpcent(TFILE *fp,struct rpcent *result) { @@ -128,7 +138,8 @@ int nslcd_rpc_byname(TFILE *fp) LA_INIT(a); LA_STRING(a)=name; LA_TYPE(a)=LA_TYPE_STRING; - retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getrpcbyname,LM_RPC,_nss_ldap_parse_rpc)); + attlst_init(); + retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getrpcbyname,LM_RPC,attlst,_nss_ldap_parse_rpc)); /* write the response */ WRITE_INT32(fp,retv); if (retv==NSLCD_RESULT_SUCCESS) @@ -159,7 +170,8 @@ int nslcd_rpc_bynumber(TFILE *fp) LA_INIT(a); LA_NUMBER(a)=number; LA_TYPE(a)=LA_TYPE_NUMBER; - retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getrpcbynumber,LM_RPC,_nss_ldap_parse_rpc)); + attlst_init(); + retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getrpcbynumber,LM_RPC,attlst,_nss_ldap_parse_rpc)); /* write the response */ WRITE_INT32(fp,retv); if (retv==NSLCD_RESULT_SUCCESS) @@ -187,7 +199,8 @@ int nslcd_rpc_all(TFILE *fp) if (_nss_ldap_ent_context_init(&rpc_context)==NULL) return -1; /* loop over all results */ - while ((retv=nss2nslcd(_nss_ldap_getent(&rpc_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getrpcent,LM_RPC,_nss_ldap_parse_rpc)))==NSLCD_RESULT_SUCCESS) + attlst_init(); + while ((retv=nss2nslcd(_nss_ldap_getent(&rpc_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getrpcent,LM_RPC,attlst,_nss_ldap_parse_rpc)))==NSLCD_RESULT_SUCCESS) { /* write the result code */ WRITE_INT32(fp,retv); diff --git a/nslcd/service.c b/nslcd/service.c index 7bf2438..58a6f09 100644 --- a/nslcd/service.c +++ b/nslcd/service.c @@ -68,6 +68,17 @@ #define SERVICE_NUMBER htons(result->s_port) #define SERVICE_PROTOCOL result->s_proto +/* the attributes to request with searches */ +static const char *attlst[4]; + +static void attlst_init(void) +{ + attlst[0] = attmap_service_cn; + attlst[1] = attmap_service_ipServicePort; + attlst[2] = attmap_service_ipServiceProtocol; + attlst[3] = NULL; +} + /* write a single host entry to the stream */ static int write_servent(TFILE *fp,struct servent *result) { @@ -214,9 +225,10 @@ int nslcd_service_byname(TFILE *fp) LA_STRING(a)=name; LA_TYPE(a)=(strlen(protocol)==0)?LA_TYPE_STRING:LA_TYPE_STRING_AND_STRING; LA_STRING2(a)=protocol; + attlst_init(); retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop, ((strlen(protocol)==0)?_nss_ldap_filt_getservbyname:_nss_ldap_filt_getservbynameproto), - LM_SERVICES,_nss_ldap_parse_serv)); + LM_SERVICES,attlst,_nss_ldap_parse_serv)); /* write the response */ WRITE_INT32(fp,retv); if (retv==NSLCD_RESULT_SUCCESS) @@ -250,9 +262,10 @@ int nslcd_service_bynumber(TFILE *fp) LA_NUMBER(a)=number; LA_TYPE(a)=(strlen(protocol)==0)?LA_TYPE_NUMBER:LA_TYPE_NUMBER_AND_STRING; LA_STRING2(a)=protocol; + attlst_init(); retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop, ((strlen(protocol)==0)?_nss_ldap_filt_getservbyport:_nss_ldap_filt_getservbyportproto), - LM_SERVICES,_nss_ldap_parse_serv)); + LM_SERVICES,attlst,_nss_ldap_parse_serv)); /* write the response */ WRITE_INT32(fp,retv); if (retv==NSLCD_RESULT_SUCCESS) @@ -280,7 +293,8 @@ int nslcd_service_all(TFILE *fp) if (_nss_ldap_ent_context_init(&serv_context)==NULL) return -1; /* loop over all results */ - while ((retv=nss2nslcd(_nss_ldap_getent(&serv_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getservent,LM_SERVICES,_nss_ldap_parse_serv)))==NSLCD_RESULT_SUCCESS) + attlst_init(); + while ((retv=nss2nslcd(_nss_ldap_getent(&serv_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getservent,LM_SERVICES,attlst,_nss_ldap_parse_serv)))==NSLCD_RESULT_SUCCESS) { /* write the result code */ WRITE_INT32(fp,retv); diff --git a/nslcd/shadow.c b/nslcd/shadow.c index 71d4134..0a3539b 100644 --- a/nslcd/shadow.c +++ b/nslcd/shadow.c @@ -52,6 +52,23 @@ #include "cfg.h" #include "ldap-schema.h" +/* the attributes to request with searches */ +static const char *attlst[10]; + +static void attlst_init(void) +{ + attlst[0] = attmap_shadow_uid; + attlst[1] = attmap_shadow_userPassword; + attlst[2] = attmap_shadow_shadowLastChange; + attlst[3] = attmap_shadow_shadowMax; + attlst[4] = attmap_shadow_shadowMin; + attlst[5] = attmap_shadow_shadowWarning; + attlst[6] = attmap_shadow_shadowInactive; + attlst[7] = attmap_shadow_shadowExpire; + attlst[8] = attmap_shadow_shadowFlag; + attlst[9] = NULL; +} + static int _nss_ldap_shadow_date (const char *val) { @@ -175,7 +192,8 @@ int nslcd_shadow_byname(TFILE *fp) LA_INIT(a); LA_STRING(a)=name; LA_TYPE(a)=LA_TYPE_STRING; - retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getspnam,LM_SHADOW,_nss_ldap_parse_sp)); + attlst_init(); + retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getspnam,LM_SHADOW,attlst,_nss_ldap_parse_sp)); /* write the response */ WRITE_INT32(fp,retv); if (retv==NSLCD_RESULT_SUCCESS) @@ -205,7 +223,8 @@ int nslcd_shadow_all(TFILE *fp) if (_nss_ldap_ent_context_init(&shadow_context)==NULL) return -1; /* loop over all results */ - while ((retv=nss2nslcd(_nss_ldap_getent(&shadow_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getspent,LM_SHADOW,_nss_ldap_parse_sp)))==NSLCD_RESULT_SUCCESS) + attlst_init(); + while ((retv=nss2nslcd(_nss_ldap_getent(&shadow_context,&result,buffer,1024,&errnop,_nss_ldap_filt_getspent,LM_SHADOW,attlst,_nss_ldap_parse_sp)))==NSLCD_RESULT_SUCCESS) { /* write the result */ WRITE_INT32(fp,retv); |