lists.arthurdejong.org
RSS feed

nss-pam-ldapd branch master updated. 0.9.4-5-ga726d29

[Date Prev][Date Next] [Thread Prev][Thread Next]

nss-pam-ldapd branch master updated. 0.9.4-5-ga726d29



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "nss-pam-ldapd".

The branch, master has been updated
       via  a726d291b0f6794abec0a0192cf2b2a742648e4a (commit)
      from  82e4423d4d17d2d09f82855bbae4bee62cc9c22a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://arthurdejong.org/git/nss-pam-ldapd/commit/?id=a726d291b0f6794abec0a0192cf2b2a742648e4a

commit a726d291b0f6794abec0a0192cf2b2a742648e4a
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Sun Sep 21 23:09:07 2014 +0200

    Fix issues with daemonising
    
    This fixes a problem with a buffer that could end up padded with
    garbage.
    
    This also clarifies the code a bit and adds extra logging for errors
    that could occur during daemonising.

diff --git a/nslcd/daemonize.c b/nslcd/daemonize.c
index 0d96f73..8edd81b 100644
--- a/nslcd/daemonize.c
+++ b/nslcd/daemonize.c
@@ -57,13 +57,13 @@ void daemonize_closefds(void)
 void daemonize_redirect_stdio(void)
 {
   /* close stdin, stdout and stderr */
-  close(0);   /* stdin */
-  close(1);   /* stdout */
-  close(2);   /* stderr */
+  (void)close(0);   /* stdin */
+  (void)close(1);   /* stdout */
+  (void)close(2);   /* stderr */
   /* reconnect to /dev/null */
-  open("/dev/null", O_RDWR);  /* stdin, fd=0 */
-  dup(0);     /* stdout, fd=1 */
-  dup(0);     /* stderr, fd=2 */
+  (void)open("/dev/null", O_RDWR);  /* stdin, fd=0 */
+  (void)dup(0);     /* stdout, fd=1 */
+  (void)dup(0);     /* stderr, fd=2 */
 }
 
 /* try to fill the buffer until EOF or error */
@@ -95,18 +95,27 @@ static int wait_for_response(int fd)
   int i, l, rc;
   char buffer[1024];
   /* read return code */
+  errno = 0;
   i = read_response(fd, (void *)&rc, sizeof(int));
+  log_log(LOG_DEBUG, "DEBUG: wait_for_response(): i=%d, rc=%d", i, rc);
   if (i != sizeof(int))
+  {
+    log_log(LOG_ERR, "wait_for_response(): read_response() returned %d 
(expected %d)",
+            i, (int)sizeof(int));
+    if (errno == 0)
+      errno = ENODATA;
     return -1;
+  }
   /* read string length */
   i = read_response(fd, (void *)&l, sizeof(int));
+  log_log(LOG_DEBUG, "DEBUG: wait_for_response(): i=%d, l=%d", i, l);
   if ((i != sizeof(int)) || (l <= 0))
     _exit(rc);
   /* read string */
   if ((size_t)l > (sizeof(buffer) - 1))
     l = sizeof(buffer) - 1;
   i = read_response(fd, buffer, l);
-  buffer[sizeof(buffer) - 1] = '\0';
+  buffer[l] = '\0';
   if (i == l)
     fprintf(stderr, "%s", buffer);
   _exit(rc);
@@ -200,22 +209,23 @@ int daemonize_daemon(void)
 
 void daemonize_ready(int status, const char *message)
 {
+  int l;
   if (daemonizefd >= 0)
   {
     /* we ignore any errors writing */
-    write(daemonizefd, &status, sizeof(int));
+    (void)write(daemonizefd, &status, sizeof(int));
     if ((message == NULL) || (message[0] == '\0'))
     {
-      status = 0;
-      write(daemonizefd, &status, sizeof(int));
+      l = 0;
+      (void)write(daemonizefd, &l, sizeof(int));
     }
     else
     {
-      status = strlen(message);
-      write(daemonizefd, &status, sizeof(int));
-      write(daemonizefd, message, status);
+      l = strlen(message);
+      (void)write(daemonizefd, &l, sizeof(int));
+      (void)write(daemonizefd, message, l);
     }
-    close(daemonizefd);
+    (void)close(daemonizefd);
     daemonizefd = -1;
   }
 }

-----------------------------------------------------------------------

Summary of changes:
 nslcd/daemonize.c |   38 ++++++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
nss-pam-ldapd
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits/