runit: update to 2.2.0.

This commit is contained in:
Đoàn Trần Công Danh 2024-09-29 21:23:35 +07:00 committed by classabbyamp
parent 582446ed67
commit 957889af23
9 changed files with 102 additions and 214 deletions

View file

@ -1,77 +0,0 @@
From 2b8000f1ebd07fd68ee0e3c32737d97bcd1687fb Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 14 Feb 2022 14:25:22 -0500
Subject: [PATCH] chpst: add -C to change working directory
---
man/chpst.8 | 8 ++++++++
src/chpst.c | 9 +++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git runit-2.1.2/man/chpst.8 runit-2.1.2/man/chpst.8
index 43c0b8d..e0829b6 100644
--- runit-2.1.2/man/chpst.8
+++ runit-2.1.2/man/chpst.8
@@ -146,6 +146,14 @@ Change the root directory to
before starting
.IR prog .
.TP
+.B \-C \fIpwd
+chdir.
+Change the working directory to
+.I pwd
+before starting
+.IR prog .
+When combined with \-/, the working directory is changed after the chroot.
+.TP
.B \-n \fIinc
nice.
Add
diff --git runit-2.1.2/src/chpst.c runit-2.1.2/src/chpst.c
index 1cca5f4..d597b68 100644
--- runit-2.1.2/src/chpst.c
+++ runit-2.1.2/src/chpst.c
@@ -20,7 +20,7 @@
#include "openreadclose.h"
#include "direntry.h"
-#define USAGE_MAIN " [-vP012] [-u user[:group]] [-U user[:group]] [-b argv0] [-e dir] [-/ root] [-n nice] [-l|-L lock] [-m n] [-d n] [-o n] [-p n] [-f n] [-c n] prog"
+#define USAGE_MAIN " [-vP012] [-u user[:group]] [-U user[:group]] [-b argv0] [-e dir] [-/ root] [-C pwd] [-n nice] [-l|-L lock] [-m n] [-d n] [-o n] [-p n] [-f n] [-c n] prog"
#define FATAL "chpst: fatal: "
#define WARNING "chpst: warning: "
@@ -60,6 +60,7 @@ long limitt =-2;
long nicelvl =0;
const char *lock =0;
const char *root =0;
+const char *pwd =0;
unsigned int lockdelay;
void suidgid(char *user, unsigned int ext) {
@@ -286,7 +287,7 @@ int main(int argc, const char **argv) {
if (str_equal(progname, "setlock")) setlock(argc, argv);
if (str_equal(progname, "softlimit")) softlimit(argc, argv);
- while ((opt =getopt(argc, argv, "u:U:b:e:m:d:o:p:f:c:r:t:/:n:l:L:vP012V"))
+ while ((opt =getopt(argc, argv, "u:U:b:e:m:d:o:p:f:c:r:t:/:C:n:l:L:vP012V"))
!= opteof)
switch(opt) {
case 'u': set_user =(char*)optarg; break;
@@ -305,6 +306,7 @@ int main(int argc, const char **argv) {
case 'r': if (optarg[scan_ulong(optarg, &ul)]) usage(); limitr =ul; break;
case 't': if (optarg[scan_ulong(optarg, &ul)]) usage(); limitt =ul; break;
case '/': root =optarg; break;
+ case 'C': pwd =optarg; break;
case 'n':
switch (*optarg) {
case '-':
@@ -337,6 +339,9 @@ int main(int argc, const char **argv) {
if (chdir(root) == -1) fatal2("unable to change directory", root);
if (chroot(".") == -1) fatal("unable to change root directory");
}
+ if (pwd) {
+ if (chdir(pwd) == -1) fatal2("unable to change directory", pwd);
+ }
if (nicelvl) {
errno =0;
if (nice(nicelvl) == -1) if (errno) fatal("unable to set nice level");

View file

@ -1,14 +0,0 @@
Fix UB which breaks -n with negative values.
Ensure optarg is incremented strictly before it is read from.
--- runit-2.1.2/src/chpst.c.orig
+++ runit-2.1.2/src/chpst.c
@@ -308,7 +308,7 @@
case 'n':
switch (*optarg) {
case '-':
- if (optarg[scan_ulong(++optarg, &ul)]) usage(); nicelvl =ul;
+ ++optarg; if (optarg[scan_ulong(optarg, &ul)]) usage(); nicelvl =ul;
nicelvl *=-1;
break;
case '+': ++optarg;

View file

@ -1,7 +1,14 @@
diff -Naur runit-2.1.2/src/svlogd.c runit-2.1.2/src/svlogd.c --- a/src/svlogd.c
--- runit-2.1.2/src/svlogd.c 2014-08-10 11:22:34.000000000 -0700 +++ b/src/svlogd.c
+++ runit-2.1.2/src/svlogd.c 2018-03-03 03:28:08.243085845 -0800 @@ -8,6 +8,7 @@
@@ -705,6 +705,7 @@ #include <dirent.h>
#include <unistd.h>
#include <stdio.h>
+#include <string.h>
#include "pmatch.h"
#include "fmt_ptime.h"
#include "alloc.h"
@@ -706,6 +707,7 @@ int main(int argc, char **argv) {
coe(fdwdir); coe(fdwdir);
dir =(struct logdir*)alloc(dirn *sizeof(struct logdir)); dir =(struct logdir*)alloc(dirn *sizeof(struct logdir));
if (! dir) die_nomem(); if (! dir) die_nomem();

View file

@ -1,36 +1,27 @@
chskshsgr must be built for the host. chskshsgr must be built for the host.
--- runit-2.1.2/src/Makefile.orig 2014-02-11 02:03:33.904789349 +0100 --- a/src/Makefile
+++ runit-2.1.2/src/Makefile 2014-02-11 02:19:28.968055164 +0100 +++ b/src/Makefile
@@ -170,11 +170,11 @@ byte_diff.o: byte.h byte_diff.c compile @@ -179,6 +179,11 @@ choose: choose.sh warn-auto.sh
byte_rchr.o: byte.h byte_rchr.c compile
./compile byte_rchr.c
-chkshsgr: chkshsgr.o load
- ./load chkshsgr
+chkshsgr: chkshsgr.o loadhost
+ ./loadhost chkshsgr
-chkshsgr.o: chkshsgr.c compile
- ./compile chkshsgr.c
+chkshsgr.o: chkshsgr.c compilehost
+ ./compilehost chkshsgr.c
choose: choose.sh warn-auto.sh
rm -f choose
@@ -185,6 +185,11 @@ choose: choose.sh warn-auto.sh
coe.o: coe.c coe.h compile coe.o: coe.c coe.h compile
./compile coe.c ./compile coe.c
+compilehost: +compilehost:
+ cat warn-auto.sh > compilehost + cat warn-auto.sh > compilehost
+ @echo 'exec cc -c $${1+"$$@"}' >> compilehost + @echo 'exec cc -D_GNU_SOURCE -c $${1+"$$@"}' >> compilehost
+ chmod 555 compilehost + chmod 555 compilehost
+ +
compile: conf-cc print-cc.sh systype warn-auto.sh compile: conf-cc print-cc.sh systype warn-auto.sh
rm -f compile rm -f compile
sh print-cc.sh > compile sh print-cc.sh > compile
@@ -246,6 +251,15 @@ iopause.h: choose compile iopause.h1 iop @@ -229,12 +234,21 @@ hassgprm.h: choose compile hassgprm.h1 h
haswaitp.h: choose compile haswaitp.h1 haswaitp.h2 load trywaitp.c
./choose cl trywaitp haswaitp.h1 haswaitp.h2 > haswaitp.h
-iopause.h: choose compile iopause.h1 iopause.h2 load trypoll.c
+iopause.h: choose compilehost iopause.h1 iopause.h2 loadhost trypoll.c
./choose clr trypoll iopause.h1 iopause.h2 > iopause.h
iopause.o: compile iopause.c iopause.h select.h tai.h taia.h uint64.h iopause.o: compile iopause.c iopause.h select.h tai.h taia.h uint64.h
./compile iopause.c ./compile iopause.c
@ -46,3 +37,48 @@ chskshsgr must be built for the host.
load: conf-ld print-ld.sh systype warn-auto.sh load: conf-ld print-ld.sh systype warn-auto.sh
rm -f load rm -f load
sh print-ld.sh > load sh print-ld.sh > load
@@ -422,7 +436,7 @@ taia_pack.o taia_sub.o taia_uint.o
taia_now.o taia_pack.o taia_sub.o taia_uint.o
uint64.h: choose compile load tryulong64.c uint64.h1 uint64.h2
- ./choose clr tryulong64 uint64.h1 uint64.h2 > uint64.h
+ ./choose cl tryulong64 uint64.h1 uint64.h2 > uint64.h
unix.a: alloc.o alloc_re.o buffer.o buffer_0.o buffer_1.o buffer_2.o \
buffer_get.o buffer_put.o buffer_read.o buffer_write.o coe.o env.o \
--- a/src/choose.sh
+++ b/src/choose.sh
@@ -2,10 +2,12 @@
result="$4"
case "$1" in
+ *c*r*) ./compilehost $2.c >/dev/null 2>&1 || result="$3" ;;
*c*) ./compile $2.c >/dev/null 2>&1 || result="$3" ;;
esac
case "$1" in
+ *l*r*) ./loadhost $2 >/dev/null 2>&1 || result="$3" ;;
*l*) ./load $2 >/dev/null 2>&1 || result="$3" ;;
esac
--- a/src/tryulong64.c
+++ b/src/tryulong64.c
@@ -1,15 +1,10 @@
/* Public domain. */
#include <unistd.h>
+#include <stdint.h>
int main()
{
- unsigned long u;
- u = 1;
- u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
- u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
- u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
- u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
- if (!u) _exit(1);
- _exit(0);
+ char u[(sizeof(unsigned long) == sizeof(uint64_t)) * 2 - 1] = { 0 };
+ return u[0];
}

View file

@ -1,8 +1,8 @@
Fix default service path in man pages Fix default service path in man pages
--- runit-2.1.2/man/sv.8 --- a/man/sv.8
+++ runit-2.1.2/man/sv.8 +++ b/man/sv.8
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@ If
.I service .I service
doesn't start with a dot or slash and doesn't end with a slash, it is doesn't start with a dot or slash and doesn't end with a slash, it is
searched in the default services directory searched in the default services directory
@ -11,7 +11,7 @@ Fix default service path in man pages
otherwise relative to the current directory. otherwise relative to the current directory.
.P .P
.I command .I command
@@ -232,7 +232,7 @@ @@ -232,7 +232,7 @@ This option implies
.TP .TP
.B SVDIR .B SVDIR
The environment variable $SVDIR overrides the default services directory The environment variable $SVDIR overrides the default services directory
@ -20,9 +20,9 @@ Fix default service path in man pages
.TP .TP
.B SVWAIT .B SVWAIT
The environment variable $SVWAIT overrides the default 7 seconds to wait The environment variable $SVWAIT overrides the default 7 seconds to wait
--- runit-2.1.2/man/runsvchdir.8 --- a/man/runsvchdir.8
+++ runit-2.1.2/man/runsvchdir.8 +++ b/man/runsvchdir.8
@@ -27,13 +27,13 @@ @@ -27,13 +27,13 @@ with a symlink pointing to
.IR dir . .IR dir .
.P .P
Normally Normally
@ -38,9 +38,9 @@ Fix default service path in man pages
.SH EXIT CODES .SH EXIT CODES
.B runsvchdir .B runsvchdir
prints an error message and exits 111 on error. prints an error message and exits 111 on error.
--- runit-2.1.2/man/utmpset.8 --- a/man/utmpset.8
+++ runit-2.1.2/man/utmpset.8 +++ b/man/utmpset.8
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@ to the
.I finish .I finish
scripts, e.g.: scripts, e.g.:
.P .P
@ -49,9 +49,9 @@ Fix default service path in man pages
#!/bin/sh #!/bin/sh
exec utmpset \-w tty5 exec utmpset \-w tty5
$ $
--- runit-2.1.2/man/runsv.8 --- a/man/runsv.8
+++ runit-2.1.2/man/runsv.8 +++ b/man/runsv.8
@@ -157,9 +157,9 @@ @@ -155,9 +155,9 @@ This command is ignored if it is given t
.IR service /log/supervise/control. .IR service /log/supervise/control.
.P .P
Example: to send a TERM signal to the socklog-unix service, either do Example: to send a TERM signal to the socklog-unix service, either do

View file

@ -3,9 +3,9 @@ runit(8): don't leak SIGCONT SIG_IGN into all child processes
https://inbox.vuxu.org/supervision/87tug3vzex.fsf@vuxu.org/ https://inbox.vuxu.org/supervision/87tug3vzex.fsf@vuxu.org/
https://github.com/ksh93/ksh/issues/301 https://github.com/ksh93/ksh/issues/301
--- runit-2.1.2/src/runit.c.orig --- a/src/runit.c
+++ runit-2.1.2/src/runit.c +++ b/src/runit.c
@@ -125,7 +125,7 @@ @@ -130,7 +130,7 @@ int main (int argc, const char * const *
sig_unblock(sig_child); sig_unblock(sig_child);
sig_uncatch(sig_child); sig_uncatch(sig_child);
sig_unblock(sig_cont); sig_unblock(sig_cont);

View file

@ -1,13 +0,0 @@
Initialize all fields of sockaddr_in.
http://skarnet.org/cgi-bin/archive.cgi?2:mss:1163:201602:gpiglpbjdemlioaeabbn
--- runit-2.1.2/src/svlogd.c 2014-08-10 15:22:34.000000000 -0300
+++ runit-2.1.2/src/svlogd.c 2016-02-04 22:53:52.910965361 -0300
@@ -430,6 +430,7 @@
ld->name =(char*)fn;
ld->ppid =0;
ld->match ='+';
+ ld->udpaddr.sin_family =AF_INET;
ld->udpaddr.sin_port =0;
ld->udponly =0;
while (! stralloc_copys(&ld->prefix, "")) pause_nomem();

View file

@ -1,56 +0,0 @@
From 20a0afcd367666efc17c59cf121a0d991ff1bd09 Mon Sep 17 00:00:00 2001
From: Gerrit Pape <pape@smarden.org>
Date: Thu, 31 Jul 2014 12:25:49 +0000
Subject: [PATCH] utmpset.c: mixes "int32_t *" and "time_t *"
Don't pass int32_t to time(), thx Lorenzo Beretta,
https://bugs.debian.org/754849
---
runit-2.1.2/src/utmpset.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/runit-2.1.2/src/utmpset.c b/runit-2.1.2/src/utmpset.c
index eea41a5..2e8a525 100644
--- runit-2.1.2/src/utmpset.c
+++ runit-2.1.2/src/utmpset.c
@@ -24,6 +24,7 @@ void usage(void) { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); }
int utmp_logout(const char *line) {
int fd;
uw_tmp ut;
+ time_t t;
int ok =-1;
if ((fd =open(UW_TMP_UFILE, O_RDWR, 0)) < 0)
@@ -35,7 +36,8 @@ int utmp_logout(const char *line) {
if (!ut.ut_name[0] || (str_diff(ut.ut_line, line) != 0)) continue;
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 (time(&t) == -1) break;
+ ut.ut_time = t;
#ifdef DEAD_PROCESS
ut.ut_type =DEAD_PROCESS;
#endif
@@ -52,6 +54,7 @@ int wtmp_logout(const char *line) {
int len;
struct stat st;
uw_tmp ut;
+ time_t t;
if ((fd = open_append(UW_TMP_WFILE)) == -1)
strerr_die4sys(111, FATAL, "unable to open ", UW_TMP_WFILE, ": ");
@@ -65,10 +68,11 @@ int wtmp_logout(const char *line) {
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) {
+ if (time(&t) == -1) {
close(fd);
return(-1);
}
+ ut.ut_time = t;
#ifdef DEAD_PROCESS
ut.ut_type =DEAD_PROCESS;
#endif
--
2.0.1

View file

@ -1,16 +1,14 @@
# Template file for 'runit' # Template file for 'runit'
pkgname=runit pkgname=runit
version=2.1.2 version=2.2.0
revision=15 revision=1
build_wrksrc="${pkgname}-${version}/src"
build_style="gnu-makefile" build_style="gnu-makefile"
short_desc="UNIX init scheme with service supervision" short_desc="UNIX init scheme with service supervision"
maintainer="Orphaned <orphan@voidlinux.org>" maintainer="Orphaned <orphan@voidlinux.org>"
license="BSD-3-Clause" license="BSD-3-Clause"
homepage="http://smarden.org/runit/" homepage="https://smarden.org/runit/"
distfiles="http://smarden.org/runit/runit-${version}.tar.gz" distfiles="https://smarden.org/runit/runit-${version}.tar.gz"
checksum=6fd0160cb0cf1207de4e66754b6d39750cff14bb0aa66ab49490992c0c47ba18 checksum=95ef4d2868b978c7179fe47901e5c578e11cf273d292bd6208bd3a7ccb029290
patch_args=-Np0
# FIXME: this is caused by some bonk tests that should be fixed in void-linux/runit at some point # FIXME: this is caused by some bonk tests that should be fixed in void-linux/runit at some point
make_check=no make_check=no
@ -21,19 +19,27 @@ if [ "$build_option_static" ]; then
LDFLAGS="-static" LDFLAGS="-static"
fi fi
pre_build() { post_extract() {
mv runit-${version}/* .
}
do_configure() {
cd src
vsed -e 's,sbin/runit,usr/bin/runit,g' -i runit.h vsed -e 's,sbin/runit,usr/bin/runit,g' -i runit.h
echo "$CC -D_GNU_SOURCE $CFLAGS" >conf-cc echo "$CC -D_GNU_SOURCE $CFLAGS" >conf-cc
echo "$CC $LDFLAGS -Wl,-z -Wl,noexecstack" >conf-ld echo "$CC $LDFLAGS -Wl,-z -Wl,noexecstack" >conf-ld
# set default service path to /var/service # set default service path to /var/service
vsed -e 's:^char \*varservice ="/service/";$:char \*varservice ="/var/service/";:' -i sv.c vsed -e 's:^char \*varservice ="/service/";$:char \*varservice ="/var/service/";:' -i sv.c
# change type short to gid_t for getgroups(2) and setgroups(2) make ${makejobs} sysdeps
vsed -e 's:short x\[4\];$:gid_t x[4];:' -i chkshsgr.c }
do_build() {
make -C src ${makejobs}
} }
do_install() { do_install() {
vlicense ../package/COPYING vlicense package/COPYING
# default services # default services
vmkdir var vmkdir var
@ -42,10 +48,9 @@ do_install() {
local f local f
for f in chpst runit runit-init runsv runsvchdir runsvdir \ for f in chpst runit runit-init runsv runsvchdir runsvdir \
sv svlogd utmpset; do sv svlogd utmpset; do
vbin $f vbin src/$f
done done
cd ..
for f in man/*; do for f in man/*; do
vman $f vman $f
done done