summary refs log tree commit diff
path: root/src/utmpset.c
diff options
context:
space:
mode:
authorGerrit Pape <pape@smarden.org>2003-02-25 12:51:38 +0000
committerGerrit Pape <pape@smarden.org>2003-02-25 12:51:38 +0000
commit2ea2e0c40b29e3a129d540e4c29bffcac304e55a (patch)
tree581fe2a05eb926605b0131eecfc834fab9c3411d /src/utmpset.c
parent761593c09e514e4219bbc187d4fafbabb970592c (diff)
downloadrunit-2ea2e0c40b29e3a129d540e4c29bffcac304e55a.tar.gz
runit-2ea2e0c40b29e3a129d540e4c29bffcac304e55a.tar.xz
runit-2ea2e0c40b29e3a129d540e4c29bffcac304e55a.zip
* doc/benefits.html: new.
  * doc/index.html, doc/upgrade.html: adapt.
  * etc/*/1, etc/*/3, etc/*/ctrlaltdel: set permissions on the magic files
    instead of creating and removing them (can make them symbolic links
    now); set PATH.
  * runit.h: new; centralize runit's compiled in magic file names.
  * runit.c: check permissions of magic files instead of sole existence;
    conditionally call reboot(RB_AUTOBOOT), reboot(RB_POWER_OFF),
    reboot(RB_HALT_SYSTEM) if possible; code cleanup.
  * runit-init.c: set permissions on magic files instead of creating or
    removing them; code cleanup.
  * runsvdir.c: detect and tolerate system time warp; code cleanup.
  * runsv.c, runsvchdir.c, runsvctrl.c, runsvstat.c, svwaitdown.c,
    svwaitup.c, utmpset.c: code cleanup.
0.8.0.
Diffstat (limited to 'src/utmpset.c')
-rw-r--r--src/utmpset.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/utmpset.c b/src/utmpset.c
index 7f9d7d2..7ea8481 100644
--- a/src/utmpset.c
+++ b/src/utmpset.c
@@ -4,6 +4,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <utmp.h>
+#include <string.h>
 #include "strerr.h"
 #include "sgetopt.h"
 #include "seek.h"
@@ -18,9 +19,7 @@
 
 const char *progname;
 
-void usage(void) {
-  strerr_die4x(1, "usage: ", progname, USAGE, "\n");
-}
+void usage(void) { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); }
 
 int utmp_logout(const char *line) {
   int fd;
@@ -33,8 +32,7 @@ int utmp_logout(const char *line) {
     strerr_die4sys(111, FATAL, "unable to lock: ", _PATH_UTMP, ": ");
 
   while (read(fd, &ut, sizeof(struct utmp)) == sizeof(struct utmp)) {
-    if (!ut.ut_name[0] || (str_diff(ut.ut_line, line) != 0))
-      continue;
+    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);
     if (time(&ut.ut_time) == -1) break;
@@ -62,8 +60,7 @@ int wtmp_logout(const char *line) {
     return(-1);
   }
   memset(&ut, 0, sizeof(struct utmp));
-  if ((len =str_len(line)) > UT_LINESIZE)
-    len =UT_LINESIZE -1;
+  if ((len =str_len(line)) > UT_LINESIZE) len =UT_LINESIZE -1;
   byte_copy(ut.ut_line, len, line);
   if (time(&ut.ut_time) == -1) {
     close(fd);
@@ -101,10 +98,9 @@ int main (int argc, const char * const *argv, const char * const *envp) {
   if (utmp_logout(*argv) == -1)
     strerr_die4x(111, WARNING, "unable to logout line ", *argv,
 		 " in utmp: no such entry");
-  if (wtmp) {
+  if (wtmp)
     if (wtmp_logout(*argv) == -1)
-      strerr_die4sys(111, WARNING, "unable to logout line ", *argv,
-		     " in wtmp: ");
-  }
-  exit(0);
+      strerr_die4sys(111, WARNING,
+		     "unable to logout line ", *argv, " in wtmp: ");
+  _exit(0);
 }