From fb512c6276272bbe3d58318ec3a6aa5c2463cc434367009e212a7eacc0481ae2 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Wed, 13 Jan 2016 18:16:58 +0000 Subject: [PATCH] Accepting request 347468 from home:rudi_m:branches:Base:System - cleanup package: * don't build binaries which are not installed * remove unused sources * remove patches (or parts of patches) which modify unused files * remove old build conditions (sysvinit, util-linux, mkinitrd) * remove unused dependencies - this cleanup does not change the resulting binaries (except some package dependencies) - list of removed patches: * sysvinit-2.82-startstop.patch * sysvinit-2.88+dsf-blowfish.dif * sysvinit-2.88+dsf-crypt.patch * sysvinit-2.88+dsf-env.patch * sysvinit-2.88dsf-multiple-sulogin.patch * sysvinit-2.88+dsf-run.diff * sysvinit-2.88+dsf-xen.patch - list of modified patches: * notify-pam-dead.patch * sysvinit-2.88+dsf.dif * sysvinit-2.88+dsf-sulogin.diff * sysvinit-2.88dsf-suse.patch OBS-URL: https://build.opensuse.org/request/show/347468 OBS-URL: https://build.opensuse.org/package/show/Base:System/sysvinit?expand=0&rev=214 --- mkinitrd-boot.sh | 35 - mkinitrd-kill1.sh | 21 - mkinitrd-kill2.sh | 34 - notify-pam-dead.patch | 162 --- powerd.changes | 5 + powerd.spec | 30 - rc.powerd | 65 - sysvinit-2.82-startstop.patch | 161 --- sysvinit-2.88+dsf-blowfish.dif | 70 -- sysvinit-2.88+dsf-crypt.patch | 22 - sysvinit-2.88+dsf-env.patch | 149 --- sysvinit-2.88+dsf-run.diff | 23 - sysvinit-2.88+dsf-sulogin.diff | 26 - sysvinit-2.88+dsf-xen.patch | 24 - sysvinit-2.88+dsf.dif | 64 +- sysvinit-2.88dsf-multiple-sulogin.patch | 1500 ----------------------- sysvinit-2.88dsf-suse.patch | 121 -- sysvinit-rpmlintrc | 7 - sysvinit.changes | 25 + sysvinit.spec | 221 +--- 20 files changed, 66 insertions(+), 2699 deletions(-) delete mode 100644 mkinitrd-boot.sh delete mode 100644 mkinitrd-kill1.sh delete mode 100644 mkinitrd-kill2.sh delete mode 100644 rc.powerd delete mode 100644 sysvinit-2.82-startstop.patch delete mode 100644 sysvinit-2.88+dsf-blowfish.dif delete mode 100644 sysvinit-2.88+dsf-crypt.patch delete mode 100644 sysvinit-2.88+dsf-env.patch delete mode 100644 sysvinit-2.88+dsf-run.diff delete mode 100644 sysvinit-2.88+dsf-xen.patch delete mode 100644 sysvinit-2.88dsf-multiple-sulogin.patch delete mode 100644 sysvinit-rpmlintrc diff --git a/mkinitrd-boot.sh b/mkinitrd-boot.sh deleted file mode 100644 index a9c84ab..0000000 --- a/mkinitrd-boot.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -#%stage: boot -#%depends: udev clock -#%programs: blogd -#%programs: ln -#%programs: mkdir -#%programs: mount -#%programs: showconsole -#%if: -x /sbin/blogd -#%dontshow -# -##### blogd start -## -## This script starts blogd if this has not happened before. -## -## Command line parameters -## ----------------------- -## - -fboot=$(get_param fastboot) -quiet=$(get_param quiet) - -if test -z "$fboot" -a -z "$quiet" -a -z "$REDIRECT" ; then - REDIRECT=$(showconsole 2>/dev/null) - if test -n "$REDIRECT" ; then - if test "$devpts" != "yes" ; then - mount -t devpts devpts /dev/pts - devpts=yes - fi - > /dev/shm/initrd.msg - ln -sf /dev/shm/initrd.msg /var/log/boot.msg - mkdir -p /var/run - blogd $REDIRECT - fi -fi diff --git a/mkinitrd-kill1.sh b/mkinitrd-kill1.sh deleted file mode 100644 index b915c8b..0000000 --- a/mkinitrd-kill1.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -#%stage: setup -# -#%programs: kill -#%programs: pidof -#%dontshow -# -##### blogd end -## -## This script tells blogd that the initrd is done. -## Additionally it moves /dev to the new root filesystem. -## -## Command line parameters -## ----------------------- -## - -blogd_pid=$(pidof blogd) -if test -n "$blogd_pid" ; then - kill -IO "$blogd_pid" -fi diff --git a/mkinitrd-kill2.sh b/mkinitrd-kill2.sh deleted file mode 100644 index c696def..0000000 --- a/mkinitrd-kill2.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# -#%stage: setup -#%depends: killblogd -#%provides: killprogs -# -#%programs: kill -#%programs: umount -#%programs: usleep -#%dontshow -# -##### blogd end2 -## -## Really kill blogd this time. -## -## Command line parameters -## ----------------------- -## - -if test -n "$blogd_pid" ; then - kill -QUIT "$blogd_pid" - typeset -i bquit=50 - while test -d "/proc/$blogd_pid" ; do - usleep 30000 - if ((bquit-- <= 0)) ; then - kill -KILL "$blogd_pid" - break - fi - done - unset bquit blogd_pid - if test "$devpts" = "yes" ; then - umount -t devpts /dev/pts - fi -fi diff --git a/notify-pam-dead.patch b/notify-pam-dead.patch index 9e95034..c62e60e 100644 --- a/notify-pam-dead.patch +++ b/notify-pam-dead.patch @@ -35,59 +35,6 @@ # $(INSTALL_DIR) $(ROOT)/etc/ # $(INSTALL_EXEC) initscript.sample $(ROOT)/etc/ ln -sf halt $(ROOT)/sbin/reboot ---- src/init.c -+++ src/init.c 2010-04-13 00:00:00.000000000 +0000 -@@ -79,6 +79,10 @@ - #include "reboot.h" - #include "set.h" - -+#ifdef USE_PAM -+extern void notify_pam_dead_session(const char *id); -+#endif -+ - #ifndef SIGPWR - # define SIGPWR SIGUSR2 - #endif -@@ -1132,6 +1136,9 @@ pid_t spawn(CHILD *ch, int *res) - } - dup(f); - dup(f); -+#ifdef USE_PAM -+ notify_pam_dead_session(ch->id); -+#endif - } - - /* -@@ -1551,6 +1558,9 @@ void read_inittab(void) - INITDBG(L_VB, "Updating utmp for pid %d [id %s]", - ch->pid, ch->id); - ch->flags &= ~RUNNING; -+#ifdef USE_PAM -+ notify_pam_dead_session(ch->id); -+#endif - if (ch->process[0] != '+') - write_utmp_wtmp("", ch->id, ch->pid, DEAD_PROCESS, NULL); - } -@@ -2012,6 +2022,9 @@ void re_exec(void) - if (ch->flags & ZOMBIE) { - INITDBG(L_VB, "Child died, PID= %d", ch->pid); - ch->flags &= ~(RUNNING|ZOMBIE|WAITING); -+#ifdef USE_PAM -+ notify_pam_dead_session(ch->id); -+#endif - if (ch->process[0] != '+') - write_utmp_wtmp("", ch->id, ch->pid, DEAD_PROCESS, NULL); - } -@@ -2465,6 +2478,9 @@ void process_signals() - if (ch->flags & ZOMBIE) { - INITDBG(L_VB, "Child died, PID= %d", ch->pid); - ch->flags &= ~(RUNNING|ZOMBIE|WAITING); -+#ifdef USE_PAM -+ notify_pam_dead_session(ch->id); -+#endif - if (ch->process[0] != '+') - write_utmp_wtmp("", ch->id, ch->pid, DEAD_PROCESS, NULL); - } --- src/init.sample +++ src/init.sample 2010-04-13 00:00:00.000000000 +0000 @@ -0,0 +1,8 @@ @@ -99,113 +46,4 @@ +auth sufficient pam_rootok.so +account include common-account +session requisite pam_lastlog.so silent ---- src/utmp.c -+++ src/utmp.c 2010-04-13 00:00:00.000000000 +0000 -@@ -34,10 +34,18 @@ - #include - #include - -+#if defined(USE_PAM) && defined(INIT_MAIN) -+# include -+# include -+#endif -+ - #include "init.h" - #include "initreq.h" - #include "paths.h" - -+#ifndef _PATH_DEV -+# define _PATH_DEV "/dev/" -+#endif - - #if defined(__GLIBC__) - # if (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0) && defined(__powerpc__) -@@ -127,9 +135,9 @@ char *line) /* Which line is this */ - strncpy(utmp.ut_name, user, sizeof(utmp.ut_name)); - strncpy(utmp.ut_id , id , sizeof(utmp.ut_id )); - strncpy(utmp.ut_line, line, sizeof(utmp.ut_line)); -- -- /* Put the OS version in place of the hostname */ -- if (uname(&uname_buf) == 0) -+ -+ /* Put the OS version in place of the hostname */ -+ if (uname(&uname_buf) == 0) - strncpy(utmp.ut_host, uname_buf.release, sizeof(utmp.ut_host)); - - #if HAVE_UPDWTMP -@@ -262,3 +270,75 @@ char *line) /* LINE if used. */ - write_wtmp(user, id, pid, type, line && line[0] ? line : oldline); - } - -+#if defined(USE_PAM) && defined(INIT_MAIN) -+static pam_handle_t *pamh = NULL; -+# ifdef __GNUC__ -+static int -+null_conv(int num_msg, const struct pam_message **msgm, -+ struct pam_response **response __attribute__((unused)), -+ void *appdata_ptr __attribute__((unused))) -+# else -+static int -+null_conv(int num_msg, const struct pam_message **msgm, -+ struct pam_response **response, void *appdata_ptr) -+# endif -+{ -+ int i; -+ for (i = 0; i < num_msg; i++) { -+ const struct pam_message *msg = msgm[i]; -+ if (msg == (const struct pam_message*)0) -+ continue; -+ if (msg->msg == (char*)0) -+ continue; -+ switch (msg->msg_style) { -+ case PAM_ERROR_MSG: -+ case PAM_TEXT_INFO: -+ initlog(L_VB, "pam_message %s", msg->msg); -+ default: -+ break; -+ } -+ } -+ return 0; -+} -+static const struct pam_conv conv = { null_conv, NULL }; -+# define PAM_FAIL_CHECK(func, args...) \ -+ { \ -+ if ((pam_ret = (func)(args)) != PAM_SUCCESS) { \ -+ initlog(L_VB, "%s", pam_strerror(pamh, pam_ret)); \ -+ goto pam_error; \ -+ } \ -+ } -+ -+void notify_pam_dead_session(const char *id) -+{ -+ struct utmp *oldut, ut; -+ -+ setutent(); -+ -+ memset(&ut, 0, sizeof(ut)); -+ ut.ut_type = DEAD_PROCESS; -+ strncpy(ut.ut_id, id, sizeof(ut.ut_id)); -+ -+ if ((oldut = getutid(&ut)) && (oldut->ut_type == USER_PROCESS)) { -+ int pam_ret; -+ char tty[UT_LINESIZE+ strlen(_PATH_DEV) + 1]; -+ -+ if (strncmp(oldut->ut_line, _PATH_DEV, strlen(_PATH_DEV))) -+ snprintf(tty, sizeof(tty), _PATH_DEV "%.*s", -+ UT_LINESIZE, oldut->ut_line); -+ else -+ snprintf(tty, sizeof(tty), "%.*s", -+ UT_LINESIZE, oldut->ut_line); -+ -+ PAM_FAIL_CHECK(pam_start, "init", oldut->ut_user, &conv, &pamh); -+ PAM_FAIL_CHECK(pam_set_item, pamh, PAM_TTY, tty); -+ PAM_FAIL_CHECK(pam_set_item, pamh, PAM_RHOST, oldut->ut_host); -+ PAM_FAIL_CHECK(pam_close_session, pamh, PAM_SILENT); -+ pam_error: -+ pam_end(pamh, pam_ret); -+ } -+ -+ endutent(); -+} -+#endif /* USE_PAM && INIT_MAIN */ + diff --git a/powerd.changes b/powerd.changes index 426b5a5..20133ec 100644 --- a/powerd.changes +++ b/powerd.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Dec 4 15:24:01 UTC 2015 - sweet_f_a@gmx.de + +- cleanup package + ------------------------------------------------------------------- Thu Aug 21 11:38:06 UTC 2014 - lnussel@suse.de diff --git a/powerd.spec b/powerd.spec index f713257..6293b54 100644 --- a/powerd.spec +++ b/powerd.spec @@ -16,11 +16,6 @@ # -%if %{undefined systemd_requires} -%global with_sysvinit 1 -%endif -%bcond_with sysvinit - Name: powerd Version: 2.0.2 Release: 0 @@ -28,25 +23,15 @@ Summary: UPS monitoring daemon License: GPL-2.0+ Group: System/Base BuildRoot: %{_tmppath}/%{name}-%{version}-build -%if 0%{?suse_version} > 1140 -%if 0%{?suse_version} > 1230 BuildRequires: systemd-rpm-macros -%else -BuildRequires: pkg-config -BuildRequires: systemd-devel -%endif -%endif Url: https://power.sourceforge.net/ Source0: powerd-%{version}.tar.bz2 -Source1: rc.powerd Source2: powerd.service Patch0: powerd-%{version}.dif Patch1: powerd-%{version}-getaddrinfo.patch -%if %{without sysvinit} %if %{undefined _unitdir} %{expand: %%global %_unitdir %(pkg-config systemd --variable=systemdsystemunitdir)} %endif -%endif %description -n powerd powerd monitors the serial port connected to an UPS device and will perform @@ -82,28 +67,17 @@ than a specified number of minutes. echo '# read manual page of detectups(8) and powerd(8) its self.' >> %{buildroot}/etc/powerd.conf echo '# ' >> %{buildroot}/etc/powerd.conf echo '# to enable powerd service run the command' >> %{buildroot}/etc/powerd.conf -%if %{with sysvinit} - echo '# insserv powerd' >> %{buildroot}/etc/powerd.conf - echo '# rcpowerd start' >> %{buildroot}/etc/powerd.conf - mkdir -p %{buildroot}/etc/init.d - install -m 0744 %{S:1} %{buildroot}/etc/init.d/powerd - ln -sf /etc/init.d/powerd %{buildroot}%{_sbindir}/rcpowerd -%else echo '# systemctl enable powerd.service' >> %{buildroot}/etc/powerd.conf echo '# systemctl start powerd.service' >> %{buildroot}/etc/powerd.conf mkdir -p %{buildroot}/%{_unitdir} install -m 0644 %{S:2} %{buildroot}/%{_unitdir}/powerd.service ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcpowerd -%endif %preun %stop_on_removal powerd %postun %restart_on_update powerd -%if %{with sysvinit} -%insserv_cleanup -%endif %files -n powerd %defattr (-,root,root,755) @@ -112,11 +86,7 @@ than a specified number of minutes. /sbin/detectups %{_sbindir}/rcpowerd %config /etc/powerd.conf -%if %{with sysvinit} -%config /etc/init.d/powerd -%else %attr(0644,root,root) %{_unitdir}/powerd.service -%endif %doc %{_mandir}/man8/powerd.8.gz %doc %{_mandir}/man8/detectups.8.gz diff --git a/rc.powerd b/rc.powerd deleted file mode 100644 index 87ec66c..0000000 --- a/rc.powerd +++ /dev/null @@ -1,65 +0,0 @@ -#! /bin/sh -# -# System startup script for the UPS monitoring daemon -# -### BEGIN INIT INFO -# Provides: powerd -# Required-Start: $syslog -# Should-Start: -# Required-Stop: $syslog -# Should-Stop: -# Default-Start: 2 3 5 -# Default-Stop: 0 1 6 -# Short-Description: Start the UPS monitoring daemon -# Description: Start the UPS monitoring daemon -### END INIT INFO - -POWERD=/sbin/powerd -test -x $POWERD || exit 5 - -POWERD_CONFIG=/etc/powerd.conf -test -f $POWERD_CONFIG || exit 6 - -# Source SuSE config -. /etc/rc.status - -rc_reset -case "$1" in - start) - echo -n "Starting UPS monitoring daemon" - startproc -f $POWERD - rc_status -v - ;; - stop) - echo -n "Shutting down UPS monitoring daemon" - killproc $POWERD - rc_status -v - ;; - try-restart) - $0 status >/dev/null && $0 restart - rc_status - ;; - restart) - $0 stop - $0 start - rc_status - ;; - force-reload) - $0 try-restart - rc_status - ;; - reload) - $0 try-restart - rc_status - ;; - status) - echo -n "Checking for UPS monitoring service" - checkproc $POWERD - rc_status -v - ;; - *) - echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" - exit 1 - ;; -esac -rc_exit diff --git a/sysvinit-2.82-startstop.patch b/sysvinit-2.82-startstop.patch deleted file mode 100644 index b6dada6..0000000 --- a/sysvinit-2.82-startstop.patch +++ /dev/null @@ -1,161 +0,0 @@ ---- contrib/start-stop-daemon.c -+++ contrib/start-stop-daemon.c Wed Feb 14 13:38:07 2001 -@@ -3,6 +3,7 @@ - * in C (faster - it is executed many times during system startup). - * - * Written by Marek Michalkiewicz , -+ * modified by Raymund Will , - * public domain. - */ - -@@ -13,12 +14,13 @@ - #include - #include - #include -+#include - #include - #include - #include - #include - --#define VERSION "version 0.3, 1996-06-05" -+#define VERSION "version 0.3.1, 1996-07-19" - - static int testmode = 0; - static int quietmode = 0; -@@ -28,9 +30,8 @@ - static int signal_nr = 15; - static int user_id = -1; - static const char *userspec = NULL; --static const char *cmdname = NULL; -+static char *cmdname = NULL; - static char *execname = NULL; --static char *startas = NULL; - static const char *pidfile = NULL; - static const char *progname = ""; - -@@ -122,9 +123,8 @@ - -x|--exec program to start/check if it is running\n\ - -p|--pidfile pid file to check\n\ - -u|--user | stop this user's processes\n\ -- -n|--name stop processes with this name\n\ -+ -n|--name start/stop processes with this name\n\ - -s|--signal signal to send (default 15)\n\ -- -a|--startas program to start (default )\n\ - -t|--test test mode, don't do anything\n\ - -o|--oknodo exit status 0 (not 1) if nothing done\n\ - -q|--quiet | -v, --verbose\n\ -@@ -183,9 +183,7 @@ - case 'V': /* --version */ - printf("start-stop-daemon " VERSION "\n"); - exit(0); -- case 'a': /* --startas */ -- startas = optarg; -- break; -+ case 'a': /* --startas : OBSOLETE */ - case 'n': /* --name */ - cmdname = optarg; - break; -@@ -225,11 +223,11 @@ - if (!execname && !pidfile && !userspec) - badusage("need at least one of --exec, --pidfile or --user"); - -- if (!startas) -- startas = execname; -+ if (!cmdname) -+ cmdname = execname; - -- if (start && !startas) -- badusage("--start needs --exec or --startas"); -+ if (start && !cmdname) -+ badusage("--start needs --exec or --cmdname"); - } - - -@@ -262,25 +260,18 @@ - static int - pid_is_cmd(int pid, const char *name) - { -- char buf[32]; -- FILE *f; -- int c; -+ char buf[1024]; -+ int h, c; - -- sprintf(buf, "/proc/%d/stat", pid); -- f = fopen(buf, "r"); -- if (!f) -- return 0; -- while ((c = getc(f)) != EOF && c != '(') -- ; -- if (c != '(') { -- fclose(f); -+ sprintf(buf, "/proc/%d/cmdline", pid); -+ if ( (h=open(buf, O_RDONLY)) < 0 || -+ (c=read( h, buf, 1023)) <= 0 ) { - return 0; - } -- /* this hopefully handles command names containing ')' */ -- while ((c = getc(f)) != EOF && c == *name) -- name++; -- fclose(f); -- return (c == ')' && *name == '\0'); -+ close( h); -+ buf[ c] = '\0'; -+ -+ return ( !strcmp( name, buf) ); - } - - -@@ -354,7 +345,7 @@ - fatal("internal error, please report"); - - if (!found) { -- if (quietmode <= 0) -+ if (quietmode < 0) - printf("no %s found; none killed.\n", what); - exit(exitnodo); - } -@@ -373,6 +364,9 @@ - for (p = killed; p; p = p->next) - printf(" %d", p->pid); - printf(").\n"); -+ } else if (quietmode == 0) { -+ printf(" %s", what); -+ fflush( stdout); - } - } - -@@ -410,21 +404,25 @@ - } - - if (found) { -- if (quietmode <= 0) -+ if (quietmode < 0) - printf("%s already running.\n", execname); - exit(exitnodo); - } - if (testmode) { -- printf("would start %s ", startas); -+ printf("would start %s ", cmdname); - while (argc-- > 0) - printf("%s ", *argv++); - printf(".\n"); - exit(0); - } -- if (quietmode < 0) -- printf("starting %s ...\n", startas); -- *--argv = startas; -- execv(startas, argv); -- fatal("unable to start %s: %s", startas, strerror(errno)); -+ if (quietmode < 0) { -+ printf("starting %s ...\n", cmdname); -+ } else if (quietmode == 0) { -+ printf(" %s", cmdname); -+ fflush( stdout); -+ } -+ *--argv = cmdname; -+ execv(execname, argv); -+ fatal("%s: %s", execname, strerror(errno)); - } - diff --git a/sysvinit-2.88+dsf-blowfish.dif b/sysvinit-2.88+dsf-blowfish.dif deleted file mode 100644 index 1f76694..0000000 --- a/sysvinit-2.88+dsf-blowfish.dif +++ /dev/null @@ -1,70 +0,0 @@ ---- src/consoles.h -+++ src/consoles.h 2011-07-27 11:10:26.620613503 +0000 -@@ -39,6 +39,7 @@ struct console { - int fd, id; - #define CON_SERIAL 0x0001 - #define CON_NOTTY 0x0002 -+#define CON_EIGHTBIT 0x1000 - pid_t pid; - struct chardata cp; - struct termios tio; ---- src/sulogin.c -+++ src/sulogin.c 2011-07-27 13:10:16.791925602 +0000 -@@ -635,6 +635,7 @@ char *getpasswd(struct console *con) - ptr = &pass[0]; - cp->eol = *ptr = '\0'; - -+ con->flags &= ~CON_EIGHTBIT; - eightbit = ((con->flags & CON_SERIAL) == 0 || (tty.c_cflag & (PARODD|PARENB)) == 0); - while (cp->eol == '\0') { - if (read(fd, &c, 1) < 1) { -@@ -697,6 +698,8 @@ char *getpasswd(struct console *con) - goto quit; - } - *ptr++ = ascval; -+ if (((unsigned char)ascval) & 0x80) -+ con->flags |= CON_EIGHTBIT; - break; - } - } -@@ -839,6 +842,30 @@ void usage(void) - fprintf(stderr, "Usage: sulogin [-e] [-p] [-t timeout] [tty device]\n\r"); - } - -+/* -+ * Wrapper for blowfish signedness bug (CVE-2011-2483) -+ */ -+ -+static -+int checkpw(const char *answer, const char *passwd, const struct console *con) -+{ -+ char buf[64]; -+ -+ if (strcmp(crypt(answer, passwd), passwd) == 0) -+ return 1; -+ if (strncmp(passwd, "$2a$", 4) != 0) -+ return 0; -+ if ((con->flags & CON_EIGHTBIT) == 0) -+ return 0; -+ if (strlen(passwd) >= 64) -+ return 0; -+ -+ strncpy(buf, passwd, 64); -+ buf[2] = 'x'; -+ -+ return (strcmp(crypt(answer, buf), buf) == 0); -+} -+ - int main(int argc, char **argv) - { - char *tty = NULL; -@@ -967,8 +994,7 @@ int main(int argc, char **argv) - if ((answer = getpasswd(con)) == NULL) - break; - -- if (passwd[0] == '\0' || -- strcmp(crypt(answer, passwd), passwd) == 0) { -+ if (passwd[0] == '\0' || checkpw(answer, passwd, con)) { - *usemask |= (1<id); - sushell(pwd); - *usemask &= ~(1<id); diff --git a/sysvinit-2.88+dsf-crypt.patch b/sysvinit-2.88+dsf-crypt.patch deleted file mode 100644 index b0f1411..0000000 --- a/sysvinit-2.88+dsf-crypt.patch +++ /dev/null @@ -1,22 +0,0 @@ -Index: src/Makefile -=================================================================== ---- src/Makefile.orig -+++ src/Makefile -@@ -70,7 +70,7 @@ MANDIR = /usr/share/man - ifeq ($(WITH_SELINUX),yes) - SELINUX_DEF = -DWITH_SELINUX - INITLIBS += -lsepol -lselinux -- SULOGINLIBS = -lselinux -+ SULOGINLIBS = -lselinux - else - SELINUX_DEF = - INITLIBS = -@@ -78,7 +78,7 @@ else - endif - - # Additional libs for GNU libc. --ifneq ($(wildcard /usr/lib*/libcrypt.a),) -+ifneq ($(wildcard /usr/lib*/libcrypt.so),) - SULOGINLIBS += -lcrypt - endif - diff --git a/sysvinit-2.88+dsf-env.patch b/sysvinit-2.88+dsf-env.patch deleted file mode 100644 index 782e8dd..0000000 --- a/sysvinit-2.88+dsf-env.patch +++ /dev/null @@ -1,149 +0,0 @@ ---- src/init.c -+++ src/init.c 2012-05-04 13:56:17.470065199 +0200 -@@ -252,7 +252,7 @@ void *imalloc(size_t size) - } - - static --char *istrdup(char *s) -+char *istrdup(const char *s) - { - char *m; - int l; -@@ -884,6 +884,27 @@ void initlog(int loglevel, char *s, ...) - } - } - -+/* -+ * Add or replace specific environment value -+ */ -+int addnewenv(const char *new, char **curr, int n) -+{ -+ size_t nlen = strcspn(new, "="); -+ int i; -+ for (i = 0; i < n; i++) { -+ if (nlen != strcspn(curr[i], "=")) -+ continue; -+ if (strncmp (new, curr[i], nlen) == 0) -+ break; -+ } -+ if (i >= n) -+ curr[n++] = istrdup(new); -+ else { -+ free(curr[i]); -+ curr[i] = istrdup(new); -+ } -+ return n; -+} - - /* - * Build a new environment for execve(). -@@ -892,35 +913,40 @@ char **init_buildenv(int child) - { - char i_lvl[] = "RUNLEVEL=x"; - char i_prev[] = "PREVLEVEL=x"; -- char i_cons[32]; -+ char i_cons[128]; - char i_shell[] = "SHELL=" SHELL; - char **e; - int n, i; - - for (n = 0; environ[n]; n++) - ; -- n += NR_EXTRA_ENV; -+ n += NR_EXTRA_ENV + 1; /* Also room for last NULL */ - if (child) - n += 8; -- e = calloc(n, sizeof(char *)); -+ -+ while ((e = (char**)calloc(n, sizeof(char *))) == NULL) { -+ initlog(L_VB, "out of memory"); -+ do_sleep(5); -+ } - - for (n = 0; environ[n]; n++) - e[n] = istrdup(environ[n]); - - for (i = 0; i < NR_EXTRA_ENV; i++) { -- if (extra_env[i]) -- e[n++] = istrdup(extra_env[i]); -+ if (extra_env[i] == NULL || *extra_env[i] == '\0') -+ continue; -+ n = addnewenv(extra_env[i], e, n); - } - - if (child) { - snprintf(i_cons, sizeof(i_cons), "CONSOLE=%s", console_dev); - i_lvl[9] = thislevel; - i_prev[10] = prevlevel; -- e[n++] = istrdup(i_shell); -- e[n++] = istrdup(i_lvl); -- e[n++] = istrdup(i_prev); -- e[n++] = istrdup(i_cons); -- e[n++] = istrdup(E_VERSION); -+ n = addnewenv(i_shell, e, n); -+ n = addnewenv(i_lvl, e, n); -+ n = addnewenv(i_prev, e, n); -+ n = addnewenv(i_cons, e, n); -+ n = addnewenv(E_VERSION, e, n); - } - - e[n++] = NULL; -@@ -2146,41 +2172,46 @@ void fifo_new_level(int level) - static - void initcmd_setenv(char *data, int size) - { -- char *env, *p, *e, *eq; -- int i, sz; -+ char *env, *p, *e; -+ size_t sz; -+ int i, eq; - - e = data + size; - - while (*data && data < e) { -- eq = NULL; - for (p = data; *p && p < e; p++) -- if (*p == '=') eq = p; -+ ; - if (*p) break; - env = data; - data = ++p; - -- sz = eq ? (eq - env) : (p - env); -- -- /*initlog(L_SY, "init_setenv: %s, %s, %d", env, eq, sz);*/ -- - /* - * We only allow INIT_* to be set. - */ - if (strncmp(env, "INIT_", 5) != 0) - continue; - -+ sz = strcspn(env, "="); -+ eq = (env[sz] == '='); -+ -+ /*initlog(L_SY, "init_setenv: %s, %d, %d", env, eq, sz);*/ -+ - /* Free existing vars. */ - for (i = 0; i < NR_EXTRA_ENV; i++) { -- if (extra_env[i] == NULL) continue; -- if (!strncmp(extra_env[i], env, sz) && -- extra_env[i][sz] == '=') { -+ if (extra_env[i] == NULL) -+ continue; -+ if (sz != strcspn(extra_env[i], "=")) -+ continue; -+ if (strncmp(extra_env[i], env, sz) == 0) { - free(extra_env[i]); - extra_env[i] = NULL; - } - } - -+ if (eq == 0) -+ continue; -+ - /* Set new vars if needed. */ -- if (eq == NULL) continue; - for (i = 0; i < NR_EXTRA_ENV; i++) { - if (extra_env[i] == NULL) { - extra_env[i] = istrdup(env); diff --git a/sysvinit-2.88+dsf-run.diff b/sysvinit-2.88+dsf-run.diff deleted file mode 100644 index 3dc4df8..0000000 --- a/sysvinit-2.88+dsf-run.diff +++ /dev/null @@ -1,23 +0,0 @@ -use /run/utmp -Index: src/paths.h -=================================================================== ---- src/paths.h.orig -+++ src/paths.h -@@ -48,3 +48,5 @@ - #define REBOOTSCRIPT2 "/etc/rc.d/rc.6" /* Ditto. */ - #endif - -+#undef UTMP_FILE -+#define UTMP_FILE "/run/utmp" -Index: src/init.c -=================================================================== ---- src/init.c.orig -+++ src/init.c -@@ -2634,6 +2634,7 @@ void init_main(void) - */ - if ((fd = open(UTMP_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0644)) >= 0) - close(fd); -+ utmpname(UTMP_FILE); - - /* - * Say hello to the world diff --git a/sysvinit-2.88+dsf-sulogin.diff b/sysvinit-2.88+dsf-sulogin.diff index 4d9f0a3..27b02a2 100644 --- a/sysvinit-2.88+dsf-sulogin.diff +++ b/sysvinit-2.88+dsf-sulogin.diff @@ -16,29 +16,3 @@ Index: src/killall5.c if (buf[0] == '\0') { nsyslog(LOG_ERR, "can't read from %s\n", path); -Index: src/shutdown.c -=================================================================== ---- src/shutdown.c (revision 116) -+++ src/shutdown.c (working copy) -@@ -76,7 +76,7 @@ - - char *clean_env[] = { - "HOME=/", -- "PATH=/bin:/usr/bin:/sbin:/usr/sbin", -+ "PATH=" PATH_DEFAULT, - "TERM=dumb", - "SHELL=/bin/sh", - NULL, -Index: src/sulogin.c -=================================================================== ---- src/sulogin.c (revision 116) -+++ src/sulogin.c (working copy) -@@ -987,7 +998,7 @@ - } - if (alarm_rised) { - tcfinal(con); -- printf("Timed out.\n\r"); -+ fprintf(stderr, "Timed out.\n\r"); - } - /* - * User may pressed Control-D. diff --git a/sysvinit-2.88+dsf-xen.patch b/sysvinit-2.88+dsf-xen.patch deleted file mode 100644 index 2e67275..0000000 --- a/sysvinit-2.88+dsf-xen.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- src/consoles.c -+++ src/consoles.c 2014-02-07 15:33:15.786235493 +0000 -@@ -313,16 +313,19 @@ console: - */ - if ((fc = fopen("/proc/consoles", "re"))) { - char fbuf[16]; -- int maj, min; -+ int maj, min, matches; - DIR *dir; - dir = opendir("/dev"); - if (!dir) { - fclose(fc); - goto fallback; - } -- while ((fscanf(fc, "%*s %*s (%[^)]) %d:%d", &fbuf[0], &maj, &min) == 3)) { -+ while ((matches = fscanf(fc, "%*s %*s (%[^)]) %d:%d", &fbuf[0], &maj, &min)) >= 1) { - char * name; - -+ if (matches != 3) -+ continue; -+ - if (!strchr(fbuf, 'E')) - continue; - comparedev = makedev(maj, min); diff --git a/sysvinit-2.88+dsf.dif b/sysvinit-2.88+dsf.dif index 888182c..8815ce8 100644 --- a/sysvinit-2.88+dsf.dif +++ b/sysvinit-2.88+dsf.dif @@ -1,6 +1,6 @@ ---- src/Makefile -+++ src/Makefile 2010-03-23 15:11:12.000000000 +0000 -@@ -9,16 +9,16 @@ +--- src/Makefile.orig 2015-12-04 14:01:44.134651379 +0100 ++++ src/Makefile 2015-12-04 14:01:50.735728998 +0100 +@@ -9,19 +9,19 @@ # CPPFLAGS = -DUSE_PAM @@ -11,19 +11,41 @@ # For some known distributions we do not build all programs, otherwise we do. BIN = - SBIN = init halt shutdown runlevel killall5 fstab-decode +-SBIN = init halt shutdown runlevel killall5 fstab-decode -USRBIN = last mesg ++SBIN = killall5 fstab-decode +USRBIN = -MAN1 = last.1 lastb.1 mesg.1 +-MAN5 = initscript.5 inittab.5 +-MAN8 = halt.8 init.8 killall5.8 pidof.8 poweroff.8 reboot.8 runlevel.8 +-MAN8 += shutdown.8 telinit.8 fstab-decode.8 +MAN1 = - MAN5 = initscript.5 inittab.5 - MAN8 = halt.8 init.8 killall5.8 pidof.8 poweroff.8 reboot.8 runlevel.8 - MAN8 += shutdown.8 telinit.8 fstab-decode.8 -@@ -176,10 +176,8 @@ endif - ln -sf halt $(ROOT)/sbin/reboot - ln -sf halt $(ROOT)/sbin/poweroff - ln -sf init $(ROOT)/sbin/telinit ++MAN5 = ++MAN8 = killall5.8 pidof.8 ++MAN8 += fstab-decode.8 + + ifeq ($(DISTRO),) + BIN += mountpoint +@@ -46,11 +46,6 @@ + + ifeq ($(DISTRO),SuSE) + CPPFLAGS+= -DUSE_SYSFS -DSANE_TIO -DSIGINT_ONLYONCE -DUSE_ONELINE +-BIN += mountpoint +-SBIN += sulogin +-USRBIN += utmpdump +-MAN1 += utmpdump.1 mountpoint.1 +-MAN8 += sulogin.8 + endif + + ID = $(shell id -u) +@@ -173,13 +168,8 @@ + endif + # $(INSTALL_DIR) $(ROOT)/etc/ + # $(INSTALL_EXEC) initscript.sample $(ROOT)/etc/ +- ln -sf halt $(ROOT)/sbin/reboot +- ln -sf halt $(ROOT)/sbin/poweroff +- ln -sf init $(ROOT)/sbin/telinit - ln -sf /sbin/killall5 $(ROOT)/bin/pidof - if [ ! -f $(ROOT)/usr/bin/lastb ]; then \ - ln -sf last $(ROOT)/usr/bin/lastb; \ @@ -33,23 +55,3 @@ $(INSTALL_DIR) $(ROOT)/usr/include/ $(INSTALL_DATA) initreq.h $(ROOT)/usr/include/ $(INSTALL_DIR) $(ROOT)$(MANDIR)/man1/ ---- src/bootlogd.c -+++ src/bootlogd.c 2011-03-15 14:58:54.000000000 +0000 -@@ -241,7 +241,7 @@ - int consolename(char *res, size_t rlen) - { - #ifdef TIOCGDEV -- unsigned int kdev; -+ kdev_t kdev; - #endif - struct stat st; - int n; -@@ -559,7 +559,7 @@ - } - - (void)ioctl(0, TIOCCONS, NULL); --#if 1 -+#if 0 - /* 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); diff --git a/sysvinit-2.88dsf-multiple-sulogin.patch b/sysvinit-2.88dsf-multiple-sulogin.patch deleted file mode 100644 index edb7dc4..0000000 --- a/sysvinit-2.88dsf-multiple-sulogin.patch +++ /dev/null @@ -1,1500 +0,0 @@ ---- src/sulogin.c -+++ src/sulogin.c 2011-07-26 14:01:55.543926269 +0200 -@@ -28,8 +28,10 @@ - * - */ - -+#include - #include - #include -+#include - #include - #include - #include -@@ -44,13 +46,34 @@ - #include - #if defined(__GLIBC__) - # include -+# define dovoid(f) if ((f)){} - #endif -+#ifdef __linux__ -+# include -+# include -+# include -+# include -+# include -+# ifndef TMPFS_MAGIC -+# define TMPFS_MAGIC 0x01021994 -+# endif -+# ifndef MNT_DETACH -+# define MNT_DETACH 2 -+# endif -+#endif -+ -+#define BS CTRL('h') -+#define NL CTRL('j') -+#define CR CTRL('m') - - #ifdef WITH_SELINUX - # include - # include - #endif - -+#include "consoles.h" -+#define CONMAX 16 -+ - #define CHECK_DES 1 - #define CHECK_MD5 1 - -@@ -63,102 +86,245 @@ char *Version = "@(#)sulogin 2.85-3 23-A - - static int timeout; - static int profile; -+static volatile uint32_t openfd; /* Remember higher file descriptors */ -+static volatile uint32_t *usemask; - --static void (*saved_sigint) = SIG_DFL; --static void (*saved_sigtstp) = SIG_DFL; --static void (*saved_sigquit) = SIG_DFL; -+static sighandler_t saved_sigint = SIG_DFL; -+static sighandler_t saved_sigtstp = SIG_DFL; -+static sighandler_t saved_sigquit = SIG_DFL; -+static sighandler_t saved_sighup = SIG_DFL; - - static volatile sig_atomic_t alarm_rised; -+static volatile sig_atomic_t sigchild; - - #ifndef IUCLC - # define IUCLC 0 - #endif - --#if defined(SANE_TIO) && (SANE_TIO == 1) - /* - * Fix the tty modes and set reasonable defaults. -- * (I'm not sure if this is needed under Linux, but..) - */ - static --void fixtty(void) -+void tcinit(struct console *con) - { -- struct termios tty; -- int serial; -+ int serial, flags; -+ struct termios *tio = &con->tio; -+ int fd = con->fd; - -- /* Skip serial console */ -- if (ioctl (0, TIOCMGET, (char*)&serial) == 0) -- goto out; - /* Expected error */ - serial = errno = 0; - -- tcgetattr(0, &tty); -+ /* Get line attributes */ -+ if (tcgetattr(fd, tio) < 0) { -+ con->flags |= CON_NOTTY; -+ return; -+ } -+ -+ /* Handle serial lines here */ -+ if (ioctl (fd, TIOCMGET, (char*)&serial) == 0) { -+ speed_t ispeed, ospeed; -+ struct winsize ws; -+ -+ /* this is a modem line */ -+ con->flags |= CON_SERIAL; -+ -+ /* Flush input and output queues on modem lines */ -+ (void) tcflush(fd, TCIOFLUSH); -+ -+ ispeed = cfgetispeed(tio); -+ ospeed = cfgetospeed(tio); -+ -+ if (!ispeed) ispeed = TTYDEF_SPEED; -+ if (!ospeed) ospeed = TTYDEF_SPEED; -+ -+ tio->c_iflag = tio->c_lflag = tio->c_oflag = 0; -+ tio->c_cflag = CREAD | CS8 | HUPCL | (tio->c_cflag & CLOCAL); -+ -+ cfsetispeed(tio, ispeed); -+ cfsetospeed(tio, ospeed); -+ -+ tio->c_line = 0; -+ tio->c_cc[VTIME] = 0; -+ tio->c_cc[VMIN] = 1; -+ -+ if (ioctl(fd, TIOCGWINSZ, &ws) == 0) { -+ int set = 0; -+ if (ws.ws_row == 0) { -+ ws.ws_row = 24; -+ set++; -+ } -+ if (ws.ws_col == 0) { -+ ws.ws_col = 80; -+ set++; -+ } -+ (void)ioctl(fd, TIOCSWINSZ, &ws); -+ } - -- /* Use defaults of for base settings */ -- tty.c_iflag |= TTYDEF_IFLAG; -- tty.c_oflag |= TTYDEF_OFLAG; -- tty.c_lflag |= TTYDEF_LFLAG; -- tty.c_cflag |= (TTYDEF_SPEED | TTYDEF_CFLAG); -+ goto setattr; -+ } -+#if defined(SANE_TIO) && (SANE_TIO == 1) -+ /* -+ * Use defaults of for base settings -+ * of a local terminal line like a virtual console. -+ */ -+ tio->c_iflag |= TTYDEF_IFLAG; -+ tio->c_oflag |= TTYDEF_OFLAG; -+ tio->c_lflag |= TTYDEF_LFLAG; -+# ifdef CBAUD -+ tio->c_lflag &= ~CBAUD; -+# endif -+ tio->c_cflag |= (B38400 | TTYDEF_CFLAG); - - /* Sane setting, allow eight bit characters, no carriage return delay - * the same result as `stty sane cr0 pass8' - */ -- tty.c_iflag |= (BRKINT | ICRNL | IMAXBEL); -- tty.c_iflag &= ~(IGNBRK | INLCR | IGNCR | IXOFF | IUCLC | IXANY | ISTRIP); -- tty.c_oflag |= (OPOST | ONLCR | NL0 | CR0 | TAB0 | BS0 | VT0 | FF0); -- tty.c_oflag &= ~(OLCUC | OCRNL | ONOCR | ONLRET | OFILL | OFDEL |\ -+ tio->c_iflag |= (BRKINT | ICRNL | IMAXBEL); -+ tio->c_iflag &= ~(IGNBRK | INLCR | IGNCR | IXOFF | IUCLC | IXANY | INPCK | ISTRIP); -+ tio->c_oflag |= (OPOST | ONLCR | NL0 | CR0 | TAB0 | BS0 | VT0 | FF0); -+ tio->c_oflag &= ~(OLCUC | OCRNL | ONOCR | ONLRET | OFILL | OFDEL |\ - NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY); -- tty.c_lflag |= (ISIG | ICANON | IEXTEN | ECHO|ECHOE|ECHOK|ECHOCTL|ECHOKE); -- tty.c_lflag &= ~(ECHONL | NOFLSH | XCASE | TOSTOP | ECHOPRT); -- tty.c_cflag |= (CREAD | CS8 | B9600); -- tty.c_cflag &= ~(PARENB); -+ tio->c_lflag |= (ISIG | ICANON | IEXTEN | ECHO|ECHOE|ECHOK|ECHOKE); -+ tio->c_lflag &= ~(ECHONL|ECHOCTL|ECHOPRT | NOFLSH | XCASE | TOSTOP); -+ tio->c_cflag |= (CREAD | CS8 | HUPCL); -+ tio->c_cflag &= ~(PARODD | PARENB); - -- /* VTIME and VMIN can overlap with VEOF and VEOL since they are -+ /* -+ * VTIME and VMIN can overlap with VEOF and VEOL since they are - * only used for non-canonical mode. We just set the at the - * beginning, so nothing bad should happen. - */ -- tty.c_cc[VTIME] = 0; -- tty.c_cc[VMIN] = 1; -- tty.c_cc[VINTR] = CINTR; -- tty.c_cc[VQUIT] = CQUIT; -- tty.c_cc[VERASE] = CERASE; /* ASCII DEL (0177) */ -- tty.c_cc[VKILL] = CKILL; -- tty.c_cc[VEOF] = CEOF; -- tty.c_cc[VSWTC] = _POSIX_VDISABLE; -- tty.c_cc[VSTART] = CSTART; -- tty.c_cc[VSTOP] = CSTOP; -- tty.c_cc[VSUSP] = CSUSP; -- tty.c_cc[VEOL] = _POSIX_VDISABLE; -- tty.c_cc[VREPRINT] = CREPRINT; -- tty.c_cc[VDISCARD] = CDISCARD; -- tty.c_cc[VWERASE] = CWERASE; -- tty.c_cc[VLNEXT] = CLNEXT; -- tty.c_cc[VEOL2] = _POSIX_VDISABLE; -- -- tcsetattr(0, TCSANOW, &tty); --out: -- return; -+ tio->c_cc[VTIME] = 0; -+ tio->c_cc[VMIN] = CMIN; -+ tio->c_cc[VINTR] = CINTR; -+ tio->c_cc[VQUIT] = CQUIT; -+ tio->c_cc[VERASE] = CERASE; /* ASCII DEL (0177) */ -+ tio->c_cc[VKILL] = CKILL; -+ tio->c_cc[VEOF] = CEOF; -+# ifdef VSWTC -+ tio->c_cc[VSWTC] = _POSIX_VDISABLE; -+# else -+ tio->c_cc[VSWTCH] = _POSIX_VDISABLE; -+# endif -+ tio->c_cc[VSTART] = CSTART; -+ tio->c_cc[VSTOP] = CSTOP; -+ tio->c_cc[VSUSP] = CSUSP; -+ tio->c_cc[VEOL] = _POSIX_VDISABLE; -+ tio->c_cc[VREPRINT] = CREPRINT; -+ tio->c_cc[VDISCARD] = CDISCARD; -+ tio->c_cc[VWERASE] = CWERASE; -+ tio->c_cc[VLNEXT] = CLNEXT; -+ tio->c_cc[VEOL2] = _POSIX_VDISABLE; -+#endif -+setattr: -+ /* Set line attributes */ -+ tcsetattr(fd, TCSANOW, tio); -+ -+ /* Enable blocking mode for read and write */ -+ if ((flags = fcntl(fd, F_GETFL, 0)) != -1) -+ (void)fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); - } -+ -+ -+/* -+ * Finalize the tty modes on modem lines. -+ */ -+static -+void tcfinal(struct console *con) -+{ -+ int serial; -+ struct termios *tio = &con->tio; -+ int fd = con->fd; -+ -+ /* Expected error */ -+ serial = errno = 0; -+ -+ if ((con->flags & CON_SERIAL) == 0) { -+#ifdef __linux__ -+ setenv("TERM", "linux", 1); -+#else -+ setenv("TERM", "vt100", 1); - #endif -+ return; -+ } -+ if (con->flags & CON_NOTTY) -+ return; -+ setenv("TERM", "vt100", 1); -+ -+ tio->c_iflag |= (IXON | IXOFF); -+ tio->c_lflag |= (ICANON | ISIG | ECHO|ECHOE|ECHOK|ECHOKE); -+ tio->c_oflag |= OPOST; -+ -+ tio->c_cc[VINTR] = CINTR; -+ tio->c_cc[VQUIT] = CQUIT; -+ tio->c_cc[VERASE] = con->cp.erase; -+ tio->c_cc[VKILL] = con->cp.kill; -+ tio->c_cc[VEOF] = CEOF; -+#ifdef VSWTC -+ tio->c_cc[VSWTC] = _POSIX_VDISABLE; -+#else -+ tio->c_cc[VSWTCH] = _POSIX_VDISABLE; -+#endif -+ tio->c_cc[VSTART] = CSTART; -+ tio->c_cc[VSTOP] = CSTOP; -+ tio->c_cc[VSUSP] = CSUSP; -+ tio->c_cc[VEOL] = _POSIX_VDISABLE; -+ -+ if (con->cp.eol == CR) { -+ tio->c_iflag |= ICRNL; -+ tio->c_iflag &= ~(INLCR|IGNCR); -+ tio->c_oflag |= ONLCR; -+ tio->c_oflag &= ~(OCRNL|ONLRET); -+ } -+ -+ switch (con->cp.parity) { -+ default: -+ case 0: -+ tio->c_cflag &= ~(PARODD | PARENB); -+ tio->c_iflag &= ~(INPCK | ISTRIP); -+ break; -+ case 1: /* odd parity */ -+ tio->c_cflag |= PARODD; -+ /* fall through */ -+ case 2: /* even parity */ -+ tio->c_cflag |= PARENB; -+ tio->c_iflag |= (INPCK | ISTRIP); -+ /* fall through */ -+ case (1 | 2): /* no parity bit */ -+ tio->c_cflag &= ~CSIZE; -+ tio->c_cflag |= CS7; -+ break; -+ } - -+ /* Set line attributes */ -+ (void)tcsetattr(fd, TCSANOW, tio); -+} - - /* - * Called at timeout. - */ - static - # ifdef __GNUC__ -+__attribute__((__noinline__)) - void alrm_handler(int sig __attribute__((unused))) - # else - void alrm_handler(int sig) - # endif - { -- /* Timeout expired */ - alarm_rised++; -+} - -- signal(SIGINT, saved_sigint); -- signal(SIGTSTP, saved_sigtstp); -- signal(SIGQUIT, saved_sigquit); -- -- /* Never use exit(3) or stdio(3) within a signal handler */ -+/* -+ * Called at timeout. -+ */ -+static -+# ifdef __GNUC__ -+__attribute__((__noinline__)) -+void chld_handler(int sig __attribute__((unused))) -+# else -+void chld_handler(int sig) -+# endif -+{ -+ sigchild++; - } - - /* -@@ -305,7 +471,7 @@ struct passwd *getrootpwent(int try_manu - * or not found, return. - */ - if (p == NULL) { -- fprintf(stderr, "%s: no entry for root\n", F_PASSWD); -+ fprintf(stderr, "sulogin: %s: no entry for root\n\r", F_PASSWD); - return &pwd; - } - if (valid(pwd.pw_passwd)) return &pwd; -@@ -316,7 +482,7 @@ struct passwd *getrootpwent(int try_manu - */ - strcpy(pwd.pw_passwd, ""); - if ((fp = fopen(F_SHADOW, "r")) == NULL) { -- fprintf(stderr, "%s: root password garbled\n", F_PASSWD); -+ fprintf(stderr, "sulogin: %s: root password garbled\n\r", F_PASSWD); - return &pwd; - } - while((p = fgets(sline, 256, fp)) != NULL) { -@@ -333,67 +499,215 @@ struct passwd *getrootpwent(int try_manu - * NULL it, and return. - */ - if (p == NULL) { -- fprintf(stderr, "%s: no entry for root\n", F_SHADOW); -+ fprintf(stderr, "sulogin: %s: no entry for root\n\r", F_SHADOW); - strcpy(pwd.pw_passwd, ""); - } - if (!valid(pwd.pw_passwd)) { -- fprintf(stderr, "%s: root password garbled\n", F_SHADOW); -+ fprintf(stderr, "sulogin: %s: root password garbled\n\r", F_SHADOW); - strcpy(pwd.pw_passwd, ""); } - return &pwd; - } - - /* -- * Ask for the password. Note that there is no -- * default timeout as we normally skip this during boot. -+ * Ask by prompt for the password. - */ - static --char *getpasswd(char *crypted) -+void doprompt(const char *crypted, struct console *con) - { -- struct sigaction sa; -- struct termios old, tty; -- static char pass[128]; -- char *ret = pass; -- int i; -+ struct termios tty; -+ -+ if (con->flags & CON_SERIAL) { -+ tty = con->tio; -+ /* -+ * For prompting: map NL in output to CR-NL -+ * otherwise we may see stairs in the output. -+ */ -+ tty.c_oflag |= (ONLCR | OPOST); -+ (void) tcsetattr(con->fd, TCSADRAIN, &tty); -+ } -+ if (con->file == (FILE*)0) { -+ if ((con->file = fdopen(con->fd, "r+")) == (FILE*)0) -+ goto err; -+ } - #if defined(USE_ONELINE) - if (crypted[0]) -- printf("Give root password for login: "); -+ fprintf(con->file, "Give root password for login: "); - else -- printf("Press enter for login: "); -+ fprintf(con->file, "Press enter for login: "); - #else - if (crypted[0]) -- printf("Give root password for maintenance\n"); -+ fprintf(con->file, "Give root password for maintenance\n\r"); - else -- printf("Press enter for maintenance"); -- printf("(or type Control-D to continue): "); -+ fprintf(con->file, "Press enter for maintenance"); -+ fprintf(con->file, "(or type Control-D to continue): "); - #endif -- fflush(stdout); -+ fflush(con->file); -+err: -+ if (con->flags & CON_SERIAL) -+ (void) tcsetattr(con->fd, TCSADRAIN, &con->tio); -+} - -- tcgetattr(0, &old); -- tcgetattr(0, &tty); -- tty.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY); -- tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP); -- tcsetattr(0, TCSANOW, &tty); -+/* -+ * Make sure to have an own session and controlling terminal -+ */ -+static -+void setup(struct console *con) -+{ -+ pid_t pid, pgrp, ppgrp, ttypgrp; -+ int fd; -+ -+ if (con->flags & CON_NOTTY) -+ return; -+ fd = con->fd; -+ -+ /* -+ * Only go through this trouble if the new -+ * tty doesn't fall in this process group. -+ */ -+ pid = getpid(); -+ pgrp = getpgid(0); -+ ppgrp = getpgid(getppid()); -+ ttypgrp = tcgetpgrp(fd); -+ -+ if (pgrp != ttypgrp && ppgrp != ttypgrp) { -+ if (pid != getsid(0)) { -+ if (pid == getpgid(0)) -+ setpgid(0, getpgid(getppid())); -+ setsid(); -+ } - -- pass[sizeof(pass) - 1] = 0; -+ signal(SIGHUP, SIG_IGN); -+ if (ttypgrp > 0) -+ ioctl(0, TIOCNOTTY, (char *)1); -+ signal(SIGHUP, saved_sighup); -+ if (fd > 0) close(0); -+ if (fd > 1) close(1); -+ if (fd > 2) close(2); -+ -+ ioctl(fd, TIOCSCTTY, (char *)1); -+ tcsetpgrp(fd, ppgrp); -+ } -+ dup2(fd, 0); -+ dup2(fd, 1); -+ dup2(fd, 2); -+ con->fd = 0; -+ -+ for (fd = 3; fd < 32; fd++) { -+ if (openfd & (1<flags & CON_NOTTY) -+ goto out; -+ fd = con->fd; -+ cp = &con->cp; -+ -+ tty = con->tio; -+ tty.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY); -+ tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP|ISIG); -+ tc = (tcsetattr(fd, TCSAFLUSH, &tty) == 0); - - sa.sa_handler = alrm_handler; - sa.sa_flags = 0; - sigaction(SIGALRM, &sa, NULL); - if (timeout) alarm(timeout); - -- if (read(0, pass, sizeof(pass) - 1) <= 0) -- ret = NULL; -- else { -- for(i = 0; i < (int)sizeof(pass) && pass[i]; i++) -- if (pass[i] == '\r' || pass[i] == '\n') { -- pass[i] = 0; -+ ptr = &pass[0]; -+ cp->eol = *ptr = '\0'; -+ -+ eightbit = ((con->flags & CON_SERIAL) == 0 || (tty.c_cflag & (PARODD|PARENB)) == 0); -+ while (cp->eol == '\0') { -+ if (read(fd, &c, 1) < 1) { -+ if (errno == EINTR || errno == EAGAIN) { -+ usleep(1000); -+ continue; -+ } -+ ret = (char*)0; -+ switch (errno) { -+ case 0: -+ case EIO: -+ case ESRCH: -+ case EINVAL: -+ case ENOENT: - break; -+ default: -+ fprintf(stderr, "sulogin: read(%s): %m\n\r", con->tty); -+ break; -+ } -+ goto quit; -+ } -+ -+ if (eightbit) -+ ascval = c; -+ else if (c != (ascval = (c & 0177))) { -+ uint32_t bits, mask; -+ for (bits = 1, mask = 1; mask & 0177; mask <<= 1) { -+ if (mask & ascval) -+ bits++; -+ } -+ cp->parity |= ((bits & 1) ? 1 : 2); -+ } -+ -+ switch (ascval) { -+ case 0: -+ *ptr = '\0'; -+ goto quit; -+ case CR: -+ case NL: -+ *ptr = '\0'; -+ cp->eol = ascval; -+ break; -+ case BS: -+ case CERASE: -+ cp->erase = ascval; -+ if (ptr > &pass[0]) -+ ptr--; -+ break; -+ case CKILL: -+ cp->kill = ascval; -+ while (ptr > &pass[0]) -+ ptr--; -+ break; -+ case CEOF: -+ goto quit; -+ default: -+ if ((size_t)(ptr - &pass[0]) >= (sizeof(pass) -1 )) { -+ fprintf(stderr, "sulogin: input overrun at %s\n\r", con->tty); -+ ret = (char*)0; -+ goto quit; - } -+ *ptr++ = ascval; -+ break; -+ } - } -+quit: - alarm(0); -- tcsetattr(0, TCSANOW, &old); -- printf("\n"); -- -+ if (tc) -+ (void)tcsetattr(fd, TCSAFLUSH, &con->tio); -+ if (ret && *ret != '\0') -+ tcfinal(con); -+ printf("\r\n"); -+out: - return ret; - } - -@@ -411,7 +725,10 @@ void sushell(struct passwd *pwd) - /* - * Set directory and shell. - */ -- (void)chdir(pwd->pw_dir); -+ if (chdir(pwd->pw_dir) < 0) { -+ if (chdir("/") < 0) -+ fprintf(stderr, "sulogin: change of working directory failed: %m\n\r"); -+ } - if ((p = getenv("SUSHELL")) != NULL) - sushell = p; - else if ((p = getenv("sushell")) != NULL) -@@ -431,7 +748,8 @@ void sushell(struct passwd *pwd) - /* - * Set some important environment variables. - */ -- getcwd(home, sizeof(home)); -+ if (getcwd(home, sizeof(home)) == (char*)0) -+ strcpy(home, "/"); - setenv("HOME", home, 1); - setenv("LOGNAME", "root", 1); - setenv("USER", "root", 1); -@@ -445,17 +763,18 @@ void sushell(struct passwd *pwd) - signal(SIGINT, saved_sigint); - signal(SIGTSTP, saved_sigtstp); - signal(SIGQUIT, saved_sigquit); -+ signal(SIGHUP, SIG_DFL); - #ifdef WITH_SELINUX - if (is_selinux_enabled() > 0) { -- security_context_t scon=NULL; -- char *seuser=NULL; -- char *level=NULL; -- if (getseuserbyname("root", &seuser, &level) == 0) -- if (get_default_context_with_level(seuser, level, 0, &scon) == 0) { -- if (setexeccon(scon) != 0) -- fprintf(stderr, "setexeccon faile\n"); -- freecon(scon); -- } -+ security_context_t scon=NULL; -+ char *seuser=NULL; -+ char *level=NULL; -+ if (getseuserbyname("root", &seuser, &level) == 0) -+ if (get_default_context_with_level(seuser, level, 0, &scon) == 0) { -+ if (setexeccon(scon) != 0) -+ fprintf(stderr, "sulogin: setexeccon failed\n\r"); -+ freecon(scon); -+ } - free(seuser); - free(level); - } -@@ -474,23 +793,72 @@ void sushell(struct passwd *pwd) - perror(STATICSH); - } - -+#ifdef __linux__ -+/* -+ * Make C library standard calls like ttyname(3) work. -+ */ -+static uint32_t mounts; -+#define MNT_PROCFS 0x0001 -+#define MNT_DEVTMPFS 0x0002 -+ -+static __attribute__((__noinline__)) -+void putmounts(void) -+{ -+ if (mounts & MNT_DEVTMPFS) -+ umount2("/dev", MNT_DETACH); -+ if (mounts & MNT_PROCFS) -+ umount2("/proc", MNT_DETACH); -+} -+ -+static __attribute__((__constructor__)) -+void getmounts(void) -+{ -+ struct statfs st; -+ if (statfs("/proc", &st) == 0 && st.f_type != PROC_SUPER_MAGIC) { -+ if (mount("proc", "/proc", "proc", MS_RELATIME, NULL) == 0) -+ mounts |= MNT_PROCFS; -+ } -+ if (statfs("/dev", &st) == 0 && st.f_type != TMPFS_MAGIC) { -+ if (mount("devtmpfs", "/dev", "devtmpfs", MS_RELATIME, "mode=0755,nr_inodes=0") == 0) { -+ mounts |= MNT_DEVTMPFS; -+ (void)mknod("/dev/console", S_IFCHR|S_IRUSR|S_IWUSR, makedev(TTYAUX_MAJOR, 1)); -+ if (symlink("/proc/self/fd", "/dev/fd") == 0) { -+ dovoid(symlink("fd/0", "/dev/stdin")); -+ dovoid(symlink("fd/1", "/dev/stdout")); -+ dovoid(symlink("fd/2", "/dev/stderr")); -+ } -+ } -+ } -+ if (mounts) atexit(putmounts); -+} -+#endif -+ - static - void usage(void) - { -- fprintf(stderr, "Usage: sulogin [-e] [-p] [-t timeout] [tty device]\n"); -+ fprintf(stderr, "Usage: sulogin [-e] [-p] [-t timeout] [tty device]\n\r"); - } - - int main(int argc, char **argv) - { - char *tty = NULL; -- char *p; - struct passwd *pwd; -- int c, fd = -1; -+ int c, status = 0; -+ int reconnect = 0; - int opt_e = 0; -- pid_t pid, pgrp, ppgrp, ttypgrp; -+ struct console *con; -+ pid_t pid; -+ -+ /* -+ * We are init. We hence need to set uo a session. -+ */ -+ if ((pid = getpid()) == 1) { -+ setsid(); -+ (void)ioctl(0, TIOCSCTTY, (char *)1); -+ } - - /* -- * See if we have a timeout flag. -+ * See if we have a timeout flag. - */ - opterr = 0; - while((c = getopt(argc, argv, "ept:")) != EOF) switch(c) { -@@ -510,115 +878,151 @@ int main(int argc, char **argv) - } - - if (geteuid() != 0) { -- fprintf(stderr, "sulogin: only root can run sulogin.\n"); -+ fprintf(stderr, "sulogin: only root can run sulogin.\n\r"); - exit(1); - } - -- /* -- * See if we need to open an other tty device. -- */ - saved_sigint = signal(SIGINT, SIG_IGN); - saved_sigquit = signal(SIGQUIT, SIG_IGN); - saved_sigtstp = signal(SIGTSTP, SIG_IGN); -- if (optind < argc) tty = argv[optind]; -- -- if (tty || (tty = getenv("CONSOLE"))) { -+ saved_sighup = signal(SIGHUP, SIG_IGN); - -- if ((fd = open(tty, O_RDWR)) < 0) { -- perror(tty); -- fd = dup(0); -- } -- -- if (!isatty(fd)) { -- fprintf(stderr, "%s: not a tty\n", tty); -- close(fd); -- } else { -+ /* -+ * See if we need to open an other tty device. -+ */ -+ if (optind < argc) -+ tty = argv[optind]; -+ if (!tty || *tty == '\0') -+ tty = getenv("CONSOLE"); - -- /* -- * Only go through this trouble if the new -- * tty doesn't fall in this process group. -- */ -- pid = getpid(); -- pgrp = getpgid(0); -- ppgrp = getpgid(getppid()); -- ttypgrp = tcgetpgrp(fd); -- -- if (pgrp != ttypgrp && ppgrp != ttypgrp) { -- if (pid != getsid(0)) { -- if (pid == getpgid(0)) -- setpgid(0, getpgid(getppid())); -- setsid(); -- } -+ /* -+ * Detect possible consoles, use stdin as fallback. -+ * If an optional tty is given, reconnect it to stdin. -+ */ -+ reconnect = detect_consoles(tty, 0); - -- signal(SIGHUP, SIG_IGN); -- if (ttypgrp > 0) -- ioctl(0, TIOCNOTTY, (char *)1); -- signal(SIGHUP, SIG_DFL); -- close(0); -- close(1); -- close(2); -- if (fd > 2) -- close(fd); -- if ((fd = open(tty, O_RDWR|O_NOCTTY)) < 0) { -- perror(tty); -- } else { -- ioctl(0, TIOCSCTTY, (char *)1); -- tcsetpgrp(fd, ppgrp); -- dup2(fd, 0); -- dup2(fd, 1); -- dup2(fd, 2); -- if (fd > 2) -- close(fd); -- } -- } else -- if (fd > 2) -- close(fd); -- } -- } else if (getpid() == 1) { -- /* We are init. We hence need to set a session anyway */ -- setsid(); -- if (ioctl(0, TIOCSCTTY, (char *)1)) -- perror("ioctl(TIOCSCTTY)"); -+ /* -+ * Should not happen -+ */ -+ if (!consoles) { -+ if (!errno) -+ errno = ENOMEM; -+ fprintf(stderr, "sulogin: cannot open console: %m\n\r"); -+ exit(1); - } - --#if defined(SANE_TIO) && (SANE_TIO == 1) -- fixtty(); --#endif -+ /* -+ * If previous stdin was not the speified tty and therefore reconnected -+ * to the specified tty also reconnect stdout and stderr. -+ */ -+ if (reconnect) { -+ if (isatty(1) == 0) -+ dup2(0, 1); -+ if (isatty(2) == 0) -+ dup2(0, 2); -+ } - - /* - * Get the root password. - */ - if ((pwd = getrootpwent(opt_e)) == NULL) { -- fprintf(stderr, "sulogin: cannot open password database!\n"); -+ fprintf(stderr, "sulogin: cannot open password database!\n\r"); - sleep(2); - } - - /* -- * Ask for the password. -+ * Prompt for input on the consoles - */ -- while(pwd) { -- int failed = 0; -- 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); -- failed++; -+ for (con = consoles; con && con->id < CONMAX; con = con->next) { -+ if (con->fd >= 0) { -+ openfd |= (1<fd); -+ tcinit(con); -+ continue; - } -- signal(SIGQUIT, SIG_IGN); -- signal(SIGTSTP, SIG_IGN); -- signal(SIGINT, SIG_IGN); -- if (failed) { -- printf("Can not execute su shell.\n"); -- break; -- } else -- printf("Login incorrect.\n"); -+ if ((con->fd = open(con->tty, O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0) -+ continue; -+ openfd |= (1<fd); -+ tcinit(con); - } -+ con = consoles; -+ usemask = (uint32_t*)mmap(NULL, sizeof(uint32_t), PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_SHARED, -1, 0); - -- if (alarm_rised) -- printf("Timed out.\n"); -+ if (con->next == (struct console*)0) -+ goto nofork; -+ -+ signal(SIGCHLD, chld_handler); -+ do { -+ switch ((con->pid = fork())) { -+ case 0: -+ signal(SIGCHLD, SIG_DFL); -+ /* fall through */ -+ nofork: -+ setup(con); -+ while (1) { -+ char *passwd = pwd->pw_passwd; -+ char *answer; -+ int failed = 0; -+ -+ doprompt(passwd, con); -+ if ((answer = getpasswd(con)) == NULL) -+ break; -+ -+ if (passwd[0] == '\0' || -+ strcmp(crypt(answer, passwd), passwd) == 0) { -+ *usemask |= (1<id); -+ sushell(pwd); -+ *usemask &= ~(1<id); -+ failed++; -+ } -+ signal(SIGQUIT, SIG_IGN); -+ signal(SIGTSTP, SIG_IGN); -+ signal(SIGINT, SIG_IGN); -+ -+ if (failed) { -+ fprintf(stderr, "sulogin: can not execute su shell.\n\r"); -+ break; -+ } -+ fprintf(stderr, "Login incorrect.\n\r"); -+ sleep(3); -+ } -+ if (alarm_rised) { -+ tcfinal(con); -+ printf("Timed out.\n\r"); -+ } -+ /* -+ * User may pressed Control-D. -+ */ -+ exit(0); -+ case -1: -+ fprintf(stderr, "sulogin: can not fork: %m\n\r"); -+ /* fall through */ -+ default: -+ break; -+ } -+ } while ((con = con->next) && (con->id < CONMAX)); -+ -+ while ((pid = wait(&status))) { -+ if (errno == ECHILD) -+ break; -+ if (pid < 0) -+ continue; -+ for (con = consoles; con && con->id < CONMAX; con = con->next) { -+ if (con->pid == pid) { -+ *usemask &= ~(1<id); -+ continue; -+ } -+ if (kill(con->pid, 0) < 0) { -+ *usemask &= ~(1<id); -+ continue; -+ } -+ if (*usemask & (1<id)) -+ continue; -+ kill(con->pid, SIGHUP); -+ usleep(5000); -+ kill(con->pid, SIGKILL); -+ } -+ } -+ signal(SIGCHLD, SIG_DFL); - -- /* -- * User may pressed Control-D. -- */ - return 0; - } ---- src/consoles.c -+++ src/consoles.c 2011-07-26 12:17:30.139926327 +0200 -@@ -27,9 +27,21 @@ - #include - #include - #include -+#include -+#ifdef __linux__ -+# include -+# include -+# include -+#endif -+#include - #include -+#include - #include "consoles.h" - -+#ifdef __linux__ -+# include -+#endif -+ - #if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) - # ifndef typeof - # define typeof __typeof__ -@@ -43,8 +55,100 @@ - - struct console *consoles; - -+/* -+ * Read and allocate one line from file, -+ * the caller has to free the result -+ */ -+static -+#ifdef __GNUC__ -+__attribute__((__nonnull__)) -+#endif -+char *oneline(const char *file) -+{ -+ FILE *fp; -+ char *ret = (char*)0, *nl; -+ size_t len = 0; -+ -+ if ((fp = fopen(file, "re")) == (FILE*)0) -+ goto err; -+ if (getline(&ret, &len, fp) < 0) -+ goto out; -+ if (len) -+ ret[len-1] = '\0'; -+ if ((nl = strchr(ret, '\n'))) -+ *nl = '\0'; -+out: -+ fclose(fp); -+err: -+ return ret; -+} -+ -+#ifdef __linux__ -+/* -+ * Read and determine active attribute for tty below -+ * /sys/class/tty, the caller has to free the result. -+ */ -+static -+__attribute__((__malloc__)) -+char *actattr(const char *tty) -+{ -+ char *ret = (char*)0; -+ char *path; -+ -+ if (!tty || *tty == '\0') -+ goto err; -+ -+ if (asprintf(&path, "/sys/class/tty/%s/active", tty) < 0) -+ goto err; -+ -+ if ((ret = oneline(path)) == (char*)0) -+ goto out; -+out: -+ free(path); -+err: -+ return ret; -+} -+ -+/* -+ * Read and determine device attribute for tty below -+ * /sys/class/tty. -+ */ -+static -+dev_t devattr(const char *tty) -+{ -+ unsigned int maj, min; -+ dev_t dev = 0; -+ char *path, *value; -+ -+ if (!tty || *tty == '\0') -+ goto err; -+ -+ if (asprintf(&path, "/sys/class/tty/%s/dev", tty) < 0) -+ goto err; -+ -+ if ((value = oneline(path)) == (char*)0) -+ goto out; -+ -+ if (sscanf(value, "%u:%u", &maj, &min) == 2) -+ dev = makedev(maj, min); -+ free(value); -+out: -+ free(path); -+err: -+ return dev; -+} -+#endif /* __linux__ */ -+ -+/* -+ * Search below /dev for the characer device in -+ * the local `dev_t comparedev' variable. -+ */ - static dev_t comparedev; --static char* scandev(DIR *dir) -+static -+#ifdef __GNUC__ -+__attribute__((__nonnull__,__malloc__,__hot__)) -+#endif -+char* scandev(DIR *dir) - { - char *name = (char*)0; - struct dirent *dent; -@@ -69,41 +173,335 @@ static char* scandev(DIR *dir) - return name; - } - --void detect_consoles(void) -+/* -+ * Default control characters for an unknown terminal line. -+ */ -+static -+struct chardata initcp = { -+ CERASE, -+ CKILL, -+ CTRL('r'), -+ 0 -+}; -+ -+/* -+ * Allocate an aligned `struct console' memory area, -+ * initialize its default values, and append it to -+ * the global linked list. -+ */ -+ -+static int concount; /* Counter for console IDs */ -+ -+static -+#ifdef __GNUC__ -+__attribute__((__nonnull__,__hot__)) -+#endif -+void consalloc(char * name) - { -+ struct console *restrict tail; -+ -+ if (posix_memalign((void*)&tail, sizeof(void*), alignof(typeof(struct console))) != 0) -+ perror("memory allocation"); -+ -+ tail->next = (struct console*)0; -+ tail->tty = name; -+ -+ tail->file = (FILE*)0; -+ tail->flags = 0; -+ tail->fd = -1; -+ tail->id = concount++; -+ tail->pid = 0; -+ memset(&tail->tio, 0, sizeof(tail->tio)); -+ memcpy(&tail->cp, &initcp, sizeof(struct chardata)); -+ -+ if (!consoles) -+ consoles = tail; -+ else -+ consoles->next = tail; -+} -+ -+/* -+ * Try to detect the real device(s) used for the system console -+ * /dev/console if but only if /dev/console is used. On Linux -+ * this can be more than one device, e.g. a serial line as well -+ * as a virtual console as well as a simple printer. -+ * -+ * Returns 1 if stdout and stderr should be reconnected and 0 -+ * otherwise. -+ */ -+int detect_consoles(const char *device, int fallback) -+{ -+ int fd, ret = 0; -+#ifdef __linux__ -+ char *attrib, *cmdline; - FILE *fc; -- if ((fc = fopen("/proc/consoles", "r"))) { -+#endif -+ if (!device || *device == '\0') -+ fd = dup(fallback); -+ else { -+ fd = open(device, O_RDWR|O_NONBLOCK|O_NOCTTY|O_CLOEXEC); -+ ret = 1; -+ } -+ -+ if (fd >= 0) { -+ DIR *dir; -+ char *name; -+ struct stat st; -+#ifdef TIOCGDEV -+ unsigned int devnum; -+#endif -+ -+ if (fstat(fd, &st) < 0) { -+ close(fd); -+ goto fallback; -+ } -+ comparedev = st.st_rdev; -+ -+ if (ret && (fstat(fallback, &st) < 0 || comparedev != st.st_rdev)) -+ dup2(fd, fallback); -+#ifdef __linux__ -+ /* -+ * Check if the device detection for Linux system console should be used. -+ */ -+ if (comparedev == makedev(TTYAUX_MAJOR, 0)) { /* /dev/tty */ -+ close(fd); -+ device = "/dev/tty"; -+ goto fallback; -+ } -+ if (comparedev == makedev(TTYAUX_MAJOR, 1)) { /* /dev/console */ -+ close(fd); -+ goto console; -+ } -+ if (comparedev == makedev(TTYAUX_MAJOR, 2)) { /* /dev/ptmx */ -+ close(fd); -+ device = "/dev/tty"; -+ goto fallback; -+ } -+ if (comparedev == makedev(TTY_MAJOR, 0)) { /* /dev/tty0 */ -+ struct vt_stat vt; -+ if (ioctl(fd, VT_GETSTATE, &vt) < 0) { -+ close(fd); -+ goto fallback; -+ } -+ comparedev = makedev(TTY_MAJOR, (int)vt.v_active); -+ } -+#endif -+#ifdef TIOCGDEV -+ if (ioctl (fd, TIOCGDEV, &devnum) < 0) { -+ close(fd); -+ goto fallback; -+ } -+ comparedev = (dev_t)devnum; -+#endif -+ close(fd); -+ dir = opendir("/dev"); -+ if (!dir) -+ goto fallback; -+ name = scandev(dir); -+ if (name) -+ consalloc(name); -+ closedir(dir); -+ if (!consoles) -+ goto fallback; -+ return ret; -+ } -+#ifdef __linux__ -+console: -+ /* -+ * Detection of devices used for Linux system consolei using -+ * the /proc/consoles API with kernel 2.6.38 and higher. -+ */ -+ if ((fc = fopen("/proc/consoles", "re"))) { - char fbuf[16]; - int maj, min; - DIR *dir; - dir = opendir("/dev"); -- if (!dir) -- goto out; -+ if (!dir) { -+ fclose(fc); -+ goto fallback; -+ } - while ((fscanf(fc, "%*s %*s (%[^)]) %d:%d", &fbuf[0], &maj, &min) == 3)) { -- struct console *restrict tail; - char * name; - - if (!strchr(fbuf, 'E')) - continue; - comparedev = makedev(maj, min); -+ - name = scandev(dir); -+ if (!name) -+ continue; -+ consalloc(name); -+ } -+ closedir(dir); -+ fclose(fc); -+ return ret; -+ } -+ /* -+ * Detection of devices used for Linux system console using -+ * the sysfs /sys/class/tty/ API with kernel 2.6.37 and higher. -+ */ -+ if ((attrib = actattr("console"))) { -+ char *words = attrib, *token; -+ DIR *dir; -+ -+ dir = opendir("/dev"); -+ if (!dir) { -+ free(attrib); -+ goto fallback; -+ } -+ while ((token = strsep(&words, " \t\r\n"))) { -+ char * name; -+ -+ if (*token == '\0') -+ continue; -+ comparedev = devattr(token); -+ if (comparedev == makedev(TTY_MAJOR, 0)) { -+ char *tmp = actattr(token); -+ if (!tmp) -+ continue; -+ comparedev = devattr(tmp); -+ free(tmp); -+ } - -+ name = scandev(dir); - if (!name) - continue; -+ consalloc(name); -+ } -+ closedir(dir); -+ free(attrib); -+ if (!consoles) -+ goto fallback; -+ return ret; - -- if (posix_memalign((void*)&tail, sizeof(void*), alignof(typeof(struct console))) != 0) -- perror("memory allocation"); -+ } -+ /* -+ * Detection of devices used for Linux system console using -+ * kernel parameter on the kernels command line. -+ */ -+ if ((cmdline = oneline("/proc/cmdline"))) { -+ char *words= cmdline, *token; -+ DIR *dir; - -- tail->next = (struct console*)0; -- tail->tty = name; -+ dir = opendir("/dev"); -+ if (!dir) { -+ free(cmdline); -+ goto fallback; -+ } -+ while ((token = strsep(&words, " \t\r\n"))) { -+#ifdef TIOCGDEV -+ unsigned int devnum; -+#else -+ struct vt_stat vt; -+ struct stat st; -+#endif -+ char *colon, *name; - -- if (!consoles) -- consoles = tail; -- else -- consoles->next = tail; -+ if (*token != 'c') -+ continue; -+ -+ if (strncmp(token, "console=", 8) != 0) -+ continue; -+ token += 8; -+ -+ if (strcmp(token, "brl") == 0) -+ token += 4; -+ if ((colon = strchr(token, ','))) -+ *colon = '\0'; -+ -+ if (asprintf(&name, "/dev/%s", token) < 0) -+ continue; -+ -+ if ((fd = open(name, O_RDWR|O_NONBLOCK|O_NOCTTY|O_CLOEXEC)) < 0) { -+ free(name); -+ continue; -+ } -+ free(name); -+#ifdef TIOCGDEV -+ if (ioctl (fd, TIOCGDEV, &devnum) < 0) { -+ close(fd); -+ continue; -+ } -+ comparedev = (dev_t)devnum; -+#else -+ if (fstat(fd, &st) < 0) { -+ close(fd); -+ continue; -+ } -+ comparedev = st.st_rdev; -+ if (comparedev == makedev(TTY_MAJOR, 0)) { -+ if (ioctl(fd, VT_GETSTATE, &vt) < 0) { -+ close(fd); -+ continue; -+ } -+ comparedev = makedev(TTY_MAJOR, (int)vt.v_active); -+ } -+#endif -+ close(fd); -+ -+ name = scandev(dir); -+ if (!name) -+ continue; -+ consalloc(name); - } - closedir(dir); --out: -- fclose(fc); -+ free(cmdline); -+ /* -+ * Detection of the device used for Linux system console using -+ * the ioctl TIOCGDEV if available (e.g. official 2.6.38). -+ */ -+ if (!consoles) { -+#ifdef TIOCGDEV -+ unsigned int devnum; -+ const char *name; -+ -+ if (!device || *device == '\0') -+ fd = dup(fallback); -+ else fd = open(device, O_RDWR|O_NONBLOCK|O_NOCTTY|O_CLOEXEC); -+ -+ if (fd < 0) -+ goto fallback; -+ -+ if (ioctl (fd, TIOCGDEV, &devnum) < 0) { -+ close(fd); -+ goto fallback; -+ } -+ comparedev = (dev_t)devnum; -+ close(fd); -+ -+ if (device && *device != '\0') -+ name = device; -+ else name = ttyname(fallback); -+ -+ if (!name) -+ name = "/dev/tty1"; -+ -+ consalloc(strdup(name)); -+ if (consoles) { -+ if (!device || *device == '\0') -+ consoles->fd = fallback; -+ return ret; -+ } -+#endif -+ goto fallback; -+ } -+ return ret; -+ } -+#endif /* __linux __ */ -+fallback: -+ if (fallback >= 0) { -+ const char *name; -+ -+ if (device && *device != '\0') -+ name = device; -+ else name = ttyname(fallback); -+ -+ if (!name) -+ name = "/dev/tty"; -+ -+ consalloc(strdup(name)); -+ if (consoles) -+ consoles->fd = fallback; - } -+ return ret; - } ---- src/consoles.h -+++ src/consoles.h 2011-07-26 11:07:40.273249830 +0200 -@@ -21,13 +21,28 @@ - * Author: Werner Fink - */ - -+#include -+#include -+#include - #include - -+struct chardata { -+ uint8_t erase; -+ uint8_t kill; -+ uint8_t eol; -+ uint8_t parity; -+}; - struct console { -- char * tty; -- int tlock; -- struct termios ltio, otio; -+ char *tty; -+ FILE *file; -+ uint32_t flags; -+ int fd, id; -+#define CON_SERIAL 0x0001 -+#define CON_NOTTY 0x0002 -+ pid_t pid; -+ struct chardata cp; -+ struct termios tio; - struct console *next; - }; - extern struct console *consoles; --extern void detect_consoles(void); -+extern int detect_consoles(const char *, int); ---- src/Makefile -+++ src/Makefile 2010-03-23 15:11:12.000000000 +0000 -@@ -112,7 +112,7 @@ utmpdump: utmpdump.o - runlevel: runlevel.o - - sulogin: LDLIBS += $(SULOGINLIBS) $(STATIC) --sulogin: sulogin.o -+sulogin: sulogin.o consoles.o - - wall: dowall.o wall.o - diff --git a/sysvinit-2.88dsf-suse.patch b/sysvinit-2.88dsf-suse.patch index 06f05e9..1a52eb7 100644 --- a/sysvinit-2.88dsf-suse.patch +++ b/sysvinit-2.88dsf-suse.patch @@ -1,113 +1,3 @@ ---- man/init.8 -+++ man/init.8 2010-03-19 14:44:16.000000000 +0000 -@@ -261,7 +261,7 @@ It activates the \fIkbrequest\fP action. - .SH CONFORMING TO - \fBInit\fP is compatible with the System V init. It works closely - together with the scripts in the directories --\fI/etc/init.d\fP and \fI/etc/rc{runlevel}.d\fP. -+\fI/etc/init.d\fP and \fI/etc/init.d/rc{runlevel}.d\fP. - If your system uses this convention, there should be a \fIREADME\fP - file in the directory \fI/etc/init.d\fP explaining how these scripts work. - .\"}}} -@@ -301,6 +301,7 @@ page by Michael Haardt (u31b3hs@pool.inf - .\"}}} - .\"{{{ See also - .SH "SEE ALSO" -+.BR init.d (7), - .BR getty (1), - .BR login (1), - .BR sh (1), ---- man/inittab.5 -+++ man/inittab.5 2004-03-12 12:33:05.000000000 +0000 -@@ -197,7 +197,7 @@ rc::bootwait:/etc/rc - .fi - .sp - .RE --This inittab file executes \fB/etc/rc\fP during boot and starts gettys -+This inittab file executes \fB/etc/rc\fP during boot and starts mingettys - on tty1\-tty4. - .PP - A more elaborate \fBinittab\fP with different runlevels (see the comments -@@ -205,23 +205,20 @@ inside): - .RS - .sp - .nf --.ne 19 -+.ne 41 - # Level to run in - id:2:initdefault: - - # Boot-time system configuration/initialization script. --si::sysinit:/etc/init.d/rcS -+si:I:bootwait:/etc/init.d/boot - --# What to do in single-user mode. --~:S:wait:/sbin/sulogin -- --# /etc/init.d executes the S and K scripts upon change --# of runlevel. --# --# Runlevel 0 is halt. --# Runlevel 1 is single-user. --# Runlevels 2-5 are multi-user. --# Runlevel 6 is reboot. -+# Runlevel 0 is System halt (Never use this as initdefault!) -+# Runlevel 1 is Single user mode -+# Runlevel 2 is Local multiuser without remote network (e.g. NFS) -+# Runlevel 3 is Full multiuser with network -+# Runlevel 4 is Not used -+# Runlevel 5 is Full multiuser with network and xdm -+# Runlevel 6 is System reboot (Never use this as initdefault!) - - l0:0:wait:/etc/init.d/rc 0 - l1:1:wait:/etc/init.d/rc 1 -@@ -231,17 +228,27 @@ l4:4:wait:/etc/init.d/rc 4 - l5:5:wait:/etc/init.d/rc 5 - l6:6:wait:/etc/init.d/rc 6 - -+# What to do in single-user mode -+ls:S:wait:/etc/init.d/rc S -+~~:S:respawn:/sbin/sulogin -+ - # What to do at the "3 finger salute". --ca::ctrlaltdel:/sbin/shutdown -t1 -h now -+ca::ctrlaltdel:/sbin/shutdown -t5 -h now - --# Runlevel 2,3: getty on virtual consoles --# Runlevel 3: getty on terminal (ttyS0) and modem (ttyS1) --1:23:respawn:/sbin/getty tty1 VC linux --2:23:respawn:/sbin/getty tty2 VC linux --3:23:respawn:/sbin/getty tty3 VC linux --4:23:respawn:/sbin/getty tty4 VC linux --S0:3:respawn:/sbin/getty -L 9600 ttyS0 vt320 --S1:3:respawn:/sbin/mgetty -x0 -D ttyS1 -+# Runlevel 2 upto 5: mingetty on console. -+# level 2, 3, and 5 also getty on serial port S0. -+1:2345:respawn:/sbin/mingetty --noclear tty1 -+2:2345:respawn:/sbin/mingetty tty2 -+3:2345:respawn:/sbin/mingetty tty3 -+4:2345:respawn:/sbin/mingetty tty4 -+5:2345:respawn:/sbin/mingetty tty5 -+6:2345:respawn:/sbin/mingetty tty6 -+S0:235:respawn:/sbin/agetty -L 9600 ttyS0 vt102 -+ -+# modem getty(s), -+# /dev/modem is a link to the modem device. -+#mo:235:respawn:/usr/sbin/mgetty -s 38400 modem -+mo:235:respawn:/sbin/uugetty modem M19200 - - .fi - .sp -@@ -261,5 +268,8 @@ by Michael Haardt (u31b3hs@pool.informat - .\"{{{ See also - .SH "SEE ALSO" - .BR init (8), --.BR telinit (8) -+.BR telinit (8), -+.BR init.d (7), -+.BR agetty (8), -+.BR mgetty (8) - .\"}}} --- man/killall5.8 +++ man/killall5.8 2010-03-19 14:43:25.000000000 +0000 @@ -44,6 +44,7 @@ process were killed, and 1 if it was una @@ -129,14 +19,3 @@ .BR shutdown (8), .BR init (8), .BR halt (8), ---- man/sulogin.8 -+++ man/sulogin.8 2004-03-12 12:26:35.000000000 +0000 -@@ -35,7 +35,7 @@ passes it the \fB\-b\fP option. - .PP - The user is prompted - .IP "" .5i --Give root password for system maintenance -+Give root password for system login - .br - (or type Control\-D for normal startup): - .PP diff --git a/sysvinit-rpmlintrc b/sysvinit-rpmlintrc deleted file mode 100644 index c47a2c5..0000000 --- a/sysvinit-rpmlintrc +++ /dev/null @@ -1,7 +0,0 @@ -addFilter(".*statically-linked-binary.*/sbin/init.*") -addFilter(".*files-duplicate.*/usr/share/man/man.*") -addFilter(".*non-remote_fs-dependency.*/etc/init.d/powerd.*") -addFilter(".*incoherent-init-script-name.*powerd.*") -addFilter(".*no-manual-page-for-binary.*sysvinit.*") -addFilter(".*dangling-symlink.*/sbin/init.*/sbin/sysvinit.*") -addFilter(".*no-manual-page-for-binary.*rcpowerd.*") diff --git a/sysvinit.changes b/sysvinit.changes index f5c00b4..cd48277 100644 --- a/sysvinit.changes +++ b/sysvinit.changes @@ -1,3 +1,28 @@ +------------------------------------------------------------------- +Fri Dec 4 15:24:01 UTC 2015 - sweet_f_a@gmx.de + +- cleanup package: + * don't build binaries which are not installed + * remove unused sources + * remove patches (or parts of patches) which modify unused files + * remove old build conditions (sysvinit, util-linux, mkinitrd) + * remove unused dependencies +- this cleanup does not change the resulting binaries (except some + package dependencies) +- list of removed patches: + * sysvinit-2.82-startstop.patch + * sysvinit-2.88+dsf-blowfish.dif + * sysvinit-2.88+dsf-crypt.patch + * sysvinit-2.88+dsf-env.patch + * sysvinit-2.88dsf-multiple-sulogin.patch + * sysvinit-2.88+dsf-run.diff + * sysvinit-2.88+dsf-xen.patch +- list of modified patches: + * notify-pam-dead.patch + * sysvinit-2.88+dsf.dif + * sysvinit-2.88+dsf-sulogin.diff + * sysvinit-2.88dsf-suse.patch + ------------------------------------------------------------------- Tue Dec 1 10:48:20 UTC 2015 - sweet_f_a@gmx.de diff --git a/sysvinit.spec b/sysvinit.spec index c12f64d..00e6503 100644 --- a/sysvinit.spec +++ b/sysvinit.spec @@ -16,22 +16,6 @@ # -%if 0%{suse_version} < 1300 -%global with_util_linux 1 -%endif -%bcond_with util_linux -%if %{undefined systemd_requires} -%bcond_without sysvinit -%else -%bcond_with sysvinit -%endif - -%if 0%{?suse_version} > 1310 -%define have_mkinitrd 0 -%else -%define have_mkinitrd 1 -%endif - Name: sysvinit %define KPVER 2.21 %define SCVER 1.16 @@ -43,57 +27,26 @@ Summary: SysV-Style init License: GPL-2.0+ Group: System/Base BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: audit-devel -BuildRequires: libselinux-devel -BuildRequires: libsepol-devel -BuildRequires: pam-devel -%if 0%{?suse_version} > 1140 -%if 0%{?suse_version} > 1230 -BuildRequires: systemd-rpm-macros -%else -BuildRequires: pkg-config -BuildRequires: systemd-devel -%endif -%endif #!BuildIgnore: sysvinit-tools -Requires(post): coreutils grep -%if %have_mkinitrd -Requires(post): mkinitrd -Requires(postun): mkinitrd -%endif Url: http://savannah.nongnu.org/projects/sysvinit/ Source: sysvinit-%{SIVER}dsf.tar.bz2 Source2: killproc-%{KPVER}.tar.bz2 Source4: showconsole-%{SCVER}.tar.bz2 Source5: startpar-%{START}.tar.bz2 -Source7: %{name}-rpmlintrc -Source8: mkinitrd-boot.sh -Source9: mkinitrd-kill1.sh -Source10: mkinitrd-kill2.sh Patch: %{name}-%{version}dsf.dif -Patch1: %{name}-2.82-startstop.patch Patch2: %{name}-2.88dsf-suse.patch Patch3: %{name}-2.88dsf-scripts2.patch Patch4: notify-pam-dead.patch -Patch5: %{name}-2.88dsf-multiple-sulogin.patch -Patch6: %{name}-%{version}dsf-run.diff -Patch7: %{name}-%{version}dsf-crypt.patch -Patch8: %{name}-%{version}dsf-blowfish.dif Patch9: %{name}-2.88dsf-no-kill.patch -Patch10: %{name}-%{version}dsf-env.patch Patch11: %{name}-%{version}dsf-dostat.patch # PATCH-FIX-UPSTREAM -- killall5: handle strange names of executables Patch12: %{name}-%{version}dsf-sulogin.diff -# PATCH-FIX-SUSE -- sulogin: find suitable console device even if first is not usable -Patch13: %{name}-%{version}dsf-xen.patch Patch30: killproc-%{KPVER}.dif Patch31: killproc-2.18-open_flags.dif Patch40: showconsole-%{SCVER}.dif Patch41: showconsole-1.16-deadlock.diff Patch42: showconsole-1.16-glibc.dif Patch50: startpar-%{START}.dif -Requires: mingetty -Requires: sysvinit-tools %description System V style init programs by Miquel van Smoorenburg that control the @@ -108,46 +61,20 @@ more information. %package tools Summary: Tools for basic booting Group: System/Base -%if 0%{suse_version} > 1120 -Requires(preun): coreutils %insserv_prereq -Requires(postun): coreutils %insserv_prereq -%else -PreReq: coreutils %insserv_prereq -%endif %description tools Helper tools from sysvinit that support booting, including but not exclusive to startpar, killproc and pidof. System V init specific programs are in the sysvinit package. -%package init -Summary: Provides /sbin/init for sysvinit -Group: System/Base -Provides: sbin_init -Conflicts: otherproviders(sbin_init) -Requires: %{name} -%ifnarch s390 s390x -Requires: powerd -%endif - -%description init -Just some symlinks and manual page for sysvinit - %prep %setup -n %{name}-%{SIVER}dsf -q -b 2 -b 4 -b 5 -%patch1 -p0 -b .startstop %patch2 -p0 -b .suse %patch3 -p0 -b .scripts2 %patch4 -p0 -b .pam -%patch5 -p0 -b .sulogin -%patch6 -p0 -b .run -%patch7 -p0 -b .crypt -%patch8 -p0 -b .blowfish %patch9 -p0 -b .no-kill -%patch10 -p0 -b .env %patch11 -p0 -b .dostat %patch12 -p0 -b .ka5 -%patch13 -p0 -b .xen %patch pushd doc mkdir killproc showconsole @@ -186,30 +113,7 @@ pushd ../startpar-%{START} popd %install - rm -rf %{buildroot} - mkdir %{buildroot} - mkdir -m 755 -p %{buildroot}/bin - mkdir -m 755 -p %{buildroot}/dev - mkdir -m 755 -p %{buildroot}/etc - mkdir -m 755 -p %{buildroot}/sbin - mkdir -m 755 -p %{buildroot}/usr/bin - mkdir -m 755 -p %{buildroot}/usr/include - mkdir -m 755 -p %{buildroot}%{_mandir}/man1 - mkdir -m 755 -p %{buildroot}%{_mandir}/man5 - mkdir -m 755 -p %{buildroot}%{_mandir}/man8 - make install -C src MANPATH=%{_mandir} ROOT=%{buildroot} WITH_SELINUX=yes DISTRO=SuSE - mv %{buildroot}/sbin/init %{buildroot}/sbin/sysvinit - mv %{buildroot}%{_mandir}/man8/init.8 %{buildroot}/%{_mandir}/man8/sysvinit.8 - ln -s /sbin/sysvinit %{buildroot}/sbin/init - ln -s sysvinit.8 %{buildroot}%{_mandir}/man8/init.8 - mkdir -p %{buildroot}/lib/sysvinit - ln -sf /sbin/sysvinit %{buildroot}/lib/sysvinit/telinit - ln -sf /sbin/sysvinit %{buildroot}/sbin/telinit - test -p %{buildroot}/dev/initctl || { - rm -f %{buildroot}/dev/initctl - mknod %{buildroot}/dev/initctl p - chmod 600 %{buildroot}/dev/initctl - } + make install -C src MANPATH=%{_mandir} ROOT=%{buildroot} DISTRO=SuSE pushd ../showconsole-%{SCVER} make install MANPATH=%{_mandir} INSTBINFLAGS="-m 0700" DESTDIR=%{buildroot} popd @@ -220,124 +124,17 @@ pushd ../startpar-%{START} make install DESTDIR=%{buildroot} popd # -# Install mkinitrd scriptlets -# -%if %have_mkinitrd - install -d %{buildroot}/lib/mkinitrd/scripts - install -m 0755 %{SOURCE8} %{buildroot}/lib/mkinitrd/scripts/boot-blogd.sh - install -m 0755 %{SOURCE9} %{buildroot}/lib/mkinitrd/scripts/boot-killblogd.sh - install -m 0755 %{SOURCE10} %{buildroot}/lib/mkinitrd/scripts/boot-killblogd2.sh -%endif -# # Remove files not packed: # - rm -f %{buildroot}/usr/include/{initreq.h,libblogger.h} - rm -f %{buildroot}/usr/lib/libblogger.a - rm -f %{buildroot}%{_mandir}/man1/mesg.1* + rm %{buildroot}/usr/include/{initreq.h,libblogger.h} + rm %{buildroot}/usr/lib/libblogger.a chmod 444 %{buildroot}%{_mandir}/man?/* -%if ! %{with util_linux} - rm -vf %{buildroot}/bin/mountpoint - rm -vf %{buildroot}/usr/bin/utmpdump - rm -vf %{buildroot}/sbin/sulogin - rm -vf %{buildroot}%{_mandir}/man1/mountpoint.1* - rm -vf %{buildroot}%{_mandir}/man1/utmpdump.1* - rm -vf %{buildroot}%{_mandir}/man8/sulogin.8* -%endif -%if !%{with sysvinit} - rm -vf %{buildroot}/sbin/sysvinit - rm -vfr %{buildroot}/lib/sysvinit - rm -vf %{buildroot}/sbin/halt - rm -vf %{buildroot}/sbin/init - rm -vf %{buildroot}/sbin/poweroff - rm -vf %{buildroot}/sbin/reboot - rm -vf %{buildroot}/sbin/runlevel - rm -vf %{buildroot}/sbin/shutdown - rm -vf %{buildroot}/sbin/telinit - rm -vf %{buildroot}%{_mandir}/man8/halt.8 - rm -vf %{buildroot}%{_mandir}/man5/initscript.5 - rm -vf %{buildroot}%{_mandir}/man5/inittab.5 - rm -vf %{buildroot}%{_mandir}/man8/init.8 - rm -vf %{buildroot}%{_mandir}/man8/sysvinit.8 - rm -vf %{buildroot}%{_mandir}/man8/poweroff.8 - rm -vf %{buildroot}%{_mandir}/man8/reboot.8 - rm -vf %{buildroot}%{_mandir}/man8/runlevel.8 - rm -vf %{buildroot}%{_mandir}/man8/shutdown.8 - rm -vf %{buildroot}%{_mandir}/man8/telinit.8 - rm -vfr %{buildroot}/lib/mkinitrd -%endif - -%if %{with sysvinit} -%post -ret=0 -if test -x /sbin/telinit -a -p /dev/initctl -a -f /proc/1/exe -a -d /proc/1/root -a ! -d /.build -a -x /sbin/init; then - icount=$(grep -cE '^[[:alnum:]]+:[[:alnum:]]*:' /etc/inittab 2>/dev/null || echo 0) - if test $(stat -Lc '%%D-%%i' /) = $(stat -Lc '%%D-%%i' /proc/1/root) -a $icount -gt 6 ; then - if test $(stat -Lc '%%D-%%i' /sbin/init) = $(stat -Lc '%%D-%%i' /sbin/sysvinit); then - /sbin/telinit u - fi - elif test $icount -le 6 ; then - echo 'Broken /etc/inittab found, installing and using %{name} make no sense!' 1>&2 - ret=1 - fi -fi -%if %have_mkinitrd -if test -x /sbin/mkinitrd_setup; then - mkinitrd_setup -fi -%endif -exit $ret - -%if %have_mkinitrd -%postun -if test -x /sbin/mkinitrd_setup; then - mkinitrd_setup -fi -%endif - -%files -%defattr (-,root,root,755) -/sbin/sysvinit -%dir /lib/sysvinit -/lib/sysvinit/telinit - -%files init -%defattr (-,root,root,755) -/sbin/halt -/sbin/init -/sbin/poweroff -/sbin/reboot -/sbin/runlevel -/sbin/shutdown -/sbin/telinit -%doc %{_mandir}/man8/halt.8.gz -%doc %{_mandir}/man5/initscript.5.gz -%doc %{_mandir}/man5/inittab.5.gz -%doc %{_mandir}/man8/init.8.gz -%doc %{_mandir}/man8/sysvinit.8.gz -%doc %{_mandir}/man8/poweroff.8.gz -%doc %{_mandir}/man8/reboot.8.gz -%doc %{_mandir}/man8/runlevel.8.gz -%doc %{_mandir}/man8/shutdown.8.gz -%doc %{_mandir}/man8/telinit.8.gz -%if %have_mkinitrd -%dir /lib/mkinitrd -%dir /lib/mkinitrd/scripts -/lib/mkinitrd/scripts/boot-blogd.sh -/lib/mkinitrd/scripts/boot-killblogd.sh -/lib/mkinitrd/scripts/boot-killblogd2.sh -%endif -%endif %files tools %defattr (-,root,root,755) %doc COPYING COPYRIGHT doc/Propaganda %doc doc/Changelog doc/killproc doc/showconsole %config /etc/pam.d/init -%if %{with util_linux} -/sbin/sulogin -/bin/mountpoint -/usr/bin/utmpdump -%endif /bin/pidof /bin/usleep /bin/fsync @@ -358,11 +155,6 @@ fi /sbin/mkill /sbin/startproc /sbin/start_daemon -%if %{with util_linux} -%doc %{_mandir}/man1/mountpoint.1.gz -%doc %{_mandir}/man1/utmpdump.1.gz -%doc %{_mandir}/man8/sulogin.8.gz -%endif %doc %{_mandir}/man1/usleep.1.gz %doc %{_mandir}/man1/fsync.1.gz # /usr/include/libblogger.h @@ -384,12 +176,5 @@ fi %doc %{_mandir}/man8/rvmtab.8.gz %doc %{_mandir}/man8/vhangup.8.gz %doc %{_mandir}/man8/mkill.8.gz -%if 0 -%doc contrib/bootlogd.README -/sbin/bootlogd -/sbin/intr -%doc %{_mandir}/man8/bootlogd.8.gz -%doc %{_mandir}/man8/intr.8.gz -%endif %changelog