From 48ca75555522716f0f686dcae3dd6cf3d8ad714d Mon Sep 17 00:00:00 2001 From: davidovski Date: Tue, 31 May 2022 11:05:19 +0100 Subject: removed idea of repos --- repo/utmps/btmpd.initd | 24 ++++++++++++++ repo/utmps/btmpd.logrotate | 6 ++++ repo/utmps/utmp-init.initd | 21 ++++++++++++ repo/utmps/utmp-prepare.initd | 25 +++++++++++++++ repo/utmps/utmpd.initd | 23 ++++++++++++++ repo/utmps/utmps.xibuild | 74 +++++++++++++++++++++++++++++++++++++++++++ repo/utmps/wtmpd.initd | 24 ++++++++++++++ repo/utmps/wtmpd.logrotate | 6 ++++ 8 files changed, 203 insertions(+) create mode 100644 repo/utmps/btmpd.initd create mode 100644 repo/utmps/btmpd.logrotate create mode 100644 repo/utmps/utmp-init.initd create mode 100644 repo/utmps/utmp-prepare.initd create mode 100644 repo/utmps/utmpd.initd create mode 100644 repo/utmps/utmps.xibuild create mode 100644 repo/utmps/wtmpd.initd create mode 100644 repo/utmps/wtmpd.logrotate (limited to 'repo/utmps') diff --git a/repo/utmps/btmpd.initd b/repo/utmps/btmpd.initd new file mode 100644 index 0000000..b9acc72 --- /dev/null +++ b/repo/utmps/btmpd.initd @@ -0,0 +1,24 @@ +#!/sbin/openrc-run +# Copyright 2020-2021 Laurent Bercot for Alpine Linux +# Distributed under the terms of the ISC License. +# +name=btmpd +description="utmps daemon for the btmp service" + +command=/bin/s6-ipcserver +command_args="/run/utmps/.btmpd-socket utmps-wtmpd btmp" +command_user=utmp +command_background=yes +directory=/var/log/btmpd +pidfile=/run/utmps/btmpd.pid + +depend() { + need localmount utmp-prepare + after bootmisc + before networking +} + +start_pre() { + checkpath -d -o utmp:utmp -m 0755 /run/utmps + checkpath -d -o utmp:utmp -m 2755 /var/log/btmpd +} diff --git a/repo/utmps/btmpd.logrotate b/repo/utmps/btmpd.logrotate new file mode 100644 index 0000000..b681d90 --- /dev/null +++ b/repo/utmps/btmpd.logrotate @@ -0,0 +1,6 @@ +/var/log/btmpd/btmp { + missingok + monthly + create 0644 utmp utmp + rotate 3 +} diff --git a/repo/utmps/utmp-init.initd b/repo/utmps/utmp-init.initd new file mode 100644 index 0000000..acb4dbe --- /dev/null +++ b/repo/utmps/utmp-init.initd @@ -0,0 +1,21 @@ +#!/sbin/openrc-run +# Copyright 2020-2022 Laurent Bercot for Alpine Linux +# Distributed under the terms of the ISC License. +# +description="clearing and initialization of the utmp database" + +depend() { + need utmp-prepare utmpd wtmpd + before networking + after clock +} + +start() { + # Create an empty utmp file + checkpath -F -f -m 0644 -o utmp:utmp /run/utmps/utmp + + # Write the initial records as sysvinit/busybox init would do. + # 20018 = 256 * 'N' + '2'. Don't ask. + utmps-write -t 2000 -uw -l reboot -p 0 -h "$(uname -r)" -- '~~' BOOT_TIME '~' + utmps-write -t 2000 -uw -l runlevel -p 20018 -h "$(uname -r)" -- '~~' RUN_LVL '~' +} diff --git a/repo/utmps/utmp-prepare.initd b/repo/utmps/utmp-prepare.initd new file mode 100644 index 0000000..9f61249 --- /dev/null +++ b/repo/utmps/utmp-prepare.initd @@ -0,0 +1,25 @@ +#!/sbin/openrc-run +# Copyright 2020-2022 Laurent Bercot for Alpine Linux +# Distributed under the terms of the ISC License. +# +description="preparation of the utmp databases" + +depend() { + before networking + after clock +} + +start() { + if ! test -L /var/log/utmp || test "$(readlink /var/log/utmp)" != /run/utmps/utmp ; then + rm -f /var/log/utmp + ln -s /run/utmps/utmp /var/log/utmp + fi + if ! test -L /var/log/wtmp || test "$(readlink /var/log/wtmp)" != wtmpd/wtmp ; then + rm -f /var/log/wtmp + ln -s wtmpd/wtmp /var/log/wtmp + fi + if ! test -L /var/log/btmp || test "$(readlink /var/log/btmp)" != btmpd/btmp ; then + rm -f /var/log/btmp + ln -s btmpd/btmp /var/log/btmp + fi +} diff --git a/repo/utmps/utmpd.initd b/repo/utmps/utmpd.initd new file mode 100644 index 0000000..d04c6b9 --- /dev/null +++ b/repo/utmps/utmpd.initd @@ -0,0 +1,23 @@ +#!/sbin/openrc-run +# Copyright 2020-2021 Laurent Bercot for Alpine Linux +# Distributed under the terms of the ISC License. +# +name="utmpd" +description="utmps daemon for the utmp service" + +command=/bin/s6-ipcserver +command_args="/run/utmps/.utmpd-socket utmps-utmpd" +command_user=utmp +command_background=yes +directory=/run/utmps +pidfile=/run/utmps/utmpd.pid + +depend() { + need utmp-prepare + after bootmisc + before networking +} + +start_pre() { + checkpath -d -o utmp:utmp -m 0755 /run/utmps +} diff --git a/repo/utmps/utmps.xibuild b/repo/utmps/utmps.xibuild new file mode 100644 index 0000000..f0112e6 --- /dev/null +++ b/repo/utmps/utmps.xibuild @@ -0,0 +1,74 @@ +#!/bin/sh + +MAKEDEPS="" +DEPS="skalibs" + +PKG_VER=0.1.1.0 +SOURCE=https://skarnet.org/software/utmps/utmps-$PKG_VER.tar.gz + +ADDITIONAL=" +btmpd.initd +btmpd.logrotate +utmpd.initd +utmp-init.initd +utmp-prepare.initd +wtmpd.initd +wtmpd.logrotate +" + +DESC="Library implementing utmpx.h family of functions" + +build () { + ./configure \ + --enable-shared \ + --libdir=/usr/lib \ + --with-dynlib=/lib \ + --libexecdir="/lib/utmps" + make +} + +package () { + make DESTDIR=$PKG_DEST install + ln -s utmps/utmpx.h $PKG_DEST/usr/include/utmpx.h + install -d $PKG_DEST/usr/lib/pkgconfig + cat > $PKG_DEST/usr/lib/pkgconfig/utmps.pc << EOF +Name: utmps +Description: A secure implementation of the utmp mechanism. +URL: https://skarnet.org/software/utmps/ +Version: $PKG_VER +Requires.private: skalibs +Libs: -lutmps +Cflags: -I/usr/include/utmps +EOF + install -D -m755 utmp-prepare.initd "$PKG_DEST/etc/init.d/utmp-prepare" + install -D -m755 utmpd.initd "$PKG_DEST/etc/init.d/utmpd" + install -D -m755 wtmpd.initd "$PKG_DEST/etc/init.d/wtmpd" + install -D -m755 btmpd.initd "$PKG_DEST/etc/init.d/btmpd" + install -D -m755 utmp-init.initd "$PKG_DEST/etc/init.d/utmp-init" + install -D -m644 wtmpd.logrotate "$PKG_DEST/etc/logrotate.d/wtmpd" + install -D -m644 btmpd.logrotate "$PKG_DEST/etc/logrotate.d/btmpd" +} + +postinstall () { + # check that shadow exists + command -v useradd || exit 1 + command -v chown || exit 1 + + grep -q "utmps" /etc/passwd || useradd -c "utmps user" -d /run/utmps \ + -u 984 -g utmp -s /bin/false utmp + [ -d /var/log/utmps ] || mkdir -p /var/log/utmps + [ -d /var/log/wtmp ] && mv /var/log/wtmp /var/log/utmps + chown -R utmp:utmp /var/log/utmps + [ -e /var/log/wtmp ] || ln -s utmps/wtmp /var/log/wtmp + +# utmps is broken, dont try to make services with it without s6 ipc +# rc-update add utmp-prepare boot +# rc-update add utmpd boot +# rc-update add wtmpd boot +# rc-update add btmpd boot +# rc-update add utmp-init boot +# rc-service utmp-prepare start +# rc-service utmpd start +# rc-service wtmpd start +# rc-service btmpd start +} diff --git a/repo/utmps/wtmpd.initd b/repo/utmps/wtmpd.initd new file mode 100644 index 0000000..8d3f624 --- /dev/null +++ b/repo/utmps/wtmpd.initd @@ -0,0 +1,24 @@ +#!/sbin/openrc-run +# Copyright 2020-2021 Laurent Bercot for Alpine Linux +# Distributed under the terms of the ISC License. +# +name=wtmpd +description="utmps daemon for the wtmp service" + +command=/bin/s6-ipcserver +command_args="/run/utmps/.wtmpd-socket utmps-wtmpd wtmp" +command_user=utmp +command_background=yes +directory=/var/log/wtmpd +pidfile=/run/utmps/wtmpd.pid + +depend() { + need localmount utmp-prepare + after bootmisc + before networking +} + +start_pre() { + checkpath -d -o utmp:utmp -m 0755 /run/utmps + checkpath -d -o utmp:utmp -m 2755 /var/log/wtmpd +} diff --git a/repo/utmps/wtmpd.logrotate b/repo/utmps/wtmpd.logrotate new file mode 100644 index 0000000..bb23536 --- /dev/null +++ b/repo/utmps/wtmpd.logrotate @@ -0,0 +1,6 @@ +/var/log/wtmpd/wtmp { + missingok + monthly + create 0644 utmp utmp + rotate 3 +} -- cgit v1.2.1