summaryrefslogtreecommitdiff
path: root/nslcd-server.c
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2006-10-31 12:17:39 +0000
committerArthur de Jong <arthur@arthurdejong.org>2006-10-31 12:17:39 +0000
commitfe8fb00dd57714528535de7e3a8d42f64e7a79aa (patch)
treee8642fbc016b084f6db00950bfb4e6e0d8da784d /nslcd-server.c
parent93bda65a159e1f03b934fcb7050a5e1fba9bb2b7 (diff)
clear up protocol macros while implementing getpwuid() and {set,get,end}pwent() functions (last not yet on NSS side)
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/libnss_ldapd@34 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nslcd-server.c')
-rw-r--r--nslcd-server.c53
1 files changed, 23 insertions, 30 deletions
diff --git a/nslcd-server.c b/nslcd-server.c
index b78db33..ff3f7b9 100644
--- a/nslcd-server.c
+++ b/nslcd-server.c
@@ -116,53 +116,46 @@ int nslcd_server_open(void)
return sock;
}
+/* redifine the ERROR_OUT mechanism */
+#undef ERROR_OUT_READERROR
+#define ERROR_OUT_READERROR(fp) \
+ fclose(fp); \
+ log_log(LOG_DEBUG,"error reading from stream: %s",strerror(errno)); \
+ return;
+
/* read a request message, returns <0 in case of errors,
this function closes the socket */
-int nslcd_server_handlerequest(int sock)
+void nslcd_server_handlerequest(int sock)
{
- int32_t tmpint32, tmp2, type;
- size_t sz;
- char *key;
+ int32_t tmpint32;
FILE *fp;
/* create a stream object */
if ((fp=fdopen(sock,"w+"))==NULL)
{
close(sock);
- return -1;
+ return;
}
/* read the protocol version */
- READ_INT32(fp,tmp2);
- if (tmp2 != NSLCD_VERSION)
+ READ_TYPE(fp,tmpint32,int32_t);
+ if (tmpint32 != NSLCD_VERSION)
{
fclose(fp);
- log_log(LOG_DEBUG,"wrong nslcd version id (%d)", tmp2);
- return -1;
+ log_log(LOG_DEBUG,"wrong nslcd version id (%d)",(int)tmpint32);
+ return;
}
/* read the request type */
- READ_INT32(fp,type);
- /* read the request key */
- /* TODO: probably move this to the request specific function */
- READ_INT32(fp,sz);
- key=(char *)malloc(sz+1);
- if (key==NULL)
- return -1; /* FIXME: report memory allocation errors */
- READ(fp,key,sz);
- key[sz]=0;
- /* log request */
- log_log(LOG_DEBUG,"request id=%d key=%s",(int)type,key);
+ READ_TYPE(fp,tmpint32,int32_t);
/* handle request */
- switch (type)
+ switch (tmpint32)
{
- case NSLCD_RT_GETPWBYNAME:
- log_log(LOG_DEBUG,"GETPWBYNAME(%s)",key);
- nslcd_getpwnam(fp,key);
- break;
+ case NSLCD_RT_GETPWBYNAME: nslcd_getpwnam(fp); break;
+ case NSLCD_RT_GETPWBYUID: nslcd_getpwuid(fp); break;
+ case NSLCD_RT_GETPWALL: nslcd_getpwall(fp); break;
default:
- return -1;
+ log_log(LOG_DEBUG,"invalid request id (%d)",(int)tmpint32);
+ break;
}
-
+ /* we're done with the request */
fclose(fp);
-
- return 0; /* success */
-
+ return;
}