chiark / gitweb /
Upgrade licence to GPLv3+.
[userv.git] / overlord.c
index 020fff09098fb36ad9d3c994a344214fe7270d2b..1cfba9b7cd6c01da5474d8b5acee00dad5eea534 100644 (file)
@@ -2,11 +2,14 @@
  * userv - overlord.c
  * daemon main program, collects request and forks handlers
  *
- * Copyright (C)1996-1997,1999 Ian Jackson
+ * userv is
+ * Copyright 1996-2017 Ian Jackson <ian@davenant.greenend.org.uk>.
+ * Copyright 2000      Ben Harris <bjh21@cam.ac.uk>
+ * Copyright 2016-2017 Peter Benie <pjb1008@cam.ac.uk>
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
@@ -15,8 +18,7 @@
  * General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with userv; if not, write to the Free Software
- * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with userv; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <unistd.h>
@@ -68,7 +70,7 @@ static void checkstalepipes(void) {
   if (time(&now) == -1) { syslog(LOG_ERR,"get current time: %m"); return; }
   dir= opendir(".");
   if (!dir) { syslog(LOG_ERR,"open directory " VARDIR ": %m"); return; }
-  while ((de= readdir(dir))) {
+  while ((errno=0, de= readdir(dir))) {
     if (fnmatch(PIPEPATTERN,de->d_name,FNM_PATHNAME|FNM_PERIOD)) continue;
     r= lstat(de->d_name,&stab); if (r && errno==ENOENT) continue;
     if (r) { syslog(LOG_ERR,"could not stat `" VARDIR "/%s': %m",de->d_name); continue; }
@@ -77,6 +79,7 @@ static void checkstalepipes(void) {
     if (unlink(de->d_name) && errno!=ENOENT)
       syslog(LOG_ERR,"could not remove stale pipe `%s': %m",de->d_name);
   }
+  if (errno) syslog(LOG_ERR,"read directory " VARDIR ": %m");
   if (closedir(dir)) syslog(LOG_ERR,"close directory " VARDIR ": %m");
 }
 
@@ -262,7 +265,8 @@ static void NONRETURNING startupsyscallerr(const char *what) {
 }
 
 int main(int argc, char *const *argv) {
-  int mfd, sfd, nfd, csocklen, e, r, becomedaemon;
+  int mfd, sfd, nfd, e, r, becomedaemon;
+  socklen_t csocklen;
   struct sigaction sigact;
   struct sockaddr_un ssockname, csockname;
   pid_t child, parentpid, sid;