summaryrefslogtreecommitdiff
path: root/nslcd/ether.c
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2007-07-28 16:20:06 +0000
committerArthur de Jong <arthur@arthurdejong.org>2007-07-28 16:20:06 +0000
commit9e68b31911052fd5270c036366d2875f02ec3280 (patch)
treeec6d37e7cb09ab75dc94747d6da7ae94879dc421 /nslcd/ether.c
parentc8fa7714097214ca7efd94ed69d27ffaacb59a07 (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
Diffstat (limited to 'nslcd/ether.c')
-rw-r--r--nslcd/ether.c38
1 files changed, 13 insertions, 25 deletions
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 (&ether->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(&ether_context)==NULL)
return -1;
/* loop over all results */
- while ((retv=nss2nslcd(_nss_ldap_getent(&ether_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(&ether_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);