lists.arthurdejong.org
RSS feed

nss-pam-ldapd commit: r1316 - nss-pam-ldapd/nslcd

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

nss-pam-ldapd commit: r1316 - nss-pam-ldapd/nslcd



Author: arthur
Date: Fri Nov 26 12:39:58 2010
New Revision: 1316
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?view=rev&revision=1316

Log:
close all open file descriptors on start

Modified:
   nss-pam-ldapd/nslcd/nslcd.c

Modified: nss-pam-ldapd/nslcd/nslcd.c
==============================================================================
--- nss-pam-ldapd/nslcd/nslcd.c Wed Nov 17 21:08:09 2010        (r1315)
+++ nss-pam-ldapd/nslcd/nslcd.c Fri Nov 26 12:39:58 2010        (r1316)
@@ -653,6 +653,14 @@
     log_log(LOG_ERR,"daemon may already be active, cannot acquire lock (%s): 
%s",NSLCD_PIDFILE,strerror(errno));
     exit(EXIT_FAILURE);
   }
+  /* close all file descriptors (except stdin/out/err) */
+  i=sysconf(_SC_OPEN_MAX);
+  /* if the system does not have OPEN_MAX just close the first 32 and
+     hope we closed enough */
+  if (i<0)
+    i=32;
+  for (;i>3;i--)
+    close(i);
   /* daemonize */
   if ((!nslcd_debugging)&&(daemon(0,0)<0))
   {
--
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits