runit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 136023b62560499c6a72343cc9837db8a24d13a1
parent 4e63019882180180f3e8c8d1fc44b87fe50b1204
Author: Gerrit Pape <pape@smarden.org>
Date:   Wed, 28 Aug 2002 13:10:06 +0000

  * utmpset: avoids libutil; compiles with deitlibc; built by default.
  * doc/usedietlibc.html: fix description.
  * stage 3: restart getties after stopping services.
  * getty-*/run: add utmpset.
0.5.0.

Diffstat:
MMakefile | 5+++--
Mdebian/changelog | 6++++++
Mdebian/postinst | 2+-
Mdebian/rules | 38+++++++++++++++++++-------------------
Mdoc/index.html | 45+++++++++++++++++++++++----------------------
Mdoc/install.html | 10+++++-----
Mdoc/replaceinit.html | 4++--
Mdoc/runit-init.8.html | 2+-
Mdoc/runit.8.html | 2+-
Adoc/upgrade.html | 25+++++++++++++++++++++++++
Mdoc/usedietlibc.html | 36+++++++++---------------------------
Ddoc/utmpset.html | 53-----------------------------------------------------
Metc/debian/3 | 3+++
Metc/debian/getty-tty5/run | 1+
Metc/freebsd/3 | 3+++
Metc/freebsd/getty-ttyv4/run | 1+
Metc/openbsd/3 | 3+++
Metc/openbsd/getty-ttyC4/run | 1+
Mman/runit-init.8 | 3++-
Mman/runit.8 | 3++-
Aman/utmpset.8 | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpackage/CHANGES | 7+++++++
Mpackage/compile | 2+-
Mpackage/upgrade | 4++--
Msrc/Makefile | 14+++++++-------
Msrc/TARGETS | 5+++--
Msrc/utmpset.c | 70+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
27 files changed, 253 insertions(+), 150 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,8 +1,9 @@ DESTDIR= -PACKAGE=runit-0.4.1 +PACKAGE=runit-0.5.0 DIRS=doc man etc package src -MANPAGES=man/runit.8 man/runit-init.8 man/svwaitdown.8 man/svwaitup.8 +MANPAGES=man/runit.8 man/runit-init.8 man/svwaitdown.8 man/svwaitup.8 \ +man/utmpset.8 all: clean .manpages $(PACKAGE).tar.gz diff --git a/debian/changelog b/debian/changelog @@ -1,3 +1,9 @@ +runit (0.5.0-1) sarge; urgency=low + + * See /package/admin/runit/package/CHANGES. + + -- Gerrit Pape <pape@smarden.org> Wed, 28 Aug 2002 13:23:11 +0200 + runit (0.4.1-1) woody; urgency=low * See /package/admin/runit/package/CHANGES. diff --git a/debian/postinst b/debian/postinst @@ -25,7 +25,7 @@ set -e case "$1" in configure) ( \ - cd /package/admin/runit-0.4.1 + cd /package/admin/runit-0.5.0 package/upgrade ) ;; diff --git a/debian/rules b/debian/rules @@ -23,18 +23,18 @@ build-stamp: # $(MAKE) #/usr/bin/docbook-to-man debian/runit.sgml > runit.1 - tar xfzvp runit-0.4.1.tar.gz + tar xfzvp runit-0.5.0.tar.gz ( \ - cd admin/runit-0.4.1 ; \ + cd admin/runit-0.5.0 ; \ echo 'diet gcc -O2 -Wall' > src/conf-cc ; \ echo 'diet gcc -s -Os -pipe' > src/conf-ld ; \ package/compile ; \ echo 'gcc -O2 -Wall' > src/conf-cc ; \ echo 'gcc -s' > src/conf-ld ; \ ( cd compile ; make utmpset ) ; \ - echo "/package/admin/runit-0.4.1" > compile/home ; \ + echo "/package/admin/runit-0.5.0" > compile/home ; \ rm -f compile/src ; \ - ln -s /package/admin/runit-0.4.1/src compile/src ; \ + ln -s /package/admin/runit-0.5.0/src compile/src ; \ install -m0755 compile/utmpset command/utmpset ; \ ) touch build-stamp @@ -62,40 +62,40 @@ install: build chmod 1755 debian/runit/package cp -a admin debian/runit/package/ - rm -rf debian/runit/package/admin/runit-0.4.1/compile - cp -a debian/runit/package/admin/runit-0.4.1/man . - rm -rf debian/runit/package/admin/runit-0.4.1/man - cp -a debian/runit/package/admin/runit-0.4.1/doc . - rm -rf debian/runit/package/admin/runit-0.4.1/doc - cp -a debian/runit/package/admin/runit-0.4.1/etc . - rm -rf debian/runit/package/admin/runit-0.4.1/etc - cp -a debian/runit/package/admin/runit-0.4.1/package . + rm -rf debian/runit/package/admin/runit-0.5.0/compile + cp -a debian/runit/package/admin/runit-0.5.0/man . + rm -rf debian/runit/package/admin/runit-0.5.0/man + cp -a debian/runit/package/admin/runit-0.5.0/doc . + rm -rf debian/runit/package/admin/runit-0.5.0/doc + cp -a debian/runit/package/admin/runit-0.5.0/etc . + rm -rf debian/runit/package/admin/runit-0.5.0/etc + cp -a debian/runit/package/admin/runit-0.5.0/package . # /etc/runit - cp -p admin/runit-0.4.1/etc/debian/[123] \ + cp -p admin/runit-0.5.0/etc/debian/[123] \ debian/runit/etc/runit/ - cp -p admin/runit-0.4.1/etc/debian/ctrlaltdel \ + cp -p admin/runit-0.5.0/etc/debian/ctrlaltdel \ debian/runit/etc/runit/ - cp -p admin/runit-0.4.1/etc/debian/getty-tty5/run.utmpset \ + cp -p admin/runit-0.5.0/etc/debian/getty-tty5/run.utmpset \ debian/runit/etc/runit/getty-5/run # runit programs - cp -p debian/runit/package/admin/runit-0.4.1/command/runit* \ + cp -p debian/runit/package/admin/runit-0.5.0/command/runit* \ debian/runit/sbin/ # cleanup - rm -rf debian/runit/package/admin/runit-0.4.1/compile + rm -rf debian/runit/package/admin/runit-0.5.0/compile # create debian/links rm -f debian/links for i in \ - `cat debian/runit/package/admin/runit-0.4.1/package/commands` ; \ + `cat debian/runit/package/admin/runit-0.5.0/package/commands` ; \ do \ echo "/package/admin/runit/command/$$i /command/$$i" \ >> debian/links ; \ done # for i in \ -# `cat debian/runit/package/admin/runit-0.4.1/package/commands` ; \ +# `cat debian/runit/package/admin/runit-0.5.0/package/commands` ; \ # do \ # echo "/command/$$i /usr/local/bin/$$i" \ # >> debian/links ; \ diff --git a/doc/index.html b/doc/index.html @@ -9,6 +9,7 @@ <h1>runit - minimal replacement for <i>sysvinit</i></h1> <hr> <a href="install.html">How to install runit</a><br> +<a href="upgrade.html">Upgrading from previous versions of runit</a><br> <a href="replaceinit.html">How to replace init</a><br> <a href="usedietlibc.html">How to use dietlibc</a> <p> @@ -19,9 +20,8 @@ Dependencies and runlevels</a> <a href="runit.8.html">The <tt>runit</tt> program</a><br> <a href="runit-init.8.html">The <tt>runit-init</tt> program</a><br> <a href="svwaitdown.8.html">The <tt>svwaitdown</tt> program</a><br> -<a href="svwaitup.8.html">The <tt>svwaitup</tt> program</a> -<p> -<a href="utmpset.html">The <tt>utmpset</tt> program</a> +<a href="svwaitup.8.html">The <tt>svwaitup</tt> program</a><br> +<a href="utmpset.8.html">The <tt>utmpset</tt> program</a> <hr> <i>runit</i> cooperates with the <a href="http://cr.yp.to/daemontools.html">daemontools</a> package to create @@ -81,20 +81,21 @@ for an example, the amount of code in process no 1 should be minimal. <hr> <b><i>runit</i> in use</b>: I replaced <i>sysvinit</i> with <i>runit</i> on several server systems and a laptop, all running Debian/GNU Linux woody -or potato, some months ago and did not encounter any problems. -This is from the second machine where I replaced <i>sysvinit</i> with -<i>runit</i>: +or potato, some months ago and did not encounter any problems. Of course +also the <tt>smarden.org</tt> content server is running with <i>runit</i> +as process no 1. This is from the second machine where I replaced +<i>sysvinit</i> with <i>runit</i>: <pre> # strings /proc/1/exe |grep Id &#36;Id: runit.c,v 1.5 2001/12/30 16:28:53 pape Exp &#36; # uptime - 19:44:10 up 139 days, 1:09, 3 users, load average: 0.00, 0.00, 0.00 + 14:59:36 up 240 days, 21:10, 2 users, load average: 0.00, 0.00, 0.00 # ps axuw |head USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 24 24 ? S 2001 0:06 runit - root 2 0.0 0.0 0 0 ? SW 2001 0:09 [kflushd] - root 3 0.0 0.0 0 0 ? SW 2001 0:07 [kupdate] - root 4 0.0 0.0 0 0 ? SW 2001 0:35 [kswapd] + root 2 0.0 0.0 0 0 ? SW 2001 0:12 [kflushd] + root 3 0.0 0.0 0 0 ? SW 2001 0:14 [kupdate] + root 4 0.0 0.0 0 0 ? SW 2001 1:09 [kswapd] root 5 0.0 0.0 0 0 ? SW 2001 0:00 [keventd] root 149 0.0 0.1 1692 120 ? S 2001 0:00 /usr/sbin/cron root 152 0.0 0.0 2196 0 ? SW 2001 0:00 [svscanboot] @@ -107,16 +108,14 @@ This is from the second machine where I replaced <i>sysvinit</i> with |-kswapd |-kupdate `-svscanboot-+-readproctitle - `-svscan-+-2*[supervise---socklog] + `-svscan-+-5*[supervise---tcpserver] |-18*[supervise---multilog] - |-5*[supervise---tcpserver] |-supervise---qmail-send-+-qmail-clean | |-qmail-lspawn | `-qmail-rspawn - |-supervise---sshd---sshd---bash---bash---pstree + |-supervise---sshd---sshd---sshd---bash---bash---ps |-supervise---bash |-2*[supervise---getty] - |-supervise---uncat |-supervise---dhcpd-2.2.x |-supervise---dnscache |-supervise---tinydns @@ -127,25 +126,27 @@ This is from the second machine where I replaced <i>sysvinit</i> with |-2*[supervise---vboxgetty] |-supervise---clockspeed |-supervise---squid---unlinkd - `-supervise---dhclient-2.2.x + |-supervise---dhclient-2.2.x + |-2*[supervise---socklog] + `-supervise---uncat </pre> This is from a more busy system: <pre> # strings /proc/1/exe |grep Id &#36;Id: runit.c,v 1.6 2002/01/29 18:56:36 pape Exp &#36; # uptime - 19:46:24 up 99 days, 19:56, 3 users, load average: 0.15, 0.12, 0.12 + 15:04:34 up 201 days, 15:34, 3 users, load average: 0.08, 0.03, 0.01 # ps axuw |head USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 24 0 ? SW Feb07 0:05 runit root 2 0.0 0.0 0 0 ? SW Feb07 0:01 [keventd] - root 3 0.0 0.0 0 0 ? SW Feb07 1:10 [kapm-idled] - root 4 0.0 0.0 0 0 ? SWN Feb07 1:09 [ksoftirqd_CPU0] - root 5 0.0 0.0 0 0 ? SW Feb07 13:23 [kswapd] - root 6 0.0 0.0 0 0 ? SW Feb07 0:00 [bdflush] - root 7 0.0 0.0 0 0 ? SW Feb07 10:18 [kupdated] + root 3 0.0 0.0 0 0 ? SW Feb07 1:45 [kapm-idled] + root 4 0.0 0.0 0 0 ? SWN Feb07 1:21 [ksoftirqd_CPU0] + root 5 0.0 0.0 0 0 ? SW Feb07 31:40 [kswapd] + root 6 0.0 0.0 0 0 ? SW Feb07 0:06 [bdflush] + root 7 0.0 0.0 0 0 ? SW Feb07 14:26 [kupdated] root 53 0.0 0.0 0 0 ? SW Feb07 0:00 [msp3410 [auto]] - daemon 115 0.0 0.0 1412 8 ? S Feb07 0:00 /sbin/portmap + daemon 115 0.0 0.0 1412 0 ? SW Feb07 0:00 /sbin/portmap </pre> <hr> See <a href="install.html">How to install runit</a> for installing diff --git a/doc/install.html b/doc/install.html @@ -13,14 +13,14 @@ Check that you have the recent version of <a href="http://cr.yp.to/daemontools.html">daemontools</a> installed. <p> Download -<a href="runit-0.4.1.tar.gz">runit-0.4.1.tar.gz</a> into <tt>/package</tt> +<a href="runit-0.5.0.tar.gz">runit-0.5.0.tar.gz</a> into <tt>/package</tt> and unpack the archive <pre> # cd /package - # gunzip runit-0.4.1.tar - # tar -xpf runit-0.4.1.tar - # rm runit-0.4.1.tar - # cd admin/runit-0.4.1 + # gunzip runit-0.5.0.tar + # tar -xpf runit-0.5.0.tar + # rm runit-0.5.0.tar + # cd admin/runit-0.5.0 </pre> Compile and install the <i>runit</i> programs <pre> diff --git a/doc/replaceinit.html b/doc/replaceinit.html @@ -107,7 +107,7 @@ default Unix process no 1 <i>runit</i>. </pre> To report success: <pre> - # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.4.1@smarden.org + # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.5.0@smarden.org </pre> <hr> @@ -187,7 +187,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.4.1@smarden.org + # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.5.0@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/doc/runit-init.8.html b/doc/runit-init.8.html @@ -38,7 +38,7 @@ files are touched. Then a CONT signal is sent to <B><I>runit</B>(8)</I>. </DD> returns 111 on error, 0 in all other cases. <H2><A NAME="sect4">See Also</A></H2> <I>runit(8)</I>, <I>svwaitdown(8)</I>, -<I>svwaitup(8)</I> <P> +<I>svwaitup(8)</I>, <I>utmpset(8)</I> <P> <I>http://smarden.org/runit/</I> <H2><A NAME="sect5">Author</A></H2> Gerrit Pape &lt;pape@smarden.org&gt; diff --git a/doc/runit.8.html b/doc/runit.8.html @@ -47,7 +47,7 @@ if <B>runit</B> receives an INT signal, a ctrl-alt-del keyboard request is triggered. <H2><A NAME="sect8">See Also</A></H2> -<I>runit-init(8)</I>, <I>svwaitdown(8)</I>, <I>svwaitup(8)</I> <P> +<I>runit-init(8)</I>, <I>svwaitdown(8)</I>, <I>svwaitup(8)</I>, <I>utmpset(8)</I> <P> <I>http://smarden.org/runit/</I> <H2><A NAME="sect9">Author</A></H2> diff --git a/doc/upgrade.html b/doc/upgrade.html @@ -0,0 +1,25 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<title>runit - upgrading from previous versions</title> +</head> +<body> +<a href="http://smarden.org/pape/">G. Pape</a><br> +<a href="index.html">runit</a><br> +<hr> +<h1>runit - upgrading from previous versions</h1> +<hr> + +<h3>0.4.1 to 0.5.0</h3> +<p> +There is a new program: <tt>utmpset</tt>. This program is used in the +getty run scripts to enable local login accounting. You might want to adapt +your getty run scripts <tt>/service/getty-*/run</tt> and stage 3 +<tt>/etc/runit/3</tt>, see the examples in <tt>/package/admin/runit/etc/</tt>. +<hr> +<address><a href="mailto:pape@smarden.org"> +Gerrit Pape &lt;pape@smarden.org&gt; +</a></address> +<small>$Id$</small> +</body> +</html> diff --git a/doc/usedietlibc.html b/doc/usedietlibc.html @@ -9,40 +9,22 @@ <hr> <h1>runit - use dietlibc</h1> <hr> -Check that you have the recent version of +To recompile the <i>socklog</i> programs with the +<a href="http://www.fefe.de/dietlibc/">diet libc</a>, check that you have +the recent version of <a href="http://www.fefe.de/dietlibc/">dietlibc</a> installed. <p> -Change to the source directory of <i>runit</i>: +Change to the package directory of <i>runit</i>: <pre> - # cd /package/admin/runit/src + # cd /package/admin/runit/ </pre> -Download -<a href="http://smarden.org/pape/djb/manpages/daemontools-pd-0.76.tar.gz"> -daemontools-pd-0.76.tar.gz</a> -into <tt>/package/admin/runit/src</tt> and unpack the archive (this -contains code from the daemontools-0.76 package which are in the Public -domain): +Change the <tt>conf-cc</tt> and <tt>conf-ld</tt> to use <tt>diet</tt>: <pre> - # gunzip daemontools-pd-0.76.tar - # tar -xpf daemontools-pd-0.76.tar - # rm daemontools-pd-0.76.tar + # echo 'diet gcc -O2 -Wall' &gt;src/conf-cc + # echo 'diet gcc -s -Os -pipe' &gt;src/conf-ld </pre> -Tell <i>runit</i> to use this archive instead of the <i>daemontools</i> -sources: +Rebuild and install the <i>runit</i> programs: <pre> - # rm -f support - # ln -s daemontools-pd-0.76 support -</pre> -Change the <tt>cc</tt> and <tt>ld</tt> settings for -<tt>support</tt> to use <tt>diet</tt>: -<pre> - # echo 'diet gcc -O2 -Wall' &gt; support/conf-cc - # echo 'diet gcc -s -Os -pipe' &gt; support/conf-ld -</pre> -Finally rebuild and install the <i>runit</i> programs: -<pre> - # make clean - # cd .. # package/install </pre> <hr> diff --git a/doc/utmpset.html b/doc/utmpset.html @@ -1,53 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html> -<head> -<title>runit - the utmpset program</title> -</head> -<body> -<a href="http://smarden.org/pape/">G. Pape</a><br> -<a href="index.html">runit</a><br> -<hr> -<h1>runit - the utmpset program</h1> -<hr> -Ordinary <i>init</i> processes handle <tt>utmp</tt> file records for -local login accounting. The <a href="runit.8.html">runit</a> program doesn't -include code to update the <tt>utmp</tt> file, the <tt>getty</tt> processes -are handled the same as all other services. So normally on systems running -with <i>runit</i> local login accounting doesn't work as expected: The -<tt>utmp</tt> file is not updated after a user logs out. -<p> -This can be done by the <i>utmpset</i> program. -<p> -To compile the <i>utmpset</i> program change to the <i>runit</i> package's -source directory: -<pre> - # cd /package/admin/runit/src -</pre> -The <i>utmpset</i> program cannot be used with the -<a href="http://www.fefe.de/dietlibc/">diet libc</a> since it needs to be -linked against <tt>libutil</tt>. Change <tt>conf-cc</tt> and <tt>conf-ld</tt> -if necessary. -<p> -Then build and install the <i>utmpset</i> program: -<pre> - # make utmpset - # install -m0755 utmpset ../command/utmpset -</pre> -For each <tt>getty</tt> service, add a line to the corresponding <tt>run</tt> -script like this: -<pre> - #!/bin/sh - /package/admin/runit/command/utmpset -w tty5 - exec /sbin/getty 38400 tty5 linux -</pre> -This will cause the <tt>utmp</tt> record for line <tt>tty5</tt> to be cleared -before the <tt>getty</tt> is started; <i>utmpset</i> additionally writes a -<tt>wtmp</tt> record if the <tt>-w</tt> option is given. Login accounting -then works as expected for this line. -<hr> -<address><a href="mailto:pape@smarden.org"> -Gerrit Pape &lt;pape@smarden.org&gt; -</a></address> -<small>$Id$</small> -</body> -</html> diff --git a/etc/debian/3 b/etc/debian/3 @@ -13,6 +13,9 @@ echo 'Stopping services...' /command/svwaitdown -t350 /service/* || \ ( echo 'Killing services...' ; /command/svc -k /service/* ) +echo 'Restarting getties...' +/command/svc -u /service/getty-* + echo 'Stopping log services...' /command/svc -d /service/*/log /command/svwaitdown -t35 /service/*/log diff --git a/etc/debian/getty-tty5/run b/etc/debian/getty-tty5/run @@ -1,2 +1,3 @@ #!/bin/sh +/package/admin/runit/command/utmpset -w tty5 exec /sbin/getty 38400 tty5 linux diff --git a/etc/freebsd/3 b/etc/freebsd/3 @@ -6,6 +6,9 @@ svc -d /service/* svwaitdown -t350 /service/* || ( echo 'Killing services...' ; \ svc -k /service/* ; svwaitdown /service/* ) +echo 'Restarting getties...' +/command/svc -u /service/getty-* + echo 'Stopping log services...' svc -d /service/*/log svwaitdown -t35 /service/*/log || ( echo 'Killing log services...' ; \ diff --git a/etc/freebsd/getty-ttyv4/run b/etc/freebsd/getty-ttyv4/run @@ -1,2 +1,3 @@ #!/bin/sh +/package/admin/runit/command/utmpset -w ttyv4 exec /usr/libexec/getty Pc ttyv4 diff --git a/etc/openbsd/3 b/etc/openbsd/3 @@ -11,6 +11,9 @@ svc -d /service/* svwaitdown -t350 /service/* || ( echo 'Killing services...' ; \ svc -k /service/* ; svwaitdown /service/* ) +echo 'Restarting getties...' +/command/svc -u /service/getty-* + echo 'Stopping log services...' svc -d /service/*/log svwaitdown -t35 /service/*/log || ( echo 'Killing log services...' ; \ diff --git a/etc/openbsd/getty-ttyC4/run b/etc/openbsd/getty-ttyC4/run @@ -1,2 +1,3 @@ #!/bin/sh +/package/admin/runit/command/utmpset -w ttyC4 exec /usr/libexec/getty Pc ttyC4 diff --git a/man/runit-init.8 b/man/runit-init.8 @@ -43,7 +43,8 @@ returns 111 on error, 0 in all other cases. .SH SEE ALSO runit(8), svwaitdown(8), -svwaitup(8) +svwaitup(8), +utmpset(8) .P http://smarden.org/runit/ .SH AUTHOR diff --git a/man/runit.8 b/man/runit.8 @@ -72,7 +72,8 @@ receives an INT signal, a ctrl-alt-del keyboard request is triggered. .SH SEE ALSO runit-init(8), svwaitdown(8), -svwaitup(8) +svwaitup(8), +utmpset(8) .P http://smarden.org/runit/ .SH AUTHOR diff --git a/man/utmpset.8 b/man/utmpset.8 @@ -0,0 +1,55 @@ +.TH utmpset 8 +.SH NAME +utmpset \- logout a line from utmp and wtmp file +.SH SYNOPSIS +.B utmpset +[ +.B \-w +] +.I line +.SH DESCRIPTION +The +.B utmpset +program modifies the user accounting database +.BR utmp (5) +and optionally +.BR wtmp (5) +to indicate that the user on the terminal +.I line +has logged out. +.P +Ordinary +.BR init (8) +processes handle utmp file records for local login accounting. The +.BR runit (8) +program doesn't include code to update the utmp file, the +.BR getty (8) +processes are handled the same as all other services. +.P +To enable local login accounting, add +.B utmpset +to the +.BR getty (8) +run scripts, e.g.: +.P + #!/bin/sh + /package/admin/runit/command/utmpset -w tty5 + exec /sbin/getty 38400 tty5 linux +.SH OPTIONS +.TP +.B \-w +wtmp. Additionally to the utmp file, write an empty record for +.I line +to the wtmp file. +.SH EXIT CODES +.B utmpset +returns 111 on error, 1 on wrong usage, 0 in all other cases. +.SH SEE ALSO +runit(8), +runit-init(8), +svwaitdown(8), +svwaitup(8) +.P +http://smarden.org/runit/ +.SH AUTHOR +Gerrit Pape <pape@smarden.org> diff --git a/package/CHANGES b/package/CHANGES @@ -1,3 +1,10 @@ +runit 0.5.0 +Wed, 28 Aug 2002 11:18:28 +0200 + * utmpset: avoids libutil; compiles with deitlibc; built by default. + * doc/usedietlibc.html: fix description. + * stage 3: restart getties after stopping services. + * getty-*/run: add utmpset. + runit 0.4.1 Mon, 24 Jun 2002 15:53:11 +0200 * utmpset.c: new option -w: additionally write wtmp record. diff --git a/package/compile b/package/compile @@ -20,7 +20,7 @@ echo 'Compiling everything in ./compile...' ( cd compile; exec make ) echo 'Copying commands into ./command...' -for i in `cat package/commands` +for i in `cat package/commands` utmpset do rm -f command/$i'{new}' cp -p compile/$i command/$i'{new}' diff --git 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.4.1...' +echo 'Creating symlink runit -> runit-0.5.0...' rm -f runit -ln -s runit-0.4.1 runit +ln -s runit-0.5.0 runit mv -f runit .. echo 'Making command links in /command...' diff --git a/src/Makefile b/src/Makefile @@ -1,4 +1,4 @@ -IT=runit runit-init svwaitup svwaitdown sysdeps +IT=runit runit-init svwaitup svwaitdown utmpset sysdeps default: $(IT) @@ -27,7 +27,7 @@ svwaitdown.o: compile svwaitdown.c uint64.h ./compile svwaitdown.c utmpset: load utmpset.o unix.a byte.a - ./load utmpset unix.a byte.a -lutil + ./load utmpset unix.a byte.a utmpset.o: compile utmpset.c ./compile utmpset.c @@ -90,11 +90,11 @@ byte_diff.o: byte.h byte_diff.c compile byte_rchr.o: byte.h byte_rchr.c compile ./compile byte_rchr.c -#chkshsgr: chkshsgr.o load -# ./load chkshsgr -# -#chkshsgr.o: chkshsgr.c compile -# ./compile chkshsgr.c +chkshsgr: chkshsgr.o load + ./load chkshsgr + +chkshsgr.o: chkshsgr.c compile + ./compile chkshsgr.c choose: choose.sh warn-auto.sh rm -f choose diff --git a/src/TARGETS b/src/TARGETS @@ -6,6 +6,8 @@ svwaitdown svwaitdown.o svwaitup svwaitup.o +utmpset +utmpset.o alloc.o alloc_re.o buffer.o @@ -23,6 +25,7 @@ byte_cr.o byte_diff.o byte_rchr.o chkshsgr +chkshsgr.o choose coe.o compile @@ -98,7 +101,5 @@ taia_uint.o time.a uint64.h unix.a -utmpset -utmpset.o wait_nohang.o wait_pid.o diff --git a/src/utmpset.c b/src/utmpset.c @@ -1,5 +1,16 @@ +#include <fcntl.h> +#include <time.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <utmp.h> #include "strerr.h" #include "sgetopt.h" +#include "seek.h" +#include "str.h" +#include "open.h" +#include "byte.h" + #define USAGE " [-w] line" #define WARNING "utmpset: warning: " @@ -9,6 +20,56 @@ void usage(void) { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); } +int utmp_logout(const char *line) { + int fd; + struct utmp ut; + int ok =-1; + + if ((fd =open(_PATH_UTMP, O_RDWR, 0)) < 0) + return(-1); + while (read(fd, &ut, sizeof(struct utmp)) == sizeof(struct utmp)) { + 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; + if (lseek(fd, -(off_t)sizeof(struct utmp), SEEK_CUR) == -1) break; + if (write(fd, &ut, sizeof(struct utmp)) != sizeof(struct utmp)) break; + ok =1; + break; + } + close(fd); + return(ok); +} +int wtmp_logout(const char *line) { + int fd; + int len; + struct stat st; + struct utmp ut; + + if ((fd = open_append(_PATH_WTMP)) == -1) + return(-1); + 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; + 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)) { + ftruncate(fd, st.st_size); + close(fd); + return(-1); + } + close(fd); + return(1); +} + int main (int argc, const char * const *argv, const char * const *envp) { int opt; int wtmp =0; @@ -29,8 +90,11 @@ int main (int argc, const char * const *argv, const char * const *envp) { argv +=optind; if (! argv || ! *argv) usage(); - if (logout(*argv) != 1) - strerr_die4sys(0, WARNING, "unable to logout line ", *argv, ": "); - if (wtmp) logwtmp(*argv, "", ""); + if (utmp_logout(*argv) == -1) + strerr_die4sys(111, WARNING, "unable to utmp logout line ", *argv, ": "); + if (wtmp) { + if (wtmp_logout(*argv) == -1) + strerr_die4sys(111, WARNING, "unable to wtmp logout line ", *argv, ": "); + } exit(0); }