Skip to Content.
Sympa Menu

sm-commit - [[SM-Commit] ] GIT changes to master grimoire by Ismael Luceno (b7c37f8103289168eb43e6837b7a3fc855bee5bb)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Ismael Luceno <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org, sm-commit AT lists.sourcemage.org
  • Subject: [[SM-Commit] ] GIT changes to master grimoire by Ismael Luceno (b7c37f8103289168eb43e6837b7a3fc855bee5bb)
  • Date: Sun, 9 Jun 2024 21:10:45 +0000

GIT changes to master grimoire by Ismael Luceno <ismael AT sourcemage.org>:

smgl/simpleinit-msb/0001-Update-bootlogd-to-version-2.99.patch
| 762 ----------
smgl/simpleinit-msb/DETAILS
| 2
smgl/simpleinit-msb/HISTORY
| 43
smgl/simpleinit-msb/PRE_BUILD
| 17
smgl/simpleinit-msb/glibc-2.28.patch
| 11
smgl/simpleinit-msb/patches/0001-Fix-stdio-handling.patch
| 93 +
smgl/simpleinit-msb/patches/0002-shutdown-Add-ramfs-support.patch
| 41
smgl/simpleinit-msb/patches/0003-shutdown-Fix-minimum-UID-to-kill.patch
| 60

smgl/simpleinit-msb/patches/0004-simpleinit-Fix-display-of-messages-on-shutdown.patch
| 33
smgl/simpleinit-msb/patches/0005-simpleinit-Add-SELinux-support.patch
| 128 +

smgl/simpleinit-msb/patches/0006-Honour-NEED_LIBCRYPT-in-sysvtools-Makefile.patch
| 35
smgl/simpleinit-msb/patches/0007-Remove-NLS-support.patch
| 45

smgl/simpleinit-msb/patches/0008-shutdown-Fix-critical-segfault-on-invoking-from-Xen-.patch
| 31
smgl/simpleinit-msb/patches/0009-Add-missing-sys-sysmacros.h-include.patch
| 29

smgl/simpleinit-msb/patches/0010-Fix-compiler-flags-setup-for-sysvtools-Makefile.patch
| 30

smgl/simpleinit-msb/patches/0011-configure-Improve-compiler-flags-setup.patch
| 38

smgl/simpleinit-msb/patches/0012-shutdown-Replace-sigsetmask-with-sigprocmask.patch
| 32
smgl/simpleinit-msb/patches/0013-Update-bootlogd-to-version-2.99.patch
| 748 +++++++++
smgl/simpleinit-msb/patches/0014-Fix-non-std-fcntl.h-include.patch
| 26

smgl/simpleinit-msb/patches/0015-mconfig-Simplify-optimization-flag-selection.patch
| 39

smgl/simpleinit-msb/patches/0016-killall5-Make-path-buffer-in-readproc-larger.patch
| 28

smgl/simpleinit-msb/patches/0017-simpleinit-Avoid-setting-termenv-var-if-unused.patch
| 32
smgl/simpleinit-msb/patches/0018-simpleinit-Fix-off-by-one-loop.patch
| 28

smgl/simpleinit-msb/patches/0019-simpleinit-Avoid-named-variadic-macros.patch
| 30

smgl/simpleinit-msb/patches/0020-simpleinit-Fix-buffer-to-accommodate-actual-message-.patch
| 36

smgl/simpleinit-msb/patches/0021-shutdown-Fix-buffer-to-accomodate-actual-message-siz.patch
| 26

smgl/simpleinit-msb/patches/0022-shutdown-Fix-string-copies-in-write_user.patch
| 44

smgl/simpleinit-msb/patches/0023-Force-modern-libc-reboot-syscall-wrapper.patch
| 218 ++
smgl/simpleinit-msb/sigsetmask.patch
| 31
smgl/simpleinit-msb/simpleinit-1000uid.patch
| 40
smgl/simpleinit-msb/simpleinit-msb-crypt.patch
| 20
smgl/simpleinit-msb/simpleinit-nonls.patch
| 25
smgl/simpleinit-msb/simpleinit-output-on-shutdown.patch
| 12
smgl/simpleinit-msb/simpleinit-poweroff.patch
| 15
smgl/simpleinit-msb/simpleinit-selinux.patch
| 109 -
smgl/simpleinit-msb/simpleinit.patch
| 94 -
36 files changed, 1895 insertions(+), 1136 deletions(-)

New commits:
commit b7c37f8103289168eb43e6837b7a3fc855bee5bb
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

simpleinit-msb: Fix reboot for musl, PATCHLEVEL++

commit 673cf4c9719a1605ec2b53c623c253d4b5f95ee9
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

simpleinit-msb: Add a bunch of misc minor fixes

commit a57ae2e91ff55a3a4ab250e8a7a7907536da6a69
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

simpleinit-msb: Bulk patch normalisation

This adds metadata to patches, normalises them in git format, removes
whitespace errors, fixes indentation, and other cosmetic changes, and
applies them using apply_patch_dir, simplifying PRE_BUILD.

