summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/sysvinit-mod
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core-testing/sysvinit-mod')
-rw-r--r--abs/core-testing/sysvinit-mod/PKGBUILD29
-rw-r--r--abs/core-testing/sysvinit-mod/sysvinit.diff276
2 files changed, 305 insertions, 0 deletions
diff --git a/abs/core-testing/sysvinit-mod/PKGBUILD b/abs/core-testing/sysvinit-mod/PKGBUILD
new file mode 100644
index 0000000..172ed18
--- /dev/null
+++ b/abs/core-testing/sysvinit-mod/PKGBUILD
@@ -0,0 +1,29 @@
+# Contributor: Simon Bachmann <simonbachmann@freesurf.ch>
+pkgname=sysvinit-mod
+pkgver=2.86
+pkgrel=2
+pkgdesc="Linux System V Init, with a patched killall5 to enable omission of specified pids"
+arch=('i686' 'x86_64')
+url="ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/"
+license=('GPL')
+depends=('shadow' 'util-linux' 'coreutils' 'glibc' 'awk')
+provides=('sysvinit')
+conflicts=('sysvinit')
+source=(ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/sysvinit-$pkgver.tar.gz sysvinit.diff)
+md5sums=('7d5d61c026122ab791ac04c8a84db967' '9fa3c71e4a12465239135d67a8859315')
+
+build() {
+ cd $startdir/src/sysvinit-$pkgver
+ #patch killall5
+ patch -p1 < $startdir/src/sysvinit.diff || return 1
+ cp src/init.c src/init.c.backup
+ sed 's/\(.*\)\(Sending processes\)\(.*\)/\1\2 started by init\3/' \
+ src/init.c > tmp~
+ mv tmp~ src/init.c
+ mkdir -p $startdir/pkg/bin $startdir/pkg/sbin
+ mkdir -p $startdir/pkg/usr/bin
+ mkdir -p $startdir/pkg/usr/man/man5 $startdir/pkg/usr/man/man8
+ mkdir -p $startdir/pkg/usr/man/man1 $startdir/pkg/usr/include
+ make -C src || return 1
+ make -C src MANDIR=/usr/man ROOT=$startdir/pkg install
+}
diff --git a/abs/core-testing/sysvinit-mod/sysvinit.diff b/abs/core-testing/sysvinit-mod/sysvinit.diff
new file mode 100644
index 0000000..d26f7cc
--- /dev/null
+++ b/abs/core-testing/sysvinit-mod/sysvinit.diff
@@ -0,0 +1,276 @@
+diff -r -u sysvinit-2.86/COPYRIGHT sysvinit-2.86.patched/COPYRIGHT
+--- sysvinit-2.86/COPYRIGHT 2004-07-30 12:12:12.000000000 +0000
++++ sysvinit-2.86.patched/COPYRIGHT 2008-04-15 14:28:52.000000000 +0000
+@@ -12,7 +12,7 @@
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ On Debian GNU/Linux systems, the complete text of the GNU General
+ Public License can be found in `/usr/share/common-licenses/GPL'.
+diff -r -u sysvinit-2.86/man/killall5.8 sysvinit-2.86.patched/man/killall5.8
+--- sysvinit-2.86/man/killall5.8 2004-06-09 12:47:45.000000000 +0000
++++ sysvinit-2.86.patched/man/killall5.8 2008-04-15 14:28:52.000000000 +0000
+@@ -4,14 +4,29 @@
+ .SH SYNOPSIS
+ .B killall5
+ .RB -signalnumber
++.RB [ \-o
++.IR omitpid ]
++.RB [ \-o
++.IR omitpid.. ]
+ .SH DESCRIPTION
+ .B killall5
+ is the SystemV killall command. It sends a signal to all processes except
+ kernel threads and the processes in its own session, so it won't kill
+ the shell that is running the script it was called from. Its primary
+ (only) use is in the \fBrc\fP scripts found in the /etc/init.d directory.
++.SH OPTIONS
++.IP "-o \fIomitpid\fP"
++Tells \fIkillall5\fP to omit processes with that process id.
++.SH NOTES
++\fIkillall5\fP can also be invoked as pidof, which is simply a
++(symbolic) link to the \fIkillall5\fP program.
++.SH EXIT STATUS
++The program return zero if it killed processes. It return 2 if no
++process were killed, and 1 if it was unable to find any processes
++(/proc/ is missing).
+ .SH SEE ALSO
+ .BR halt (8),
+-.BR reboot (8)
++.BR reboot (8),
++.BR pidof (8)
+ .SH AUTHOR
+ Miquel van Smoorenburg, miquels@cistron.nl
+diff -r -u sysvinit-2.86/man/pidof.8 sysvinit-2.86.patched/man/pidof.8
+--- sysvinit-2.86/man/pidof.8 1998-09-02 12:49:33.000000000 +0000
++++ sysvinit-2.86.patched/man/pidof.8 2008-04-15 14:28:52.000000000 +0000
+@@ -27,13 +27,20 @@
+ .IP -x
+ Scripts too - this causes the program to also return process id's of
+ shells running the named scripts.
+-.IP -o \fIomitpid\fP
++.IP "-o \fIomitpid\fP"
+ Tells \fIpidof\fP to omit processes with that process id. The special
+ pid \fB%PPID\fP can be used to name the parent process of the \fIpidof\fP
+ program, in other words the calling shell or shell script.
++.SH "EXIT STATUS"
++.TP
++.B 0
++At least one program was found with the requested name.
++.TP
++.B 1
++No program was found with the requested name.
+ .SH NOTES
+-\fIpidof\fP is simply a (symbolic) link to the \fIkillall5\fP program,
+-which should also be located in \fP/sbin\fP.
++\fIpidof\fP is actually the same program as \fIkillall5\fP;
++the program behaves according to the name under which it is called.
+ .PP
+ When \fIpidof\fP is invoked with a full pathname to the program it
+ should find the pid of, it is reasonably safe. Otherwise it is possible
+@@ -43,6 +50,7 @@
+ .BR shutdown (8),
+ .BR init (8),
+ .BR halt (8),
+-.BR reboot (8)
++.BR reboot (8),
++.BR killall5 (8)
+ .SH AUTHOR
+ Miquel van Smoorenburg, miquels@cistron.nl
+diff -r -u sysvinit-2.86/src/killall5.c sysvinit-2.86.patched/src/killall5.c
+--- sysvinit-2.86/src/killall5.c 2004-07-30 12:16:23.000000000 +0000
++++ sysvinit-2.86.patched/src/killall5.c 2008-04-15 14:28:52.000000000 +0000
+@@ -378,8 +378,8 @@
+ int foundone = 0;
+ int ok = 0;
+
+- /* Try to stat the executable. */
+- if (prog[0] == '/' && stat(prog, &st) == 0) dostat++;
++ if (! prog)
++ return NULL;
+
+ /* Get basename of program. */
+ if ((s = strrchr(prog, '/')) == NULL)
+@@ -387,9 +387,16 @@
+ else
+ s++;
+
++ if (! *s)
++ return NULL;
++
+ q = (PIDQ_HEAD *)xmalloc(sizeof(PIDQ_HEAD));
+ q = init_pid_q(q);
+
++ /* Try to stat the executable. */
++ if (prog[0] == '/' && stat(prog, &st) == 0)
++ dostat++;
++
+ /* First try to find a match based on dev/ino pair. */
+ if (dostat) {
+ for (p = plist; p; p = p->next) {
+@@ -404,15 +411,35 @@
+ if (!foundone) for (p = plist; p; p = p->next) {
+ ok = 0;
+
+- /* Compare name (both basename and full path) */
+- ok += (p->argv0 && strcmp(p->argv0, prog) == 0);
+- ok += (p->argv0 && strcmp(p->argv0base, s) == 0);
++ /* matching nonmatching
++ * proc name prog name prog name
++ * --- ----------- ------------
++ * b b, p/b, q/b
++ * p/b b, p/b q/b
++ *
++ * Algorithm: Match if:
++ * cmd = arg
++ * or cmd = base(arg)
++ * or base(cmd) = arg
++ *
++ * Specifically, do not match just because base(cmd) = base(arg)
++ * as was done in earlier versions of this program, since this
++ * allows /aaa/foo to match /bbb/foo .
++ */
++ ok |=
++ (p->argv0 && strcmp(p->argv0, prog) == 0)
++ || (p->argv0 && s != prog && strcmp(p->argv0, s) == 0)
++ || (p->argv0base && strcmp(p->argv0base, prog) == 0);
+
+ /* For scripts, compare argv[1] as well. */
+- if (scripts_too && p->argv1 &&
+- !strncmp(p->statname, p->argv1base, STATNAMELEN)) {
+- ok += (strcmp(p->argv1, prog) == 0);
+- ok += (strcmp(p->argv1base, s) == 0);
++ if (
++ scripts_too && p->statname && p->argv1base
++ && !strncmp(p->statname, p->argv1base, STATNAMELEN)
++ ) {
++ ok |=
++ (p->argv1 && strcmp(p->argv1, prog) == 0)
++ || (p->argv1 && s != prog && strcmp(p->argv1, s) == 0)
++ || (p->argv1base && strcmp(p->argv1base, prog) == 0);
+ }
+
+ /*
+@@ -423,7 +450,7 @@
+ (p->argv0 == NULL ||
+ p->argv0[0] == 0 ||
+ strchr(p->argv0, ' '))) {
+- ok += (strcmp(p->statname, s) == 0);
++ ok |= (strcmp(p->statname, s) == 0);
+ }
+ if (ok) add_pid_to_q(q, p);
+ }
+@@ -548,20 +575,28 @@
+ }
+ }
+ }
+- printf("\n");
++ if (!first)
++ printf("\n");
+ closelog();
+ return(first ? 1 : 0);
+ }
+
+
+
++#define KILLALL_OMITSZ 16
++
+ /* Main for either killall or pidof. */
+ int main(int argc, char **argv)
+ {
+ PROC *p;
+ int pid, sid = -1;
++ pid_t opid[KILLALL_OMITSZ];
++ int i, oind, omit = 0;
+ int sig = SIGKILL;
+
++ /* return non-zero if no process was killed */
++ int retval = 2;
++
+ /* Get program name. */
+ if ((progname = strrchr(argv[0], '/')) == NULL)
+ progname = argv[0];
+@@ -576,10 +611,34 @@
+ return main_pidof(argc, argv);
+
+ /* Right, so we are "killall". */
++ for (oind = KILLALL_OMITSZ-1; oind > 0; oind--)
++ opid[oind] = 0;
++
+ if (argc > 1) {
+- if (argc != 2) usage();
+- if (argv[1][0] == '-') (argv[1])++;
+- if ((sig = atoi(argv[1])) <= 0 || sig > 31) usage();
++ for (i = 1; i < argc; i++) {
++ if (argv[i][0] == '-') (argv[i])++;
++ if (argv[i][0] == 'o') {
++ if (++i >= argc) usage();
++ if (oind >= KILLALL_OMITSZ -1) {
++ nsyslog(LOG_ERR,"omit pid buffer size "
++ "%d exceeded!\n",
++ KILLALL_OMITSZ);
++ closelog();
++ exit(1);
++ }
++ if ((opid[oind] = atoi(argv[i])) < 1) {
++ nsyslog(LOG_ERR,
++ "illegal omit pid value "
++ "(%s)!\n", argv[i]);
++ closelog();
++ exit(1);
++ }
++ oind++;
++ omit = 1;
++ }
++ else if ((sig = atoi(argv[1])) <= 0 || sig > 31)
++ usage();
++ }
+ }
+
+ /* First get the /proc filesystem online. */
+@@ -602,15 +661,26 @@
+ /* Read /proc filesystem */
+ if (readproc() < 0) {
+ kill(-1, SIGCONT);
+- exit(1);
++ return(1);
+ }
+
+- /* Now kill all processes except our session. */
++ /* Now kill all processes except init (pid 1) and our session. */
+ sid = (int)getsid(0);
+ pid = (int)getpid();
+- for (p = plist; p; p = p->next)
+- if (p->pid != pid && p->sid != sid && !p->kernel)
+- kill(p->pid, sig);
++ for (p = plist; p; p = p->next) {
++ if (p->pid == 1 || p->pid == pid || p->sid == sid || p->kernel)
++ continue;
++ if (omit) {
++ for (i = 0; i < oind; i++)
++ if (opid[i] == p->pid)
++ break;
++ /* On a match, continue with the for loop above. */
++ if (i < oind)
++ continue;
++ }
++ kill(p->pid, sig);
++ retval = 0;
++ }
+
+ /* And let them continue. */
+ kill(-1, SIGCONT);
+@@ -618,5 +688,8 @@
+ /* Done. */
+ closelog();
+
+- return 0;
++ /* Force the kernel to run the scheduler */
++ usleep(1);
++
++ return retval;
+ }
+