Improve utmp handling

This commit is contained in:
Roy Marples 2009-04-16 23:39:37 +00:00
parent 744a8bbb4a
commit 95d954e7b5

View File

@ -1,5 +1,5 @@
#!@PREFIX@/sbin/runscript #!@PREFIX@/sbin/runscript
# Copyright 2007-2008 Roy Marples <roy@marples.name> # Copyright 2007-2009 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license. # All rights reserved. Released under the 2-clause BSD license.
depend() depend()
@ -61,9 +61,16 @@ cleanup_tmp_dir()
fi fi
} }
mkutmp()
{
: >"$1"
chgrp utmp "$1"
chmod 0664 "$1"
}
start() start()
{ {
local logw=false local logw=false runw=false
# Ensure that our basic dirs exist # Ensure that our basic dirs exist
for x in /var/log /var/run /tmp; do for x in /var/log /var/run /tmp; do
if ! [ -d "${x}" ]; then if ! [ -d "${x}" ]; then
@ -76,15 +83,12 @@ start()
if dir_writeable /var/run; then if dir_writeable /var/run; then
ebegin "Creating user login records" ebegin "Creating user login records"
cp /dev/null /var/run/utmp local xtra=
chgrp utmp /var/run/utmp [ "${RC_UNAME}" = NetBSD ] && extra=x
chmod 0664 /var/run/utmp for x in "" $xtra; do
if dir_writeable /var/log; then mkutmp /var/run/utmp${x}
logw=true done
[ -e /var/log/wtmp ] || cp /dev/null /var/log/wtmp [ -e /var/log/wtmp ] && mkutmp /var/log/wtmp
chgrp utmp /var/log/wtmp
chmod 0664 /var/log/wtmp
fi
eend 0 eend 0
ebegin "Cleaning /var/run" ebegin "Cleaning /var/run"