Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/nslcd/host.c
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2007-09-08 21:15:12 +0200
committerArthur de Jong <arthur@arthurdejong.org>2007-09-08 21:15:12 +0200
commit78028ef3928c05573826daa726ffde40db291e83 (patch)
tree7ef92dd3689aa05091e2f79fc46545b410223111 /nslcd/host.c
parent4b539318232ffc077eaa882963b9788d686610cb (diff)
move base and scope handling to database specific modules, gettting rid of ldap_service_search_descriptor
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@384 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nslcd/host.c')
-rw-r--r--nslcd/host.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/nslcd/host.c b/nslcd/host.c
index 535b0e6..43e528e 100644
--- a/nslcd/host.c
+++ b/nslcd/host.c
@@ -113,8 +113,15 @@ static int mkfilter_host_byaddr(const char *name,
attmap_host_ipHostNumber,buf2);
}
-static void host_attrs_init(void)
+static void host_init(void)
{
+ /* set up base */
+ if (host_base==NULL)
+ host_base=nslcd_cfg->ldc_base;
+ /* set up scope */
+ if (host_scope==LDAP_SCOPE_DEFAULT)
+ host_scope=nslcd_cfg->ldc_scope;
+ /* set up attribute list */
host_attrs[0]=attmap_host_cn;
host_attrs[1]=attmap_host_ipHostNumber;
host_attrs[2]=NULL;
@@ -324,9 +331,9 @@ int nslcd_host_byname(TFILE *fp)
WRITE_INT32(fp,NSLCD_ACTION_HOST_BYNAME);
/* do the LDAP request */
mkfilter_host_byname(name,filter,sizeof(filter));
- host_attrs_init();
- retv=_nss_ldap_getbyname(&result,buffer,1024,&errnop,LM_HOSTS,
- NULL,filter,host_attrs,
+ host_init();
+ retv=_nss_ldap_getbyname(&result,buffer,1024,&errnop,
+ host_base,host_scope,filter,host_attrs,
#ifdef INET6
(af == AF_INET6)?_nss_ldap_parse_hostv6:_nss_ldap_parse_hostv4);
#else
@@ -381,9 +388,9 @@ int nslcd_host_byaddr(TFILE *fp)
WRITE_INT32(fp,NSLCD_ACTION_HOST_BYADDR);
/* do the LDAP request */
mkfilter_host_byaddr(name,filter,sizeof(filter));
- host_attrs_init();
- retv=_nss_ldap_getbyname(&result,buffer,1024,&errnop,LM_HOSTS,
- NULL,filter,host_attrs,
+ host_init();
+ retv=_nss_ldap_getbyname(&result,buffer,1024,&errnop,
+ host_base,host_scope,filter,host_attrs,
#ifdef INET6
(af == AF_INET6)?_nss_ldap_parse_hostv6:_nss_ldap_parse_hostv4);
#else
@@ -415,9 +422,9 @@ int nslcd_host_all(TFILE *fp)
/* initialize context */
_nss_ldap_ent_context_init(&context);
/* loop over all results */
- host_attrs_init();
+ host_init();
while ((retv=_nss_ldap_getent(&context,&result,buffer,sizeof(buffer),&errnop,
- NULL,host_filter,host_attrs,LM_HOSTS,
+ host_base,host_scope,host_filter,host_attrs,
#ifdef INET6
(_res.options&RES_USE_INET6)?_nss_ldap_parse_hostv6:_nss_ldap_parse_hostv4
#else