diff --git a/smgl/simpleinit-msb/0001-Update-bootlogd-to-version-2.99.patch
b/smgl/simpleinit-msb/0001-Update-bootlogd-to-version-2.99.patch
deleted file mode 100644
index de177e5..0000000
--- a/smgl/simpleinit-msb/0001-Update-bootlogd-to-version-2.99.patch
+++ /dev/null
@@ -1,762 +0,0 @@
-From 52d2ede2771e76f186526cf67a8b1454e88cc5b8 Mon Sep 17 00:00:00 2001
-From: Florian Franzmann <bwlf AT bandrate.org>
-Date: Fri, 4 Jun 2021 15:05:44 +0200
-Subject: [PATCH] Update bootlogd to version 2.99
-
----
- sysvtools/bootlogd.c | 444 +++++++++++++++++++++++++++----------------
- sysvtools/bootlogd.h | 12 ++
- 2 files changed, 290 insertions(+), 166 deletions(-)
- create mode 100644 sysvtools/bootlogd.h
-
-diff --git a/sysvtools/bootlogd.c b/sysvtools/bootlogd.c
-index e220349..787db87 100644
---- a/sysvtools/bootlogd.c
-+++ b/sysvtools/bootlogd.c
-@@ -8,18 +8,21 @@
- * Bugs: Uses openpty(), only available in glibc. Sorry.
- *
- * This file is part of the sysvinit suite,
-- * Copyright 1991-2004 Miquel van Smoorenburg.
-+ * Copyright (C) 1991-2004 Miquel van Smoorenburg.
- *
-- * This program is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU General Public License
-- * as published by the Free Software Foundation; either version
-- * 2 of the License, or (at your option) any later version.
-+ * This program is free software; you can redistribute it and/or
modify
-+ * it under the terms of the GNU General Public License as
published by
-+ * the Free Software Foundation; either version 2 of the
License, or
-+ * (at your option) any later version.
- *
-- * *NOTE* *NOTE* *NOTE*
-- * This is a PROOF OF CONCEPT IMPLEMENTATION
-+ * This program is distributed in the hope that it will be
useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ * GNU General Public License for more details.
- *
-- * I have bigger plans for Debian, but for now
-- * this has to do ;)
-+ * You should have received a copy of the GNU General Public
License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
- *
- */
-
-@@ -31,7 +34,6 @@
- #include <time.h>
- #include <stdio.h>
- #include <errno.h>
--#include <malloc.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <string.h>
-@@ -39,15 +41,23 @@
- #include <getopt.h>
- #include <dirent.h>
- #include <fcntl.h>
-+#ifdef __linux__
- #include <pty.h>
-+#endif
-+
-+#ifdef __FreeBSD__
-+#include <termios.h>
-+#include <libutil.h>
-+#endif
-+
- #include <ctype.h>
- #ifdef __linux__
- #include <sys/mount.h>
- #endif
-+#include "bootlogd.h"
-
--char *Version = "@(#) bootlogd 2.86 03-Jun-2004 miquels AT cistron.nl";
--
--#define LOGFILE "/var/log/boot"
-+#define MAX_CONSOLES 16
-+#define KERNEL_COMMAND_LENGTH 4096
-
- char ringbuf[32768];
- char *endptr = ringbuf + sizeof(ringbuf);
-@@ -56,11 +66,13 @@ char *outptr = ringbuf;
-
- int got_signal = 0;
- int didnl = 1;
-+int createlogfile = 0;
-+int syncalot = 0;
-
--struct line {
-- char buf[256];
-- int pos;
--} line;
-+struct real_cons {
-+ char name[1024];
-+ int fd;
-+};
-
- /*
- * Console devices as listed on the kernel command line and
-@@ -71,6 +83,7 @@ struct consdev {
- char *dev1;
- char *dev2;
- } consdev[] = {
-+ { "ttyB", "/dev/ttyB%s", NULL },
- { "ttySC", "/dev/ttySC%s", "/dev/ttsc/%s" },
- { "ttyS", "/dev/ttyS%s", "/dev/tts/%s" },
- { "tty", "/dev/tty%s", "/dev/vc/%s" },
-@@ -82,7 +95,7 @@ struct consdev {
- * Devices to try as console if not found on kernel command line.
- * Tried from left to right (as opposed to kernel cmdline).
- */
--char *defcons[] = { "tty0", "hvc0", "ttyS0", "ttySC0", NULL };
-+char *defcons[] = { "tty0", "hvc0", "ttyS0", "ttySC0", "ttyB0", NULL };
-
- /*
- * Catch signals.
-@@ -95,43 +108,69 @@ void handler(int sig)
-
- /*
- * Scan /dev and find the device name.
-- * Side-effect: directory is changed to /dev
-- *
-- * FIXME: scan subdirectories for devfs support ?
- */
--int findtty(char *res, int rlen, dev_t dev)
-+/*
-+This function does not appear to be called anymore. Commenting it
-+out for now, can probably be removed entirely in the future.
-+
-+static int findtty(char *res, const char *startdir, int rlen, dev_t dev)
- {
- DIR *dir;
- struct dirent *ent;
- struct stat st;
-- int r = 0;
--
-- if (chdir("/dev") < 0 || (dir = opendir(".")) == NULL) {
-- perror("bootlogd: /dev");
-+ int r = -1;
-+ char *olddir = getcwd(NULL, 0);
-+
-+ if (chdir(startdir) < 0 || (dir = opendir(".")) == NULL) {
-+ int msglen = strlen(startdir) + 11;
-+ char *msg = malloc(msglen);
-+ snprintf(msg, msglen, "bootlogd: %s", startdir);
-+ perror(msg);
-+ free(msg);
-+ chdir(olddir);
- return -1;
- }
- while ((ent = readdir(dir)) != NULL) {
- if (lstat(ent->d_name, &st) != 0)
- continue;
-+ if (S_ISDIR(st.st_mode)
-+ && 0 != strcmp(".", ent->d_name)
-+ && 0 != strcmp("..", ent->d_name)) {
-+ char *path = malloc(rlen);
-+ snprintf(path, rlen, "%s/%s", startdir, ent->d_name);
-+ r = findtty(res, path, rlen, dev);
-+ free(path);
-+ if (0 == r) {
-+ closedir(dir);
-+ chdir(olddir);
-+ return 0;
-+ }
-+ continue;
-+ }
- if (!S_ISCHR(st.st_mode))
- continue;
- if (st.st_rdev == dev) {
-- break;
-+ if ( (int) (strlen(ent->d_name) + strlen(startdir) +
1) >= rlen) {
-+ fprintf(stderr, "bootlogd: console device
name too long\n");
-+ closedir(dir);
-+ chdir(olddir);
-+ return -1;
-+ } else {
-+ snprintf(res, rlen, "%s/%s", startdir,
ent->d_name);
-+ closedir(dir);
-+ chdir(olddir);
-+ return 0;
-+ }
- }
- }
-- if (ent == NULL) {
-- fprintf(stderr, "bootlogd: cannot find console device "
-- "%d:%d in /dev\n", major(dev), minor(dev));
-- r = -1;
-- } else if (strlen(ent->d_name) + 5 >= rlen) {
-- fprintf(stderr, "bootlogd: console device name too long\n");
-- r = -1;
-- } else
-- snprintf(res, rlen, "/dev/%s", ent->d_name);
- closedir(dir);
-
-+ chdir(olddir);
- return r;
- }
-+*/
-+
-+
-
- /*
- * For some reason, openpty() in glibc sometimes doesn't
-@@ -167,7 +206,7 @@ int findpty(int *master, int *slave, char *name)
- }
- if (found) break;
- }
-- if (found < 0) return -1;
-+ if (!found) return -1;
-
- if (name) strcpy(name, tty);
-
-@@ -204,34 +243,21 @@ int isconsole(char *s, char *res, int rlen)
- }
-
- /*
-- * Find out the _real_ console. Assume that stdin is connected to
-+ * Find out the _real_ console(s). Assume that stdin is connected to
- * the console device (/dev/console).
- */
--int consolename(char *res, int rlen)
-+int consolenames(struct real_cons *cons, int max_consoles)
- {
- #ifdef TIOCGDEV
-- unsigned int kdev;
-+ /* This appears to be unused. unsigned int kdev; */
- #endif
- struct stat st, st2;
-- char buf[256];
-+ char buf[KERNEL_COMMAND_LENGTH];
- char *p;
- int didmount = 0;
-- int n, r;
-+ int n;
- int fd;
--
-- fstat(0, &st);
-- if (major(st.st_rdev) != 5 || minor(st.st_rdev) != 1) {
-- /*
-- * Old kernel, can find real device easily.
-- */
-- return findtty(res, rlen, st.st_rdev);
-- }
--
--#ifdef TIOCGDEV
-- if (ioctl(0, TIOCGDEV, &kdev) == 0)
-- return findtty(res, rlen, (dev_t)kdev);
-- if (errno != ENOIOCTLCMD) return -1;
--#endif
-+ int considx, num_consoles = 0;
-
- #ifdef __linux__
- /*
-@@ -240,7 +266,7 @@ int consolename(char *res, int rlen)
- stat("/", &st);
- if (stat("/proc", &st2) < 0) {
- perror("bootlogd: /proc");
-- return -1;
-+ return 0;
- }
- if (st.st_dev == st2.st_dev) {
- if (mount("proc", "/proc", "proc", 0, NULL) < 0) {
-@@ -250,45 +276,51 @@ int consolename(char *res, int rlen)
- didmount = 1;
- }
-
-- n = 0;
-- r = -1;
-+ n = -1;
- if ((fd = open("/proc/cmdline", O_RDONLY)) < 0) {
- perror("bootlogd: /proc/cmdline");
- } else {
- buf[0] = 0;
-- if ((n = read(fd, buf, sizeof(buf) - 1)) >= 0)
-- r = 0;
-- else
-+ if ((n = read(fd, buf, KERNEL_COMMAND_LENGTH - 1)) < 0)
- perror("bootlogd: /proc/cmdline");
- close(fd);
- }
- if (didmount) umount("/proc");
--
-- if (r < 0) return r;
-+
-+ if (n < 0) return 0;
-
- /*
- * OK, so find console= in /proc/cmdline.
- * Parse in reverse, opening as we go.
-- *
-- * Valid console devices: ttySC, ttyS, tty, hvc.
- */
- p = buf + n;
- *p-- = 0;
-- r = -1;
- while (p >= buf) {
- if (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n') {
- *p-- = 0;
- continue;
- }
- if (strncmp(p, "console=", 8) == 0 &&
-- isconsole(p + 8, res, rlen)) {
-- r = 0;
-- break;
-+ isconsole(p + 8, cons[num_consoles].name,
sizeof(cons[num_consoles].name))) {
-+ /*
-+ * Suppress duplicates
-+ */
-+ for (considx = 0; considx < num_consoles;
considx++) {
-+ if (!strcmp(cons[num_consoles].name,
cons[considx].name)) {
-+ goto dontuse;
-+ }
-+ }
-+
-+ num_consoles++;
-+ if (num_consoles >= max_consoles) {
-+ break;
-+ }
- }
-+dontuse:
- p--;
- }
-
-- if (r == 0) return r;
-+ if (num_consoles > 0) return num_consoles;
- #endif
-
- /*
-@@ -296,83 +328,99 @@ int consolename(char *res, int rlen)
- * guess the default console.
- */
- for (n = 0; defcons[n]; n++)
-- if (isconsole(defcons[n], res, rlen))
-- return 0;
-+ if (isconsole(defcons[n], cons[0].name,
sizeof(cons[0].name)))
-+ return 1;
-
- fprintf(stderr, "bootlogd: cannot deduce real console device\n");
-
-- return -1;
-+ return 0;
- }
-
-
- /*
- * Write data and make sure it's on disk.
- */
--void writelog(FILE *fp, unsigned char *ptr, int len)
-+void writelog(FILE *fp, unsigned char *ptr, int len, int
print_escape_characters)
- {
-- time_t t;
-- char *s;
-- char tmp[8];
-- int olen = len;
-- int dosync = 0;
-- int tlen;
--
-- while (len > 0) {
-- tmp[0] = 0;
-- if (didnl) {
-+ int dosync = 0;
-+ int i;
-+ static int first_run = 1;
-+ static int inside_esc = 0;
-+
-+ for (i = 0; i < len; i++) {
-+ int ignore = 0;
-+
-+ /* prepend date to every line */
-+ if (*(ptr-1) == '\n' || first_run) {
-+ time_t t;
-+ char *s;
- time(&t);
- s = ctime(&t);
- fprintf(fp, "%.24s: ", s);
-- didnl = 0;
-+ dosync = 1;
-+ first_run = 0;
- }
-- switch (*ptr) {
-- case 27: /* ESC */
-- strcpy(tmp, "^[");
-- break;
-- case '\r':
-- line.pos = 0;
-- break;
-- case 8: /* ^H */
-- if (line.pos > 0) line.pos--;
-- break;
-- case '\n':
-- didnl = 1;
-- dosync = 1;
-- break;
-- case '\t':
-- line.pos += (line.pos / 8 + 1) * 8;
-- if (line.pos >= sizeof(line.buf))
-- line.pos = sizeof(line.buf) - 1;
-- break;
-- case 32 ... 127:
-- case 161 ... 255:
-- tmp[0] = *ptr;
-- tmp[1] = 0;
-- break;
-- default:
-- sprintf(tmp, "\\%03o", *ptr);
-- break;
-- }
-- ptr++;
-- len--;
-
-- tlen = strlen(tmp);
-- if (tlen && (line.pos + tlen < sizeof(line.buf))) {
-- memcpy(line.buf + line.pos, tmp, tlen);
-- line.pos += tlen;
-- }
-- if (didnl) {
-- fprintf(fp, "%s\n", line.buf);
-- memset(&line, 0, sizeof(line));
-+ /* remove escape sequences, but do it in a way that allows us
to stop
-+ * in the middle in case the string was cut off */
-+ if (! print_escape_characters)
-+ {
-+ if (inside_esc == 1) {
-+ /* first '[' is special because if we encounter it
again, it should be considered the final byte */
-+ if (*ptr == '[') {
-+ /* multi char sequence */
-+ ignore = 1;
-+ inside_esc = 2;
-+ } else {
-+ /* single char sequence */
-+ if (*ptr >= 64 && *ptr <= 95) {
-+ ignore = 1;
-+ }
-+ inside_esc = 0;
-+ }
-+ } else if (inside_esc == 2) {
-+ switch (*ptr) {
-+ case '0' ... '9': /* intermediate chars of
escape sequence */
-+ case ';':
-+ case 32 ... 47:
-+ if (inside_esc) {
-+ ignore = 1;
-+ }
-+ break;
-+ case 64 ... 126: /* final char of escape
sequence */
-+ if (inside_esc) {
-+ ignore = 1;
-+ inside_esc = 0;
-+ }
-+ break;
-+ }
-+ } else {
-+ switch (*ptr) {
-+ case '\r':
-+ ignore = 1;
-+ break;
-+ case 27: /* ESC */
-+ ignore = 1;
-+ inside_esc = 1;
-+ break;
-+ }
-+ }
-+ } /* end of if we should filter escape characters */
-+
-+ if (!ignore) {
-+ fwrite(ptr, sizeof(char), 1, fp);
- }
-- }
-
-+ ptr++;
-+ }
- if (dosync) {
- fflush(fp);
-- fdatasync(fileno(fp));
-+ if (syncalot) {
-+ fdatasync(fileno(fp));
-+ }
- }
-
-- outptr += olen;
-+ outptr += len;
- if (outptr >= endptr)
- outptr = ringbuf;
-
-@@ -384,7 +432,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len)
- */
- void usage(void)
- {
-- fprintf(stderr, "Usage: bootlogd [-v] [-r] [-d] [-p pidfile] [-l
logfile]\n");
-+ fprintf(stderr, "Usage: bootlogd [-v] [-r] [-d] [-e] [-s] [-c] [-p
pidfile] [-l logfile]\n");
- exit(1);
- }
-
-@@ -429,24 +477,29 @@ int main(int argc, char **argv)
- struct timeval tv;
- fd_set fds;
- char buf[1024];
-- char realcons[1024];
- char *p;
- char *logfile;
- char *pidfile;
- int rotate;
- int dontfork;
- int ptm, pts;
-- int realfd;
-+ /* int realfd; -- this is now unused */
- int n, m, i;
- int todo;
--
-+#ifndef __linux__ /* BSD-style ioctl needs an argument. */
-+ int on = 1;
-+#endif
-+ int considx;
-+ struct real_cons cons[MAX_CONSOLES];
-+ int num_consoles, consoles_left;
-+ int print_escape_sequence = 0;
- fp = NULL;
- logfile = LOGFILE;
- pidfile = NULL;
- rotate = 0;
- dontfork = 0;
-
-- while ((i = getopt(argc, argv, "dl:p:rv")) != EOF) switch(i) {
-+ while ((i = getopt(argc, argv, "cdesl:p:rv")) != EOF) switch(i) {
- case 'l':
- logfile = optarg;
- break;
-@@ -454,15 +507,24 @@ int main(int argc, char **argv)
- rotate = 1;
- break;
- case 'v':
-- printf("%s\n", Version);
-+ printf("bootlogd - %s\n", "2.99");
- exit(0);
- break;
- case 'p':
- pidfile = optarg;
- break;
-+ case 'c':
-+ createlogfile = 1;
-+ break;
- case 'd':
- dontfork = 1;
- break;
-+ case 'e':
-+ print_escape_sequence = 1;
-+ break;
-+ case 's':
-+ syncalot = 1;
-+ break;
- default:
- usage();
- break;
-@@ -479,6 +541,7 @@ int main(int argc, char **argv)
- /*
- * Open console device directly.
- */
-+ /*
- if (consolename(realcons, sizeof(realcons)) < 0)
- return 1;
-
-@@ -488,9 +551,28 @@ int main(int argc, char **argv)
- strcpy(realcons, "/dev/vc/1");
-
- if ((realfd = open_nb(realcons)) < 0) {
-- fprintf(stderr, "bootlogd: %s: %s\n", buf, strerror(errno));
-+ fprintf(stderr, "bootlogd: %s: %s\n", realcons,
strerror(errno));
- return 1;
- }
-+ */
-+ if ((num_consoles = consolenames(cons, MAX_CONSOLES)) <= 0)
-+ return 1;
-+ consoles_left = num_consoles;
-+ for (considx = 0; considx < num_consoles; considx++) {
-+ if (strcmp(cons[considx].name, "/dev/tty0") == 0)
-+ strcpy(cons[considx].name, "/dev/tty1");
-+ if (strcmp(cons[considx].name, "/dev/vc/0") == 0)
-+ strcpy(cons[considx].name, "/dev/vc/1");
-+
-+ if ((cons[considx].fd = open_nb(cons[considx].name)) < 0) {
-+ fprintf(stderr, "bootlogd: %s: %s\n",
-+ cons[considx].name, strerror(errno));
-+ consoles_left--;
-+ }
-+ }
-+ if (!consoles_left)
-+ return 1;
-+
-
- /*
- * Grab a pty, and redirect console messages to it.
-@@ -505,15 +587,20 @@ int main(int argc, char **argv)
- return 1;
- }
-
-+#ifdef __linux__
- (void)ioctl(0, TIOCCONS, NULL);
--#if 1
- /* Work around bug in 2.1/2.2 kernels. Fixed in 2.2.13 and 2.3.18 */
- if ((n = open("/dev/tty0", O_RDWR)) >= 0) {
- (void)ioctl(n, TIOCCONS, NULL);
- close(n);
- }
- #endif
-- if (ioctl(pts, TIOCCONS, NULL) < 0) {
-+#ifdef __linux__
-+ if (ioctl(pts, TIOCCONS, NULL) < 0)
-+#else /* BSD usage of ioctl TIOCCONS. */
-+ if (ioctl(pts, TIOCCONS, &on) < 0)
-+#endif
-+ {
- fprintf(stderr, "bootlogd: ioctl(%s, TIOCCONS): %s\n",
- buf, strerror(errno));
- return 1;
-@@ -523,8 +610,19 @@ int main(int argc, char **argv)
- * Fork and write pidfile if needed.
- */
- if (!dontfork) {
-- if (fork())
-+ pid_t child_pid = fork();
-+ switch (child_pid) {
-+ case -1: /* I am parent and the attempt to create a child
failed */
-+ fprintf(stderr, "bootlogd: fork failed: %s\n",
-+ strerror(errno));
- exit(1);
-+ break;
-+ case 0: /* I am the child */
-+ break;
-+ default: /* I am parent and got child's pid */
-+ exit(0);
-+ break;
-+ }
- setsid();
- }
- if (pidfile) {
-@@ -558,27 +656,35 @@ int main(int argc, char **argv)
- if ((n = read(ptm, inptr, endptr - inptr)) >= 0) {
- /*
- * Write data (in chunks if needed)
-- * to the real output device.
-+ * to the real output devices.
- */
-- m = n;
-- p = inptr;
-- while (m > 0) {
-- i = write(realfd, p, m);
-- if (i >= 0) {
-- m -= i;
-- p += i;
-- continue;
-- }
-- /*
-- * Handle EIO (somebody hung
-- * up our filedescriptor)
-- */
-- realfd = write_err(pts, realfd,
-- realcons, errno);
-- if (realfd >= 0) continue;
-- got_signal = 1; /* Not really */
-- break;
-- }
-+ for (considx = 0; considx < num_consoles;
considx++) {
-+ if (cons[considx].fd < 0) continue;
-+ m = n;
-+ p = inptr;
-+ while (m > 0) {
-+ i = write(cons[considx].fd,
p, m);
-+ if (i >= 0) {
-+ m -= i;
-+ p += i;
-+ continue;
-+ }
-+ /*
-+ * Handle EIO (somebody
hung
-+ * up our filedescriptor)
-+ */
-+ cons[considx].fd =
write_err(pts,
-+ cons[considx].fd,
-+ cons[considx].name,
errno);
-+ if (cons[considx].fd >= 0)
continue;
-+ /*
-+ * If this was the last
console,
-+ * generate a fake signal
-+ */
-+ if (--consoles_left <= 0)
got_signal = 1;
-+ break;
-+ } /* end of while */
-+ } /* end of going through all consoles */
-
- /*
- * Increment buffer position. Handle
-@@ -592,25 +698,29 @@ int main(int argc, char **argv)
- inptr = ringbuf;
- if (outptr >= endptr)
- outptr = ringbuf;
-- }
-- }
-+ } /* end of got data from read */
-+ } /* end of checking select for new data */
-
- /*
- * Perhaps we need to open the logfile.
- */
-- if (fp == NULL && rotate && access(logfile, F_OK) == 0) {
-- snprintf(buf, sizeof(buf), "%s~", logfile);
-- rename(logfile, buf);
-+ if (fp == NULL && access(logfile, F_OK) == 0) {
-+ if (rotate) {
-+ snprintf(buf, sizeof(buf), "%s~", logfile);
-+ rename(logfile, buf);
-+ }
-+ fp = fopen(logfile, "a");
- }
-- if (fp == NULL)
-+ if (fp == NULL && createlogfile)
- fp = fopen(logfile, "a");
-+
- if (inptr >= outptr)
- todo = inptr - outptr;
- else
- todo = endptr - outptr;
- if (fp && todo)
-- writelog(fp, outptr, todo);
-- }
-+ writelog(fp, (unsigned char *)outptr, todo,
print_escape_sequence);
-+ } /* end of while waiting for signal */
-
- if (fp) {
- if (!didnl) fputc('\n', fp);
-@@ -619,7 +729,9 @@ int main(int argc, char **argv)
-
- close(pts);
- close(ptm);
-- close(realfd);
-+ for (considx = 0; considx < num_consoles; considx++) {
-+ close(cons[considx].fd);
-+ }
-
- return 0;
- }
-diff --git a/sysvtools/bootlogd.h b/sysvtools/bootlogd.h
-new file mode 100644
-index 0000000..b47bc9d
---- /dev/null
-+++ b/sysvtools/bootlogd.h
-@@ -0,0 +1,12 @@
-+#ifndef LOGFILE
-+#define LOGFILE "/var/log/boot"
-+#endif
-+
-+#ifndef TRUE
-+#define TRUE 1
-+#endif
-+
-+#ifndef FALSE
-+#define FALSE 0
-+#endif
-+
---
-2.31.1
-
diff --git a/smgl/simpleinit-msb/DETAILS b/smgl/simpleinit-msb/DETAILS
index 415aa89..e0e55f9 100755
--- a/smgl/simpleinit-msb/DETAILS
+++ b/smgl/simpleinit-msb/DETAILS
@@ -1,6 +1,6 @@
SPELL=simpleinit-msb
VERSION=1.3
- PATCHLEVEL=1
+ PATCHLEVEL=2
SOURCE=$SPELL-$VERSION.tar.bz2
SOURCE_DIRECTORY="$BUILD_DIRECTORY/$SPELL-$VERSION"
SOURCE_URL[0]=http://ftp.sourcemage.us/mirror/$SOURCE
diff --git a/smgl/simpleinit-msb/HISTORY b/smgl/simpleinit-msb/HISTORY
index 1f45004..81cb8e6 100644
--- a/smgl/simpleinit-msb/HISTORY
+++ b/smgl/simpleinit-msb/HISTORY
@@ -1,3 +1,46 @@
+2024-06-09 Ismael Luceno <ismael AT sourcemage.org>
+ * PRE_BUILD: added apply_patch_dir and removed manual application
+ * simpleinit.patch: normalised and split into
+ patches/0001-Fix-stdio-handling.patch and
+ patches/0002-shutdown-Add-ramfs-support.patch
+ * simpleinit-1000uid.patch: normalised and moved to
+ patches/0003-shutdown-Fix-minimum-UID-to-kill.patch
+ * simpleinit-output-on-shutdown.patch: normalised and moved to
+ patches/0004-simpleinit-Fix-display-of-messages-on-shutdown.patch
+ * simpleinit-selinux.patch: normalised and moved to
+ patches/0005-simpleinit-Add-SELinux-support.patch
+ * simpleinit-msb-crypt.patch: normalised and moved to
+ patches/0006-Honour-NEED_LIBCRYPT-in-sysvtools-Makefile.patch
+ * simpleinit-nonls.patch: normalised and moved to
+ patches/0007-Remove-NLS-support.patch
+ * simpleinit-poweroff.patch: normalised and moved to
+
patches/0008-shutdown-Fix-critical-segfault-on-invoking-from-Xen-.patch
+ * glibc-2.28.patch: normalised and moved to
+ patches/0009-Add-missing-sys-sysmacros.h-include.patch.
+ * patches/0010-Fix-compiler-flags-setup-for-sysvtools-Makefile.patch:
+ added in replacement of sed-editing the Makefile in PRE_BUILD
+ * patches/0011-configure-Improve-compiler-flags-setup.patch:
+ added to improve default flags
+ * sigsetmask.patch: normalised and moved to
+ patches/0012-shutdown-Replace-sigsetmask-with-sigprocmask.patch
+ * 0001-Update-bootlogd-to-version-2.99.patch: normalised and moved to
+ patches/0013-Update-bootlogd-to-version-2.99.patch
+ * patches/0014-Fix-non-std-fcntl.h-include.patch:
+ added to quiesce standards-compliance warnings
+ * patches/0015-mconfig-Simplify-optimization-flag-selection.patch:
+ added to fix omission of -pipe
+ * patches/0016-killall5-Make-path-buffer-in-readproc-larger.patch,
+ patches/0017-simpleinit-Avoid-setting-termenv-var-if-unused.patch,
+ patches/0018-simpleinit-Fix-off-by-one-loop.patch,
+ patches/0019-simpleinit-Avoid-named-variadic-macros.patch,
+
patches/0020-simpleinit-Fix-buffer-to-accommodate-actual-message-.patch
+
patches/0021-shutdown-Fix-buffer-to-accomodate-actual-message-siz.patch
+ patches/0022-shutdown-Fix-string-copies-in-write_user.patch:
+ added misc bug fixes
+ * patches/0023-Force-modern-libc-reboot-syscall-wrapper.patch:
+ added fix for non-glibc builds bug calling the reboot syscall
+ * DETAILS: PATCHLEVEL++
+
2022-05-25 Florian Franzmann <bwlf AT bandrate.org>
* DEPENDS: depend on util-linux without sulogin

diff --git a/smgl/simpleinit-msb/PRE_BUILD b/smgl/simpleinit-msb/PRE_BUILD
index 35b55bc..03a6a57 100755
--- a/smgl/simpleinit-msb/PRE_BUILD
+++ b/smgl/simpleinit-msb/PRE_BUILD
@@ -1,21 +1,6 @@
default_pre_build &&
cd "$SOURCE_DIRECTORY" &&
-
-patch -p0 < "$SPELL_DIRECTORY/simpleinit.patch" &&
-patch -p0 < "$SPELL_DIRECTORY/simpleinit-1000uid.patch" &&
-patch -p0 < "$SPELL_DIRECTORY/simpleinit-msb-crypt.patch" &&
-patch -p0 < "$SPELL_DIRECTORY/simpleinit-output-on-shutdown.patch" &&
-patch -p0 < "$SPELL_DIRECTORY/simpleinit-selinux.patch" &&
-patch -p0 < "$SPELL_DIRECTORY/simpleinit-nonls.patch" &&
-patch -p0 < "$SPELL_DIRECTORY/simpleinit-poweroff.patch" &&
-message "${MESSAGE_COLOR}Apply linux 2.6.38+ headers
patch...${DEFAULT_COLOR}" &&
-message "${MESSAGE_COLOR}Applying glibc 2.28 patch...${DEFAULT_COLOR}" &&
-patch -p1 < "$SPELL_DIRECTORY"/glibc-2.28.patch &&
-patch -fp1 -i "$SPELL_DIRECTORY"/sigsetmask.patch &&
-patch -p1 < "$SPELL_DIRECTORY"/0001-Update-bootlogd-to-version-2.99.patch &&
-
-sedit '/^LDFLAGS[\t ]*=/d;/^CFLAGS[\t ]*=/s/=.*/+= -D_GNU_SOURCE/' \
- sysvtools/Makefile &&
+apply_patch_dir patches &&

if [[ $SIMPLEINIT_STATIC == y ]]; then
sedit '/^shutdown:/a\t$(CC) -static $(LDFLAGS) -o $@ $^'
login-utils/Makefile
diff --git a/smgl/simpleinit-msb/glibc-2.28.patch
b/smgl/simpleinit-msb/glibc-2.28.patch
deleted file mode 100644
index 2fb4494..0000000
--- a/smgl/simpleinit-msb/glibc-2.28.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-diff -Naur simpleinit-msb-1.3.orig/sysvtools/mountpoint.c
simpleinit-msb-1.3/sysvtools/mountpoint.c
---- simpleinit-msb-1.3.orig/sysvtools/mountpoint.c 2018-09-13
16:05:48.825572632 -0700
-+++ simpleinit-msb-1.3/sysvtools/mountpoint.c 2018-09-13 16:09:28.807822475
-0700
-@@ -14,6 +14,7 @@
- * 2 of the License, or (at your option) any later version.
- */
-
-+#include <sys/sysmacros.h>
- #include <sys/stat.h>
- #include <unistd.h>
- #include <stdlib.h>
diff --git a/smgl/simpleinit-msb/patches/0001-Fix-stdio-handling.patch
b/smgl/simpleinit-msb/patches/0001-Fix-stdio-handling.patch
new file mode 100644
index 0000000..7a47f97
--- /dev/null
+++ b/smgl/simpleinit-msb/patches/0001-Fix-stdio-handling.patch
@@ -0,0 +1,93 @@
+From 473297022c81498ed0f4296c9bbf70addbddb335 Mon Sep 17 00:00:00 2001
+From: Unknown <root AT fawkes.sourcemage.org>
+Date: Mon, 24 Apr 2006 09:03:08 -0500
+Subject: [PATCH 01/23] Fix stdio handling
+
+* Add SIGUSR handler
+* Fix SIGTERM handler
+
+[ismael AT sourcemage.org: Normalised patch and added proper commit message]
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ login-utils/simpleinit.c | 36 ++++++++++++++++++++++++++++++------
+ 1 file changed, 30 insertions(+), 6 deletions(-)
+
+diff --git a/login-utils/simpleinit.c b/login-utils/simpleinit.c
+index f7031dfa2c21..4d0b4111aa4a 100644
+--- a/login-utils/simpleinit.c
++++ b/login-utils/simpleinit.c
+@@ -321,6 +321,8 @@ void sigchild_handler (int sig);
+ void sigquit_handler (int sig);
+ void userspace_sigquit_handler (int sig);
+ void sigterm_handler (int sig);
++void open_initctl_fifo (void);
++void sigusr_handler (int sig);
+ #ifdef SET_TZ
+ void set_tz (void);
+ #endif
+@@ -396,6 +398,8 @@ int main(int argc, char *argv[])
+ sigaction (SIGCHLD, &sa, NULL);
+ sa.sa_handler = userspace_sigquit_handler;
+ sigaction (SIGQUIT, &sa, NULL);
++ sa.sa_handler = sigusr_handler;
++ sigaction (SIGUSR1, &sa, NULL);
+ if (userspace) fix_userspace_paths(); else
+ {
+ sa.sa_handler = sigtstp_handler;
+@@ -440,12 +444,7 @@ int main(int argc, char *argv[])
+ }
+ }
+
+- if ( ( initctl_fd = open (initctl_name, O_RDWR|O_NONBLOCK, 0) ) < 0 )
{
+- mkfifo (initctl_name, S_IRUSR | S_IWUSR);
+- if ( ( initctl_fd = open (initctl_name, O_RDWR|O_NONBLOCK, 0)
) < 0 )
+- err ( _("error opening fifo\n") );
+- }
+- fcntl(initctl_fd,F_SETFD,FD_CLOEXEC); /*make sure no one inherits the
fd*/
++ open_initctl_fifo();
+
+ if (userspace){
+ pid_t mypid=getpid();
+@@ -885,6 +884,28 @@ void sigtstp_handler (int sig)
+ if (!stopped) hup_handler (sig);
+ } /* End Function sigtstp_handler */
+
++void open_initctl_fifo()
++{
++ if ( ( initctl_fd = open (initctl_name, O_RDWR|O_NONBLOCK, 0) ) < 0 )
{
++ mkfifo (initctl_name, S_IRUSR | S_IWUSR);
++ if ( ( initctl_fd = open (initctl_name, O_RDWR|O_NONBLOCK, 0)
) < 0 )
++ err ( _("error opening fifo\n") );
++ }
++ fcntl(initctl_fd,F_SETFD,FD_CLOEXEC); /*make sure no one inherits the
fd*/
++}
++
++void sigusr_handler (int sig)
++{
++ close (0);
++ close (1);
++ close (2);
++ open ("/dev/console", O_RDONLY, 0);
++ open ("/dev/console", O_RDWR, 0);
++ dup2 (1, 2);
++ open_initctl_fifo();
++ sig=sig;
++}
++
+ void sigterm_handler (int sig)
+ {
+ int i;
+@@ -1686,6 +1707,9 @@ int run_command (const char *file, const char *name,
pid_t pid, struct script_st
+ for (i = 1; i < NSIG; i++) signal (i, SIG_DFL);
+ sigprocmask(SIG_UNBLOCK,&all_signals,NULL);
+ if (!userspace) {
++ close (0);
++ close (1);
++ close (2);
+ open ("/dev/console", O_RDONLY, 0);
+ open ("/dev/console", O_RDWR, 0);
+ dup2 (1, 2);
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0002-shutdown-Add-ramfs-support.patch
b/smgl/simpleinit-msb/patches/0002-shutdown-Add-ramfs-support.patch
new file mode 100644
index 0000000..d2c399b
--- /dev/null
+++ b/smgl/simpleinit-msb/patches/0002-shutdown-Add-ramfs-support.patch
@@ -0,0 +1,41 @@
+From a0727a2932266ff27bdf8f487948af512a5114df Mon Sep 17 00:00:00 2001
+From: Unknown <root AT fawkes.sourcemage.org>
+Date: Mon, 24 Apr 2006 09:03:08 -0500
+Subject: [PATCH 02/23] shutdown: Add ramfs support
+
+[ismael AT sourcemage.org: Normalised patch and added proper commit message]
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ lib/pathnames.h | 2 +-
+ login-utils/shutdown.c | 1 +
+ 2 files changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/lib/pathnames.h b/lib/pathnames.h
+index 58bfa59bd27e..d15d94aabf5c 100644
+--- a/lib/pathnames.h
++++ b/lib/pathnames.h
+@@ -130,7 +130,7 @@ Libc5 and glibc 2.0-2.1 have /var/spool/mail, but glibc
2.1.1 has /var/mail.
+ #define _PATH_MTAB "/etc/mtab"
+ #define _PATH_PROC_MOUNTS "/proc/mounts"
+ #define _PATH_UMOUNT "/bin/umount"
+-#define UMOUNT_ARGS "umount", "-a", "-t", "nodevfs,noproc"
++#define UMOUNT_ARGS "umount", "-a", "-t", "nodevfs,noproc,noramfs"
+ #define SWAPOFF_ARGS "swapoff", "-a"
+
+ /* used in login-utils/setpwnam.h and login-utils/islocal.c */
+diff --git a/login-utils/shutdown.c b/login-utils/shutdown.c
+index 5b68a618d76a..ba74121dc8ba 100644
+--- a/login-utils/shutdown.c
++++ b/login-utils/shutdown.c
+@@ -746,6 +746,7 @@ unmount_disks_ourselves(void)
+ n = 0;
+ while (n < 100 && (mnt = getmntent(mtab))) {
+ if (strcmp (mnt->mnt_type, "devfs") == 0) continue;
++ if (strcmp (mnt->mnt_type, "ramfs") == 0) continue;
+ mntlist[n++] = strdup(mnt->mnt_dir);
+ }
+ endmntent(mtab);
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0003-shutdown-Fix-minimum-UID-to-kill.patch
b/smgl/simpleinit-msb/patches/0003-shutdown-Fix-minimum-UID-to-kill.patch
new file mode 100644
index 0000000..6532522
--- /dev/null
+++ b/smgl/simpleinit-msb/patches/0003-shutdown-Fix-minimum-UID-to-kill.patch
@@ -0,0 +1,60 @@
+From 3be9d767afb30d770d4963e41cc4117c8b9b2f54 Mon Sep 17 00:00:00 2001
+From: Unknown <root AT fawkes.sourcemage.org>
+Date: Mon, 24 Apr 2006 09:03:08 -0500
+Subject: [PATCH 03/23] shutdown: Fix minimum UID to kill
+
+[ismael AT sourcemage.org: Add proper commit message]
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ login-utils/shutdown.8 | 2 +-
+ login-utils/shutdown.c | 6 +++---
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/login-utils/shutdown.8 b/login-utils/shutdown.8
+index a84454b56dc3..266e8a082528 100644
+--- a/login-utils/shutdown.8
++++ b/login-utils/shutdown.8
+@@ -64,7 +64,7 @@ writes the shutdown time into the
+ .I /var/log/wtmp
+ file and terminates all processes as follows:
+
+-It kills (SIGTERM) all non-privileged (uid>=100) processes on the system,
++It kills (SIGTERM) all non-privileged (uid>=1000) processes on the system,
+ executes \fBfinalprog\fP as specified in \fI/etc/inittab\fP (see
+ .BR init (8)
+ ) with the argument "stop", tells
+diff --git a/login-utils/shutdown.c b/login-utils/shutdown.c
+index ba74121dc8ba..ee6ebb087847 100644
+--- a/login-utils/shutdown.c
++++ b/login-utils/shutdown.c
+@@ -413,7 +413,7 @@ main(int argc, char *argv[])
+ #ifndef DEBUGGING
+ my_puts ("");
+ my_puts (""); /* Get past the login prompt */
+- /* a gentle kill of all other processes except those with uid>=100 */
++ /* a gentle kill of all other processes except those with uid>=1000 */
+ /* the message stating this is in kill_mortals() because it is */
+ /* only printed if some processes are actually killed.*/
+ kill_mortals (SIGTERM);
+@@ -789,7 +789,7 @@ static void kill_mortals (int sig)
+ pid = atoi (de->d_name);
+ sprintf (path, "/proc/%d", pid);
+ if (stat (path, &statbuf) != 0) continue;
+- if (statbuf.st_uid < 100) continue;
++ if (statbuf.st_uid < 1000) continue;
+ if (index >= npids)
+ {
+ pids2 = realloc (pids, (npids+4096)*sizeof(pid_t));
+@@ -801,7 +801,7 @@ static void kill_mortals (int sig)
+ }
+ closedir (dp);
+ if (pids == NULL) return;
+- my_puts ("Sending TERM signal to processes with UID>=100...");
++ my_puts ("Sending TERM signal to processes with UID>=1000...");
+ for (--index; index >= 0; --index) kill (pids[index], sig);
+ free (pids);
+ } /* End Function kill_mortals */
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0004-simpleinit-Fix-display-of-messages-on-shutdown.patch

b/smgl/simpleinit-msb/patches/0004-simpleinit-Fix-display-of-messages-on-shutdown.patch
new file mode 100644
index 0000000..39c3ec7
--- /dev/null
+++
b/smgl/simpleinit-msb/patches/0004-simpleinit-Fix-display-of-messages-on-shutdown.patch
@@ -0,0 +1,33 @@
+From 3aff594bcaf7378fe2e174a3e99483f7cb7c7188 Mon Sep 17 00:00:00 2001
+From: Arwed von Merkatz <v.merkatz AT gmx.net>
+Date: Wed, 28 Feb 2007 22:27:32 +0100
+Subject: [PATCH 04/23] simpleinit: Fix display of messages on shutdown
+
+Fix stdio handling in the process_command function. This was missed in the
+stdio handling patch ("Fix stdio handling", 2006-04-24).
+
+Ref: https://bugs.sourcemage.org/show_bug.cgi?id=13114
+[ismael AT sourcemage.org: Added proper commit message]
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ login-utils/simpleinit.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/login-utils/simpleinit.c b/login-utils/simpleinit.c
+index 4d0b4111aa4a..34a31d4a420c 100644
+--- a/login-utils/simpleinit.c
++++ b/login-utils/simpleinit.c
+@@ -1497,6 +1497,9 @@ static void process_command (unsigned command,const
struct command_struct *comda
+ for (ival = 1; ival < NSIG; ival++) signal (ival, SIG_DFL);
+ sigprocmask(SIG_UNBLOCK,&all_signals,NULL);
+ if (!userspace){
++ close (0);
++ close (1);
++ close (2);
+ open ("/dev/console", O_RDONLY, 0);
+ open ("/dev/console", O_RDWR, 0);
+ dup2 (1, 2);
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0005-simpleinit-Add-SELinux-support.patch
b/smgl/simpleinit-msb/patches/0005-simpleinit-Add-SELinux-support.patch
new file mode 100644
index 0000000..ce33ba2
--- /dev/null
+++ b/smgl/simpleinit-msb/patches/0005-simpleinit-Add-SELinux-support.patch
@@ -0,0 +1,128 @@
+From 288548ae97605008c053c5aff3a607714942353b Mon Sep 17 00:00:00 2001
+From: David Michael Leo Brown Jr <dmlb2000 AT gmail.com>
+Date: Sat, 15 Sep 2007 00:23:25 +0000
+Subject: [PATCH 05/23] simpleinit: Add SELinux support
+
+Load policy if enabled.
+
+[ismael AT sourcemage.org: Normalised commit message]
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ login-utils/simpleinit.c | 72 +++++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 71 insertions(+), 1 deletion(-)
+
+diff --git a/login-utils/simpleinit.c b/login-utils/simpleinit.c
+index 34a31d4a420c..4a7be83973f3 100644
+--- a/login-utils/simpleinit.c
++++ b/login-utils/simpleinit.c
+@@ -218,6 +218,8 @@
+ #include <sys/ioctl.h>
+ #include <dirent.h>
+ #include <termios.h>
++#include <sys/mount.h>
++#include <sys/mman.h>
+ #include <utmp.h>
+ #include <sched.h>
+ #include <time.h>
+@@ -271,6 +273,7 @@ struct initline {
+ struct initline inittab[NUMCMD];
+ int numcmd;
+ int stopped = 0; /* are we stopped */
++int no_selinux = 1; /* disabled by default */
+ static char boot_prog[PATH_SIZE] = _PATH_RC;
+ static char init_root[PATH_SIZE] = "\0";
+ static char script_prefix[PATH_SIZE] = "\0";
+@@ -332,6 +335,8 @@ void utmp_init_process(int id);
+ pid_t mywait (int *status);
+ int run_command (const char *file, const char *name, pid_t pid,struct
script_struct* waiting_script);
+ void ystrncat(char* dest,const char* src,ssize_t n);
++int security_load_policy(void *data, size_t len);
++int load_policy(void);
+
+ /* like strcat, but dest will never contain more than n characters after
+ the call (i.e. a 0-terminator will be found among the first n characters,
+@@ -445,7 +450,14 @@ int main(int argc, char *argv[])
+ }
+
+ open_initctl_fifo();
+-
++
++ if (!no_selinux) {
++ if (load_policy() != 0) {
++ err( _("Failed to load SELinux policy.\n"));
++ exit(1);
++ }
++ }
++
+ if (userspace){
+ pid_t mypid=getpid();
+ int fd;
+@@ -542,6 +554,64 @@ int main(int argc, char *argv[])
+
+ #define MAXTRIES 3 /* number of tries allowed when giving the password */
+
++int security_load_policy(void *data, size_t len) {
++ int fd, ret;
++ fd = open("/selinux/load", O_RDWR);
++ if (fd < 0)
++ return -1;
++ ret = write(fd, data, len);
++ close(fd);
++ if (ret < 0)
++ return -1;
++ return 0;
++}
++
++int load_policy(void) {
++ int ret;
++ int fd;
++ void *map;
++ struct stat sb;
++ ret = mount("none", "/selinux", "selinuxfs", 0, 0);
++ if (ret < 0) {
++ char txt[256];
++ sprintf(txt, "SELinux: failed to mount /selinux
(errno=%d)\n", errno);
++ err( _(txt));
++ return ret;
++ }
++
++ fd = open("/etc/selinux/policy.bin", O_RDONLY);
++ if (fd < 0) {
++ char txt[256];
++ sprintf(txt, "SELinux: couldn't find /etc/selinux/policy.bin
(errno=%d)\n", errno);
++ err( _(txt));
++ return -1;
++ }
++
++ ret = fstat(fd, &sb);
++ if (ret < 0) {
++ char txt[256];
++ sprintf(txt, "Can't stat /etc/selinux/policy.bin
(errno=%d)\n", errno);
++ err( _(txt));
++ close(fd);
++ return ret;
++ }
++ map = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
++ if (map == MAP_FAILED) {
++ char txt[256];
++ sprintf(txt, "Can't map /etc/selinux/policy.bin (errno=%d\n",
errno);
++ err( _(txt));
++ close(fd);
++ return -1;
++ }
++ ret = security_load_policy(map, sb.st_size);
++ if (ret < 0) {
++ err( _("security_load_policy failed\n"));
++ }
++ close(fd);
++ return ret;
++}
++
++
+ /*
+ * run boot script(s). The environment is passed to the script(s), so the RC
+ * environment variable can be used to decide what to do.
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0006-Honour-NEED_LIBCRYPT-in-sysvtools-Makefile.patch

b/smgl/simpleinit-msb/patches/0006-Honour-NEED_LIBCRYPT-in-sysvtools-Makefile.patch
new file mode 100644
index 0000000..abdd114
--- /dev/null
+++
b/smgl/simpleinit-msb/patches/0006-Honour-NEED_LIBCRYPT-in-sysvtools-Makefile.patch
@@ -0,0 +1,35 @@
+From b247ce0e8745104a383d124e37378eb6c705d14e Mon Sep 17 00:00:00 2001
+From: Vlad Glagolev <stealth AT sourcemage.org>
+Date: Wed, 30 Jul 2008 23:49:53 +0400
+Subject: [PATCH 06/23] Honour NEED_LIBCRYPT in sysvtools/Makefile
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ sysvtools/Makefile | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/sysvtools/Makefile b/sysvtools/Makefile
+index 64af14f74f11..53af34ce47f1 100644
+--- a/sysvtools/Makefile
++++ b/sysvtools/Makefile
+@@ -8,6 +8,8 @@
+ # Version: @(#)Makefile 2.85-13 23-Mar-2004 miquels AT cistron.nl
+ #
+
++include ../make_include
++
+ CC = gcc
+ CFLAGS = -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE
+ LDFLAGS = -s
+@@ -36,7 +38,7 @@ INSTALL = install -o $(BIN_OWNER) -g
$(BIN_GROUP)
+ MANDIR = /usr/share/man
+
+ # Additional libs for GNU libc.
+-ifneq ($(wildcard /usr/lib/libcrypt.a),)
++ifeq "$(NEED_LIBCRYPT)" "yes"
+ LCRYPT = -lcrypt
+ endif
+
+--
+2.44.0
+
diff --git a/smgl/simpleinit-msb/patches/0007-Remove-NLS-support.patch
b/smgl/simpleinit-msb/patches/0007-Remove-NLS-support.patch
new file mode 100644
index 0000000..4687a86
--- /dev/null
+++ b/smgl/simpleinit-msb/patches/0007-Remove-NLS-support.patch
@@ -0,0 +1,45 @@
+From 1dcdbec8d0d2f7fa49ef4c3917ec8244bf5910ee Mon Sep 17 00:00:00 2001
+From: Vlad Glagolev <stealth AT sourcemage.org>
+Date: Wed, 30 Jul 2008 23:49:53 +0400
+Subject: [PATCH 07/23] Remove NLS support
+
+[ismael AT sourcemage.org: Added proper commit messsage]
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ login-utils/shutdown.c | 3 ---
+ login-utils/simpleinit.c | 4 ----
+ 2 files changed, 7 deletions(-)
+
+diff --git a/login-utils/shutdown.c b/login-utils/shutdown.c
+index ee6ebb087847..5f009129e508 100644
+--- a/login-utils/shutdown.c
++++ b/login-utils/shutdown.c
+@@ -197,9 +197,6 @@ main(int argc, char *argv[])
+ }
+ sigsetmask (0); /* simpleinit(8) blocks all signals: undo for ALRM
*/
+ for (i = 1; i < NSIG; i++) signal (i, SIG_DFL); /* unnecessary */
+- setlocale(LC_ALL, "");
+- bindtextdomain(PACKAGE, LOCALEDIR);
+- textdomain(PACKAGE);
+
+ #ifndef DEBUGGING
+ if(setreuid (0, 0)) {
+diff --git a/login-utils/simpleinit.c b/login-utils/simpleinit.c
+index 4a7be83973f3..5c40a48f7a3f 100644
+--- a/login-utils/simpleinit.c
++++ b/login-utils/simpleinit.c
+@@ -417,10 +417,6 @@ int main(int argc, char *argv[])
+ my_reboot (LINUX_REBOOT_CMD_CAD_OFF);
+ }
+
+- setlocale(LC_ALL, "");
+- bindtextdomain(PACKAGE, LOCALEDIR);
+- textdomain(PACKAGE);
+-
+ /* Find script to run. Command-line overrides config file overrides
+ built-in default */
+ for (i = 0; i < NUMCMD; i++) inittab[i].pid = -1;
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0008-shutdown-Fix-critical-segfault-on-invoking-from-Xen-.patch

b/smgl/simpleinit-msb/patches/0008-shutdown-Fix-critical-segfault-on-invoking-from-Xen-.patch
new file mode 100644
index 0000000..be0f10b
--- /dev/null
+++
b/smgl/simpleinit-msb/patches/0008-shutdown-Fix-critical-segfault-on-invoking-from-Xen-.patch
@@ -0,0 +1,31 @@
+From ebcfb9551977066de4f79c267ac0d11aabd7ac16 Mon Sep 17 00:00:00 2001
+From: Vlad Glagolev <stealth AT sourcemage.org>
+Date: Wed, 25 Jun 2014 15:35:46 +0400
+Subject: [PATCH 08/23] shutdown: Fix critical segfault on invoking from Xen
+ guest HVM DomU
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ login-utils/shutdown.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/login-utils/shutdown.c b/login-utils/shutdown.c
+index 5f009129e508..38a9a084f529 100644
+--- a/login-utils/shutdown.c
++++ b/login-utils/shutdown.c
+@@ -210,10 +210,10 @@ main(int argc, char *argv[])
+ prog = argv[0];
+ if((ptr = strrchr(argv[0], '/'))) prog = ++ptr;
+
+- /* All names (halt, reboot, fasthalt, fastboot, shutdown)
++ /* All names (halt, poweroff, reboot, fasthalt, fastboot, shutdown)
+ refer to the same program with the same options,
+ only the defaults differ. */
+- if(!strcmp("halt", prog)) {
++ if(!strcmp("halt", prog) || !strcmp("poweroff", prog)) {
+ opt_reboot = 0;
+ opt_quiet = 1;
+ opt_fast = 0;
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0009-Add-missing-sys-sysmacros.h-include.patch
b/smgl/simpleinit-msb/patches/0009-Add-missing-sys-sysmacros.h-include.patch
new file mode 100644
index 0000000..50df56c
--- /dev/null
+++
b/smgl/simpleinit-msb/patches/0009-Add-missing-sys-sysmacros.h-include.patch
@@ -0,0 +1,29 @@
+From 1663d9902b9985a8bad13918fa603c759aaaaefc Mon Sep 17 00:00:00 2001
+From: Eric Sandall <sandalle AT sourcemage.org>
+Date: Thu, 13 Sep 2018 16:14:41 -0700
+Subject: [PATCH 09/23] Add missing <sys/sysmacros.h> include
+
+For major & minor macros in mountpoint.c.
+
+[ismael AT sourcemage.org: Added proper commit message]
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ sysvtools/mountpoint.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/sysvtools/mountpoint.c b/sysvtools/mountpoint.c
+index c2477279ce7d..02d30805a4dd 100644
+--- a/sysvtools/mountpoint.c
++++ b/sysvtools/mountpoint.c
+@@ -14,6 +14,7 @@
+ * 2 of the License, or (at your option) any later version.
+ */
+
++#include <sys/sysmacros.h>
+ #include <sys/stat.h>
+ #include <unistd.h>
+ #include <stdlib.h>
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0010-Fix-compiler-flags-setup-for-sysvtools-Makefile.patch

b/smgl/simpleinit-msb/patches/0010-Fix-compiler-flags-setup-for-sysvtools-Makefile.patch
new file mode 100644
index 0000000..8c0fe10
--- /dev/null
+++
b/smgl/simpleinit-msb/patches/0010-Fix-compiler-flags-setup-for-sysvtools-Makefile.patch
@@ -0,0 +1,30 @@
+From 5f3637625bce6ee3b790ed7b86f798c06603e964 Mon Sep 17 00:00:00 2001
+From: Ismael Luceno <ismael AT iodev.co.uk>
+Date: Wed, 29 May 2019 07:02:21 +0200
+Subject: [PATCH 10/23] Fix compiler flags setup for sysvtools/Makefile
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ sysvtools/Makefile | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/sysvtools/Makefile b/sysvtools/Makefile
+index 53af34ce47f1..7546c7620303 100644
+--- a/sysvtools/Makefile
++++ b/sysvtools/Makefile
+@@ -10,10 +10,8 @@
+
+ include ../make_include
+
+-CC = gcc
+-CFLAGS = -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE
+-LDFLAGS = -s
+-STATIC =
++CFLAGS += -D_GNU_SOURCE
++STATIC =
+
+ # For some known distributions we do not build all programs, otherwise we
do.
+ BIN =
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0011-configure-Improve-compiler-flags-setup.patch

b/smgl/simpleinit-msb/patches/0011-configure-Improve-compiler-flags-setup.patch
new file mode 100644
index 0000000..96db403
--- /dev/null
+++
b/smgl/simpleinit-msb/patches/0011-configure-Improve-compiler-flags-setup.patch
@@ -0,0 +1,38 @@
+From e9fe0f88770f55cd799e6c2d2fb44bfa5cbe80f3 Mon Sep 17 00:00:00 2001
+From: Ismael Luceno <ismael AT iodev.co.uk>
+Date: Wed, 29 May 2019 07:09:33 +0200
+Subject: [PATCH 11/23] configure: Improve compiler flags setup
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ configure | 14 ++++++++------
+ 1 file changed, 8 insertions(+), 6 deletions(-)
+
+diff --git a/configure b/configure
+index bd18811354da..d26b5792680e 100755
+--- a/configure
++++ b/configure
+@@ -46,12 +46,14 @@ echo '#define SIMPLEINIT_MSB_VERSION "'$VERSION'"' >
defines.h
+ echo '#define simpleinit_msb_version "simpleinit-msb-'$VERSION'"' >>
defines.h
+ echo >> defines.h
+
+-CC=${CC-cc}
+-CFLAGS=${CFLAGS-"-O"}
+-LDFLAGS=${LDFLAGS-"-s"}
+-echo CC=$CC >> make_include
+-echo CFLAGS=$CFLAGS >> make_include
+-echo LDFLAGS=$LDFLAGS >> make_include
++: ${CC:=gcc}
++: ${CFLAGS=-Wall -O2 -fomit-frame-pointer}
++: ${LDFLAGS=-s}
++cat >> make_include << EOF
++CC = $CC
++CFLAGS = $CFLAGS
++LDFLAGS = $LDFLAGS
++EOF
+
+ DEFS=
+ LIBS=
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0012-shutdown-Replace-sigsetmask-with-sigprocmask.patch

b/smgl/simpleinit-msb/patches/0012-shutdown-Replace-sigsetmask-with-sigprocmask.patch
new file mode 100644
index 0000000..457d83f
--- /dev/null
+++
b/smgl/simpleinit-msb/patches/0012-shutdown-Replace-sigsetmask-with-sigprocmask.patch
@@ -0,0 +1,32 @@
+From 526973fd961ba4d5169c15962c60de22f34c59e4 Mon Sep 17 00:00:00 2001
+From: Ismael Luceno <ismael AT iodev.co.uk>
+Date: Tue, 11 Jun 2019 22:37:06 +0200
+Subject: [PATCH 12/23] shutdown: Replace sigsetmask with sigprocmask
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ login-utils/shutdown.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/login-utils/shutdown.c b/login-utils/shutdown.c
+index 38a9a084f529..2961d9174ba4 100644
+--- a/login-utils/shutdown.c
++++ b/login-utils/shutdown.c
+@@ -195,7 +195,13 @@ main(int argc, char *argv[])
+ for (fd = 0; fd < 3; fd++) close (fd);
+ while (1) wait (NULL); /* Grim reaper never stops */
+ }
+- sigsetmask (0); /* simpleinit(8) blocks all signals: undo for ALRM
*/
++ /* simpleinit(8) blocks all signals: undo for ALRM */
++ {
++ sigset_t n;
++ sigemptyset(&n);
++ sigaddset(&n, SIGALRM);
++ sigprocmask(SIG_UNBLOCK, &n, NULL);
++ }
+ for (i = 1; i < NSIG; i++) signal (i, SIG_DFL); /* unnecessary */
+
+ #ifndef DEBUGGING
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0013-Update-bootlogd-to-version-2.99.patch
b/smgl/simpleinit-msb/patches/0013-Update-bootlogd-to-version-2.99.patch
new file mode 100644
index 0000000..ed5b827
--- /dev/null
+++ b/smgl/simpleinit-msb/patches/0013-Update-bootlogd-to-version-2.99.patch
@@ -0,0 +1,748 @@
+From 7a16f4ba6ef4bf1505540038e0b51120f38e5d7c Mon Sep 17 00:00:00 2001
+From: Florian Franzmann <bwlf AT bandrate.org>
+Date: Fri, 4 Jun 2021 15:05:44 +0200
+Subject: [PATCH 13/23] Update bootlogd to version 2.99
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ sysvtools/bootlogd.c | 430 +++++++++++++++++++++++++++----------------
+ sysvtools/bootlogd.h | 11 ++
+ 2 files changed, 282 insertions(+), 159 deletions(-)
+ create mode 100644 sysvtools/bootlogd.h
+
+diff --git a/sysvtools/bootlogd.c b/sysvtools/bootlogd.c
+index e220349b597d..d3ab181eefa1 100644
+--- a/sysvtools/bootlogd.c
++++ b/sysvtools/bootlogd.c
+@@ -15,11 +15,14 @@
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+- * *NOTE* *NOTE* *NOTE*
+- * This is a PROOF OF CONCEPT IMPLEMENTATION
++ * This program is distributed in the hope that it will be
useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
+ *
+- * I have bigger plans for Debian, but for now
+- * this has to do ;)
++ * You should have received a copy of the GNU General Public
License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ */
+
+@@ -31,7 +34,6 @@
+ #include <time.h>
+ #include <stdio.h>
+ #include <errno.h>
+-#include <malloc.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+ #include <string.h>
+@@ -39,15 +41,23 @@
+ #include <getopt.h>
+ #include <dirent.h>
+ #include <fcntl.h>
++#ifdef __linux__
+ #include <pty.h>
++#endif
++
++#ifdef __FreeBSD__
++#include <termios.h>
++#include <libutil.h>
++#endif
++
+ #include <ctype.h>
+ #ifdef __linux__
+ #include <sys/mount.h>
+ #endif
++#include "bootlogd.h"
+
+-char *Version = "@(#) bootlogd 2.86 03-Jun-2004 miquels AT cistron.nl";
+-
+-#define LOGFILE "/var/log/boot"
++#define MAX_CONSOLES 16
++#define KERNEL_COMMAND_LENGTH 4096
+
+ char ringbuf[32768];
+ char *endptr = ringbuf + sizeof(ringbuf);
+@@ -56,11 +66,13 @@ char *outptr = ringbuf;
+
+ int got_signal = 0;
+ int didnl = 1;
++int createlogfile = 0;
++int syncalot = 0;
+
+-struct line {
+- char buf[256];
+- int pos;
+-} line;
++struct real_cons {
++ char name[1024];
++ int fd;
++};
+
+ /*
+ * Console devices as listed on the kernel command line and
+@@ -71,6 +83,7 @@ struct consdev {
+ char *dev1;
+ char *dev2;
+ } consdev[] = {
++ { "ttyB", "/dev/ttyB%s", NULL },
+ { "ttySC", "/dev/ttySC%s", "/dev/ttsc/%s" },
+ { "ttyS", "/dev/ttyS%s", "/dev/tts/%s" },
+ { "tty", "/dev/tty%s", "/dev/vc/%s" },
+@@ -82,7 +95,7 @@ struct consdev {
+ * Devices to try as console if not found on kernel command line.
+ * Tried from left to right (as opposed to kernel cmdline).
+ */
+-char *defcons[] = { "tty0", "hvc0", "ttyS0", "ttySC0", NULL };
++char *defcons[] = { "tty0", "hvc0", "ttyS0", "ttySC0", "ttyB0", NULL };
+
+ /*
+ * Catch signals.
+@@ -95,43 +108,69 @@ void handler(int sig)
+
+ /*
+ * Scan /dev and find the device name.
+- * Side-effect: directory is changed to /dev
+- *
+- * FIXME: scan subdirectories for devfs support ?
+ */
+-int findtty(char *res, int rlen, dev_t dev)
++/*
++This function does not appear to be called anymore. Commenting it
++out for now, can probably be removed entirely in the future.
++
++static int findtty(char *res, const char *startdir, int rlen, dev_t dev)
+ {
+ DIR *dir;
+ struct dirent *ent;
+ struct stat st;
+- int r = 0;
++ int r = -1;
++ char *olddir = getcwd(NULL, 0);
+
+- if (chdir("/dev") < 0 || (dir = opendir(".")) == NULL) {
+- perror("bootlogd: /dev");
++ if (chdir(startdir) < 0 || (dir = opendir(".")) == NULL) {
++ int msglen = strlen(startdir) + 11;
++ char *msg = malloc(msglen);
++ snprintf(msg, msglen, "bootlogd: %s", startdir);
++ perror(msg);
++ free(msg);
++ chdir(olddir);
+ return -1;
+ }
+ while ((ent = readdir(dir)) != NULL) {
+ if (lstat(ent->d_name, &st) != 0)
+ continue;
++ if (S_ISDIR(st.st_mode)
++ && 0 != strcmp(".", ent->d_name)
++ && 0 != strcmp("..", ent->d_name)) {
++ char *path = malloc(rlen);
++ snprintf(path, rlen, "%s/%s", startdir, ent->d_name);
++ r = findtty(res, path, rlen, dev);
++ free(path);
++ if (0 == r) {
++ closedir(dir);
++ chdir(olddir);
++ return 0;
++ }
++ continue;
++ }
+ if (!S_ISCHR(st.st_mode))
+ continue;
+ if (st.st_rdev == dev) {
+- break;
++ if ( (int) (strlen(ent->d_name) + strlen(startdir) +
1) >= rlen) {
++ fprintf(stderr, "bootlogd: console device
name too long\n");
++ closedir(dir);
++ chdir(olddir);
++ return -1;
++ } else {
++ snprintf(res, rlen, "%s/%s", startdir,
ent->d_name);
++ closedir(dir);
++ chdir(olddir);
++ return 0;
++ }
+ }
+ }
+- if (ent == NULL) {
+- fprintf(stderr, "bootlogd: cannot find console device "
+- "%d:%d in /dev\n", major(dev), minor(dev));
+- r = -1;
+- } else if (strlen(ent->d_name) + 5 >= rlen) {
+- fprintf(stderr, "bootlogd: console device name too long\n");
+- r = -1;
+- } else
+- snprintf(res, rlen, "/dev/%s", ent->d_name);
+ closedir(dir);
+
++ chdir(olddir);
+ return r;
+ }
++*/
++
++
+
+ /*
+ * For some reason, openpty() in glibc sometimes doesn't
+@@ -167,7 +206,7 @@ int findpty(int *master, int *slave, char *name)
+ }
+ if (found) break;
+ }
+- if (found < 0) return -1;
++ if (!found) return -1;
+
+ if (name) strcpy(name, tty);
+
+@@ -204,34 +243,21 @@ int isconsole(char *s, char *res, int rlen)
+ }
+
+ /*
+- * Find out the _real_ console. Assume that stdin is connected to
++ * Find out the _real_ console(s). Assume that stdin is connected to
+ * the console device (/dev/console).
+ */
+-int consolename(char *res, int rlen)
++int consolenames(struct real_cons *cons, int max_consoles)
+ {
+ #ifdef TIOCGDEV
+- unsigned int kdev;
++ /* This appears to be unused. unsigned int kdev; */
+ #endif
+ struct stat st, st2;
+- char buf[256];
++ char buf[KERNEL_COMMAND_LENGTH];
+ char *p;
+ int didmount = 0;
+- int n, r;
++ int n;
+ int fd;
+-
+- fstat(0, &st);
+- if (major(st.st_rdev) != 5 || minor(st.st_rdev) != 1) {
+- /*
+- * Old kernel, can find real device easily.
+- */
+- return findtty(res, rlen, st.st_rdev);
+- }
+-
+-#ifdef TIOCGDEV
+- if (ioctl(0, TIOCGDEV, &kdev) == 0)
+- return findtty(res, rlen, (dev_t)kdev);
+- if (errno != ENOIOCTLCMD) return -1;
+-#endif
++ int considx, num_consoles = 0;
+
+ #ifdef __linux__
+ /*
+@@ -240,7 +266,7 @@ int consolename(char *res, int rlen)
+ stat("/", &st);
+ if (stat("/proc", &st2) < 0) {
+ perror("bootlogd: /proc");
+- return -1;
++ return 0;
+ }
+ if (st.st_dev == st2.st_dev) {
+ if (mount("proc", "/proc", "proc", 0, NULL) < 0) {
+@@ -250,45 +276,51 @@ int consolename(char *res, int rlen)
+ didmount = 1;
+ }
+
+- n = 0;
+- r = -1;
++ n = -1;
+ if ((fd = open("/proc/cmdline", O_RDONLY)) < 0) {
+ perror("bootlogd: /proc/cmdline");
+ } else {
+ buf[0] = 0;
+- if ((n = read(fd, buf, sizeof(buf) - 1)) >= 0)
+- r = 0;
+- else
++ if ((n = read(fd, buf, KERNEL_COMMAND_LENGTH - 1)) < 0)
+ perror("bootlogd: /proc/cmdline");
+ close(fd);
+ }
+ if (didmount) umount("/proc");
+
+- if (r < 0) return r;
++ if (n < 0) return 0;
+
+ /*
+ * OK, so find console= in /proc/cmdline.
+ * Parse in reverse, opening as we go.
+- *
+- * Valid console devices: ttySC, ttyS, tty, hvc.
+ */
+ p = buf + n;
+ *p-- = 0;
+- r = -1;
+ while (p >= buf) {
+ if (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n') {
+ *p-- = 0;
+ continue;
+ }
+ if (strncmp(p, "console=", 8) == 0 &&
+- isconsole(p + 8, res, rlen)) {
+- r = 0;
+- break;
++ isconsole(p + 8, cons[num_consoles].name,
sizeof(cons[num_consoles].name))) {
++ /*
++ * Suppress duplicates
++ */
++ for (considx = 0; considx < num_consoles;
considx++) {
++ if (!strcmp(cons[num_consoles].name,
cons[considx].name)) {
++ goto dontuse;
++ }
++ }
++
++ num_consoles++;
++ if (num_consoles >= max_consoles) {
++ break;
++ }
+ }
++dontuse:
+ p--;
+ }
+
+- if (r == 0) return r;
++ if (num_consoles > 0) return num_consoles;
+ #endif
+
+ /*
+@@ -296,83 +328,99 @@ int consolename(char *res, int rlen)
+ * guess the default console.
+ */
+ for (n = 0; defcons[n]; n++)
+- if (isconsole(defcons[n], res, rlen))
+- return 0;
++ if (isconsole(defcons[n], cons[0].name, sizeof(cons[0].name)))
++ return 1;
+
+ fprintf(stderr, "bootlogd: cannot deduce real console device\n");
+
+- return -1;
++ return 0;
+ }
+
+
+ /*
+ * Write data and make sure it's on disk.
+ */
+-void writelog(FILE *fp, unsigned char *ptr, int len)
++void writelog(FILE *fp, unsigned char *ptr, int len, int
print_escape_characters)
+ {
+- time_t t;
+- char *s;
+- char tmp[8];
+- int olen = len;
+- int dosync = 0;
+- int tlen;
++ int dosync = 0;
++ int i;
++ static int first_run = 1;
++ static int inside_esc = 0;
+
+- while (len > 0) {
+- tmp[0] = 0;
+- if (didnl) {
++ for (i = 0; i < len; i++) {
++ int ignore = 0;
++
++ /* prepend date to every line */
++ if (*(ptr-1) == '\n' || first_run) {
++ time_t t;
++ char *s;
+ time(&t);
+ s = ctime(&t);
+ fprintf(fp, "%.24s: ", s);
+- didnl = 0;
++ dosync = 1;
++ first_run = 0;
+ }
+- switch (*ptr) {
+- case 27: /* ESC */
+- strcpy(tmp, "^[");
+- break;
+- case '\r':
+- line.pos = 0;
+- break;
+- case 8: /* ^H */
+- if (line.pos > 0) line.pos--;
+- break;
+- case '\n':
+- didnl = 1;
+- dosync = 1;
+- break;
+- case '\t':
+- line.pos += (line.pos / 8 + 1) * 8;
+- if (line.pos >= sizeof(line.buf))
+- line.pos = sizeof(line.buf) - 1;
+- break;
+- case 32 ... 127:
+- case 161 ... 255:
+- tmp[0] = *ptr;
+- tmp[1] = 0;
+- break;
+- default:
+- sprintf(tmp, "\\%03o", *ptr);
+- break;
++
++ /* remove escape sequences, but do it in a way that allows us
to stop
++ * in the middle in case the string was cut off */
++ if (! print_escape_characters)
++ {
++ if (inside_esc == 1) {
++ /* first '[' is special because if we encounter it
again, it should be considered the final byte */
++ if (*ptr == '[') {
++ /* multi char sequence */
++ ignore = 1;
++ inside_esc = 2;
++ } else {
++ /* single char sequence */
++ if (*ptr >= 64 && *ptr <= 95) {
++ ignore = 1;
++ }
++ inside_esc = 0;
++ }
++ } else if (inside_esc == 2) {
++ switch (*ptr) {
++ case '0' ... '9': /* intermediate chars of
escape sequence */
++ case ';':
++ case 32 ... 47:
++ if (inside_esc) {
++ ignore = 1;
++ }
++ break;
++ case 64 ... 126: /* final char of escape
sequence */
++ if (inside_esc) {
++ ignore = 1;
++ inside_esc = 0;
++ }
++ break;
++ }
++ } else {
++ switch (*ptr) {
++ case '\r':
++ ignore = 1;
++ break;
++ case 27: /* ESC */
++ ignore = 1;
++ inside_esc = 1;
++ break;
++ }
++ }
++ } /* end of if we should filter escape characters */
++
++ if (!ignore) {
++ fwrite(ptr, sizeof(char), 1, fp);
+ }
++
+ ptr++;
+- len--;
+-
+- tlen = strlen(tmp);
+- if (tlen && (line.pos + tlen < sizeof(line.buf))) {
+- memcpy(line.buf + line.pos, tmp, tlen);
+- line.pos += tlen;
+- }
+- if (didnl) {
+- fprintf(fp, "%s\n", line.buf);
+- memset(&line, 0, sizeof(line));
+- }
+ }
+-
+ if (dosync) {
+ fflush(fp);
+- fdatasync(fileno(fp));
++ if (syncalot) {
++ fdatasync(fileno(fp));
++ }
+ }
+
+- outptr += olen;
++ outptr += len;
+ if (outptr >= endptr)
+ outptr = ringbuf;
+
+@@ -384,7 +432,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len)
+ */
+ void usage(void)
+ {
+- fprintf(stderr, "Usage: bootlogd [-v] [-r] [-d] [-p pidfile] [-l
logfile]\n");
++ fprintf(stderr, "Usage: bootlogd [-v] [-r] [-d] [-e] [-s] [-c] [-p
pidfile] [-l logfile]\n");
+ exit(1);
+ }
+
+@@ -429,24 +477,29 @@ int main(int argc, char **argv)
+ struct timeval tv;
+ fd_set fds;
+ char buf[1024];
+- char realcons[1024];
+ char *p;
+ char *logfile;
+ char *pidfile;
+ int rotate;
+ int dontfork;
+ int ptm, pts;
+- int realfd;
++ /* int realfd; -- this is now unused */
+ int n, m, i;
+ int todo;
+-
++#ifndef __linux__ /* BSD-style ioctl needs an argument. */
++ int on = 1;
++#endif
++ int considx;
++ struct real_cons cons[MAX_CONSOLES];
++ int num_consoles, consoles_left;
++ int print_escape_sequence = 0;
+ fp = NULL;
+ logfile = LOGFILE;
+ pidfile = NULL;
+ rotate = 0;
+ dontfork = 0;
+
+- while ((i = getopt(argc, argv, "dl:p:rv")) != EOF) switch(i) {
++ while ((i = getopt(argc, argv, "cdesl:p:rv")) != EOF) switch(i) {
+ case 'l':
+ logfile = optarg;
+ break;
+@@ -454,15 +507,24 @@ int main(int argc, char **argv)
+ rotate = 1;
+ break;
+ case 'v':
+- printf("%s\n", Version);
++ printf("bootlogd - %s\n", "2.99");
+ exit(0);
+ break;
+ case 'p':
+ pidfile = optarg;
+ break;
++ case 'c':
++ createlogfile = 1;
++ break;
+ case 'd':
+ dontfork = 1;
+ break;
++ case 'e':
++ print_escape_sequence = 1;
++ break;
++ case 's':
++ syncalot = 1;
++ break;
+ default:
+ usage();
+ break;
+@@ -479,6 +541,7 @@ int main(int argc, char **argv)
+ /*
+ * Open console device directly.
+ */
++ /*
+ if (consolename(realcons, sizeof(realcons)) < 0)
+ return 1;
+
+@@ -488,9 +551,28 @@ int main(int argc, char **argv)
+ strcpy(realcons, "/dev/vc/1");
+
+ if ((realfd = open_nb(realcons)) < 0) {
+- fprintf(stderr, "bootlogd: %s: %s\n", buf, strerror(errno));
++ fprintf(stderr, "bootlogd: %s: %s\n", realcons,
strerror(errno));
+ return 1;
+ }
++ */
++ if ((num_consoles = consolenames(cons, MAX_CONSOLES)) <= 0)
++ return 1;
++ consoles_left = num_consoles;
++ for (considx = 0; considx < num_consoles; considx++) {
++ if (strcmp(cons[considx].name, "/dev/tty0") == 0)
++ strcpy(cons[considx].name, "/dev/tty1");
++ if (strcmp(cons[considx].name, "/dev/vc/0") == 0)
++ strcpy(cons[considx].name, "/dev/vc/1");
++
++ if ((cons[considx].fd = open_nb(cons[considx].name)) < 0) {
++ fprintf(stderr, "bootlogd: %s: %s\n",
++ cons[considx].name, strerror(errno));
++ consoles_left--;
++ }
++ }
++ if (!consoles_left)
++ return 1;
++
+
+ /*
+ * Grab a pty, and redirect console messages to it.
+@@ -505,15 +587,20 @@ int main(int argc, char **argv)
+ return 1;
+ }
+
++#ifdef __linux__
+ (void)ioctl(0, TIOCCONS, NULL);
+-#if 1
+ /* Work around bug in 2.1/2.2 kernels. Fixed in 2.2.13 and 2.3.18 */
+ if ((n = open("/dev/tty0", O_RDWR)) >= 0) {
+ (void)ioctl(n, TIOCCONS, NULL);
+ close(n);
+ }
+ #endif
+- if (ioctl(pts, TIOCCONS, NULL) < 0) {
++#ifdef __linux__
++ if (ioctl(pts, TIOCCONS, NULL) < 0)
++#else /* BSD usage of ioctl TIOCCONS. */
++ if (ioctl(pts, TIOCCONS, &on) < 0)
++#endif
++ {
+ fprintf(stderr, "bootlogd: ioctl(%s, TIOCCONS): %s\n",
+ buf, strerror(errno));
+ return 1;
+@@ -523,8 +610,19 @@ int main(int argc, char **argv)
+ * Fork and write pidfile if needed.
+ */
+ if (!dontfork) {
+- if (fork())
++ pid_t child_pid = fork();
++ switch (child_pid) {
++ case -1: /* I am parent and the attempt to create a child
failed */
++ fprintf(stderr, "bootlogd: fork failed: %s\n",
++ strerror(errno));
+ exit(1);
++ break;
++ case 0: /* I am the child */
++ break;
++ default: /* I am parent and got child's pid */
++ exit(0);
++ break;
++ }
+ setsid();
+ }
+ if (pidfile) {
+@@ -558,27 +656,35 @@ int main(int argc, char **argv)
+ if ((n = read(ptm, inptr, endptr - inptr)) >= 0) {
+ /*
+ * Write data (in chunks if needed)
+- * to the real output device.
++ * to the real output devices.
+ */
+- m = n;
+- p = inptr;
+- while (m > 0) {
+- i = write(realfd, p, m);
+- if (i >= 0) {
+- m -= i;
+- p += i;
+- continue;
+- }
+- /*
+- * Handle EIO (somebody hung
+- * up our filedescriptor)
+- */
+- realfd = write_err(pts, realfd,
+- realcons, errno);
+- if (realfd >= 0) continue;
+- got_signal = 1; /* Not really */
+- break;
+- }
++ for (considx = 0; considx < num_consoles;
considx++) {
++ if (cons[considx].fd < 0) continue;
++ m = n;
++ p = inptr;
++ while (m > 0) {
++ i = write(cons[considx].fd,
p, m);
++ if (i >= 0) {
++ m -= i;
++ p += i;
++ continue;
++ }
++ /*
++ * Handle EIO (somebody
hung
++ * up our filedescriptor)
++ */
++ cons[considx].fd =
write_err(pts,
++ cons[considx].fd,
++ cons[considx].name,
errno);
++ if (cons[considx].fd >= 0)
continue;
++ /*
++ * If this was the last
console,
++ * generate a fake signal
++ */
++ if (--consoles_left <= 0)
got_signal = 1;
++ break;
++ } /* end of while */
++ } /* end of going through all consoles */
+
+ /*
+ * Increment buffer position. Handle
+@@ -592,25 +698,29 @@ int main(int argc, char **argv)
+ inptr = ringbuf;
+ if (outptr >= endptr)
+ outptr = ringbuf;
+- }
+- }
++ } /* end of got data from read */
++ } /* end of checking select for new data */
+
+ /*
+ * Perhaps we need to open the logfile.
+ */
+- if (fp == NULL && rotate && access(logfile, F_OK) == 0) {
+- snprintf(buf, sizeof(buf), "%s~", logfile);
+- rename(logfile, buf);
+- }
+- if (fp == NULL)
++ if (fp == NULL && access(logfile, F_OK) == 0) {
++ if (rotate) {
++ snprintf(buf, sizeof(buf), "%s~", logfile);
++ rename(logfile, buf);
++ }
+ fp = fopen(logfile, "a");
++ }
++ if (fp == NULL && createlogfile)
++ fp = fopen(logfile, "a");
++
+ if (inptr >= outptr)
+ todo = inptr - outptr;
+ else
+ todo = endptr - outptr;
+ if (fp && todo)
+- writelog(fp, outptr, todo);
+- }
++ writelog(fp, (unsigned char *)outptr, todo,
print_escape_sequence);
++ } /* end of while waiting for signal */
+
+ if (fp) {
+ if (!didnl) fputc('\n', fp);
+@@ -619,7 +729,9 @@ int main(int argc, char **argv)
+
+ close(pts);
+ close(ptm);
+- close(realfd);
++ for (considx = 0; considx < num_consoles; considx++) {
++ close(cons[considx].fd);
++ }
+
+ return 0;
+ }
+diff --git a/sysvtools/bootlogd.h b/sysvtools/bootlogd.h
+new file mode 100644
+index 000000000000..412dc768771a
+--- /dev/null
++++ b/sysvtools/bootlogd.h
+@@ -0,0 +1,11 @@
++#ifndef LOGFILE
++#define LOGFILE "/var/log/boot"
++#endif
++
++#ifndef TRUE
++#define TRUE 1
++#endif
++
++#ifndef FALSE
++#define FALSE 0
++#endif
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0014-Fix-non-std-fcntl.h-include.patch
b/smgl/simpleinit-msb/patches/0014-Fix-non-std-fcntl.h-include.patch
new file mode 100644
index 0000000..55ffd56
--- /dev/null
+++ b/smgl/simpleinit-msb/patches/0014-Fix-non-std-fcntl.h-include.patch
@@ -0,0 +1,26 @@
+From 5bd831d439ace38e0c3a358e8bd3a1cc584ff9c1 Mon Sep 17 00:00:00 2001
+From: Ismael Luceno <ismael AT iodev.co.uk>
+Date: Sat, 8 Jun 2024 20:57:28 +0200
+Subject: [PATCH 14/23] Fix non-std fcntl.h include
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ sysvtools/last.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/sysvtools/last.c b/sysvtools/last.c
+index 70a142c034dc..7339d38989ca 100644
+--- a/sysvtools/last.c
++++ b/sysvtools/last.c
+@@ -19,7 +19,7 @@
+
+ #include <sys/types.h>
+ #include <sys/stat.h>
+-#include <sys/fcntl.h>
++#include <fcntl.h>
+ #include <time.h>
+ #include <stdio.h>
+ #include <ctype.h>
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0015-mconfig-Simplify-optimization-flag-selection.patch

b/smgl/simpleinit-msb/patches/0015-mconfig-Simplify-optimization-flag-selection.patch
new file mode 100644
index 0000000..58883a8
--- /dev/null
+++
b/smgl/simpleinit-msb/patches/0015-mconfig-Simplify-optimization-flag-selection.patch
@@ -0,0 +1,39 @@
+From bbac8263560dc88c5da9c9726da5306e3af08678 Mon Sep 17 00:00:00 2001
+From: Ismael Luceno <ismael AT iodev.co.uk>
+Date: Sat, 8 Jun 2024 21:05:58 +0200
+Subject: [PATCH 15/23] mconfig: Simplify optimization flag selection
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ mconfig | 9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/mconfig b/mconfig
+index 6d88bd691baf..c2b99fe020b3 100644
+--- a/mconfig
++++ b/mconfig
+@@ -21,17 +21,16 @@ HAVE_SYSVINIT=no
+
+
+ # Different optimizations for different cpus.
++OPT = -pipe -O2 -fomit-frame-pointer
+ ifeq "$(ARCH)" "intel"
+ ifeq "$(CPU)" "i386"
+- OPT= -pipe -O2 -m386 -fomit-frame-pointer
++ OPT += -m386
+ else
+- OPT= -pipe -O2 -m486 -fomit-frame-pointer
++ OPT += -m486
+ endif
+ else
+ ifeq "$(ARCH)" "arm"
+- OPT= -pipe -O2 -fsigned-char -fomit-frame-pointer
+- else
+- OPT= -O2 -fomit-frame-pointer
++ OPT += -fsigned-char
+ endif
+ endif
+
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0016-killall5-Make-path-buffer-in-readproc-larger.patch

b/smgl/simpleinit-msb/patches/0016-killall5-Make-path-buffer-in-readproc-larger.patch
new file mode 100644
index 0000000..278ea26
--- /dev/null
+++
b/smgl/simpleinit-msb/patches/0016-killall5-Make-path-buffer-in-readproc-larger.patch
@@ -0,0 +1,28 @@
+From 71c39f518fc3070d44b3ec0fa07ca83e00068f03 Mon Sep 17 00:00:00 2001
+From: Ismael Luceno <ismael AT iodev.co.uk>
+Date: Sat, 8 Jun 2024 21:15:40 +0200
+Subject: [PATCH 16/23] killall5: Make path buffer in readproc larger
+
+270 should be enough to store any output from snprintf.
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ sysvtools/killall5.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/sysvtools/killall5.c b/sysvtools/killall5.c
+index 2775777ee464..2dec9825017e 100644
+--- a/sysvtools/killall5.c
++++ b/sysvtools/killall5.c
+@@ -173,7 +173,7 @@ int readproc()
+ PROC *p, *n;
+ struct dirent *d;
+ struct stat st;
+- char path[256];
++ char path[270];
+ char buf[256];
+ char *s, *q;
+ unsigned long startcode, endcode;
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0017-simpleinit-Avoid-setting-termenv-var-if-unused.patch

b/smgl/simpleinit-msb/patches/0017-simpleinit-Avoid-setting-termenv-var-if-unused.patch
new file mode 100644
index 0000000..0afe627
--- /dev/null
+++
b/smgl/simpleinit-msb/patches/0017-simpleinit-Avoid-setting-termenv-var-if-unused.patch
@@ -0,0 +1,32 @@
+From 87b889f1fcb9d973d99279c2dc755a1d94d19acf Mon Sep 17 00:00:00 2001
+From: Ismael Luceno <ismael AT iodev.co.uk>
+Date: Sat, 8 Jun 2024 21:22:38 +0200
+Subject: [PATCH 17/23] simpleinit: Avoid setting termenv var if unused
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ login-utils/simpleinit.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/login-utils/simpleinit.c b/login-utils/simpleinit.c
+index 5c40a48f7a3f..cfd9f3b0564d 100644
+--- a/login-utils/simpleinit.c
++++ b/login-utils/simpleinit.c
+@@ -818,12 +818,11 @@ void read_inittab (void)
+ #ifdef SPECIAL_CONSOLE_TERM
+ char tty[50];
+ struct stat stb;
+-#endif
+ char *termenv;
+-
+ termenv = getenv("TERM"); /* set by kernel */
+ /* termenv = "vt100"; */
+-
++#endif
++
+ if(!(f = fopen(_path_inittab, "r"))) {
+ err(_("cannot open inittab\n"));
+ return;
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0018-simpleinit-Fix-off-by-one-loop.patch
b/smgl/simpleinit-msb/patches/0018-simpleinit-Fix-off-by-one-loop.patch
new file mode 100644
index 0000000..b6cabaa
--- /dev/null
+++ b/smgl/simpleinit-msb/patches/0018-simpleinit-Fix-off-by-one-loop.patch
@@ -0,0 +1,28 @@
+From 5b0247d66408a9507e3007ba0fb3dfb3402b587a Mon Sep 17 00:00:00 2001
+From: Ismael Luceno <ismael AT iodev.co.uk>
+Date: Sat, 8 Jun 2024 21:23:40 +0200
+Subject: [PATCH 18/23] simpleinit: Fix off-by-one loop
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ login-utils/simpleinit.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/login-utils/simpleinit.c b/login-utils/simpleinit.c
+index cfd9f3b0564d..5b3280a41638 100644
+--- a/login-utils/simpleinit.c
++++ b/login-utils/simpleinit.c
+@@ -832,9 +832,7 @@ void read_inittab (void)
+ i = 0;
+ while(!feof(f) && i < NUMCMD - 2) {
+ if(fgets(buf, CMDSIZ - 1, f) == 0) break;
+- buf[CMDSIZ-1] = 0;
+-
+- for(k = 0; k < CMDSIZ && buf[k]; k++)
++ for(k = 0; k < CMDSIZ - 1 && buf[k]; k++)
+ if ((buf[k] == '#') || (buf[k] == '\n')) break;
+ buf[k]=0;
+ /*treat lines that start with whitespace as empty*/
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0019-simpleinit-Avoid-named-variadic-macros.patch

b/smgl/simpleinit-msb/patches/0019-simpleinit-Avoid-named-variadic-macros.patch
new file mode 100644
index 0000000..b495900
--- /dev/null
+++
b/smgl/simpleinit-msb/patches/0019-simpleinit-Avoid-named-variadic-macros.patch
@@ -0,0 +1,30 @@
+From a718a991d9f415878759f9533682f8e9a86fcda0 Mon Sep 17 00:00:00 2001
+From: Ismael Luceno <ismael AT iodev.co.uk>
+Date: Sat, 8 Jun 2024 21:25:44 +0200
+Subject: [PATCH 19/23] simpleinit: Avoid named variadic macros
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ login-utils/simpleinit.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/login-utils/simpleinit.c b/login-utils/simpleinit.c
+index 5b3280a41638..5b858afac41c 100644
+--- a/login-utils/simpleinit.c
++++ b/login-utils/simpleinit.c
+@@ -356,10 +356,10 @@ void ystrncat(char* dest,const char* src,ssize_t n)
+
+ /* like sprintf but protects against overflow and works if source(s) and
+ target overlap*/
+-#define ysprintf(dest,rest...) \
++#define ysprintf(dest, ...) \
+ { \
+ char buffy[sizeof(dest)]; \
+- snprintf(buffy,sizeof(buffy), ##rest); \
++ snprintf(buffy,sizeof(buffy), ##__VA_ARGS__); \
+ buffy[sizeof(dest)-1]=0; \
+ memcpy((dest),buffy,sizeof(dest)); \
+ }
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0020-simpleinit-Fix-buffer-to-accommodate-actual-message-.patch

b/smgl/simpleinit-msb/patches/0020-simpleinit-Fix-buffer-to-accommodate-actual-message-.patch
new file mode 100644
index 0000000..795fb84
--- /dev/null
+++
b/smgl/simpleinit-msb/patches/0020-simpleinit-Fix-buffer-to-accommodate-actual-message-.patch
@@ -0,0 +1,36 @@
+From 1bfb0fc0086a4db907e1049feb856e23ed54a074 Mon Sep 17 00:00:00 2001
+From: Ismael Luceno <ismael AT iodev.co.uk>
+Date: Sat, 8 Jun 2024 21:29:30 +0200
+Subject: [PATCH 20/23] simpleinit: Fix buffer to accommodate actual message
+ sizes
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ login-utils/simpleinit.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/login-utils/simpleinit.c b/login-utils/simpleinit.c
+index 5b858afac41c..de8e60cb97b1 100644
+--- a/login-utils/simpleinit.c
++++ b/login-utils/simpleinit.c
+@@ -1552,7 +1552,7 @@ static void process_command (unsigned command,const
struct command_struct *comda
+ { /* launch stop script */
+ pid_t pid;
+ struct script_struct *victim = available_list.first;
+- char txt[256];
++ char txt[335];
+
+ sigprocmask(SIG_BLOCK,&all_signals,&oldsigmask);
+ if ( ( pid = fork () ) == 0 ) /* Child */
+@@ -1584,7 +1584,7 @@ static void process_command (unsigned command,const
struct command_struct *comda
+ }
+
+ exec_with_params(fpath, stop, NULL);
+- snprintf(txt,256,"errno %u running program %s\n",
++ snprintf(txt,sizeof(txt),"errno %u running program %s\n",
+ errno,fpath);
+ err ( txt );
+ _exit (SIG_NOT_STOPPED);
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0021-shutdown-Fix-buffer-to-accomodate-actual-message-siz.patch

b/smgl/simpleinit-msb/patches/0021-shutdown-Fix-buffer-to-accomodate-actual-message-siz.patch
new file mode 100644
index 0000000..1988b83
--- /dev/null
+++
b/smgl/simpleinit-msb/patches/0021-shutdown-Fix-buffer-to-accomodate-actual-message-siz.patch
@@ -0,0 +1,26 @@
+From 00b0ddfa46fc80e2d41fac2b59460308e9d646cd Mon Sep 17 00:00:00 2001
+From: Ismael Luceno <ismael AT iodev.co.uk>
+Date: Sat, 8 Jun 2024 21:56:49 +0200
+Subject: [PATCH 21/23] shutdown: Fix buffer to accomodate actual message size
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ login-utils/shutdown.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/login-utils/shutdown.c b/login-utils/shutdown.c
+index 2961d9174ba4..23fe24fca1e2 100644
+--- a/login-utils/shutdown.c
++++ b/login-utils/shutdown.c
+@@ -582,7 +582,7 @@ write_user(struct utmp *ut)
+ int fd;
+ int minutes, hours;
+ char term[40] = {'/','d','e','v','/',0};
+- char msg[100];
++ char msg[266];
+
+ minutes = timeout / 60;
+ hours = minutes / 60;
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0022-shutdown-Fix-string-copies-in-write_user.patch

b/smgl/simpleinit-msb/patches/0022-shutdown-Fix-string-copies-in-write_user.patch
new file mode 100644
index 0000000..eefd0b9
--- /dev/null
+++
b/smgl/simpleinit-msb/patches/0022-shutdown-Fix-string-copies-in-write_user.patch
@@ -0,0 +1,44 @@
+From 4ffc87a2588ba553ec667f6ef4ec0a1d00bbff4e Mon Sep 17 00:00:00 2001
+From: Ismael Luceno <ismael AT iodev.co.uk>
+Date: Sat, 8 Jun 2024 22:02:51 +0200
+Subject: [PATCH 22/23] shutdown: Fix string copies in write_user
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ login-utils/shutdown.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/login-utils/shutdown.c b/login-utils/shutdown.c
+index 23fe24fca1e2..950c14a82efd 100644
+--- a/login-utils/shutdown.c
++++ b/login-utils/shutdown.c
+@@ -581,14 +581,15 @@ write_user(struct utmp *ut)
+ {
+ int fd;
+ int minutes, hours;
+- char term[40] = {'/','d','e','v','/',0};
++#define TERM_PREFIX "/dev/"
++ char term[40] = TERM_PREFIX;
+ char msg[266];
+
+ minutes = timeout / 60;
+ hours = minutes / 60;
+ minutes %= 60;
+
+- (void) strncat(term, ut->ut_line, sizeof(ut->ut_line));
++ strncat(term, ut->ut_line, sizeof(term) - sizeof(TERM_PREFIX));
+
+ /* try not to get stuck on a mangled ut_line entry... */
+ if((fd = open(term, O_WRONLY|O_NONBLOCK)) < 0)
+@@ -649,7 +650,7 @@ write_wtmp(void)
+
+ memset((char *)&ut, 0, sizeof(ut));
+ strcpy(ut.ut_line, "~");
+- memcpy(ut.ut_name, "shutdown", sizeof(ut.ut_name));
++ strcpy(ut.ut_name, "shutdown");
+
+ time(&ut.ut_time);
+ ut.ut_type = BOOT_TIME;
+--
+2.44.0
+
diff --git
a/smgl/simpleinit-msb/patches/0023-Force-modern-libc-reboot-syscall-wrapper.patch

b/smgl/simpleinit-msb/patches/0023-Force-modern-libc-reboot-syscall-wrapper.patch
new file mode 100644
index 0000000..76e469a
--- /dev/null
+++
b/smgl/simpleinit-msb/patches/0023-Force-modern-libc-reboot-syscall-wrapper.patch
@@ -0,0 +1,218 @@
+From 204e222f1974feccb09466e5fcdbb28b8076037c Mon Sep 17 00:00:00 2001
+From: Ismael Luceno <ismael AT iodev.co.uk>
+Date: Sat, 8 Jun 2024 22:30:06 +0200
+Subject: [PATCH 23/23] Force modern libc reboot syscall wrapper
+
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ lib/Makefile | 4 +---
+ lib/linux_reboot.h | 30 ------------------------------
+ lib/my_reboot.c | 40 ----------------------------------------
+ login-utils/Makefile | 9 ++++-----
+ login-utils/shutdown.c | 10 +++++-----
+ login-utils/simpleinit.c | 6 +++---
+ 6 files changed, 13 insertions(+), 86 deletions(-)
+ delete mode 100644 lib/linux_reboot.h
+ delete mode 100644 lib/my_reboot.c
+
+diff --git a/lib/Makefile b/lib/Makefile
+index 6747061c389e..4d87dcf805c7 100644
+--- a/lib/Makefile
++++ b/lib/Makefile
+@@ -1,9 +1,7 @@
+ include ../make_include
+ include ../mconfig
+
+-all: my_reboot.o xstrncpy.o
+-
+-my_reboot.o: my_reboot.c linux_reboot.h
++all: xstrncpy.o
+
+ xstrncpy.o: xstrncpy.h
+
+diff --git a/lib/linux_reboot.h b/lib/linux_reboot.h
+deleted file mode 100644
+index 780d7509344c..000000000000
+--- a/lib/linux_reboot.h
++++ /dev/null
+@@ -1,30 +0,0 @@
+-extern int my_reboot(int);
+-
+-/*
+- * Magic values required to use _reboot() system call.
+- */
+-
+-#define LINUX_REBOOT_MAGIC1 0xfee1dead
+-#define LINUX_REBOOT_MAGIC2 672274793
+-#define LINUX_REBOOT_MAGIC2A 85072278
+-#define LINUX_REBOOT_MAGIC2B 369367448
+-
+-
+-/*
+- * Commands accepted by the _reboot() system call.
+- *
+- * RESTART Restart system using default command and mode.
+- * HALT Stop OS and give system control to ROM monitor, if any.
+- * CAD_ON Ctrl-Alt-Del sequence causes RESTART command.
+- * CAD_OFF Ctrl-Alt-Del sequence sends SIGINT to init task.
+- * POWER_OFF Stop OS and remove all power from system, if possible.
+- * RESTART2 Restart system using given command string.
+- */
+-
+-#define LINUX_REBOOT_CMD_RESTART 0x01234567
+-#define LINUX_REBOOT_CMD_HALT 0xCDEF0123
+-#define LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF
+-#define LINUX_REBOOT_CMD_CAD_OFF 0x00000000
+-#define LINUX_REBOOT_CMD_POWER_OFF 0x4321FEDC
+-#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
+-
+diff --git a/lib/my_reboot.c b/lib/my_reboot.c
+deleted file mode 100644
+index 12ea4c926c69..000000000000
+--- a/lib/my_reboot.c
++++ /dev/null
+@@ -1,40 +0,0 @@
+-/* Including <unistd.h> makes sure that on a glibc system
+- <features.h> is included, which again defines __GLIBC__ */
+-#include <unistd.h>
+-#include "linux_reboot.h"
+-
+-#define USE_LIBC
+-
+-#ifdef USE_LIBC
+-
+-/* libc version */
+-#if defined __GLIBC__ && __GLIBC__ >= 2
+-# include <sys/reboot.h>
+-# define REBOOT(cmd) reboot(cmd)
+-#else
+-extern int reboot(int, int, int);
+-# define REBOOT(cmd) reboot(LINUX_REBOOT_MAGIC1,LINUX_REBOOT_MAGIC2,(cmd))
+-#endif
+-int
+-my_reboot(int cmd) {
+- return REBOOT(cmd);
+-}
+-
+-#else /* no USE_LIBC */
+-
+-/* direct syscall version */
+-#include <linux/unistd.h>
+-
+-#ifdef _syscall3
+-_syscall3(int, reboot, int, magic, int, magic_too, int, cmd);
+-#else
+-/* Let us hope we have a 3-argument reboot here */
+-extern int reboot(int, int, int);
+-#endif
+-
+-int
+-my_reboot(int cmd) {
+- return reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd);
+-}
+-
+-#endif
+diff --git a/login-utils/Makefile b/login-utils/Makefile
+index 7639c356db91..96ac2d334ccb 100644
+--- a/login-utils/Makefile
++++ b/login-utils/Makefile
+@@ -52,14 +52,13 @@ debug:
+
+ # Rules for everything else
+
+-simpleinit.o: simpleinit.h simpleinit.c $(LIB)/pathnames.h \
+- $(LIB)/linux_reboot.h
++simpleinit.o: simpleinit.h simpleinit.c $(LIB)/pathnames.h
+ initctl.o: simpleinit.h initctl.c $(LIB)/pathnames.h
+-shutdown.o: $(LIB)/pathnames.h $(LIB)/linux_reboot.h shutdown.c
++shutdown.o: $(LIB)/pathnames.h shutdown.c
+
+-shutdown: shutdown.o $(LIB)/my_reboot.o $(LIB)/xstrncpy.o
++shutdown: shutdown.o $(LIB)/xstrncpy.o
+
+-simpleinit: simpleinit.o $(LIB)/my_reboot.o $(LIB)/xstrncpy.o
++simpleinit: simpleinit.o $(LIB)/xstrncpy.o
+ $(CC) $(LDFLAGS) -o $@ $^ #$(CRYPT)
+
+ telinit:
+diff --git a/login-utils/shutdown.c b/login-utils/shutdown.c
+index 950c14a82efd..f46e8570b515 100644
+--- a/login-utils/shutdown.c
++++ b/login-utils/shutdown.c
+@@ -112,7 +112,7 @@
+ #include <limits.h>
+ #include <sys/stat.h>
+ #include <sys/utsname.h>
+-#include "linux_reboot.h"
++#include <sys/reboot.h>
+ #include "pathnames.h"
+ #include "xstrncpy.h"
+ #include "nls.h"
+@@ -472,13 +472,13 @@ main(int argc, char *argv[])
+ if(opt_reboot) {
+ my_puts(_("Please stand by while rebooting the system...\n"));
+ sleep(1);
+- my_reboot(LINUX_REBOOT_CMD_RESTART); /* RB_AUTOBOOT */
++ reboot(RB_AUTOBOOT);
+ my_puts(_("\nWhy am I still alive after reboot?"));
+ } else {
+ my_puts(_("\nNow you can turn off the power..."));
+
+ /* allow C-A-D now, faith AT cs.unc.edu, re-fixed 8-Jul-96 */
+- my_reboot(LINUX_REBOOT_CMD_CAD_ON); /* RB_ENABLE_CAD */
++ reboot(RB_ENABLE_CAD);
+ sleep (1); /* Wait for devices to finish writing to media
*/
+ do_halt(halt_action);
+ }
+@@ -555,7 +555,7 @@ do_halt(char *action) {
+ if (strcasecmp (action, "power_off") == 0) {
+ printf(_("Calling kernel power-off facility...\n"));
+ fflush(stdout);
+- my_reboot(LINUX_REBOOT_CMD_POWER_OFF);
++ reboot(RB_POWER_OFF);
+ printf(_("Error powering off\t%s\n"), ERRSTRING);
+ fflush(stdout);
+ sleep (2);
+@@ -573,7 +573,7 @@ do_halt(char *action) {
+ sleep (2);
+ }
+
+- my_reboot(LINUX_REBOOT_CMD_HALT); /* RB_HALT_SYSTEM */
++ reboot(RB_HALT_SYSTEM);
+ }
+
+ void
+diff --git a/login-utils/simpleinit.c b/login-utils/simpleinit.c
+index de8e60cb97b1..bf1d08bc7a15 100644
+--- a/login-utils/simpleinit.c
++++ b/login-utils/simpleinit.c
+@@ -225,7 +225,7 @@
+ #include <time.h>
+ #include "defines.h"
+ #include "pathnames.h"
+-#include "linux_reboot.h"
++#include <sys/reboot.h>
+ #include "xstrncpy.h"
+ #include "nls.h"
+ #include "simpleinit.h"
+@@ -414,7 +414,7 @@ int main(int argc, char *argv[])
+ sa.sa_handler = sigquit_handler;
+ sigaction (SIGQUIT, &sa, NULL);
+
+- my_reboot (LINUX_REBOOT_CMD_CAD_OFF);
++ reboot (RB_DISABLE_CAD);
+ }
+
+ /* Find script to run. Command-line overrides config file overrides
+@@ -1018,7 +1018,7 @@ void int_handler (int sig)
+ or the user specified his own program (in which case he probably
+ doesn't like the hard reboot) */
+ if (!(userspace || have_cad_prog))
+- my_reboot(LINUX_REBOOT_CMD_RESTART);
++ reboot(RB_AUTOBOOT);
+ if (pid==0) exit(1);
+ sig=sig;
+ }
+--
+2.44.0
+
diff --git a/smgl/simpleinit-msb/sigsetmask.patch
b/smgl/simpleinit-msb/sigsetmask.patch
deleted file mode 100644
index e0dcba4..0000000
--- a/smgl/simpleinit-msb/sigsetmask.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From 63710dafab6b84204ab7a8c7001bcbe3c22b033f Mon Sep 17 00:00:00 2001
-From: Ismael Luceno <ismael AT iodev.co.uk>
-Date: Tue, 11 Jun 2019 22:37:06 +0200
-Subject: [PATCH] shutdown: Replace sigsetmask with sigprocmask
-
-Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
----
- login-utils/shutdown.c | 8 +++++++-
- 1 file changed, 7 insertions(+), 1 deletion(-)
-
-diff --git a/login-utils/shutdown.c b/login-utils/shutdown.c
-index 5b68a618d76a..202e12e1f08e 100644
---- a/login-utils/shutdown.c
-+++ b/login-utils/shutdown.c
-@@ -195,7 +195,13 @@ main(int argc, char *argv[])
- for (fd = 0; fd < 3; fd++) close (fd);
- while (1) wait (NULL); /* Grim reaper never stops */
- }
-- sigsetmask (0); /* simpleinit(8) blocks all signals: undo for ALRM
*/
-+ /* simpleinit(8) blocks all signals: undo for ALRM */
-+ {
-+ sigset_t n;
-+ sigemptyset(&n);
-+ sigaddset(&n, SIGALRM);
-+ sigprocmask(SIG_UNBLOCK, &n, NULL);
-+ }
- for (i = 1; i < NSIG; i++) signal (i, SIG_DFL); /* unnecessary */
- setlocale(LC_ALL, "");
- bindtextdomain(PACKAGE, LOCALEDIR);
---
-2.21.0
diff --git a/smgl/simpleinit-msb/simpleinit-1000uid.patch
b/smgl/simpleinit-msb/simpleinit-1000uid.patch
deleted file mode 100644
index bf1d90c..0000000
--- a/smgl/simpleinit-msb/simpleinit-1000uid.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- login-utils/shutdown.8.bak 2004-06-04 15:48:59.310506982 -0700
-+++ login-utils/shutdown.8 2001-09-26 03:59:46.000000000 -0700
-@@ -64,7 +64,7 @@
- .I /var/log/wtmp
- file and terminates all processes as follows:
-
--It kills (SIGTERM) all non-privileged (uid>=100) processes on the system,
-+It kills (SIGTERM) all non-privileged (uid>=1000) processes on the system,
- executes \fBfinalprog\fP as specified in \fI/etc/inittab\fP (see
- .BR init (8)
- ) with the argument "stop", tells
---- login-utils/shutdown.c.bak 2004-06-04 15:47:48.586379290 -0700
-+++ login-utils/shutdown.c 2004-06-04 15:48:17.197949294 -0700
-@@ -413,7 +413,7 @@
- #ifndef DEBUGGING
- my_puts ("");
- my_puts (""); /* Get past the login prompt */
-- /* a gentle kill of all other processes except those with uid>=100 */
-+ /* a gentle kill of all other processes except those with uid>=1000 */
- /* the message stating this is in kill_mortals() because it is */
- /* only printed if some processes are actually killed.*/
- kill_mortals (SIGTERM);
-@@ -789,7 +789,7 @@
- pid = atoi (de->d_name);
- sprintf (path, "/proc/%d", pid);
- if (stat (path, &statbuf) != 0) continue;
-- if (statbuf.st_uid < 100) continue;
-+ if (statbuf.st_uid < 1000) continue;
- if (index >= npids)
- {
- pids2 = realloc (pids, (npids+4096)*sizeof(pid_t));
-@@ -801,7 +801,7 @@
- }
- closedir (dp);
- if (pids == NULL) return;
-- my_puts ("Sending TERM signal to processes with UID>=100...");
-+ my_puts ("Sending TERM signal to processes with UID>=1000...");
- for (--index; index >= 0; --index) kill (pids[index], sig);
- free (pids);
- } /* End Function kill_mortals */
diff --git a/smgl/simpleinit-msb/simpleinit-msb-crypt.patch
b/smgl/simpleinit-msb/simpleinit-msb-crypt.patch
deleted file mode 100644
index ba40d7e..0000000
--- a/smgl/simpleinit-msb/simpleinit-msb-crypt.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- sysvtools/Makefile.orig 2007-11-09 00:16:54.000000000 +0300
-+++ sysvtools/Makefile 2008-07-30 23:00:07.328860627 +0400
-@@ -8,6 +8,8 @@
- # Version: @(#)Makefile 2.85-13 23-Mar-2004 miquels AT cistron.nl
- #
-
-+include ../make_include
-+
- CC = gcc
- CFLAGS = -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE
- LDFLAGS = -s
-@@ -36,7 +38,7 @@
- MANDIR = /usr/share/man
-
- # Additional libs for GNU libc.
--ifneq ($(wildcard /usr/lib/libcrypt.a),)
-+ifeq "$(NEED_LIBCRYPT)" "yes"
- LCRYPT = -lcrypt
- endif
-
diff --git a/smgl/simpleinit-msb/simpleinit-nonls.patch
b/smgl/simpleinit-msb/simpleinit-nonls.patch
deleted file mode 100644
index 1a40bfd..0000000
--- a/smgl/simpleinit-msb/simpleinit-nonls.patch
+++ /dev/null
@@ -1,25 +0,0 @@
---- login-utils/simpleinit.c.orig 2006-11-19 15:42:20.000000000 +0100
-+++ login-utils/simpleinit.c 2006-11-19 15:43:16.000000000 +0100
-@@ -408,10 +407,6 @@
- my_reboot (LINUX_REBOOT_CMD_CAD_OFF);
- }
-
-- setlocale(LC_ALL, "");
-- bindtextdomain(PACKAGE, LOCALEDIR);
-- textdomain(PACKAGE);
--
- /* Find script to run. Command-line overrides config file overrides
- built-in default */
- for (i = 0; i < NUMCMD; i++) inittab[i].pid = -1;
---- login-utils/shutdown.c.orig 2006-11-19 15:43:36.000000000 +0100
-+++ login-utils/shutdown.c 2006-11-19 15:44:43.000000000 +0100
-@@ -197,9 +197,6 @@
- }
- sigsetmask (0); /* simpleinit(8) blocks all signals: undo for ALRM
*/
- for (i = 1; i < NSIG; i++) signal (i, SIG_DFL); /* unnecessary */
-- setlocale(LC_ALL, "");
-- bindtextdomain(PACKAGE, LOCALEDIR);
-- textdomain(PACKAGE);
-
- #ifndef DEBUGGING
- if(setreuid (0, 0)) {
diff --git a/smgl/simpleinit-msb/simpleinit-output-on-shutdown.patch
b/smgl/simpleinit-msb/simpleinit-output-on-shutdown.patch
deleted file mode 100644
index 9e537e2..0000000
--- a/smgl/simpleinit-msb/simpleinit-output-on-shutdown.patch
+++ /dev/null
@@ -1,12 +0,0 @@
---- login-utils/simpleinit.c.orig 2007-02-28 22:12:16.000000000 +0100
-+++ login-utils/simpleinit.c 2007-02-28 22:15:45.000000000 +0100
-@@ -1476,6 +1476,9 @@
- for (ival = 1; ival < NSIG; ival++) signal (ival, SIG_DFL);
- sigprocmask(SIG_UNBLOCK,&all_signals,NULL);
- if (!userspace){
-+ close (0);
-+ close (1);
-+ close (2);
- open ("/dev/console", O_RDONLY, 0);
- open ("/dev/console", O_RDWR, 0);
- dup2 (1, 2);
diff --git a/smgl/simpleinit-msb/simpleinit-poweroff.patch
b/smgl/simpleinit-msb/simpleinit-poweroff.patch
deleted file mode 100644
index 315d325..0000000
--- a/smgl/simpleinit-msb/simpleinit-poweroff.patch
+++ /dev/null
@@ -1,15 +0,0 @@
---- login-utils/shutdown.c.orig 2014-06-25 15:09:23.000000000 +0400
-+++ login-utils/shutdown.c 2014-06-25 15:11:12.534462171 +0400
-@@ -210,10 +210,10 @@
- prog = argv[0];
- if((ptr = strrchr(argv[0], '/'))) prog = ++ptr;
-
-- /* All names (halt, reboot, fasthalt, fastboot, shutdown)
-+ /* All names (halt, poweroff, reboot, fasthalt, fastboot, shutdown)
- refer to the same program with the same options,
- only the defaults differ. */
-- if(!strcmp("halt", prog)) {
-+ if(!strcmp("halt", prog) || !strcmp("poweroff", prog)) {
- opt_reboot = 0;
- opt_quiet = 1;
- opt_fast = 0;
diff --git a/smgl/simpleinit-msb/simpleinit-selinux.patch
b/smgl/simpleinit-msb/simpleinit-selinux.patch
deleted file mode 100644
index a495647..0000000
--- a/smgl/simpleinit-msb/simpleinit-selinux.patch
+++ /dev/null
@@ -1,109 +0,0 @@
---- login-utils/simpleinit.c 2007-09-14 23:44:34.726342737 +0000
-+++ login-utils/simpleinit.c 2007-09-14 23:44:18.000000000 +0000
-@@ -218,6 +218,8 @@
- #include <sys/ioctl.h>
- #include <dirent.h>
- #include <termios.h>
-+#include <sys/mount.h>
-+#include <sys/mman.h>
- #include <utmp.h>
- #include <sched.h>
- #include <time.h>
-@@ -271,6 +273,7 @@
- struct initline inittab[NUMCMD];
- int numcmd;
- int stopped = 0; /* are we stopped */
-+int no_selinux = 1; /* disabled by default */
- static char boot_prog[PATH_SIZE] = _PATH_RC;
- static char init_root[PATH_SIZE] = "\0";
- static char script_prefix[PATH_SIZE] = "\0";
-@@ -332,6 +335,8 @@
- pid_t mywait (int *status);
- int run_command (const char *file, const char *name, pid_t pid,struct
script_struct* waiting_script);
- void ystrncat(char* dest,const char* src,ssize_t n);
-+int security_load_policy(void *data, size_t len);
-+int load_policy(void);
-
- /* like strcat, but dest will never contain more than n characters after
- the call (i.e. a 0-terminator will be found among the first n characters,
-@@ -441,7 +446,14 @@
- }
-
- open_initctl_fifo();
--
-+
-+ if (!no_selinux) {
-+ if (load_policy() != 0) {
-+ err( _("Failed to load SELinux policy.\n"));
-+ exit(1);
-+ }
-+ }
-+
- if (userspace){
- pid_t mypid=getpid();
- int fd;
-@@ -538,6 +550,64 @@
-
- #define MAXTRIES 3 /* number of tries allowed when giving the password */
-
-+int security_load_policy(void *data, size_t len) {
-+ int fd, ret;
-+ fd = open("/selinux/load", O_RDWR);
-+ if (fd < 0)
-+ return -1;
-+ ret = write(fd, data, len);
-+ close(fd);
-+ if (ret < 0)
-+ return -1;
-+ return 0;
-+}
-+
-+int load_policy(void) {
-+ int ret;
-+ int fd;
-+ void *map;
-+ struct stat sb;
-+ ret = mount("none", "/selinux", "selinuxfs", 0, 0);
-+ if (ret < 0) {
-+ char txt[256];
-+ sprintf(txt, "SELinux: failed to mount /selinux
(errno=%d)\n", errno);
-+ err( _(txt));
-+ return ret;
-+ }
-+
-+ fd = open("/etc/selinux/policy.bin", O_RDONLY);
-+ if (fd < 0) {
-+ char txt[256];
-+ sprintf(txt, "SELinux: couldn't find /etc/selinux/policy.bin
(errno=%d)\n", errno);
-+ err( _(txt));
-+ return -1;
-+ }
-+
-+ ret = fstat(fd, &sb);
-+ if (ret < 0) {
-+ char txt[256];
-+ sprintf(txt, "Can't stat /etc/selinux/policy.bin
(errno=%d)\n", errno);
-+ err( _(txt));
-+ close(fd);
-+ return ret;
-+ }
-+ map = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
-+ if (map == MAP_FAILED) {
-+ char txt[256];
-+ sprintf(txt, "Can't map /etc/selinux/policy.bin (errno=%d\n",
errno);
-+ err( _(txt));
-+ close(fd);
-+ return -1;
-+ }
-+ ret = security_load_policy(map, sb.st_size);
-+ if (ret < 0) {
-+ err( _("security_load_policy failed\n"));
-+ }
-+ close(fd);
-+ return ret;
-+}
-+
-+
- /*
- * run boot script(s). The environment is passed to the script(s), so the RC
- * environment variable can be used to decide what to do.
diff --git a/smgl/simpleinit-msb/simpleinit.patch
b/smgl/simpleinit-msb/simpleinit.patch
deleted file mode 100644
index f853a23..0000000
--- a/smgl/simpleinit-msb/simpleinit.patch
+++ /dev/null
@@ -1,94 +0,0 @@
---- lib/pathnames.h.orig 2001-09-26 12:59:46.000000000 +0200
-+++ lib/pathnames.h 2004-02-20 14:33:35.000000000 +0100
-@@ -130,7 +130,7 @@
- #define _PATH_MTAB "/etc/mtab"
- #define _PATH_PROC_MOUNTS "/proc/mounts"
- #define _PATH_UMOUNT "/bin/umount"
--#define UMOUNT_ARGS "umount", "-a", "-t", "nodevfs,noproc"
-+#define UMOUNT_ARGS "umount", "-a", "-t", "nodevfs,noproc,noramfs"
- #define SWAPOFF_ARGS "swapoff", "-a"
-
- /* used in login-utils/setpwnam.h and login-utils/islocal.c */
---- login-utils/shutdown.c.orig 2001-09-26 12:59:46.000000000 +0200
-+++ login-utils/shutdown.c 2004-02-20 15:53:27.000000000 +0100
-@@ -746,6 +746,7 @@
- n = 0;
- while (n < 100 && (mnt = getmntent(mtab))) {
- if (strcmp (mnt->mnt_type, "devfs") == 0) continue;
-+ if (strcmp (mnt->mnt_type, "ramfs") == 0) continue;
- mntlist[n++] = strdup(mnt->mnt_dir);
- }
- endmntent(mtab);
---- login-utils/simpleinit.c.orig 2004-01-11 00:24:42.000000000 +0100
-+++ login-utils/simpleinit.c 2004-02-20 14:28:31.000000000 +0100
-@@ -321,6 +321,8 @@
- void sigquit_handler (int sig);
- void userspace_sigquit_handler (int sig);
- void sigterm_handler (int sig);
-+void open_initctl_fifo (void);
-+void sigusr_handler (int sig);
- #ifdef SET_TZ
- void set_tz (void);
- #endif
-@@ -396,6 +398,8 @@
- sigaction (SIGCHLD, &sa, NULL);
- sa.sa_handler = userspace_sigquit_handler;
- sigaction (SIGQUIT, &sa, NULL);
-+ sa.sa_handler = sigusr_handler;
-+ sigaction (SIGUSR1, &sa, NULL);
- if (userspace) fix_userspace_paths(); else
- {
- sa.sa_handler = sigtstp_handler;
-@@ -440,12 +444,7 @@
- }
- }
-
-- if ( ( initctl_fd = open (initctl_name, O_RDWR|O_NONBLOCK, 0) ) < 0 )
{
-- mkfifo (initctl_name, S_IRUSR | S_IWUSR);
-- if ( ( initctl_fd = open (initctl_name, O_RDWR|O_NONBLOCK, 0)
) < 0 )
-- err ( _("error opening fifo\n") );
-- }
-- fcntl(initctl_fd,F_SETFD,FD_CLOEXEC); /*make sure no one inherits the
fd*/
-+ open_initctl_fifo();
-
- if (userspace){
- pid_t mypid=getpid();
-@@ -885,6 +884,28 @@
- if (!stopped) hup_handler (sig);
- } /* End Function sigtstp_handler */
-
-+void open_initctl_fifo()
-+{
-+ if ( ( initctl_fd = open (initctl_name, O_RDWR|O_NONBLOCK, 0) ) < 0 )
{
-+ mkfifo (initctl_name, S_IRUSR | S_IWUSR);
-+ if ( ( initctl_fd = open (initctl_name, O_RDWR|O_NONBLOCK, 0)
) < 0 )
-+ err ( _("error opening fifo\n") );
-+ }
-+ fcntl(initctl_fd,F_SETFD,FD_CLOEXEC); /*make sure no one inherits the
fd*/
-+}
-+
-+void sigusr_handler (int sig)
-+{
-+ close (0);
-+ close (1);
-+ close (2);
-+ open ("/dev/console", O_RDONLY, 0);
-+ open ("/dev/console", O_RDWR, 0);
-+ dup2 (1, 2);
-+ open_initctl_fifo();
-+ sig=sig;
-+}
-+
- void sigterm_handler (int sig)
- {
- int i;
-@@ -1686,6 +1707,9 @@
- for (i = 1; i < NSIG; i++) signal (i, SIG_DFL);
- sigprocmask(SIG_UNBLOCK,&all_signals,NULL);
- if (!userspace) {
-+ close (0);
-+ close (1);
-+ close (2);
- open ("/dev/console", O_RDONLY, 0);
- open ("/dev/console", O_RDWR, 0);
- dup2 (1, 2);


  • [[SM-Commit] ] GIT changes to master grimoire by Ismael Luceno (b7c37f8103289168eb43e6837b7a3fc855bee5bb), Ismael Luceno, 06/09/2024

Archive powered by MHonArc 2.6.24.

Top of Page