summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--doc/install.html12
-rw-r--r--doc/replaceinit.html4
-rw-r--r--package/CHANGES13
-rwxr-xr-xpackage/upgrade4
-rw-r--r--src/Makefile36
-rw-r--r--src/TARGETS2
-rw-r--r--src/reboot_system.h18
-rw-r--r--src/reboot_system.h28
-rw-r--r--src/runit.c36
-rw-r--r--src/runsv.c9
-rw-r--r--src/tryreboot.c6
-rw-r--r--src/tryuwtmp.c9
-rw-r--r--src/tryuwtmpx.c9
-rw-r--r--src/utmpset.c40
-rw-r--r--src/uw_tmp.h19
-rw-r--r--src/uw_tmp.h213
17 files changed, 165 insertions, 55 deletions
diff --git a/Makefile b/Makefile
index eeadc9d..c1c5628 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 DESTDIR=
 
-PACKAGE=runit-0.11.2
+PACKAGE=runit-0.11.4
 DIRS=doc man etc package src
 MANPAGES=runit.8 runit-init.8 runsvdir.8 runsv.8 svwaitdown.8 svwaitup.8 \
 utmpset.8 runsvchdir.8 runsvstat.8 runsvctrl.8 svlogd.8 chpst.8
diff --git a/doc/install.html b/doc/install.html
index 8ae1249..62b775a 100644
--- a/doc/install.html
+++ b/doc/install.html
@@ -17,14 +17,14 @@ If you don't have a <tt>/package</tt> directory, create it now:
   # chmod 1755 /package
 </pre>
 Download
-<a href="runit-0.11.2.tar.gz">runit-0.11.2.tar.gz</a> into <tt>/package</tt>
+<a href="runit-0.11.4.tar.gz">runit-0.11.4.tar.gz</a> into <tt>/package</tt>
 and unpack the archive
 <pre>
   # cd /package
-  # gunzip runit-0.11.2.tar
-  # tar -xpf runit-0.11.2.tar
-  # rm runit-0.11.2.tar
-  # cd admin/runit-0.11.2
+  # gunzip runit-0.11.4.tar
+  # tar -xpf runit-0.11.4.tar
+  # rm runit-0.11.4.tar
+  # cd admin/runit-0.11.4
 </pre>
 On MacOSX, do
 <pre>
@@ -43,7 +43,7 @@ hierarchy, do:
 </pre>
 To report success:
 <pre>
-  # mail pape-runit-0.11.2@smarden.org &lt;compile/sysdeps
+  # mail pape-runit-0.11.4@smarden.org &lt;compile/sysdeps
 </pre>
 Refer to <a href="replaceinit.html">replacing init</a> for
 replacing <i>init</i> with <i>runit</i>, or to
diff --git a/doc/replaceinit.html b/doc/replaceinit.html
index e12a165..7def19c 100644
--- a/doc/replaceinit.html
+++ b/doc/replaceinit.html
@@ -108,7 +108,7 @@ default Unix process no 1 <i>runit</i>.
 </pre>
 To report success:
 <pre>
-  # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.11.2@smarden.org
+  # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.11.4@smarden.org
 </pre>
 <hr>
 
@@ -189,7 +189,7 @@ Use <b>init 6</b> to reboot and <b>init 0</b> to halt a system that runs
 <p>
 To report success:
 <pre>
-  # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.11.2@smarden.org
+  # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.11.4@smarden.org
 </pre>
 <h3>Step 5: Service migration</h3>
 The goal is to migrate all services from <i>/etc/rc.*</i> scheme to the
diff --git a/package/CHANGES b/package/CHANGES
index f970fed..6a60fff 100644
--- a/package/CHANGES
+++ b/package/CHANGES
@@ -1,3 +1,14 @@
+  * runsv.c: don't use EOVERFLOW as it is not standard (thx Christoph
+    Scheurer).
+  * reboot_system.h1, reboot_system.h2, tryreboot.c: new; test if reboot()
+    function takes one or two arguments (solaris).
+  * runit.c: fallthrough stage 3: re-get stderr; sync() before reboot().
+  * uw_tmp.h1, uw_tmp.h2, tryuwtmp.c, tryuwtmpx.c: new; test for utmpx or
+    utmp support.
+  * utmpset.c: support systems with utmp or utmpx (solaris).
+  * Makefile: adapt.
+  * supports the solaris platform (thx Uffe Jakobsen).
+
 runit 0.11.2
 Tue, 23 Sep 2003 10:15:32 +0200
   * doc/useinit.html, etc/macosx/StartupItems/runit: don't use /etc/runit/2
@@ -46,12 +57,12 @@ Wed, 04 Jun 2003 13:56:33 +0200
   * man/svlogd.8: document -v option; minor.
   * etc/freebsd/3, etc/openbsd/3: check if magic files in /etc/runit/ are
     executable, not readable.
-  A
   * etc/*/getty-tty*/run: remove utmpset from script.
   * etc/*/getty-tty*/finish: new: run utmpset.
   * doc/replaceinit.html: adapt.
   * setuidgid.c: new: daemontools' setuidgid drop in replacement (not
     installed by default).
+  A
   * Makefile: build setuidgid.
   * doc/index.html: update.
 
diff --git a/package/upgrade b/package/upgrade
index 5892b48..90d16ca 100755
--- a/package/upgrade
+++ b/package/upgrade
@@ -7,9 +7,9 @@ test -d src || ( echo 'Wrong working directory.'; exit 1 )
 here=`env - PATH=$PATH pwd`
 parent=`dirname $here`
 
-echo 'Creating symlink runit -> runit-0.11.2...'
+echo 'Creating symlink runit -> runit-0.11.4...'
 rm -f runit
-ln -s runit-0.11.2 runit
+ln -s runit-0.11.4 runit
 mv -f runit ..
 
 echo 'Making command links in /command...'
diff --git a/src/Makefile b/src/Makefile
index abf64db..901d43d 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -63,7 +63,7 @@ svwaitup.o: compile sysdeps svwaitup.c
 svwaitdown.o: compile sysdeps svwaitdown.c
 	./compile svwaitdown.c
 
-utmpset.o: compile utmpset.c
+utmpset.o: compile sysdeps utmpset.c
 	./compile utmpset.c
 
 runsvchdir.o: compile runsvchdir.c
@@ -85,6 +85,14 @@ pmatch.o: compile pmatch.c
 fmt_ptime.o: compile sysdeps fmt_ptime.c
 	./compile fmt_ptime.c
 
+reboot_system.h: choose compile reboot_system.h1 reboot_system.h2
+	./choose c tryreboot reboot_system.h1 reboot_system.h2 > \
+	  reboot_system.h
+
+uw_tmp.h: compile uw_tmp.h1 uw_tmp.h2
+	( ./compile tryuwtmpx.c 2>/dev/null && cat uw_tmp.h2 >uw_tmp.h ) || \
+	( ./compile tryuwtmp.c 2>/dev/null && cat uw_tmp.h1 >uw_tmp.h )
+	rm -f tryuwtmp.o tryuwtmpx.o
 
 clean:
 	find . -name \*~ -exec rm -f {} \;
@@ -347,19 +355,21 @@ subgetopt.o: compile subgetopt.c subgetopt.h
 
 sysdeps: compile direntry.h hasflock.h hasmkffo.h hassgact.h \
 hassgprm.h hasshsgr.h haswaitp.h iopause.h load select.h systype \
-uint64.h
+uint64.h reboot_system.h uw_tmp.h
 	rm -f sysdeps
-	cat systype compile load >> sysdeps
-	grep sysdep direntry.h >> sysdeps
-	grep sysdep haswaitp.h >> sysdeps
-	grep sysdep hassgact.h >> sysdeps
-	grep sysdep hassgprm.h >> sysdeps
-	grep sysdep select.h >> sysdeps
-	grep sysdep uint64.h >> sysdeps
-	grep sysdep iopause.h >> sysdeps
-	grep sysdep hasmkffo.h >> sysdeps
-	grep sysdep hasflock.h >> sysdeps
-	grep sysdep hasshsgr.h >> sysdeps
+	cat systype compile load >>sysdeps
+	grep sysdep direntry.h >>sysdeps
+	grep sysdep haswaitp.h >>sysdeps
+	grep sysdep hassgact.h >>sysdeps
+	grep sysdep hassgprm.h >>sysdeps
+	grep sysdep select.h >>sysdeps
+	grep sysdep uint64.h >>sysdeps
+	grep sysdep iopause.h >>sysdeps
+	grep sysdep hasmkffo.h >>sysdeps
+	grep sysdep hasflock.h >>sysdeps
+	grep sysdep hasshsgr.h >>sysdeps
+	grep sysdep reboot_system.h >>sysdeps
+	grep sysdep uw_tmp.h >>sysdeps
 	cat sysdeps
 
 systype: find-systype.sh trycpp.c x86cpuid.c
diff --git a/src/TARGETS b/src/TARGETS
index 0d8ae6b..3b00443 100644
--- a/src/TARGETS
+++ b/src/TARGETS
@@ -25,6 +25,8 @@ chpst.o
 pmatch.o
 fmt_ptime.o
 uidgid.o
+reboot_system.h
+uw_tmp.h
 alloc.o
 alloc_re.o
 buffer.o
diff --git a/src/reboot_system.h1 b/src/reboot_system.h1
new file mode 100644
index 0000000..d4950c9
--- /dev/null
+++ b/src/reboot_system.h1
@@ -0,0 +1,8 @@
+#include <unistd.h>
+#include <sys/reboot.h>
+
+/* sysdep: -std reboot */
+
+int reboot_system(int what) {
+  return(reboot(what, (char *)0));
+}
diff --git a/src/reboot_system.h2 b/src/reboot_system.h2
new file mode 100644
index 0000000..b30d1e9
--- /dev/null
+++ b/src/reboot_system.h2
@@ -0,0 +1,8 @@
+#include <unistd.h>
+#include <sys/reboot.h>
+
+/* sysdep: +std reboot */
+
+int reboot_system(int what) {
+  return(reboot(what));
+}
diff --git a/src/runit.c b/src/runit.c
index 225333a..3882e50 100644
--- a/src/runit.c
+++ b/src/runit.c
@@ -14,6 +14,7 @@
 #include "ndelay.h"
 #include "wait.h"
 #include "open.h"
+#include "reboot_system.h"
 
 /* #define DEBUG */
 
@@ -69,8 +70,9 @@ int main (int argc, const char * const *argv, char * const *envp) {
 
   /* console */
   if ((ttyfd =open_write("/dev/console")) != -1) {
-    if (ioctl(ttyfd, TIOCSCTTY, (char *)NULL) != -1)
-      strerr_warn2(WARNING, "ioctl: ", &strerr_sys);
+#ifdef TIOCSCTTY
+    ioctl(ttyfd, TIOCSCTTY, (char *)0);
+#endif
     dup2(ttyfd, 0); dup2(ttyfd, 1); dup2(ttyfd, 2);
     if (ttyfd > 2) close(ttyfd);
   }
@@ -86,8 +88,8 @@ int main (int argc, const char * const *argv, char * const *envp) {
   ndelay_on(selfpipe[1]);
 
 #ifdef RB_DISABLE_CAD
-  /* activate ctrlaltdel handling, glibc */
-  if (RB_DISABLE_CAD == 0) reboot(0);
+  /* activate ctrlaltdel handling, glibc, dietlibc */
+  if (RB_DISABLE_CAD == 0) reboot_system(0);
 #endif
 
   strerr_warn3(INFO, "$Id$",
@@ -280,6 +282,12 @@ int main (int argc, const char * const *argv, char * const *envp) {
     }
   }
 
+  /* reget stderr */
+  if ((ttyfd =open_write("/dev/console")) != -1) {
+    dup2(ttyfd, 2);
+    if (ttyfd > 2) close(ttyfd);
+  }
+
 #ifdef RB_AUTOBOOT
   /* fallthrough stage 3 */
   strerr_warn2(INFO, "sending KILL signal to all processes...", 0);
@@ -287,20 +295,30 @@ int main (int argc, const char * const *argv, char * const *envp) {
 
   if ((stat(REBOOT, &s) != -1) && (s.st_mode & S_IXUSR)) {
     strerr_warn2(INFO, "system reboot.", 0);
-    reboot(RB_AUTOBOOT);
+    sync();
+    reboot_system(RB_AUTOBOOT);
   }
   else {
-#ifdef RB_HALT_SYSTEM
 #ifdef RB_POWER_OFF
     strerr_warn2(INFO, "power off...", 0);
-    reboot(RB_POWER_OFF);
+    sync();
+    reboot_system(RB_POWER_OFF);
     sleep(2);
 #endif
+#ifdef RB_HALT_SYSTEM
     strerr_warn2(INFO, "system halt.", 0);
-    reboot(RB_HALT_SYSTEM);
+    sync();
+    reboot_system(RB_HALT_SYSTEM);
+#else
+#ifdef RB_HALT
+    strerr_warn2(INFO, "system halt.", 0);
+    sync();
+    reboot_system(RB_HALT);
 #else
     strerr_warn2(INFO, "system reboot.", 0);
-    reboot(RB_AUTOBOOT);
+    sync();
+    reboot_system(RB_AUTOBOOT);
+#endif
 #endif
   }
 #endif
diff --git a/src/runsv.c b/src/runsv.c
index bcf1dfe..2d96e8b 100644
--- a/src/runsv.c
+++ b/src/runsv.c
@@ -65,6 +65,9 @@ void fatal(char *m) {
 void fatal2(char *m1, char *m2) {
   strerr_die6sys(111, "runsv ", dir, ": fatal: ", m1, m2, ": ");
 }
+void fatalx(char *m1, char *m2) {
+  strerr_die5x(111, "runsv ", dir, ": fatal: ", m1, m2);
+}
 void warn(char *m) {
   strerr_warn5("runsv ", dir, ": warning: ", m, ": ", &strerr_sys);
 }
@@ -370,10 +373,8 @@ int main(int argc, char **argv) {
 
   if (mkdir("supervise", 0700) == -1) {
     if ((fd =readlink("supervise", buf, 256)) != -1) {
-      if (fd == 256) {
-	errno =EOVERFLOW;
-	fatal("unable to readlink ./supervise");
-      }
+      if (fd == 256)
+	fatalx("unable to readlink ./supervise: ", "name too long");
       buf[fd] =0;
       mkdir(buf, 0700);
     }
diff --git a/src/tryreboot.c b/src/tryreboot.c
new file mode 100644
index 0000000..aefc703
--- /dev/null
+++ b/src/tryreboot.c
@@ -0,0 +1,6 @@
+#include <unistd.h>
+#include <sys/reboot.h>
+
+int main(void) {
+  return(reboot(0));
+}
diff --git a/src/tryuwtmp.c b/src/tryuwtmp.c
new file mode 100644
index 0000000..2192a1e
--- /dev/null
+++ b/src/tryuwtmp.c
@@ -0,0 +1,9 @@
+#include <sys/types.h>
+#include <utmp.h>
+
+struct utmp ut;
+
+int main(void) {
+  char *s =ut.ut_name;
+  return(0);
+}
diff --git a/src/tryuwtmpx.c b/src/tryuwtmpx.c
new file mode 100644
index 0000000..d711c01
--- /dev/null
+++ b/src/tryuwtmpx.c
@@ -0,0 +1,9 @@
+#include <sys/types.h>
+#include <utmpx.h>
+
+struct futmpx ut;
+
+int main(void) {
+  char *s =ut.ut_name;
+  return(0);
+}
diff --git a/src/utmpset.c b/src/utmpset.c
index 7ea8481..0b0e6a5 100644
--- a/src/utmpset.c
+++ b/src/utmpset.c
@@ -3,8 +3,8 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <utmp.h>
 #include <string.h>
+#include "uw_tmp.h"
 #include "strerr.h"
 #include "sgetopt.h"
 #include "seek.h"
@@ -23,21 +23,24 @@ void usage(void) { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); }
 
 int utmp_logout(const char *line) {
   int fd;
-  struct utmp ut;
+  uw_tmp ut;
   int ok =-1;
 
-  if ((fd =open(_PATH_UTMP, O_RDWR, 0)) < 0)
-    strerr_die4sys(111, FATAL, "unable to open ", _PATH_UTMP, ": ");
+  if ((fd =open(UW_TMP_UFILE, O_RDWR, 0)) < 0)
+    strerr_die4sys(111, FATAL, "unable to open ", UW_TMP_UFILE, ": ");
   if (lock_ex(fd) == -1)
-    strerr_die4sys(111, FATAL, "unable to lock: ", _PATH_UTMP, ": ");
+    strerr_die4sys(111, FATAL, "unable to lock: ", UW_TMP_UFILE, ": ");
 
-  while (read(fd, &ut, sizeof(struct utmp)) == sizeof(struct utmp)) {
+  while (read(fd, &ut, sizeof(uw_tmp)) == sizeof(uw_tmp)) {
     if (!ut.ut_name[0] || (str_diff(ut.ut_line, line) != 0)) continue;
-    memset(ut.ut_name, 0, UT_NAMESIZE);
-    memset(ut.ut_host, 0, UT_HOSTSIZE);
+    memset(ut.ut_name, 0, sizeof ut.ut_name);
+    memset(ut.ut_host, 0, sizeof ut.ut_host);
     if (time(&ut.ut_time) == -1) break;
-    if (lseek(fd, -(off_t)sizeof(struct utmp), SEEK_CUR) == -1) break;
-    if (write(fd, &ut, sizeof(struct utmp)) != sizeof(struct utmp)) break;
+#ifdef DEAD_PROCESS
+    ut.ut_type =DEAD_PROCESS;
+#endif
+    if (lseek(fd, -(off_t)sizeof(uw_tmp), SEEK_CUR) == -1) break;
+    if (write(fd, &ut, sizeof(uw_tmp)) != sizeof(uw_tmp)) break;
     ok =1;
     break;
   }
@@ -48,25 +51,28 @@ int wtmp_logout(const char *line) {
   int fd;
   int len;
   struct stat st;
-  struct utmp ut;
+  uw_tmp ut;
 
-  if ((fd = open_append(_PATH_WTMP)) == -1)
-    strerr_die4sys(111, FATAL, "unable to open ", _PATH_WTMP, ": ");
+  if ((fd = open_append(UW_TMP_WFILE)) == -1)
+    strerr_die4sys(111, FATAL, "unable to open ", UW_TMP_WFILE, ": ");
   if (lock_ex(fd) == -1)
-    strerr_die4sys(111, FATAL, "unable to lock ", _PATH_WTMP, ": ");
+    strerr_die4sys(111, FATAL, "unable to lock ", UW_TMP_WFILE, ": ");
 
   if (fstat(fd, &st) == -1) {
     close(fd);
     return(-1);
   }
-  memset(&ut, 0, sizeof(struct utmp));
-  if ((len =str_len(line)) > UT_LINESIZE) len =UT_LINESIZE -1;
+  memset(&ut, 0, sizeof(uw_tmp));
+  if ((len =str_len(line)) > sizeof ut.ut_line) len =sizeof ut.ut_line -2;
   byte_copy(ut.ut_line, len, line);
   if (time(&ut.ut_time) == -1) {
     close(fd);
     return(-1);
   }
-  if (write(fd, &ut, sizeof(struct utmp)) != sizeof(struct utmp)) {
+#ifdef DEAD_PROCESS
+  ut.ut_type =DEAD_PROCESS;
+#endif
+  if (write(fd, &ut, sizeof(uw_tmp)) != sizeof(uw_tmp)) {
     ftruncate(fd, st.st_size);
     close(fd);
     return(-1);
diff --git a/src/uw_tmp.h1 b/src/uw_tmp.h1
new file mode 100644
index 0000000..57231fb
--- /dev/null
+++ b/src/uw_tmp.h1
@@ -0,0 +1,9 @@
+#include <sys/types.h>
+#include <utmp.h>
+
+/* sysdep: -utmpx */
+
+#define UW_TMP_UFILE _PATH_UTMP
+#define UW_TMP_WFILE _PATH_WTMP
+
+typedef struct utmp uw_tmp;
diff --git a/src/uw_tmp.h2 b/src/uw_tmp.h2
new file mode 100644
index 0000000..ae9542e
--- /dev/null
+++ b/src/uw_tmp.h2
@@ -0,0 +1,13 @@
+#include <sys/types.h>
+#include <utmpx.h>
+
+/* sysdep: +utmpx */
+
+#define UW_TMP_UFILE _UTMPX_FILE
+#define UW_TMP_WFILE _WTMPX_FILE
+
+#ifndef ut_time
+#define ut_time ut_tv.tv_sec
+#endif
+
+typedef struct futmpx uw_tmp;