From df7684106431170548b0e7bcf2ec20153b818fcb Mon Sep 17 00:00:00 2001 From: ruskie Date: Fri, 5 Jan 2007 15:25:42 +0100 Subject: [PATCH] smgl/simpleinit-msb: initial commit --- smgl/simpleinit-msb/BUILD | 3 + smgl/simpleinit-msb/DEPENDS | 2 + smgl/simpleinit-msb/DETAILS | 18 + smgl/simpleinit-msb/HISTORY | 83 ++++ smgl/simpleinit-msb/INSTALL | 11 + smgl/simpleinit-msb/PRE_BUILD | 14 + smgl/simpleinit-msb/patches/dowall.c.diff | 271 +++++++++++ smgl/simpleinit-msb/patches/killall5.c.diff | 513 +++++++++++++++++++++ smgl/simpleinit-msb/patches/last.c.diff | 298 ++++++++++++ smgl/simpleinit-msb/patches/shutdown.c.diff | 20 + .../patches/simpleinit-1000uid.patch | 40 ++ .../patches/simpleinit-msb-crypt.diff | 21 + smgl/simpleinit-msb/patches/simpleinit.patch | 97 ++++ smgl/simpleinit-msb/patches/sulogin.c.diff | 68 +++ smgl/simpleinit-msb/telinit | 46 ++ 15 files changed, 1505 insertions(+) create mode 100755 smgl/simpleinit-msb/BUILD create mode 100755 smgl/simpleinit-msb/DEPENDS create mode 100755 smgl/simpleinit-msb/DETAILS create mode 100644 smgl/simpleinit-msb/HISTORY create mode 100755 smgl/simpleinit-msb/INSTALL create mode 100755 smgl/simpleinit-msb/PRE_BUILD create mode 100644 smgl/simpleinit-msb/patches/dowall.c.diff create mode 100644 smgl/simpleinit-msb/patches/killall5.c.diff create mode 100644 smgl/simpleinit-msb/patches/last.c.diff create mode 100644 smgl/simpleinit-msb/patches/shutdown.c.diff create mode 100644 smgl/simpleinit-msb/patches/simpleinit-1000uid.patch create mode 100644 smgl/simpleinit-msb/patches/simpleinit-msb-crypt.diff create mode 100644 smgl/simpleinit-msb/patches/simpleinit.patch create mode 100644 smgl/simpleinit-msb/patches/sulogin.c.diff create mode 100755 smgl/simpleinit-msb/telinit diff --git a/smgl/simpleinit-msb/BUILD b/smgl/simpleinit-msb/BUILD new file mode 100755 index 0000000..68f85d7 --- /dev/null +++ b/smgl/simpleinit-msb/BUILD @@ -0,0 +1,3 @@ +./configure && +# sedit 's/CFLAGS.*:=/CFLAGS := -DDEBUG_GETPATH=1 /' mconfig && +make OPT="$CFLAGS" diff --git a/smgl/simpleinit-msb/DEPENDS b/smgl/simpleinit-msb/DEPENDS new file mode 100755 index 0000000..18594eb --- /dev/null +++ b/smgl/simpleinit-msb/DEPENDS @@ -0,0 +1,2 @@ +depends gnupg && +depends smgl-fhs diff --git a/smgl/simpleinit-msb/DETAILS b/smgl/simpleinit-msb/DETAILS new file mode 100755 index 0000000..2a4d17c --- /dev/null +++ b/smgl/simpleinit-msb/DETAILS @@ -0,0 +1,18 @@ + SPELL=simpleinit-msb + VERSION=1.2 + SOURCE=$SPELL-$VERSION.tar.bz2 +SOURCE_DIRECTORY=$BUILD_DIRECTORY/$SPELL-$VERSION + SOURCE_URL[0]=http://www.winterdrache.de/linux/newboot/$SOURCE + SOURCE_HASH=sha512:e31b517d7da11c91b93d03808b5bec663973e4b4ea07b2451dcb9ccb6034eca8e79e1226ff62d527421070123d339106db354220e2c7a0393cd9c99d2a4e62e0 + WEB_SITE=http://www.winterdrache.de/linux/newboot/ + ENTERED=20030505 + UPDATED=20040919 + LICENSE[0]=GPL + BUILD_API=2 + KEYWORDS="smgl" + SHORT="Replacement for SysVinit" +cat << EOF +Simpleinit-MSB is a replacement for the SysVinit. It provides a simple way of +defining dependancies between initscripts. +This spell also installs some useful utilities from sysvinit. +EOF diff --git a/smgl/simpleinit-msb/HISTORY b/smgl/simpleinit-msb/HISTORY new file mode 100644 index 0000000..de04e38 --- /dev/null +++ b/smgl/simpleinit-msb/HISTORY @@ -0,0 +1,83 @@ +2006-03-12 Karsten Behrmann + * DETAILS: (automated) Add KEYWORDS + +2006-02-08 Eric Sandall + * DEPENDS: Depends on smgl-fhs (for directory structure) + +2006-02-06 Eric Sandall + * DEPENDS: Depends on gnupg (for SOURCE verification) + +2005-11-29 Seth Woolley + * DETAILS: MD5 -> SHA512 + +2005-05-15 Eric Sandall + * CONFLICTS: Removed, was destroying a machines normal init system + and didn't use INSTALL_ROOT, plus sysvinit is no longer even a spell + to need this conversion code (thanks to + Daniel Willmann ) + +2005-05-12 Andrew Stitt + * INSTALL: Update to install into a chroot correctly, bug 8853. + +2005-04-15 Benoit PAPILLAULT * + * PRE_BUILD, simpleinit-msb-crypt.diff: added to properly detect + the need for -lcrypt + * Fixed http://bugs.sourcemage.org/show_bug.cgi?id=8598 + +2005-01-11 Eric Sandall + * DETAILS: Added BUILD_API=2 + Shortened SHORT + * PRE_BUILD: Added to apply patches + * BUILD: Converted to build_api 2 + Moved patches to PRE_BUILD + * INSTALL: Branched from BUILD + Converted to build_api 2 + Copy telinit to $INSTALL_ROOT/sbin/telinit + +2004-09-19 Seth Woolley + * telinit: exits properly after su'd + * DETAILS: updated UPDATED + +2004-07-04 Seth Woolley + * telinit: doesn't block stderr anymore -- who had that bright idea? + +2004-06-30 Eric Schabell + * BUILD: copy modified telinit over to sbin, now root enabled. + +2004-06-13 Seth Woolley + * BUILD, simpleinit-1000uid.patch: edited, added patch for + graceful shutdowns. + * DETAILS: updated to force recompile + +2004-04-07 hgg and Arwed v. Merkatz + * BUILD, simpleinit.patch, POST_INSTALL: + add patch that's needed for /dev on a virtual filesystem, + remove POST_INSTALL, inittab now in init.d spell + +2004-01-11 Arwed v. Merkatz + * DETAILS: updated to 1.2 + * BUILD, simpleinit.c.patch: patch isn't needed anymore + +2004-01-10 Robert Helgesson + * BUILD, simpleinit.c.patch: Apply a fix to simpleinit.c which fixes + an overflow bug. + +2003-12-02 Eric Sandall + * BUILD: Use INSTALL_ROOT + Should write a patch to change sysvtools/Makefile to use + DESTDIR instead of ROOT, but I don't feel like doing that until + either the author picks it back up or we decide to pick it up. + * POST_INSTALL: Use INSTALL_ROOT + +2003-11-04 Seth Woolley + * POST_INSTALL: changed mount to devices, #4618 + +2003-10-20 hgg + * inittab: changed to /dev as default + +2003-07-28 Eric Schabell + * Better now? + +2003-05-05 Robert Helgesson + * created spell + diff --git a/smgl/simpleinit-msb/INSTALL b/smgl/simpleinit-msb/INSTALL new file mode 100755 index 0000000..eb8416e --- /dev/null +++ b/smgl/simpleinit-msb/INSTALL @@ -0,0 +1,11 @@ +# yes their makefile assumes these exist +mkdir -p $INSTALL_ROOT/sbin +mkdir -p $INSTALL_ROOT/usr/share/man/man1 +mkdir -p $INSTALL_ROOT/usr/share/man/man5 +mkdir -p $INSTALL_ROOT/usr/share/man/man8 +make DESTDIR=${INSTALL_ROOT} \ + ROOT=${INSTALL_ROOT} \ + install && + +cp $SCRIPT_DIRECTORY/telinit \ + ${INSTALL_ROOT}/sbin/telinit diff --git a/smgl/simpleinit-msb/PRE_BUILD b/smgl/simpleinit-msb/PRE_BUILD new file mode 100755 index 0000000..4a9eeac --- /dev/null +++ b/smgl/simpleinit-msb/PRE_BUILD @@ -0,0 +1,14 @@ +default_pre_build && +cd $SOURCE_DIRECTORY && +patch -p1 < $SCRIPT_DIRECTORY/patches/simpleinit.patch && +patch -p0 < $SCRIPT_DIRECTORY/patches/simpleinit-1000uid.patch && +patch -p1 < $SCRIPT_DIRECTORY/patches/simpleinit-msb-crypt.diff && +cd $SOURCE_DIRECTORY/sysvtools && +patch -p0 < $SCRIPT_DIRECTORY/patches/dowall.c.diff && +patch -p0 < $SCRIPT_DIRECTORY/patches/killall5.c.diff && +patch -p0 < $SCRIPT_DIRECTORY/patches/last.c.diff && +patch -p0 < $SCRIPT_DIRECTORY/patches/sulogin.c.diff && +if is_gnu_kfbsd ; then +cd $SOURCE_DIRECTORY/login-utils && +patch -p0 < $SCRIPT_DIRECTORY/patches/shutdown.c.diff +fi diff --git a/smgl/simpleinit-msb/patches/dowall.c.diff b/smgl/simpleinit-msb/patches/dowall.c.diff new file mode 100644 index 0000000..64169a5 --- /dev/null +++ b/smgl/simpleinit-msb/patches/dowall.c.diff @@ -0,0 +1,271 @@ +--- dowall.c 2001-09-26 12:59:46.000000000 +0200 ++++ ../../sysvinit-2.86.ds1/src/dowall.c 2004-06-09 14:47:45.000000000 +0200 +@@ -3,10 +3,10 @@ + * + * Author: Miquel van Smoorenburg, miquels@cistron.nl + * +- * Version: @(#)dowall.c 2.79 11-Sep-2000 miquels@cistron.nl ++ * Version: @(#)dowall.c 2.85-5 02-Jul-2003 miquels@cistron.nl + * + * This file is part of the sysvinit suite, +- * Copyright 1991-2000 Miquel van Smoorenburg. ++ * Copyright 1991-2003 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 +@@ -15,6 +15,8 @@ + */ + #include + #include ++#include ++#include + #include + #include + #include +@@ -26,29 +28,24 @@ + #include + #include + +-static jmp_buf jbuf; +- +-/* display pid of rpc.rwalld if wall() is called with 'remote' non-zero */ +-#define RWALLDPID ++static sigjmp_buf jbuf; + + /* + * Alarm handler + */ + /*ARGSUSED*/ +-static void handler(arg) +-int arg; ++static void handler(int arg) + { +- signal(SIGALRM, handler); +- longjmp(jbuf, 1); ++ siglongjmp(jbuf, 1); + } + + + /* + * Print a text, escape all characters not in Latin-1. + */ +-void feputs(char *line, FILE *fp) ++static void feputs(char *line, FILE *fp) + { +- unsigned char *p; ++ unsigned char *p; + + for (p = (unsigned char *)line; *p; p++) { + if (strchr("\t\r\n", *p) || +@@ -62,35 +59,25 @@ + } + + +-/* +- * Wall function. +- */ +-void wall(char *text, int fromshutdown, int remote) ++static void getuidtty(char **userp, char **ttyp) + { +- FILE *tp; +- char line[81]; +- char term[UT_LINESIZE+6]; +- static char *user, ttynm[32], *date; +- char uidbuf[32]; +- static int fd, init = 0; +- struct passwd *pwd; +- char *tty, *p; +- time_t t; +- struct utmp *utmp; +- uid_t uid; ++ struct passwd *pwd; ++ uid_t uid; ++ char *tty; ++ static char uidbuf[32]; ++ static char ttynm[32]; ++ static int init = 0; + +- setutent(); ++ if (!init) { + +- if (init == 0) { + uid = getuid(); +- pwd = getpwuid(uid); +- sprintf (uidbuf, "uid %d", (int)uid); +- /* +- * display uid if no corresponding username found in +- * password file. superuser (uid 0) is always "root", +- * not "uid 0". +- */ +- user = pwd ? pwd->pw_name : (uid == 0 ? "root" : uidbuf); ++ if ((pwd = getpwuid(uid)) != NULL) { ++ uidbuf[0] = 0; ++ strncat(uidbuf, pwd->pw_name, sizeof(uidbuf) - 1); ++ } else { ++ sprintf(uidbuf, uid ? "uid %d" : "root", (int)uid); ++ } ++ + if ((tty = ttyname(0)) != NULL) { + if (strncmp(tty, "/dev/", 5) == 0) + tty += 5; +@@ -98,9 +85,65 @@ + } else + ttynm[0] = 0; + init++; +- signal(SIGALRM, handler); + } +- ++ ++ *userp = uidbuf; ++ *ttyp = ttynm; ++} ++ ++/* ++ * Check whether given filename looks like tty device. ++ */ ++static int file_isatty(const char *fname) ++{ ++ struct stat st; ++ int major; ++ ++ if (stat(fname, &st) < 0) ++ return 0; ++ ++ if (st.st_nlink != 1 || !S_ISCHR(st.st_mode)) ++ return 0; ++ ++ /* ++ * It would be an impossible task to list all major/minors ++ * of tty devices here, so we just exclude the obvious ++ * majors of which just opening has side-effects: ++ * printers and tapes. ++ */ ++ major = major(st.st_dev); ++ if (major == 1 || major == 2 || major == 6 || major == 9 || ++ major == 12 || major == 16 || major == 21 || major == 27 || ++ major == 37 || major == 96 || major == 97 || major == 206 || ++ major == 230) return 0; ++ ++ return 1; ++} ++ ++/* ++ * Wall function. ++ */ ++void wall(char *text, int fromshutdown, int remote) ++{ ++ FILE *tp; ++ struct sigaction sa; ++ struct utmp *utmp; ++ time_t t; ++ char term[UT_LINESIZE+6]; ++ char line[81]; ++ char *date, *p; ++ char *user, *tty; ++ int fd, flags; ++ ++ /* ++ * Make sure tp and fd aren't in a register. Some versions ++ * of gcc clobber those after longjmp (or so I understand). ++ */ ++ (void) &tp; ++ (void) &fd; ++ ++ getuidtty(&user, &tty); ++ + /* Get the time */ + time(&t); + date = ctime(&t); +@@ -115,7 +158,7 @@ + } else { + snprintf(line, sizeof(line), + "\007\r\nBroadcast message from %s %s(%s):\r\n\r\n", +- user, ttynm, date); ++ user, tty, date); + } + + /* +@@ -124,50 +167,50 @@ + if (fork() != 0) + return; + +- siginterrupt (SIGALRM, 1); ++ memset(&sa, 0, sizeof(sa)); ++ sa.sa_handler = handler; ++ sa.sa_flags = 0; ++ sigemptyset(&sa.sa_mask); ++ sigaction(SIGALRM, &sa, NULL); ++ ++ setutent(); ++ + while ((utmp = getutent()) != NULL) { + if(utmp->ut_type != USER_PROCESS || + utmp->ut_user[0] == 0) continue; +- term[sizeof(term) - 1] = 0; +- if (strncmp(utmp->ut_line, "/dev/", 5) == 0) +- strncpy(term, utmp->ut_line, sizeof(term)-1); +- else +- snprintf(term, sizeof(term), "/dev/%s", +- utmp->ut_line); +- +- /* +- * Sometimes the open/write hangs in spite of the O_NDELAY +- */ +- alarm(2); +-#ifdef O_NDELAY ++ if (strncmp(utmp->ut_line, "/dev/", 5) == 0) { ++ term[0] = 0; ++ strncat(term, utmp->ut_line, UT_LINESIZE); ++ } else ++ snprintf(term, sizeof(term), "/dev/%.*s", ++ UT_LINESIZE, utmp->ut_line); ++ if (strstr(term, "/../")) continue; ++ ++ fd = -1; ++ tp = NULL; ++ + /* + * Open it non-delay + */ +- if (setjmp(jbuf) == 0 && +- (fd = open(term, O_WRONLY | O_NDELAY )) > 0) { +- if ((tp = fdopen(fd, "w")) != NULL) { +- fputs(line, tp); +- feputs(text, tp); +- fclose(tp); +- } else +- close(fd); +- fd = -1; +- alarm(0); ++ if (sigsetjmp(jbuf, 1) == 0) { ++ alarm(2); ++ flags = O_WRONLY|O_NDELAY|O_NOCTTY; ++ if (file_isatty(term) && ++ (fd = open(term, flags)) >= 0) { ++ if (isatty(fd) && ++ (tp = fdopen(fd, "w")) != NULL) { ++ fputs(line, tp); ++ feputs(text, tp); ++ fflush(tp); ++ } ++ } + } ++ alarm(0); + if (fd >= 0) close(fd); +-#else +- if (setjmp(jbuf) == 0 && (tp = fopen(term, "w")) != NULL) { +- fputs(line, tp); +- feputs(text, tp); +- alarm(0); +- fclose(tp); +- tp = NULL; +- } + if (tp != NULL) fclose(tp); +-#endif +- alarm(0); + } + endutent(); ++ + exit(0); + } + diff --git a/smgl/simpleinit-msb/patches/killall5.c.diff b/smgl/simpleinit-msb/patches/killall5.c.diff new file mode 100644 index 0000000..5f74e43 --- /dev/null +++ b/smgl/simpleinit-msb/patches/killall5.c.diff @@ -0,0 +1,513 @@ +--- killall5.c 2001-09-26 12:59:46.000000000 +0200 ++++ ../../sysvinit-2.86.ds1/src/killall5.c 2004-07-30 14:16:23.000000000 +0200 +@@ -5,7 +5,7 @@ + * + * pidof.c Tries to get the pid of the process[es] named. + * +- * Version: 2.81 31-Jul-2001 MvS ++ * Version: 2.86 30-Jul-2004 MvS + * + * Usage: killall5 [-][signal] + * pidof [-s] [-o omitpid [-o omitpid]] program [program..] +@@ -20,7 +20,7 @@ + * - swapped out programs pids are caught now + * + * This file is part of the sysvinit suite, +- * Copyright 1991-2001 Miquel van Smoorenburg. ++ * Copyright 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 +@@ -30,6 +30,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -40,34 +41,43 @@ + #include + #include + +-char *Version = "@(#)killall5 2.81 31-Jul-2001 miquels@cistron.nl"; ++char *Version = "@(#)killall5 2.86 31-Jul-2004 miquels@cistron.nl"; ++ ++#define STATNAMELEN 15 + + /* Info about a process. */ +-typedef struct _proc_ +-{ +- char *fullname; /* Name as found out from argv[0] */ +- char *basename; /* Only the part after the last / */ +- char *statname; /* the statname without braces */ +- ino_t ino; /* Inode number */ +- dev_t dev; /* Device it is on */ +- pid_t pid; /* Process ID. */ +- int sid; /* Session ID. */ +- struct _proc_ *next; /* Pointer to next struct. */ ++typedef struct proc { ++ char *argv0; /* Name as found out from argv[0] */ ++ char *argv0base; /* `basename argv[1]` */ ++ char *argv1; /* Name as found out from argv[1] */ ++ char *argv1base; /* `basename argv[1]` */ ++ char *statname; /* the statname without braces */ ++ ino_t ino; /* Inode number */ ++ dev_t dev; /* Device it is on */ ++ pid_t pid; /* Process ID. */ ++ int sid; /* Session ID. */ ++ int kernel; /* Kernel thread or zombie. */ ++ struct proc *next; /* Pointer to next struct. */ + } PROC; + + /* pid queue */ +-typedef struct _pidq_ { +- struct _pidq_ *front; +- struct _pidq_ *next; +- struct _pidq_ *rear; +- PROC *proc; ++ ++typedef struct pidq { ++ PROC *proc; ++ struct pidq *next; + } PIDQ; + ++typedef struct { ++ PIDQ *head; ++ PIDQ *tail; ++ PIDQ *next; ++} PIDQ_HEAD; ++ + /* List of processes. */ + PROC *plist; + +-/* Did we stop a number of processes? */ +-int stopped; ++/* Did we stop all processes ? */ ++int sent_sigstop; + + int scripts_too = 0; + +@@ -85,7 +95,7 @@ + void *p; + + if ((p = malloc(bytes)) == NULL) { +- if (stopped) kill(-1, SIGCONT); ++ if (sent_sigstop) kill(-1, SIGCONT); + nsyslog(LOG_ERR, "out of memory"); + exit(1); + } +@@ -97,13 +107,14 @@ + */ + int mount_proc(void) + { +- struct stat st; +- int pid, wst; +- char *args[] = { "mount", "-t", "proc", "none", "/proc", NULL }; +- int did_mount = 0; ++ struct stat st; ++ char *args[] = { "mount", "-t", "proc", "proc", "/proc", 0 }; ++ pid_t pid, rc; ++ int wst; ++ int did_mount = 0; + + /* Stat /proc/version to see if /proc is mounted. */ +- if (stat("/proc/version", &st) < 0) { ++ if (stat("/proc/version", &st) < 0 && errno == ENOENT) { + + /* It's not there, so mount it. */ + if ((pid = fork()) < 0) { +@@ -113,7 +124,6 @@ + if (pid == 0) { + /* Try a few mount binaries. */ + execv("/sbin/mount", args); +- execv("/etc/mount", args); + execv("/bin/mount", args); + + /* Okay, I give up. */ +@@ -121,9 +131,10 @@ + exit(1); + } + /* Wait for child. */ +- while (wait(&wst) != pid) +- ; +- if (WEXITSTATUS(wst) != 0) ++ while ((rc = wait(&wst)) != pid) ++ if (rc < 0 && errno == ECHILD) ++ break; ++ if (rc != pid || WEXITSTATUS(wst) != 0) + nsyslog(LOG_ERR, "mount returned non-zero exit status"); + + did_mount = 1; +@@ -131,28 +142,42 @@ + + /* See if mount succeeded. */ + if (stat("/proc/version", &st) < 0) { +- nsyslog(LOG_ERR, "/proc not mounted, failed to mount."); ++ if (errno == ENOENT) ++ nsyslog(LOG_ERR, "/proc not mounted, failed to mount."); ++ else ++ nsyslog(LOG_ERR, "/proc unavailable."); + exit(1); + } + + return did_mount; + } + ++int readarg(FILE *fp, char *buf, int sz) ++{ ++ int c = 0, f = 0; ++ ++ while (f < (sz-1) && (c = fgetc(fp)) != EOF && c) ++ buf[f++] = c; ++ buf[f] = 0; ++ ++ return (c == EOF && f == 0) ? c : f; ++} ++ + /* + * Read the proc filesystem. + */ + int readproc() + { +- DIR *dir; +- struct dirent *d; +- char path[256]; +- char buf[256]; +- char *s, *q; +- FILE *fp; +- int pid, f; +- PROC *p, *n; +- struct stat st; +- int c; ++ DIR *dir; ++ FILE *fp; ++ PROC *p, *n; ++ struct dirent *d; ++ struct stat st; ++ char path[256]; ++ char buf[256]; ++ char *s, *q; ++ unsigned long startcode, endcode; ++ int pid, f; + + /* Open the /proc directory. */ + if ((dir = opendir("/proc")) == NULL) { +@@ -164,7 +189,8 @@ + n = plist; + for (p = plist; n; p = n) { + n = p->next; +- if (p->fullname) free(p->fullname); ++ if (p->argv0) free(p->argv0); ++ if (p->argv1) free(p->argv1); + free(p); + } + plist = NULL; +@@ -185,7 +211,7 @@ + /* Read SID & statname from it. */ + if ((fp = fopen(path, "r")) != NULL) { + buf[0] = 0; +- fgets(buf, 256, fp); ++ fgets(buf, sizeof(buf), fp); + + /* See if name starts with '(' */ + s = buf; +@@ -212,14 +238,21 @@ + p->statname = (char *)xmalloc(strlen(s)+1); + strcpy(p->statname, s); + +- /* This could be replaced by getsid(pid) */ +- if (sscanf(q, "%*c %*d %*d %d", &p->sid) != 1) { ++ /* Get session, startcode, endcode. */ ++ startcode = endcode = 0; ++ if (sscanf(q, "%*c %*d %*d %d %*d %*d %*u %*u " ++ "%*u %*u %*u %*u %*u %*d %*d " ++ "%*d %*d %*d %*d %*u %*u %*d " ++ "%*u %lu %lu", ++ &p->sid, &startcode, &endcode) != 3) { + p->sid = 0; + nsyslog(LOG_ERR, "can't read sid from %s\n", + path); + free(p); + continue; + } ++ if (startcode == 0 && endcode == 0) ++ p->kernel = 1; + fclose(fp); + } else { + /* Process disappeared.. */ +@@ -227,24 +260,44 @@ + continue; + } + +- /* Now read argv[0] */ + snprintf(path, sizeof(path), "/proc/%s/cmdline", d->d_name); + if ((fp = fopen(path, "r")) != NULL) { +- f = 0; +- while(f < 127 && (c = fgetc(fp)) != EOF && c) +- buf[f++] = c; +- buf[f++] = 0; ++ ++ /* Now read argv[0] */ ++ f = readarg(fp, buf, sizeof(buf)); ++ ++ if (buf[0]) { ++ /* Store the name into malloced memory. */ ++ p->argv0 = (char *)xmalloc(f + 1); ++ strcpy(p->argv0, buf); ++ ++ /* Get a pointer to the basename. */ ++ p->argv0base = strrchr(p->argv0, '/'); ++ if (p->argv0base != NULL) ++ p->argv0base++; ++ else ++ p->argv0base = p->argv0; ++ } ++ ++ /* And read argv[1] */ ++ while ((f = readarg(fp, buf, sizeof(buf))) != EOF) ++ if (buf[0] != '-') break; ++ ++ if (buf[0]) { ++ /* Store the name into malloced memory. */ ++ p->argv1 = (char *)xmalloc(f + 1); ++ strcpy(p->argv1, buf); ++ ++ /* Get a pointer to the basename. */ ++ p->argv1base = strrchr(p->argv1, '/'); ++ if (p->argv1base != NULL) ++ p->argv1base++; ++ else ++ p->argv1base = p->argv1; ++ } ++ + fclose(fp); + +- /* Store the name into malloced memory. */ +- p->fullname = (char *)xmalloc(f); +- strcpy(p->fullname, buf); +- +- /* Get a pointer to the basename. */ +- if ((p->basename = strrchr(p->fullname, '/')) != NULL) +- p->basename++; +- else +- p->basename = p->fullname; + } else { + /* Process disappeared.. */ + free(p); +@@ -269,19 +322,18 @@ + return 0; + } + +-PIDQ *init_pid_q(PIDQ *q) ++PIDQ_HEAD *init_pid_q(PIDQ_HEAD *q) + { +- q->front = q->next = q->rear = NULL; +- q->proc = NULL; ++ q->head = q->next = q->tail = NULL; + return q; + } + +-int empty_q(PIDQ *q) ++int empty_q(PIDQ_HEAD *q) + { +- return (q->front == NULL); ++ return (q->head == NULL); + } + +-int add_pid_to_q(PIDQ *q, PROC *p) ++int add_pid_to_q(PIDQ_HEAD *q, PROC *p) + { + PIDQ *tmp; + +@@ -291,23 +343,23 @@ + tmp->next = NULL; + + if (empty_q(q)) { +- q->front = tmp; +- q->rear = tmp; ++ q->head = tmp; ++ q->tail = tmp; + } else { +- q->rear->next = tmp; +- q->rear = tmp; ++ q->tail->next = tmp; ++ q->tail = tmp; + } + return 0; + } + +-PROC *get_next_from_pid_q(PIDQ *q) ++PROC *get_next_from_pid_q(PIDQ_HEAD *q) + { +- PROC *p; +- PIDQ *tmp = q->front; ++ PROC *p; ++ PIDQ *tmp = q->head; + + if (!empty_q(q)) { +- p = q->front->proc; +- q->front = tmp->next; ++ p = q->head->proc; ++ q->head = tmp->next; + free(tmp); + return p; + } +@@ -316,15 +368,15 @@ + } + + /* Try to get the process ID of a given process. */ +-PIDQ *pidof(char *prog) ++PIDQ_HEAD *pidof(char *prog) + { +- struct stat st; +- int dostat = 0; +- PROC *p; +- PIDQ *q; +- char *s; +- int foundone = 0; +- int ok = 0; ++ PROC *p; ++ PIDQ_HEAD *q; ++ struct stat st; ++ char *s; ++ int dostat = 0; ++ int foundone = 0; ++ int ok = 0; + + /* Try to stat the executable. */ + if (prog[0] == '/' && stat(prog, &st) == 0) dostat++; +@@ -335,7 +387,7 @@ + else + s++; + +- q = (PIDQ *)xmalloc(sizeof(PIDQ)); ++ q = (PIDQ_HEAD *)xmalloc(sizeof(PIDQ_HEAD)); + q = init_pid_q(q); + + /* First try to find a match based on dev/ino pair. */ +@@ -349,20 +401,31 @@ + } + + /* If we didn't find a match based on dev/ino, try the name. */ +- if (!foundone) { +- for (p = plist; p; p = p->next) { +- ok = 0; ++ if (!foundone) for (p = plist; p; p = p->next) { ++ ok = 0; + +- ok += (strcmp(p->fullname, prog) == 0); +- ok += (strcmp(p->basename, s) == 0); +- +- if (p->fullname[0] == 0 || +- strchr(p->fullname, ' ') || +- scripts_too) +- ok += (strcmp(p->statname, s) == 0); ++ /* Compare name (both basename and full path) */ ++ ok += (p->argv0 && strcmp(p->argv0, prog) == 0); ++ ok += (p->argv0 && strcmp(p->argv0base, s) == 0); ++ ++ /* For scripts, compare argv[1] as well. */ ++ if (scripts_too && p->argv1 && ++ !strncmp(p->statname, p->argv1base, STATNAMELEN)) { ++ ok += (strcmp(p->argv1, prog) == 0); ++ ok += (strcmp(p->argv1base, s) == 0); ++ } + +- if (ok) add_pid_to_q(q, p); ++ /* ++ * if we have a space in argv0, process probably ++ * used setproctitle so try statname. ++ */ ++ if (strlen(s) <= STATNAMELEN && ++ (p->argv0 == NULL || ++ p->argv0[0] == 0 || ++ strchr(p->argv0, ' '))) { ++ ok += (strcmp(p->statname, s) == 0); + } ++ if (ok) add_pid_to_q(q, p); + } + + return q; +@@ -407,12 +470,12 @@ + */ + int main_pidof(int argc, char **argv) + { +- PROC *p; +- PIDQ *q; +- int f; +- int first = 1; +- int i,oind, opt, flags = 0; +- pid_t opid[PIDOF_OMITSZ], spid; ++ PIDQ_HEAD *q; ++ PROC *p; ++ pid_t opid[PIDOF_OMITSZ], spid; ++ int f; ++ int first = 1; ++ int i, oind, opt, flags = 0; + + for (oind = PIDOF_OMITSZ-1; oind > 0; oind--) + opid[oind] = 0; +@@ -495,9 +558,9 @@ + /* Main for either killall or pidof. */ + int main(int argc, char **argv) + { +- PROC *p; +- int pid, sid = -1; +- int sig = SIGKILL; ++ PROC *p; ++ int pid, sid = -1; ++ int sig = SIGKILL; + + /* Get program name. */ + if ((progname = strrchr(argv[0], '/')) == NULL) +@@ -508,9 +571,6 @@ + /* Now connect to syslog. */ + openlog(progname, LOG_CONS|LOG_PID, LOG_DAEMON); + +- /* First get the /proc filesystem online. */ +- mount_proc(); +- + /* Were we called as 'pidof' ? */ + if (strcmp(progname, "pidof") == 0) + return main_pidof(argc, argv); +@@ -522,6 +582,9 @@ + if ((sig = atoi(argv[1])) <= 0 || sig > 31) usage(); + } + ++ /* First get the /proc filesystem online. */ ++ mount_proc(); ++ + /* + * Ignoring SIGKILL and SIGSTOP do not make sense, but + * someday kill(-1, sig) might kill ourself if we don't +@@ -534,24 +597,19 @@ + + /* Now stop all processes. */ + kill(-1, SIGSTOP); +- stopped = 1; ++ sent_sigstop = 1; + +- /* Find out our own 'sid'. */ ++ /* Read /proc filesystem */ + if (readproc() < 0) { + kill(-1, SIGCONT); + exit(1); + } + +- pid = getpid(); +- for (p = plist; p; p = p->next) +- if (p->pid == pid) { +- sid = p->sid; +- break; +- } +- + /* Now kill all processes except our session. */ ++ sid = (int)getsid(0); ++ pid = (int)getpid(); + for (p = plist; p; p = p->next) +- if (p->pid != pid && p->sid != sid) ++ if (p->pid != pid && p->sid != sid && !p->kernel) + kill(p->pid, sig); + + /* And let them continue. */ diff --git a/smgl/simpleinit-msb/patches/last.c.diff b/smgl/simpleinit-msb/patches/last.c.diff new file mode 100644 index 0000000..0390d5d --- /dev/null +++ b/smgl/simpleinit-msb/patches/last.c.diff @@ -0,0 +1,298 @@ +--- last.c 2001-09-26 12:59:46.000000000 +0200 ++++ ../../sysvinit-2.86.ds1/src/last.c 2004-07-30 14:16:26.000000000 +0200 +@@ -6,10 +6,10 @@ + * + * Author: Miquel van Smoorenburg, miquels@cistron.nl + * +- * Version: @(#)last 2.79 13-Jun-2001 miquels@cistron.nl ++ * Version: @(#)last 2.85 30-Jul-2004 miquels@cistron.nl + * + * This file is part of the sysvinit suite, +- * Copyright 1991-2001 Miquel van Smoorenburg. ++ * Copyright 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 +@@ -40,7 +40,7 @@ + # define SHUTDOWN_TIME 254 + #endif + +-char *Version = "@(#) last 2.79 11-Sep-2000 miquels"; ++char *Version = "@(#) last 2.85 31-Apr-2004 miquels"; + + #define CHOP_DOMAIN 0 /* Define to chop off local domainname. */ + #define NEW_UTMP 1 /* Fancy & fast utmp read code. */ +@@ -128,16 +128,16 @@ + * Initialize and position. + */ + utsize = oldfmt ? sizeof(uto) : sizeof(struct utmp); +- fseek(fp, 0L, SEEK_END); +- fpos = ftell(fp); ++ fseeko(fp, 0, SEEK_END); ++ fpos = ftello(fp); + if (fpos == 0) + return 0; + o = ((fpos - 1) / UCHUNKSIZE) * UCHUNKSIZE; +- if (fseek(fp, o, SEEK_SET) < 0) { ++ if (fseeko(fp, o, SEEK_SET) < 0) { + fprintf(stderr, "%s: seek failed!\n", progname); + return 0; + } +- bpos = fpos - o; ++ bpos = (int)(fpos - o); + if (fread(buf, bpos, 1, fp) != 1) { + fprintf(stderr, "%s: read failed!\n", progname); + return 0; +@@ -170,7 +170,7 @@ + * Copy whatever is left in the buffer. + */ + memcpy(tmp + (-bpos), buf, utsize + bpos); +- if (fseek(fp, fpos, SEEK_SET) < 0) { ++ if (fseeko(fp, fpos, SEEK_SET) < 0) { + perror("fseek"); + return 0; + } +@@ -207,25 +207,25 @@ + int uread(FILE *fp, struct utmp *u, int *quit) + { + struct oldutmp uto; +- int r; ++ off_t r; + + if (u == NULL) { + r = oldfmt ? sizeof(struct oldutmp) : sizeof(struct utmp); +- fseek(fp, -1L * r, SEEK_END); ++ fseek(fp, -1 * r, SEEK_END); + return 1; + } + + if (!oldfmt) { + r = fread(u, sizeof(struct utmp), 1, fp); + if (r == 1) { +- if (fseek(fp, -2L * sizeof(struct utmp), SEEK_CUR) < 0) ++ if (fseeko(fp, -2 * sizeof(struct utmp), SEEK_CUR) < 0) + if (quit) *quit = 1; + } + return r; + } + r = fread(&uto, sizeof(struct oldutmp), 1, fp); + if (r == 1) { +- if (fseek(fp, -2L * sizeof(struct oldutmp), SEEK_CUR) < 0) ++ if (fseeko(fp, -2 * sizeof(struct oldutmp), SEEK_CUR) < 0) + if (quit) *quit = 1; + uconv(&uto, u); + } +@@ -300,29 +300,48 @@ + /* + * Lookup a host with DNS. + */ +-int dns_lookup(char *result, int size, char *org, unsigned int ip) ++int dns_lookup(char *result, int size, int useip, int32_t *a) + { +- struct hostent *h; +- +- /* +- * Try to catch illegal IP numbers +- */ +- if (ip == 0 || (int)ip == -1 || (ip >> 24) == 0 || (ip & 255) == 0) { +- if (size > UT_HOSTSIZE) size = UT_HOSTSIZE+1; +- strncpy(result, org, size - 1); +- result[size-1] = 0; +- return 0; +- } +- +- if ((h = gethostbyaddr((char *)&ip, 4, AF_INET)) == NULL) { +- strncpy(result, inet_ntoa(*(struct in_addr *)&ip), size); +- result[size-1] = 0; +- return 0; ++ struct sockaddr_in sin; ++ struct sockaddr_in6 sin6; ++ struct sockaddr *sa; ++ int salen, flags; ++ unsigned int topnibble; ++ int mapped = 0; ++ ++ flags = useip ? NI_NUMERICHOST : 0; ++ ++ /* ++ * IPv4 or IPv6 ? We use 2 heuristics: ++ * 1. Current IPv6 range uses 2000-3fff. Outside of ++ * that is illegal and must be IPv4. ++ * 2. If last 3 bytes are 0, must be IPv4 ++ * 3. If IPv6 in IPv4, handle as IPv4 ++ * ++ * Ugly. ++ */ ++ if (a[0] == 0 && a[1] == 0 && a[2] == htonl (0xffff)) ++ mapped = 1; ++ topnibble = ntohl((unsigned int)a[0]) >> 28; ++ if (topnibble < 2 || topnibble > 3 || mapped || ++ (a[1] == 0 && a[2] == 0 && a[3] == 0)) { ++ /* IPv4 */ ++ sin.sin_family = AF_INET; ++ sin.sin_port = 0; ++ sin.sin_addr.s_addr = mapped ? a[3] : a[0]; ++ sa = (struct sockaddr *)&sin; ++ salen = sizeof(sin); ++ } else { ++ /* IPv6 */ ++ memset(&sin6, 0, sizeof(sin6)); ++ sin6.sin6_family = AF_INET6; ++ sin6.sin6_port = 0; ++ memcpy(sin6.sin6_addr.s6_addr, a, 16); ++ sa = (struct sockaddr *)&sin6; ++ salen = sizeof(sin6); + } +- strncpy(result, h->h_name, size-1); +- result[size-1] = 0; + +- return 0; ++ return getnameinfo(sa, salen, result, size, NULL, 0, flags); + } + + /* +@@ -330,22 +349,22 @@ + */ + int list(struct utmp *p, time_t t, int what) + { +- struct in_addr in; +- char logintime[32]; +- char logouttime[32]; +- char length[32]; +- char final[128]; +- char utline[UT_LINESIZE+1]; +- char domain[256]; +- time_t secs, tmp; +- int mins, hours, days; +- char *s, **walk; ++ time_t secs, tmp; ++ char logintime[32]; ++ char logouttime[32]; ++ char length[32]; ++ char final[128]; ++ char utline[UT_LINESIZE+1]; ++ char domain[256]; ++ char *s, **walk; ++ int mins, hours, days; ++ int r, len; + + /* + * uucp and ftp have special-type entries + */ +- strncpy(utline, p->ut_line, UT_LINESIZE); +- utline[UT_LINESIZE - 1] = 0; ++ utline[0] = 0; ++ strncat(utline, p->ut_line, UT_LINESIZE); + if (strncmp(utline, "ftp", 3) == 0 && isdigit(utline[3])) + utline[3] = 0; + if (strncmp(utline, "uucp", 4) == 0 && isdigit(utline[4])) +@@ -412,14 +431,14 @@ + /* + * Look up host with DNS if needed. + */ +- if (usedns) +- dns_lookup(domain, sizeof(domain), p->ut_host, p->ut_addr); +- if (useip) { +- in.s_addr = p->ut_addr; +- strcpy(domain, inet_ntoa(in)); +- } else { +- strncpy(domain, p->ut_host, UT_HOSTSIZE); +- domain[UT_HOSTSIZE-1] = 0; ++ r = -1; ++ if (usedns || useip) ++ r = dns_lookup(domain, sizeof(domain), useip, p->ut_addr_v6); ++ if (r < 0) { ++ len = UT_HOSTSIZE; ++ if (len >= sizeof(domain)) len = sizeof(domain) - 1; ++ domain[0] = 0; ++ strncat(domain, p->ut_host, len); + } + + if (showhost) { +@@ -472,10 +491,48 @@ + void usage(char *s) + { + fprintf(stderr, "Usage: %s [-num | -n num] [-f file] " ++ "[-t YYYYMMDDHHMMSS] " + "[-R] [-x] [-o] [username..] [tty..]\n", s); + exit(1); + } + ++time_t parsetm(char *ts) ++{ ++ struct tm u = {0}, origu; ++ time_t tm; ++ ++ if (sscanf(ts, "%4d%2d%2d%2d%2d%2d", &u.tm_year, ++ &u.tm_mon, &u.tm_mday, &u.tm_hour, &u.tm_min, ++ &u.tm_sec) != 6) ++ return (time_t)-1; ++ ++ u.tm_year -= 1900; ++ u.tm_mon -= 1; ++ u.tm_isdst = -1; ++ ++ origu = u; ++ ++ if ((tm = mktime(&u)) == (time_t)-1) ++ return tm; ++ ++ /* ++ * Unfortunately mktime() is much more forgiving than ++ * it should be. For example, it'll gladly accept ++ * "30" as a valid month number. This behavior is by ++ * design, but we don't like it, so we want to detect ++ * it and complain. ++ */ ++ if (u.tm_year != origu.tm_year || ++ u.tm_mon != origu.tm_mon || ++ u.tm_mday != origu.tm_mday || ++ u.tm_hour != origu.tm_hour || ++ u.tm_min != origu.tm_min || ++ u.tm_sec != origu.tm_sec) ++ return (time_t)-1; ++ ++ return tm; ++} ++ + int main(int argc, char **argv) + { + FILE *fp; /* Filepointer of wtmp file */ +@@ -499,10 +556,12 @@ + int extended = 0; /* Lots of info. */ + char *altufile = NULL;/* Alternate wtmp */ + ++ time_t until = 0; /* at what time to stop parsing the file */ ++ + progname = mybasename(argv[0]); + + /* Process the arguments. */ +- while((c = getopt(argc, argv, "f:n:Rxadio0123456789")) != EOF) ++ while((c = getopt(argc, argv, "f:n:Rxadiot:0123456789")) != EOF) + switch(c) { + case 'R': + showhost = 0; +@@ -533,6 +592,13 @@ + case 'a': + altlist++; + break; ++ case 't': ++ if ((until = parsetm(optarg)) == (time_t)-1) { ++ fprintf(stderr, "%s: Invalid time value \"%s\"\n", ++ progname, optarg); ++ usage(progname); ++ } ++ break; + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + maxrecs = 10*maxrecs + c - '0'; +@@ -631,6 +697,9 @@ + if (uread(fp, &ut, &quit) != 1) + break; + ++ if (until && until < ut.ut_time) ++ continue; ++ + if (memcmp(&ut, &oldut, sizeof(struct utmp)) == 0) continue; + memcpy(&oldut, &ut, sizeof(struct utmp)); + lastdate = ut.ut_time; diff --git a/smgl/simpleinit-msb/patches/shutdown.c.diff b/smgl/simpleinit-msb/patches/shutdown.c.diff new file mode 100644 index 0000000..3aa1e84 --- /dev/null +++ b/smgl/simpleinit-msb/patches/shutdown.c.diff @@ -0,0 +1,20 @@ +--- shutdown.c.orig 2006-04-22 16:38:28.000000000 +0200 ++++ shutdown.c 2006-04-23 00:16:58.000000000 +0200 +@@ -733,6 +733,8 @@ + char *filesys; + + sync(); ++ sync(); ++ sync(); + if (!(mtab = setmntent(_PATH_PROC_MOUNTS, "r"))) { + char buffy[256]; + sprintf(buffy,"shutdown: Cannot open " _PATH_PROC_MOUNTS ": %s",ERRSTRING); +@@ -758,7 +760,7 @@ + #ifdef DEBUGGING + printf("umount %s\n", filesys); + #else +- if (umount(mntlist[i]) < 0) ++ if (unmount(mntlist[i],0) < 0) + { + char buffy[1024]; + sprintf(buffy,_("shutdown: Couldn't umount %s: %s"), diff --git a/smgl/simpleinit-msb/patches/simpleinit-1000uid.patch b/smgl/simpleinit-msb/patches/simpleinit-1000uid.patch new file mode 100644 index 0000000..bf1d90c --- /dev/null +++ b/smgl/simpleinit-msb/patches/simpleinit-1000uid.patch @@ -0,0 +1,40 @@ +--- 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/patches/simpleinit-msb-crypt.diff b/smgl/simpleinit-msb/patches/simpleinit-msb-crypt.diff new file mode 100644 index 0000000..27b3cfd --- /dev/null +++ b/smgl/simpleinit-msb/patches/simpleinit-msb-crypt.diff @@ -0,0 +1,21 @@ +diff -urN simpleinit-msb-1.2/sysvtools/Makefile simpleinit-msb-1.2-new/sysvtools/Makefile +--- simpleinit-msb-1.2/sysvtools/Makefile 2001-09-26 13:01:08.000000000 +0200 ++++ simpleinit-msb-1.2-new/sysvtools/Makefile 2005-04-15 00:43:31.281944078 +0200 +@@ -8,6 +8,8 @@ + # Version: @(#)Makefile 2.78 13-Nov-1999 miquels@cistron.nl + # + ++include ../make_include ++ + CC = cc + CFLAGS = -Wall -O2 -D_GNU_SOURCE + LDFLAGS = -s +@@ -22,7 +24,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/patches/simpleinit.patch b/smgl/simpleinit-msb/patches/simpleinit.patch new file mode 100644 index 0000000..fc15f17 --- /dev/null +++ b/smgl/simpleinit-msb/patches/simpleinit.patch @@ -0,0 +1,97 @@ +diff -Nur simpleinit-msb-1.2/lib/pathnames.h simpleinit-msb-1.2-smgl/lib/pathnames.h +--- simpleinit-msb-1.2/lib/pathnames.h 2001-09-26 12:59:46.000000000 +0200 ++++ simpleinit-msb-1.2-smgl/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 */ +diff -Nur simpleinit-msb-1.2/login-utils/shutdown.c simpleinit-msb-1.2-smgl/login-utils/shutdown.c +--- simpleinit-msb-1.2/login-utils/shutdown.c 2001-09-26 12:59:46.000000000 +0200 ++++ simpleinit-msb-1.2-smgl/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); +diff -Nur simpleinit-msb-1.2/login-utils/simpleinit.c simpleinit-msb-1.2-smgl/login-utils/simpleinit.c +--- simpleinit-msb-1.2/login-utils/simpleinit.c 2004-01-11 00:24:42.000000000 +0100 ++++ simpleinit-msb-1.2-smgl/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); diff --git a/smgl/simpleinit-msb/patches/sulogin.c.diff b/smgl/simpleinit-msb/patches/sulogin.c.diff new file mode 100644 index 0000000..d660dba --- /dev/null +++ b/smgl/simpleinit-msb/patches/sulogin.c.diff @@ -0,0 +1,68 @@ +--- ../../simpleinit-msb-1.2/sysvtools/sulogin.c 2001-09-26 12:59:46.000000000 +0200 ++++ sulogin.c 2004-07-30 13:40:28.000000000 +0200 +@@ -8,7 +8,7 @@ + * encrypted root password is "x" the shadow + * password will be used. + * +- * Version: @(#)sulogin 2.81 31-Jul-2001 miquels@cistron.nl ++ * Version: @(#)sulogin 2.85-3 23-Apr-2003 miquels@cistron.nl + * + */ + +@@ -35,11 +35,15 @@ + #define F_SHADOW "/etc/shadow" + #define BINSH "/bin/sh" + +-char *Version = "@(#)sulogin 2.81 31-Jul-2001 miquels@cistron.nl"; ++char *Version = "@(#)sulogin 2.85-3 23-Apr-2003 miquels@cistron.nl"; + + int timeout = 0; + int profile = 0; + ++#ifndef IUCLC ++# define IUCLC 0 ++#endif ++ + #if 0 + /* + * Fix the tty modes and set reasonable defaults. +@@ -240,7 +244,7 @@ + * Ask for the password. Note that there is no + * default timeout as we normally skip this during boot. + */ +-char *getpasswd(void) ++char *getpasswd(char *crypted) + { + struct sigaction sa; + struct termios old, tty; +@@ -248,8 +252,11 @@ + char *ret = pass; + int i; + +- printf("Give root password for maintenance\n"); +- printf("(or type Control-D for normal startup): "); ++ if (crypted[0]) ++ printf("Give root password for maintenance\n"); ++ else ++ printf("Press enter for maintenance\n"); ++ printf("(or type Control-D to continue): "); + fflush(stdout); + + tcgetattr(0, &old); +@@ -387,6 +394,7 @@ + perror(tty); + } else if (!isatty(fd)) { + fprintf(stderr, "%s: not a tty\n", tty); ++ close(fd); + } else { + + /* +@@ -433,7 +441,7 @@ + * Ask for the password. + */ + while(pwd) { +- if (pwd->pw_passwd[0] && (p = getpasswd()) == NULL) break; ++ if ((p = getpasswd(pwd->pw_passwd)) == NULL) break; + if (pwd->pw_passwd[0] == 0 || + strcmp(crypt(p, pwd->pw_passwd), pwd->pw_passwd) == 0) + sushell(pwd); diff --git a/smgl/simpleinit-msb/telinit b/smgl/simpleinit-msb/telinit new file mode 100755 index 0000000..9a86799 --- /dev/null +++ b/smgl/simpleinit-msb/telinit @@ -0,0 +1,46 @@ +#!/bin/sh + +#Copyright (c) 2001 Matthias S. Benkmann +#licensed under the GNU General Public License (GPL) Version 2 +# +# Modified for Source Mage GNU/Linux by erics/rycee, 2004-06-30. +# - removed -u option and checks for root UID as all smgl scripts. +# + +if [ $# -eq 0 ]; then + echo 1>&2 Usage: telinit args + echo 1>&2 'telinit calls "bootprog telinit args" where bootprog is the program' + echo 1>&2 'specified in /etc/inittab' . + echo 1>&2 'e.g.: "telinit " might tell bootprog to switch to runlevel ' + exit 1 +fi + +test -p /dev/initctl && touch /dev/initctl 2>/dev/null +perm=$? #0 if writing to /dev/initctl is permitted + +INIT_ROOT="" +PRE_PATH="" + +if [ $UID != 0 ]; then + echo "Enter the root password, please." + exec su - -c "DISPLAY=$DISPLAY PATH=$PATH $0 $*" +fi + +if [ z"$1" == z"--" ]; then shift 1; fi + +get_inittab_entry() +{ +# sed -n s/$'^[ \r\t]*'${1}$'[ \r\t]*=*[ \r\t]*''\('$'[^ \r\t]*''\).*$/\1/p' <$INIT_ROOT/etc/inittab + + #echo before cat to get initial newline because the regex needs it + expr "`echo ; cat $INIT_ROOT/etc/inittab`" : $'.*\n[ \r\t]*'${1}$'[ \r\t]*=*[ \r\t]*''\('$'[^ \r\t\n]*''\).*' +} + + +export INIT_D=$INIT_ROOT`get_inittab_entry fileprefix` +bootprog=`get_inittab_entry bootprog` +export PATH=$PRE_PATH`get_inittab_entry PATH` +export INIT_PATH=`get_inittab_entry INIT_PATH` + + +$INIT_D$bootprog telinit "$@" -- 2.11.4.GIT