From 817d0ec30cf31a4a1cab4ba0a06119336ded86aa Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Sun, 24 May 2009 09:11:13 +0000 Subject: initialise database modules only once after parsing config git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@893 ef36b2f9-881f-0410-afb5-c4e39611909c --- nslcd/alias.c | 2 +- nslcd/cfg.c | 12 ++++++++++++ nslcd/common.h | 16 ++++++++++++++-- nslcd/ether.c | 2 +- nslcd/group.c | 2 +- nslcd/host.c | 2 +- nslcd/netgroup.c | 2 +- nslcd/network.c | 2 +- nslcd/passwd.c | 4 +--- nslcd/protocol.c | 2 +- nslcd/rpc.c | 2 +- nslcd/service.c | 2 +- nslcd/shadow.c | 2 +- 13 files changed, 37 insertions(+), 15 deletions(-) diff --git a/nslcd/alias.c b/nslcd/alias.c index ab44e57..42a880c 100644 --- a/nslcd/alias.c +++ b/nslcd/alias.c @@ -75,7 +75,7 @@ static int mkfilter_alias_byname(const char *name, attmap_alias_cn,buf2); } -static void alias_init(void) +void alias_init(void) { int i; /* set up search bases */ diff --git a/nslcd/cfg.c b/nslcd/cfg.c index a193ffe..6f443ae 100644 --- a/nslcd/cfg.c +++ b/nslcd/cfg.c @@ -1052,4 +1052,16 @@ void cfg_init(const char *fname) log_log(LOG_ERR,"no base defined in config and couldn't get one from server"); exit(EXIT_FAILURE); } + /* initialise all database modules */ + alias_init(); + ether_init(); + group_init(); + host_init(); + netgroup_init(); + network_init(); + passwd_init(); + protocol_init(); + rpc_init(); + service_init(); + shadow_init(); } diff --git a/nslcd/common.h b/nslcd/common.h index 3503e59..cf49625 100644 --- a/nslcd/common.h +++ b/nslcd/common.h @@ -85,6 +85,20 @@ MUST_USE char *dn2uid(MYLDAP_SESSION *session,const char *dn,char *buf,size_t bu /* transforms the uid into a DN by doing an LDAP lookup */ MUST_USE char *uid2dn(MYLDAP_SESSION *session,const char *uid,char *buf,size_t buflen); +/* these are the functions for initialising the database specific + modules */ +void alias_init(void); +void ether_init(void); +void group_init(void); +void host_init(void); +void netgroup_init(void); +void network_init(void); +void passwd_init(void); +void protocol_init(void); +void rpc_init(void); +void service_init(void); +void shadow_init(void); + /* these are the different functions that handle the database specific actions, see nslcd.h for the action descriptions */ int nslcd_alias_byname(TFILE *fp,MYLDAP_SESSION *session); @@ -141,8 +155,6 @@ int nslcd_shadow_all(TFILE *fp,MYLDAP_SESSION *session); log_log(LOG_WARNING,"nslcd_" __STRING(db) "_" __STRING(fn) "(): filter buffer too small"); \ return -1; \ } \ - /* build the list of attributes */ \ - db##_init(); \ /* perform a search for each search base */ \ for (i=0; (base=db##_bases[i])!=NULL; i++) \ { \ diff --git a/nslcd/ether.c b/nslcd/ether.c index c3ff43d..0f8ca94 100644 --- a/nslcd/ether.c +++ b/nslcd/ether.c @@ -94,7 +94,7 @@ static int mkfilter_ether_byether(const struct ether_addr *addr, attmap_ether_macAddress,buf2); } -static void ether_init(void) +void ether_init(void) { int i; /* set up search bases */ diff --git a/nslcd/group.c b/nslcd/group.c index 8f681eb..fa83de4 100644 --- a/nslcd/group.c +++ b/nslcd/group.c @@ -124,7 +124,7 @@ static int mkfilter_group_bymember(MYLDAP_SESSION *session, attmap_group_uniqueMember,dn); } -static void group_init(void) +void group_init(void) { int i; /* set up search bases */ diff --git a/nslcd/host.c b/nslcd/host.c index fdd327b..db27fa4 100644 --- a/nslcd/host.c +++ b/nslcd/host.c @@ -92,7 +92,7 @@ static int mkfilter_host_byaddr(const char *name, attmap_host_ipHostNumber,buf2); } -static void host_init(void) +void host_init(void) { int i; /* set up search bases */ diff --git a/nslcd/netgroup.c b/nslcd/netgroup.c index 5d80c81..6ba4e11 100644 --- a/nslcd/netgroup.c +++ b/nslcd/netgroup.c @@ -76,7 +76,7 @@ static int mkfilter_netgroup_byname(const char *name, attmap_netgroup_cn,buf2); } -static void netgroup_init(void) +void netgroup_init(void) { int i; /* set up search bases */ diff --git a/nslcd/network.c b/nslcd/network.c index 60eaa6c..a7a49d2 100644 --- a/nslcd/network.c +++ b/nslcd/network.c @@ -91,7 +91,7 @@ static int mkfilter_network_byaddr(const char *name, attmap_network_ipNetworkNumber,buf2); } -static void network_init(void) +void network_init(void) { int i; /* set up search bases */ diff --git a/nslcd/passwd.c b/nslcd/passwd.c index b934257..2b105d6 100644 --- a/nslcd/passwd.c +++ b/nslcd/passwd.c @@ -106,7 +106,7 @@ static int mkfilter_passwd_byuid(uid_t uid, attmap_passwd_uidNumber,(int)uid); } -static void passwd_init(void) +void passwd_init(void) { int i; /* set up search bases */ @@ -257,8 +257,6 @@ char *uid2dn(MYLDAP_SESSION *session,const char *uid,char *buf,size_t buflen) return NULL; /* set up attributes (we don't care, we just want the DN) */ attrs[0]=NULL; - /* initialize default base, scrope, etc */ - passwd_init(); /* we have to look up the entry */ mkfilter_passwd_byname(uid,filter,sizeof(filter)); for (i=0;(i