{
printf("\
start-stop-daemon for Debian Linux - small and fast C version written by\n\
-Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>, public domain.\n\
-VERSION \n\
+Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>, public domain.\n"
+VERSION "\n\
\n\
Usage:
start-stop-daemon -S|--start options ... -- arguments ...\n\
+sysvinit (2.87dsf-8slp2+s5) unstable; urgency=low
+
+ [ dongil01.park ]
+ * SLP add patch for supporting command with reboot.
+ * Git: slp/pkgs/s/sysvinit
+ * Tag: sysvinit_2.87dsf-8slp2+s5
+
+ -- Karol Lewandowski <k.lewandowsk@samsung.com> Wed, 18 Jan 2012 12:13:21 +0100
+
sysvinit (2.87dsf-8slp2+s4) unstable; urgency=low
* Bring sysvinit's postinst script back
--- /dev/null
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 64_init_add_cmd_for_reboot.dpatch by <lpg@ubuntu>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+@DPATCH@
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' sysvinit~/src/halt.c sysvinit/src/halt.c
+--- sysvinit~/src/halt.c 2012-01-17 11:50:23.000000000 +0900
++++ sysvinit/src/halt.c 2012-01-17 15:48:10.765930225 +0900
+@@ -8,7 +8,7 @@
+ * execute an "shutdown -r". This is for compatibility with
+ * sysvinit 2.4.
+ *
+- * Usage: halt [-n] [-w] [-d] [-f] [-h] [-i] [-p]
++ * Usage: halt [-n] [-w] [-d] [-f] [-h] [-i] [-p] cmd
+ * -n: don't sync before halting the system
+ * -w: only write a wtmp reboot record and exit.
+ * -d: don't write a wtmp record.
+@@ -16,7 +16,7 @@
+ * -h: put harddisks in standby mode
+ * -i: shut down all network interfaces.
+ * -p: power down the system (if possible, otherwise halt).
+- *
++ * cmd: command which delivered to reboot syscall.
+ * Reboot and halt are both this program. Reboot
+ * is just a link to halt. Invoking the program
+ * as poweroff implies the -p option.
+@@ -51,6 +51,7 @@
+
+ char *Version = "@(#)halt 2.86 31-Jul-2004 miquels@cistron.nl";
+ char *progname;
++char *cmd;
+
+ #define KERNEL_MONITOR 1 /* If halt() puts you into the kernel monitor. */
+ #define RUNLVL_PICKY 0 /* Be picky about the runlevel */
+@@ -64,7 +65,7 @@
+ */
+ void usage(void)
+ {
+- fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i]%s\n",
++ fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i] cmd%s\n",
+ progname, strcmp(progname, "halt") ? "" : " [-p]");
+ fprintf(stderr, "\t-n: don't sync before halting the system\n");
+ fprintf(stderr, "\t-w: only write a wtmp reboot record and exit.\n");
+@@ -72,6 +73,7 @@
+ fprintf(stderr, "\t-f: force halt/reboot, don't call shutdown.\n");
+ fprintf(stderr, "\t-h: put harddisks in standby mode.\n");
+ fprintf(stderr, "\t-i: shut down all network interfaces.\n");
++ fprintf(stderr, "\tcmd: command which delivered to reboot syscall.\n");
+ if (!strcmp(progname, "halt"))
+ fprintf(stderr, "\t-p: power down the system (if possible, otherwise halt).\n");
+ exit(1);
+@@ -148,6 +150,9 @@
+ args[i++] = tm;
+ }
+ args[i++] = "now";
++ if (cmd) {
++ args[i++] = cmd;
++ }
+ args[i++] = NULL;
+
+ execv("/sbin/shutdown", args);
+@@ -222,7 +227,11 @@
+ usage();
+ }
+ }
+- if (argc != optind) usage();
++
++ if (argc > optind +1) {
++ fprintf(stderr, "%s: too many arguments.\n", argv[0]);
++ usage();
++ }
+
+ if (geteuid() != 0) {
+ fprintf(stderr, "%s: must be superuser.\n", progname);
+@@ -231,6 +240,8 @@
+
+ (void)chdir("/");
+
++ cmd = argv[optind];
++
+ if (!do_hard && !do_nothing) {
+ /*
+ * See if we are in runlevel 0 or 6.
+@@ -265,7 +276,10 @@
+ if (do_nothing) exit(0);
+
+ if (do_reboot) {
+- init_reboot(BMAGIC_REBOOT);
++ if (cmd)
++ syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, argv[optind]);
++ else
++ init_reboot(BMAGIC_REBOOT);
+ } else {
+ /*
+ * Turn on hard reboot, CTRL-ALT-DEL will reboot now
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' sysvinit~/src/init.c sysvinit/src/init.c
+--- sysvinit~/src/init.c 2012-01-17 11:50:23.000000000 +0900
++++ sysvinit/src/init.c 2012-01-17 15:48:35.505929530 +0900
+@@ -197,6 +197,7 @@
+ #define NR_EXTRA_ENV 16
+ char *extra_env[NR_EXTRA_ENV];
+
++char* initcmd_getenv(char *data);
+
+ /*
+ * Sleep a number of seconds.
+@@ -915,6 +916,14 @@
+ /* Split up command line arguments */
+ buf[0] = 0;
+ strncat(buf, proc, sizeof(buf) - 1);
++
++ char *opts = initcmd_getenv("INIT_OPTS");
++
++ if(!strncmp(ch->id, "rebt", 4) && opts) {
++ strncat(buf, " ", 1);
++ strncat(buf, opts, strlen(opts));
++ }
++
+ ptr = buf;
+ for(f = 1; f < 15; f++) {
+ /* Skip white space */
+@@ -1946,6 +1955,24 @@
+ }
+ }
+
++char* initcmd_getenv(char *data)
++{
++ int i, j, sz;
++ char *ptr = NULL;
++
++ sz = strlen(data);
++
++ for (i = 0; i < NR_EXTRA_ENV; i++) {
++ if (extra_env[i] == NULL) continue;
++ if (!strncmp(extra_env[i], data, sz) &&
++ extra_env[i][sz] == '=') {
++ ptr = &extra_env[i][sz+1];
++
++ return ptr;
++ }
++ }
++ return NULL;
++}
+
+ /*
+ * Set/unset environment variables. The variables are
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' sysvinit~/src/reboot.h sysvinit/src/reboot.h
+--- sysvinit~/src/reboot.h 2012-01-17 11:50:23.000000000 +0900
++++ sysvinit/src/reboot.h 2012-01-17 15:48:40.141929398 +0900
+@@ -7,6 +7,8 @@
+ */
+
+ #include <sys/reboot.h>
++#include <linux/reboot.h>
++#include <sys/syscall.h>
+
+ #ifdef RB_ENABLE_CAD
+ # define BMAGIC_HARD RB_ENABLE_CAD
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' sysvinit~/src/shutdown.c sysvinit/src/shutdown.c
+--- sysvinit~/src/shutdown.c 2012-01-17 11:50:23.000000000 +0900
++++ sysvinit/src/shutdown.c 2012-01-17 15:51:32.121924563 +0900
+@@ -1,7 +1,7 @@
+ /*
+ * shutdown.c Shut the system down.
+ *
+- * Usage: shutdown [-krhfnc] time [warning message]
++ * Usage: shutdown [-krhfnc] time [warning message] cmd
+ * -k: don't really shutdown, only warn.
+ * -r: reboot after shutdown.
+ * -h: halt after shutdown.
+@@ -10,6 +10,7 @@
+ * -n: do not go through init but do it ourselves.
+ * -c: cancel an already running shutdown.
+ * -t secs: delay between SIGTERM and SIGKILL for init.
++ * cmd: command which delivered to reboot syscall.
+ *
+ * Author: Miquel van Smoorenburg, miquels@cistron.nl
+ *
+@@ -102,7 +103,7 @@
+ void usage(void)
+ {
+ fprintf(stderr,
+- "Usage:\t shutdown [-akrhHPfnc] [-t secs] time [warning message]\n"
++ "Usage:\t shutdown [-akrhHPfnc] [-t secs] time [warning message] cmd\n"
+ "\t\t -a: use /etc/shutdown.allow\n"
+ "\t\t -k: don't really shutdown, only warn.\n"
+ "\t\t -r: reboot after shutdown.\n"
+@@ -114,7 +115,8 @@
+ "\t\t -n: do not go through \"init\" but go down real fast.\n"
+ "\t\t -c: cancel a running shutdown.\n"
+ "\t\t -t secs: delay between warning and kill signal.\n"
+- "\t\t ** the \"time\" argument is mandatory! (try \"now\") **\n");
++ "\t\t ** the \"time\" argument is mandatory! (try \"now\") **\n"
++ "\t\t cmd: command which delivered to reboot syscall.\n");
+ exit(1);
+ }
+
+@@ -595,6 +597,16 @@
+ strcat(message, argv[c]);
+ strcat(message, " ");
+ }
++
++ if (message[0]) {
++ char *opts = malloc(strlen(message));
++ strncpy(opts, message, strlen(message)-1);
++ opts[strlen(message)-1] = 0;
++ if (opts) {
++ init_setenv("INIT_OPTS", opts);
++ }
++ }
++
+ if (message[0]) strcat(message, "\r\n");
+
+ /* See if we want to run or cancel. */
60_init_selinux_ifdef.dpatch
62_init_freebsdterm.dpatch
63_init_keep_utf8_ttyflag.patch
+64_init_add_cmd_for_reboot.dpatch
70_compiler_warnings.dpatch
91_sulogin_lockedpw.dpatch
94_fstab-decode.dpatch
--- /dev/null
+From 5c9ebe6dfdd14e24776206782e044f75665e8dfa Mon Sep 17 00:00:00 2001
+From: pkarurmo <prajwal.karur.mohan@intel.com>
+Date: Fri, 6 Apr 2012 11:11:36 -0700
+Subject: [PATCH] Fixing syntax error in start-stop-daemon.c
+
+---
+ contrib/start-stop-daemon.c | 4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/contrib/start-stop-daemon.c b/contrib/start-stop-daemon.c
+index 6795ebd..045ede3 100644
+--- a/contrib/start-stop-daemon.c
++++ b/contrib/start-stop-daemon.c
+@@ -112,13 +112,13 @@ start-stop-daemon for Debian Linux - small and fast C version written by\n\
+ Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>, public domain.\n\
+ VERSION \n\
+ \n\
+-Usage:
++Usage:\
+ start-stop-daemon -S|--start options ... -- arguments ...\n\
+ start-stop-daemon -K|--stop options ...\n\
+ start-stop-daemon -H|--help\n\
+ start-stop-daemon -V|--version\n\
+ \n\
+-Options (at least one of --exec|--pidfile|--user is required):
++Options (at least one of --exec|--pidfile|--user is required):\
+ -x|--exec <executable> program to start/check if it is running\n\
+ -p|--pidfile <pid-file> pid file to check\n\
+ -u|--user <username>|<uid> stop this user's processes\n\
+--
+1.7.5.4
+
--- /dev/null
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 64_init_add_cmd_for_reboot.dpatch by <lpg@ubuntu>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+@DPATCH@
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' sysvinit~/src/halt.c sysvinit/src/halt.c
+--- sysvinit~/src/halt.c 2012-01-17 11:50:23.000000000 +0900
++++ sysvinit/src/halt.c 2012-01-17 15:48:10.765930225 +0900
+@@ -8,7 +8,7 @@
+ * execute an "shutdown -r". This is for compatibility with
+ * sysvinit 2.4.
+ *
+- * Usage: halt [-n] [-w] [-d] [-f] [-h] [-i] [-p]
++ * Usage: halt [-n] [-w] [-d] [-f] [-h] [-i] [-p] cmd
+ * -n: don't sync before halting the system
+ * -w: only write a wtmp reboot record and exit.
+ * -d: don't write a wtmp record.
+@@ -16,7 +16,7 @@
+ * -h: put harddisks in standby mode
+ * -i: shut down all network interfaces.
+ * -p: power down the system (if possible, otherwise halt).
+- *
++ * cmd: command which delivered to reboot syscall.
+ * Reboot and halt are both this program. Reboot
+ * is just a link to halt. Invoking the program
+ * as poweroff implies the -p option.
+@@ -51,6 +51,7 @@
+
+ char *Version = "@(#)halt 2.86 31-Jul-2004 miquels@cistron.nl";
+ char *progname;
++char *cmd;
+
+ #define KERNEL_MONITOR 1 /* If halt() puts you into the kernel monitor. */
+ #define RUNLVL_PICKY 0 /* Be picky about the runlevel */
+@@ -64,7 +65,7 @@
+ */
+ void usage(void)
+ {
+- fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i]%s\n",
++ fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i] cmd%s\n",
+ progname, strcmp(progname, "halt") ? "" : " [-p]");
+ fprintf(stderr, "\t-n: don't sync before halting the system\n");
+ fprintf(stderr, "\t-w: only write a wtmp reboot record and exit.\n");
+@@ -72,6 +73,7 @@
+ fprintf(stderr, "\t-f: force halt/reboot, don't call shutdown.\n");
+ fprintf(stderr, "\t-h: put harddisks in standby mode.\n");
+ fprintf(stderr, "\t-i: shut down all network interfaces.\n");
++ fprintf(stderr, "\tcmd: command which delivered to reboot syscall.\n");
+ if (!strcmp(progname, "halt"))
+ fprintf(stderr, "\t-p: power down the system (if possible, otherwise halt).\n");
+ exit(1);
+@@ -148,6 +150,9 @@
+ args[i++] = tm;
+ }
+ args[i++] = "now";
++ if (cmd) {
++ args[i++] = cmd;
++ }
+ args[i++] = NULL;
+
+ execv("/sbin/shutdown", args);
+@@ -222,7 +227,11 @@
+ usage();
+ }
+ }
+- if (argc != optind) usage();
++
++ if (argc > optind +1) {
++ fprintf(stderr, "%s: too many arguments.\n", argv[0]);
++ usage();
++ }
+
+ if (geteuid() != 0) {
+ fprintf(stderr, "%s: must be superuser.\n", progname);
+@@ -231,6 +240,8 @@
+
+ (void)chdir("/");
+
++ cmd = argv[optind];
++
+ if (!do_hard && !do_nothing) {
+ /*
+ * See if we are in runlevel 0 or 6.
+@@ -265,7 +276,10 @@
+ if (do_nothing) exit(0);
+
+ if (do_reboot) {
+- init_reboot(BMAGIC_REBOOT);
++ if (cmd)
++ syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, argv[optind]);
++ else
++ init_reboot(BMAGIC_REBOOT);
+ } else {
+ /*
+ * Turn on hard reboot, CTRL-ALT-DEL will reboot now
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' sysvinit~/src/init.c sysvinit/src/init.c
+--- sysvinit~/src/init.c 2012-01-17 11:50:23.000000000 +0900
++++ sysvinit/src/init.c 2012-01-17 15:48:35.505929530 +0900
+@@ -197,6 +197,7 @@
+ #define NR_EXTRA_ENV 16
+ char *extra_env[NR_EXTRA_ENV];
+
++char* initcmd_getenv(char *data);
+
+ /*
+ * Sleep a number of seconds.
+@@ -915,6 +916,14 @@
+ /* Split up command line arguments */
+ buf[0] = 0;
+ strncat(buf, proc, sizeof(buf) - 1);
++
++ char *opts = initcmd_getenv("INIT_OPTS");
++
++ if(!strncmp(ch->id, "rebt", 4) && opts) {
++ strncat(buf, " ", 1);
++ strncat(buf, opts, strlen(opts));
++ }
++
+ ptr = buf;
+ for(f = 1; f < 15; f++) {
+ /* Skip white space */
+@@ -1946,6 +1955,24 @@
+ }
+ }
+
++char* initcmd_getenv(char *data)
++{
++ int i, j, sz;
++ char *ptr = NULL;
++
++ sz = strlen(data);
++
++ for (i = 0; i < NR_EXTRA_ENV; i++) {
++ if (extra_env[i] == NULL) continue;
++ if (!strncmp(extra_env[i], data, sz) &&
++ extra_env[i][sz] == '=') {
++ ptr = &extra_env[i][sz+1];
++
++ return ptr;
++ }
++ }
++ return NULL;
++}
+
+ /*
+ * Set/unset environment variables. The variables are
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' sysvinit~/src/reboot.h sysvinit/src/reboot.h
+--- sysvinit~/src/reboot.h 2012-01-17 11:50:23.000000000 +0900
++++ sysvinit/src/reboot.h 2012-01-17 15:48:40.141929398 +0900
+@@ -7,6 +7,8 @@
+ */
+
+ #include <sys/reboot.h>
++#include <linux/reboot.h>
++#include <sys/syscall.h>
+
+ #ifdef RB_ENABLE_CAD
+ # define BMAGIC_HARD RB_ENABLE_CAD
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' sysvinit~/src/shutdown.c sysvinit/src/shutdown.c
+--- sysvinit~/src/shutdown.c 2012-01-17 11:50:23.000000000 +0900
++++ sysvinit/src/shutdown.c 2012-01-17 15:51:32.121924563 +0900
+@@ -1,7 +1,7 @@
+ /*
+ * shutdown.c Shut the system down.
+ *
+- * Usage: shutdown [-krhfnc] time [warning message]
++ * Usage: shutdown [-krhfnc] time [warning message] cmd
+ * -k: don't really shutdown, only warn.
+ * -r: reboot after shutdown.
+ * -h: halt after shutdown.
+@@ -10,6 +10,7 @@
+ * -n: do not go through init but do it ourselves.
+ * -c: cancel an already running shutdown.
+ * -t secs: delay between SIGTERM and SIGKILL for init.
++ * cmd: command which delivered to reboot syscall.
+ *
+ * Author: Miquel van Smoorenburg, miquels@cistron.nl
+ *
+@@ -102,7 +103,7 @@
+ void usage(void)
+ {
+ fprintf(stderr,
+- "Usage:\t shutdown [-akrhHPfnc] [-t secs] time [warning message]\n"
++ "Usage:\t shutdown [-akrhHPfnc] [-t secs] time [warning message] cmd\n"
+ "\t\t -a: use /etc/shutdown.allow\n"
+ "\t\t -k: don't really shutdown, only warn.\n"
+ "\t\t -r: reboot after shutdown.\n"
+@@ -114,7 +115,8 @@
+ "\t\t -n: do not go through \"init\" but go down real fast.\n"
+ "\t\t -c: cancel a running shutdown.\n"
+ "\t\t -t secs: delay between warning and kill signal.\n"
+- "\t\t ** the \"time\" argument is mandatory! (try \"now\") **\n");
++ "\t\t ** the \"time\" argument is mandatory! (try \"now\") **\n"
++ "\t\t cmd: command which delivered to reboot syscall.\n");
+ exit(1);
+ }
+
+@@ -595,6 +597,16 @@
+ strcat(message, argv[c]);
+ strcat(message, " ");
+ }
++
++ if (message[0]) {
++ char *opts = malloc(strlen(message));
++ strncpy(opts, message, strlen(message)-1);
++ opts[strlen(message)-1] = 0;
++ if (opts) {
++ init_setenv("INIT_OPTS", opts);
++ }
++ }
++
+ if (message[0]) strcat(message, "\r\n");
+
+ /* See if we want to run or cancel. */
Patch15: dont_set_ownership.patch
Patch16: add_initscripts.patch
Patch17: add_sysvrc.patch
+Patch18: 64_init_add_cmd_for_reboot.dpatch
+Patch19: 0001-Fixing-syntax-error-in-start-stop-daemon.c.patch
%description
The sysvinit package contains a group of processes that control
Summary: System-V-like utilities
Group: System/Base
Provides: /usr/sbin/service
+Provides: /bin/pidof
%description utils
This package contains the important System-V-like utilities.
%package -n sysv-rc
Summary: System-V-like runlevel change mechanism
Group: System/Base
-Requires: sysvinit-utils, insserv
+Requires: sysvinit-utils
%description -n sysv-rc
This package provides support for the System-V like system
%patch15 -p1 -b .dont_set_ownership
%patch16 -p1
%patch17 -p1
+%patch18 -p1
+%patch19 -p1
%build
make -C src
if [ ! -f "$F" ] && touch "$F" >/dev/null 2>&1
then
echo "(Nothing has been logged yet.)" >| "$F"
- chown root:adm "$F"
+ # root UID is 0, adm GID is ordinary 4
+ chown 0:4 "$F"
chmod 640 "$F"
fi
done
#
if ! mountpoint -q /dev
then
- [ -d /dev/pts ] || { mkdir --mode=755 /dev/pts ; chown root:root /dev/pts || [ "$FAKECHROOT" = true ]; }
- [ -d /dev/shm ] || { mkdir --mode=755 /dev/shm ; chown root:root /dev/shm || [ "$FAKECHROOT" = true ]; }
+ # root UID is 0
+ [ -d /dev/pts ] || { mkdir --mode=755 /dev/pts ; chown 0:0 /dev/pts || [ "$FAKECHROOT" = true ]; }
+ [ -d /dev/shm ] || { mkdir --mode=755 /dev/shm ; chown 0:0 /dev/shm || [ "$FAKECHROOT" = true ]; }
fi
fi
%files
%defattr(-,root,root)
-/bin/pidof
/sbin/init
/sbin/halt
/sbin/runlevel
%{_includedir}/initreq.h
%files utils
+/bin/pidof
/sbin/bootlogd
/sbin/fstab-decode
/sbin/killall5