Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/nslcd/service.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/service.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/service.c')
-rw-r--r--nslcd/service.c51
1 files changed, 33 insertions, 18 deletions
diff --git a/nslcd/service.c b/nslcd/service.c
index 35799cc..3dde1bc 100644
--- a/nslcd/service.c
+++ b/nslcd/service.c
@@ -67,7 +67,31 @@
#define SERVICE_NUMBER htons(result->s_port)
#define SERVICE_PROTOCOL result->s_proto
+/* ( nisSchema.2.3 NAME 'ipService' SUP top STRUCTURAL
+ * DESC 'Abstraction an Internet Protocol service.
+ * Maps an IP port and protocol (such as tcp or udp)
+ * to one or more names; the distinguished value of
+ * the cn attribute denotes the service's canonical
+ * name'
+ * MUST ( cn $ ipServicePort $ ipServiceProtocol )
+ * MAY ( description ) )
+ */
+
+/* the search base for searches */
+const char *service_base = NULL;
+
+/* the search scope for searches */
+int service_scope = LDAP_SCOPE_DEFAULT;
+
+/* the basic search filter for searches */
+const char *service_filter = "(objectClass=ipService)";
+
/* the attributes to request with searches */
+const char *attmap_service_cn = "cn";
+const char *attmap_service_ipServicePort = "ipServicePort";
+const char *attmap_service_ipServiceProtocol = "ipServiceProtocol";
+
+/* the attribute list to request with searches */
static const char *service_attrs[4];
static int mkfilter_service_byname(const char *name,
@@ -84,14 +108,14 @@ static int mkfilter_service_byname(const char *name,
/* build filter */
if (*protocol!='\0')
return mysnprintf(buffer,buflen,
- "(&(%s=%s)(%s=%s)(%s=%s))",
- attmap_objectClass,attmap_service_objectClass,
+ "(&%s(%s=%s)(%s=%s))",
+ service_filter,
attmap_service_cn,buf2,
attmap_service_ipServiceProtocol,buf3);
else
return mysnprintf(buffer,buflen,
- "(&(%s=%s)(%s=%s))",
- attmap_objectClass,attmap_service_objectClass,
+ "(&%s(%s=%s))",
+ service_filter,
attmap_service_cn,buf2);
}
@@ -107,24 +131,17 @@ static int mkfilter_service_bynumber(int number,
/* build filter */
if (*protocol!='\0')
return mysnprintf(buffer,buflen,
- "(&(%s=%s)(%s=%d)(%s=%s))",
- attmap_objectClass,attmap_service_objectClass,
+ "(&%s(%s=%d)(%s=%s))",
+ service_filter,
attmap_service_ipServicePort,number,
attmap_service_ipServiceProtocol,buf3);
else
return mysnprintf(buffer,buflen,
- "(&(%s=%s)(%s=%d))",
- attmap_objectClass,attmap_service_objectClass,
+ "(&%s(%s=%d))",
+ service_filter,
attmap_service_ipServicePort,number);
}
-static int mkfilter_service_all(char *buffer,size_t buflen)
-{
- return mysnprintf(buffer,buflen,
- "(%s=%s)",
- attmap_objectClass,attmap_service_objectClass);
-}
-
static void service_attrs_init(void)
{
service_attrs[0]=attmap_service_cn;
@@ -325,7 +342,6 @@ int nslcd_service_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 servent result;
char buffer[1024];
@@ -339,10 +355,9 @@ int nslcd_service_all(TFILE *fp)
/* initialize context */
_nss_ldap_ent_context_init(&context);
/* loop over all results */
- mkfilter_service_all(filter,sizeof(filter));
service_attrs_init();
while ((retv=_nss_ldap_getent(&context,&result,buffer,sizeof(buffer),&errnop,
- NULL,filter,service_attrs,LM_SERVICES,_nss_ldap_parse_serv))==NSLCD_RESULT_SUCCESS)
+ NULL,service_filter,service_attrs,LM_SERVICES,_nss_ldap_parse_serv))==NSLCD_RESULT_SUCCESS)
{
/* write the result code */
WRITE_INT32(fp,retv);