lists.arthurdejong.org
RSS feed

nss-pam-ldapd branch master updated. 0.9.12-16-gb7841fc

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

nss-pam-ldapd branch master updated. 0.9.12-16-gb7841fc



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  b7841fc5647fafcea9258e13190ee2058dd4e7b0 (commit)
       via  ed4041ca4cd8a7642340b791f3782d2df52c1a8e (commit)
      from  cced2139509099064a916b3ed188edbbc87f4df4 (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 -----------------------------------------------------------------
https://arthurdejong.org/git/nss-pam-ldapd/commit/?id=b7841fc5647fafcea9258e13190ee2058dd4e7b0

commit b7841fc5647fafcea9258e13190ee2058dd4e7b0
Author: Consus <consus@ftml.net>
Date:   Sat Jun 29 09:53:11 2024 +0300

    Do not pass invalid file descriptor to FD_ISSET()
    
    Currently there is a race condition between the main thread and the
    workers threads. The main thread sets nslcd_serversocket to -1 without
    ensuring that all worker threads are stopped, giving them the window of
    opportunity to pass the now invalid fd to FD_ISSET(). This results in
    SIGBUS on musl libc.
    
    Closing the file descriptor is enough. I've also dropped close() in
    exithandler() to prevent misleading logs. The OS will close the socket
    anyway.

diff --git a/nslcd/nslcd.c b/nslcd/nslcd.c
index 2f52e01..4a212b0 100644
--- a/nslcd/nslcd.c
+++ b/nslcd/nslcd.c
@@ -221,13 +221,6 @@ static void sig_handler(int signum)
 /* do some cleaning up before terminating */
 static void exithandler(void)
 {
-  /* close socket if it's still in use */
-  if (nslcd_serversocket >= 0)
-  {
-    if (close(nslcd_serversocket))
-      log_log(LOG_WARNING, "problem closing server socket (ignored): %s",
-              strerror(errno));
-  }
   /* remove existing named socket */
   if (unlink(NSLCD_SOCKET) < 0)
   {
@@ -918,7 +911,6 @@ int main(int argc, char *argv[])
               i, strerror(errno));
   /* close server socket to trigger failures in threads waiting on accept() */
   close(nslcd_serversocket);
-  nslcd_serversocket = -1;
   /* if we can, wait a few seconds for the threads to finish */
 #ifdef HAVE_PTHREAD_TIMEDJOIN_NP
   ts.tv_sec = time(NULL) + 3;

https://arthurdejong.org/git/nss-pam-ldapd/commit/?id=ed4041ca4cd8a7642340b791f3782d2df52c1a8e

commit ed4041ca4cd8a7642340b791f3782d2df52c1a8e
Author: Consus <consus@ftml.net>
Date:   Sat Jun 29 09:53:10 2024 +0300

    Do not try to kill thread that was successfully joined
    
    Calling pthread_kill() after a successfull call pthread_timedjoin_np()
    is considered a UB because pthread_t object is no longer valid. This
    results in SIGSEGV at least on musl libc.

diff --git a/nslcd/nslcd.c b/nslcd/nslcd.c
index d54e2db..2f52e01 100644
--- a/nslcd/nslcd.c
+++ b/nslcd/nslcd.c
@@ -927,10 +927,16 @@ int main(int argc, char *argv[])
   for (i = 0; i < nslcd_cfg->threads; i++)
   {
 #ifdef HAVE_PTHREAD_TIMEDJOIN_NP
-    pthread_timedjoin_np(nslcd_threads[i], NULL, &ts);
-#endif /* HAVE_PTHREAD_TIMEDJOIN_NP */
+    if (pthread_timedjoin_np(nslcd_threads[i], NULL, &ts) == -1) {
+      if (errno != EBUSY)
+        log_log(LOG_ERR, "thread %d cannot be joined (ignoring): %s", i,
+                strerror(errno));
+      log_log(LOG_ERR, "thread %d is still running, shutting down anyway", i);
+    }
+#else
     if (pthread_kill(nslcd_threads[i], 0) == 0)
       log_log(LOG_ERR, "thread %d is still running, shutting down anyway", i);
+#endif /* HAVE_PTHREAD_TIMEDJOIN_NP */
   }
   /* we're done */
   return EXIT_SUCCESS;

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

Summary of changes:
 nslcd/nslcd.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
nss-pam-ldapd