mrrl

Minimal Reliable Reproducible Linux
git clone https://ccx.te2000.cz/git/mrrl
Log | Files | Refs | Submodules | README

commit c03aa385af5fcca65a696146d81c52ffeeaafee0
Author: Jan Pobříslo <ccx@te2000.cz>
Date:   Fri, 26 Feb 2021 23:36:41 +0000

initial commit

Diffstat:
A.gitmodules | 30++++++++++++++++++++++++++++++
Aexecline | 1+
Ainstall-all | 46++++++++++++++++++++++++++++++++++++++++++++++
Amdevd | 1+
As6 | 1+
As6-dns | 1+
As6-linux-init | 1+
As6-linux-utils | 1+
As6-networking | 1+
As6-portable-utils | 1+
As6-rc | 1+
As6_clone_newpid.patch | 113+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
As6_clone_newpid.patch.old | 121+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Askalibs | 1+
14 files changed, 320 insertions(+), 0 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -0,0 +1,30 @@ +[submodule "s6"] + path = s6 + url = https://git.skarnet.org/cgi-bin/cgit.cgi/s6 +[submodule "s6-rc"] + path = s6-rc + url = https://git.skarnet.org/cgi-bin/cgit.cgi/s6-rc +[submodule "skalibs"] + path = skalibs + url = https://git.skarnet.org/cgi-bin/cgit.cgi/skalibs +[submodule "execline"] + path = execline + url = https://git.skarnet.org/cgi-bin/cgit.cgi/execline +[submodule "mdevd"] + path = mdevd + url = https://git.skarnet.org/cgi-bin/cgit.cgi/mdevd +[submodule "s6-dns"] + path = s6-dns + url = https://git.skarnet.org/cgi-bin/cgit.cgi/s6-dns +[submodule "s6-linux-init"] + path = s6-linux-init + url = https://git.skarnet.org/cgi-bin/cgit.cgi/s6-linux-init +[submodule "s6-linux-utils"] + path = s6-linux-utils + url = https://git.skarnet.org/cgi-bin/cgit.cgi/s6-linux-utils +[submodule "s6-networking"] + path = s6-networking + url = https://git.skarnet.org/cgi-bin/cgit.cgi/s6-networking +[submodule "s6-portable-utils"] + path = s6-portable-utils + url = https://git.skarnet.org/cgi-bin/cgit.cgi/s6-portable-utils diff --git a/execline b/execline @@ -0,0 +1 @@ +Subproject commit baf6a7a26b5bb8d0a727e37912c2bf955964f357 diff --git a/install-all b/install-all @@ -0,0 +1,46 @@ +#!/bin/sh +set -x + +: ${slashpackage:=${HOME}/local} + +install_skalibs() { + git checkout --force || exit $? + git clean -fx || exit $? + ./configure --disable-shared --enable-static --enable-slashpackage="$slashpackage" || exit $? + make || exit $? + make install || exit $? + make -L update || exit $? + make -L global-links || exit $? +} + +install_s6() { + git checkout --force || exit $? + git clean -fx || exit $? + patch -up 1 -i ../s6_clone_newpid.patch || exit $? + ./configure --disable-shared --enable-static --enable-allstatic --enable-slashpackage="$slashpackage" || exit $? + make || exit $? + make install || exit $? + make -L update || exit $? + make -L global-links || exit $? +} + +install_generic() { + git checkout --force || exit $? + git clean -fx || exit $? + ./configure --disable-shared --enable-static --enable-allstatic --enable-slashpackage="$slashpackage" || exit $? + make || exit $? + make install || exit $? + make -L update || exit $? + make -L global-links || exit $? +} + +(cd skalibs && install_skalibs) || exit $? +(cd execline && install_generic) || exit $? +(cd s6 && install_s6) || exit $? +(cd s6-rc && install_generic) || exit $? +(cd s6-portable-utils && install_generic) || exit $? +(cd s6-linux-utils && install_generic) || exit $? +(cd s6-linux-init && install_generic) || exit $? +(cd mdevd && install_generic) || exit $? +(cd s6-dns && install_generic) || exit $? +(cd s6-networking && install_generic) || exit $? diff --git a/mdevd b/mdevd @@ -0,0 +1 @@ +Subproject commit 9358ede0e510fe25cf26fd6cc349395ac8bc8558 diff --git a/s6 b/s6 @@ -0,0 +1 @@ +Subproject commit 5e3fcefc47824c9ce3bff156804dd44995a04073 diff --git a/s6-dns b/s6-dns @@ -0,0 +1 @@ +Subproject commit 04199d6a903c7ecad0bada112949b0b0590b1236 diff --git a/s6-linux-init b/s6-linux-init @@ -0,0 +1 @@ +Subproject commit e79bcd1505f1f11fe87ff706a038223f76e97326 diff --git a/s6-linux-utils b/s6-linux-utils @@ -0,0 +1 @@ +Subproject commit 137f093d2d4964d253d740cbc101f53ba3a6fd99 diff --git a/s6-networking b/s6-networking @@ -0,0 +1 @@ +Subproject commit 02ba4310747629ab0c552673d504855f746c584f diff --git a/s6-portable-utils b/s6-portable-utils @@ -0,0 +1 @@ +Subproject commit 8a3b18c61d42d822cc25c74d5c04c53c7b053643 diff --git a/s6-rc b/s6-rc @@ -0,0 +1 @@ +Subproject commit 5e009777db90c9e69e62115c29eafff910d43a0d diff --git a/s6_clone_newpid.patch b/s6_clone_newpid.patch @@ -0,0 +1,113 @@ +diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c +index bda8e52..2c3fb2d 100644 +--- a/src/supervision/s6-supervise.c ++++ b/src/supervision/s6-supervise.c +@@ -12,6 +12,9 @@ + #include <fcntl.h> + #include <sys/stat.h> + #include <sys/wait.h> ++#ifdef WANT_CLONE_NEWPID ++# include <sched.h> ++#endif + + #include <skalibs/allreadwrite.h> + #include <skalibs/bytestr.h> +@@ -234,6 +237,64 @@ static void failcoe (int fd) + errno = e ; + } + ++ static void exec_run(int p[2], int notifyp[2], int fd) gccattr_noreturn ; ++ static void exec_run(int p[2], int notifyp[2], int fd) ++ { ++ char const *cargv[2] = { "run", 0 } ; ++ PROG = "s6-supervise (child)" ; ++ selfpipe_finish() ; ++ sig_restore(SIGPIPE) ; ++ if (notifyp[0] >= 0) close(notifyp[0]) ; ++ close(p[0]) ; ++ if (notifyp[1] >= 0 && fd_move(fd, notifyp[1]) < 0) ++ { ++ failcoe(p[1]) ; ++ strerr_diefu1sys(127, "move notification descriptor") ; ++ } ++ setsid() ; ++ execv("./run", (char *const *)cargv) ; ++ failcoe(p[1]) ; ++ strerr_dieexec(127, "run") ; ++} ++ ++static pid_t spawn_run_fork(int p[2], int notifyp[2], int fd) ++{ ++ pid_t pid = fork() ; ++ if (!pid) exec_run(p, notifyp, fd) ; ++ return pid ; ++} ++ ++#ifdef WANT_CLONE_NEWPID ++typedef struct ++{ ++ int p[2] ; ++ int notifyp[2] ; ++ int fd ; ++} exec_run_t ; ++ ++static int exec_run_shim(void *ctx) gccattr_noreturn ; ++static int exec_run_shim(void *ctx) ++{ ++ exec_run_t *er = (exec_run_t *) ctx ; ++ exec_run(er->p, er->notifyp, er->fd) ; ++} ++ ++static pid_t spawn_run(int p[2], int notifyp[2], int fd) ++{ ++ exec_run_t arg = { { p[0], p[1] }, { notifyp[0], notifyp[1] }, fd } ; ++ char child_stack[SIGSTKSZ] ; ++ if (access("clone-newpid", F_OK) < 0 && errno == ENOENT) ++ return spawn_run_fork(p, notifyp, fd) ; ++ return (pid_t) clone(&exec_run_shim, child_stack + sizeof(child_stack), ++ CLONE_NEWPID | SIGCHLD, &arg) ; ++} ++#else /* if !defined(WANT_CLONE_NEWPID) */ ++static pid_t spawn_run(int p[2], int notifyp[2], int fd) ++{ ++ return spawn_run_fork(p, notifyp, fd) ; ++} ++#endif /* defined(WANT_CLONE_NEWPID) */ ++ + static void trystart (void) + { + int p[2] ; +@@ -253,7 +314,7 @@ static void trystart (void) + fd_close(p[1]) ; fd_close(p[0]) ; + return ; + } +- pid = fork() ; ++ pid = spawn_run(p, notifyp, (int)fd) ; + if (pid < 0) + { + settimeout(60) ; +@@ -263,24 +324,6 @@ static void trystart (void) + fd_close(p[1]) ; fd_close(p[0]) ; + return ; + } +- else if (!pid) +- { +- char const *cargv[2] = { "run", 0 } ; +- PROG = "s6-supervise (child)" ; +- selfpipe_finish() ; +- sig_restore(SIGPIPE) ; +- if (notifyp[0] >= 0) close(notifyp[0]) ; +- close(p[0]) ; +- if (notifyp[1] >= 0 && fd_move((int)fd, notifyp[1]) < 0) +- { +- failcoe(p[1]) ; +- strerr_diefu1sys(127, "move notification descriptor") ; +- } +- setsid() ; +- execv("./run", (char *const *)cargv) ; +- failcoe(p[1]) ; +- strerr_dieexec(127, "run") ; +- } + if (notifyp[1] >= 0) fd_close(notifyp[1]) ; + fd_close(p[1]) ; + { diff --git a/s6_clone_newpid.patch.old b/s6_clone_newpid.patch.old @@ -0,0 +1,121 @@ +from https://www.mail-archive.com/skaware@list.skarnet.org/msg01006.html + +diff --git a/src/supervision/s6-supervise.c +b/src/supervision/s6-supervise.c index 2e8fa38..7605a82 100644 +--- a/src/supervision/s6-supervise.c ++++ b/src/supervision/s6-supervise.c +@@ -9,6 +9,9 @@ + #include <errno.h> + #include <fcntl.h> + #include <signal.h> ++#ifdef WANT_CLONE_NEWPID ++# include <sched.h> ++#endif + #include <skalibs/allreadwrite.h> + #include <skalibs/bytestr.h> + #include <skalibs/uint.h> +@@ -203,6 +206,67 @@ static int maybesetsid (void) + return 1 ; + } + ++ static void exec_run(int p[2], int notifyp[2], int fd) gccattr_noreturn ; ++ static void exec_run(int p[2], int notifyp[2], int fd) ++ { ++ char const *cargv[2] = { "run", 0 } ; ++ PROG = "s6-supervise (child)" ; ++ selfpipe_finish() ; ++ if (notifyp[0] >= 0) close(notifyp[0]) ; ++ close(p[0]) ; ++ if (notifyp[1] >= 0 && fd_move(fd, notifyp[1]) < 0) ++ { ++ failcoe(p[1]) ; ++ strerr_diefu1sys(127, "move notification descriptor") ; ++ } ++ if (!maybesetsid()) ++ { ++ failcoe(p[1]) ; ++ strerr_diefu1sys(127, "access ./nosetsid") ; ++ } ++ execve("./run", (char *const *)cargv, (char *const *)environ) ; ++ failcoe(p[1]) ; ++ strerr_dieexec(127, "run") ; ++} ++ ++static pid_t spawn_run_fork(int p[2], int notifyp[2], int fd) ++{ ++ pid_t pid = fork() ; ++ if (!pid) exec_run(p, notifyp, fd) ; ++ return pid ; ++} ++ ++#ifdef WANT_CLONE_NEWPID ++typedef struct ++{ ++ int p[2] ; ++ int notifyp[2] ; ++ int fd ; ++} exec_run_t ; ++ ++static int exec_run_shim(void *ctx) gccattr_noreturn ; ++static int exec_run_shim(void *ctx) ++{ ++ exec_run_t *er = (exec_run_t *) ctx ; ++ exec_run(er->p, er->notifyp, er->fd) ; ++} ++ ++static pid_t spawn_run(int p[2], int notifyp[2], int fd) ++{ ++ exec_run_t arg = { { p[0], p[1] }, { notifyp[0], notifyp[1] }, fd } ; ++ char child_stack[SIGSTKSZ] ; ++ if (access("clone-newpid", F_OK) < 0 && errno == ENOENT) ++ return spawn_run_fork(p, notifyp, fd) ; ++ return (pid_t) clone(&exec_run_shim, child_stack + sizeof(child_stack), ++ CLONE_NEWPID | SIGCHLD, &arg) ; ++} ++#else /* if !defined(WANT_CLONE_NEWPID) */ ++static pid_t spawn_run(int p[2], int notifyp[2], int fd) ++{ ++ return spawn_run_fork(p, notifyp, fd) ; ++} ++#endif /* defined(WANT_CLONE_NEWPID) */ ++ + static void trystart (void) + { + int p[2] ; +@@ -222,7 +286,7 @@ static void trystart (void) + fd_close(p[1]) ; fd_close(p[0]) ; + return ; + } +- pid = fork() ; ++ pid = spawn_run(p, notifyp, (int)fd) ; + if (pid < 0) + { + settimeout(60) ; +@@ -232,27 +296,6 @@ static void trystart (void) + fd_close(p[1]) ; fd_close(p[0]) ; + return ; + } +- else if (!pid) +- { +- char const *cargv[2] = { "run", 0 } ; +- PROG = "s6-supervise (child)" ; +- selfpipe_finish() ; +- if (notifyp[0] >= 0) close(notifyp[0]) ; +- close(p[0]) ; +- if (notifyp[1] >= 0 && fd_move((int)fd, notifyp[1]) < 0) +- { +- failcoe(p[1]) ; +- strerr_diefu1sys(127, "move notification descriptor") ; +- } +- if (!maybesetsid()) +- { +- failcoe(p[1]) ; +- strerr_diefu1sys(127, "access ./nosetsid") ; +- } +- execve("./run", (char *const *)cargv, (char *const *)environ) ; +- failcoe(p[1]) ; +- strerr_dieexec(127, "run") ; +- } + if (notifyp[1] >= 0) fd_close(notifyp[1]) ; + fd_close(p[1]) ; + { diff --git a/skalibs b/skalibs @@ -0,0 +1 @@ +Subproject commit 5c0a576fdfc382350f90edd5483ef2fed7dcf90f