Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/nslcd/network.c
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2007-09-08 17:19:07 +0200
committerArthur de Jong <arthur@arthurdejong.org>2007-09-08 17:19:07 +0200
commit4b539318232ffc077eaa882963b9788d686610cb (patch)
treeee200bf041a84ff883270309064e6284d6f421be /nslcd/network.c
parent30423d96ecd243663906a3a1c13f1f0e90ac6330 (diff)
move filters definitions to the database modules themselves (and already define base and scope but don't use them yet)
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@383 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nslcd/network.c')
-rw-r--r--nslcd/network.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/nslcd/network.c b/nslcd/network.c
index 69049f5..2d6c4fe 100644
--- a/nslcd/network.c
+++ b/nslcd/network.c
@@ -57,7 +57,26 @@
#define MAXADDRSIZE 4
#endif /* HAVE_USERSEC_H */
-/* the attributes to request with searches */
+/* the search base for searches */
+const char *network_base = NULL;
+
+/* the search scope for searches */
+int network_scope = LDAP_SCOPE_DEFAULT;
+
+/* the basic search filter for searches */
+const char *network_filter = "(objectClass=ipNetwork)";
+
+/* the attributes used in searches
+ * ( nisSchema.2.7 NAME 'ipNetwork' SUP top STRUCTURAL
+ * DESC 'Abstraction of a network. The distinguished value of
+ * MUST ( cn $ ipNetworkNumber )
+ * MAY ( ipNetmaskNumber $ l $ description $ manager ) )
+ */
+const char *attmap_network_cn = "cn";
+const char *attmap_network_ipNetworkNumber = "ipNetworkNumber";
+/*const char *attmap_network_ipNetmaskNumber = "ipNetmaskNumber"; */
+
+/* the attribute list to request with searches */
static const char *network_attrs[3];
/* create a search filter for searching a network entry
@@ -71,8 +90,8 @@ static int mkfilter_network_byname(const char *name,
return -1;
/* build filter */
return mysnprintf(buffer,buflen,
- "(&(%s=%s)(%s=%s))",
- attmap_objectClass,attmap_network_objectClass,
+ "(&%s(%s=%s))",
+ network_filter,
attmap_network_cn,buf2);
}
@@ -85,18 +104,11 @@ static int mkfilter_network_byaddr(const char *name,
return -1;
/* build filter */
return mysnprintf(buffer,buflen,
- "(&(%s=%s)(%s=%s))",
- attmap_objectClass,attmap_network_objectClass,
+ "(&%s(%s=%s))",
+ network_filter,
attmap_network_ipNetworkNumber,buf2);
}
-static int mkfilter_network_all(char *buffer,size_t buflen)
-{
- return mysnprintf(buffer,buflen,
- "(%s=%s)",
- attmap_objectClass,attmap_network_objectClass);
-}
-
static void network_attrs_init(void)
{
network_attrs[0]=attmap_network_cn;
@@ -256,7 +268,6 @@ int nslcd_network_all(TFILE *fp)
{
int32_t tmpint32;
struct ent_context context;
- char filter[1024];
/* these are here for now until we rewrite the LDAP code */
struct netent result;
char buffer[1024];
@@ -270,10 +281,9 @@ int nslcd_network_all(TFILE *fp)
/* initialize context */
_nss_ldap_ent_context_init(&context);
/* loop over all results */
- mkfilter_network_all(filter,sizeof(filter));
network_attrs_init();
while ((retv=_nss_ldap_getent(&context,&result,buffer,sizeof(buffer),&errnop,
- NULL,filter,network_attrs,LM_NETWORKS,_nss_ldap_parse_net))==NSLCD_RESULT_SUCCESS)
+ NULL,network_filter,network_attrs,LM_NETWORKS,_nss_ldap_parse_net))==NSLCD_RESULT_SUCCESS)
{
/* write the result */
WRITE_INT32(fp,retv);