Hello community,
here is the log from the commit of package sysvinit
checked in at Thu Dec 14 18:05:57 CET 2006.
--------
--- sysvinit/sysvinit.changes 2006-08-22 15:51:06.000000000 +0200
+++ /mounts/work_src_done/STABLE/sysvinit/sysvinit.changes 2006-12-14 16:26:42.000000000 +0100
@@ -1,0 +2,8 @@
+Thu Dec 14 13:43:12 CET 2006 - werner@suse.de
+
+- New killproc 2.12 with new option -N better handling for NFS
+ based programs which is not to stat(2) the binary with -N
+- Make killall5 and pidof not to stat(2) binaries which are
+ loacted on NFS partitions (#224563)
+
+-------------------------------------------------------------------
Old:
----
killproc-2.11.dif
killproc-2.11.tar.bz2
New:
----
killproc-2.12.dif
killproc-2.12.tar.bz2
sysvinit-2.86-nfs4pidof.patch
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ sysvinit.spec ++++++
--- /var/tmp/diff_new_pack.vnpGRH/_old 2006-12-14 18:05:47.000000000 +0100
+++ /var/tmp/diff_new_pack.vnpGRH/_new 2006-12-14 18:05:47.000000000 +0100
@@ -13,27 +13,28 @@
Name: sysvinit
%define MGVER 0.9.6s
%define PDVER 2.0.2
-%define KPVER 2.11
+%define KPVER 2.12
%define SCVER 1.08
%define SIVER 2.86
%define START 0.49
-License: GPL, Other License(s), see package
+License: GNU General Public License (GPL), Other License(s), see package
Group: System/Base
PreReq: coreutils
Autoreqprov: on
Version: 2.86
-Release: 28
+Release: 49
Summary: SysV-Style init
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source: sysvinit-2.86.tar.bz2
-Source2: killproc-2.11.tar.bz2
+Source2: killproc-2.12.tar.bz2
Source3: powerd-2.0.2.tar.bz2
Source4: showconsole-1.08.tar.bz2
Source5: startpar-0.49.tar.bz2
Source6: rc.powerd
Patch: sysvinit-2.86.dif
+Patch1: sysvinit-2.86-nfs4pidof.patch
Patch2: powerd-2.0.2.dif
-Patch3: killproc-2.11.dif
+Patch3: killproc-2.12.dif
Patch4: swsusp-for-sysvinit-2.86.diff
Patch5: sysvinit-2.86-sulogin.patch
Patch6: sysvinit-2.82-startstop.patch
@@ -68,6 +69,7 @@
%prep
%setup -q -b 2 -b 3 -b 4 -b 5
+%patch -P 1 -b .nfs4pidof
%patch -P 5 -b .sulogin
%patch -P 6 -b .ststdmn
%patch -P 7 -b .suse
@@ -285,6 +287,11 @@
%doc %{_mandir}/man8/startpar.8.gz
%changelog -n sysvinit
+* Thu Dec 14 2006 - werner@suse.de
+- New killproc 2.12 with new option -N better handling for NFS
+ based programs which is not to stat(2) the binary with -N
+- Make killall5 and pidof not to stat(2) binaries which are
+ loacted on NFS partitions (#224563)
* Tue Aug 22 2006 - werner@suse.de
- More on delayed utmp write: redo the write on telinit q (#148038)
* Mon Aug 21 2006 - werner@suse.de
@@ -504,7 +511,7 @@
- showconsole: check for environment variable NOTIOCGDEV
* Fri Jun 06 2003 - mfabian@suse.de
- also set the scroll region to the full window (ESC [ r) when
---noclear is not set.
+ --noclear is not set.
* Thu Jun 05 2003 - mfabian@suse.de
- if the option "--noclear" is not set, don't write a full reset
because this leaves the unicode mode again if the terminal was in
@@ -769,9 +776,9 @@
- New killproc-1.10
* startproc which is able to sleep
* better zombie handling
-- killproc doesn't ignore zombies
-- checkproc ignores zombies without `-z' by default
-- startproc checks zombie state of child while sleeping
+ - killproc doesn't ignore zombies
+ - checkproc ignores zombies without `-z' by default
+ - startproc checks zombie state of child while sleeping
* Tue Jul 06 1999 - werner@suse.de
- Fix pts problem of shutdown (dowall.c)
* Thu Jun 24 1999 - werner@suse.de
++++++ killproc-2.11.dif -> killproc-2.12.dif ++++++
--- sysvinit/killproc-2.11.dif 2006-06-09 17:22:10.000000000 +0200
+++ /mounts/work_src_done/STABLE/sysvinit/killproc-2.12.dif 2006-12-14 16:23:20.000000000 +0100
@@ -1,336 +1,4 @@
---- libinit.c
-+++ libinit.c 2006-06-09 17:03:21.000000000 +0200
-@@ -745,27 +745,53 @@
- if (!(flags & (KTHREAD|KSHORT)) && !isscrpt &&
- (stat(exe_entry(tmp, d->d_name), &pid_st) == 0)) {
-
-- if ( pid_st.st_dev == full_st.st_dev
-- && pid_st.st_ino == full_st.st_ino
-- && pid_st.st_nlink == 1
-- )
-- {
-- do_list(pid,getsession(pid),false);
-- num++;
-- continue; /* Found */
-+ const char *name;
-+ char *realname;
-+ boolean found;
-+
-+ if (pid_st.st_dev != full_st.st_dev)
-+ continue; /* No processes below (kernel 2.2 and up) */
-+
-+ found = false;
-+ switch (pid_st.st_nlink) {
-+ case 1: /* One file on disk */
-+
-+ if (pid_st.st_ino == full_st.st_ino)
-+ found = true;
-+ break;
-+
-+ case 0: /* file was deleted or */
-+ default: /* has several hard links */
-+
-+ if (strlen(fullname) > MAXNAMLEN)
-+ continue;
-+
-+ if (readlink(exe_entry(tmp, d->d_name),clean_buf(entry),MAXNAMLEN) < 0)
-+ continue;
-+ name = handl_buf(entry);
-+
-+ if (strncmp(fullname, name, MAXNAMLEN) == 0) {
-+ found = true;
-+ break;
-+ }
-
-- } else if (
-- (readlink(exe_entry(tmp, d->d_name),clean_buf(entry),MAXNAMLEN) != -1)
-- && (strlen(fullname) <= MAXNAMLEN)
-- && (strncmp(fullname,handl_buf(entry),MAXNAMLEN) == 0)
-- )
-- {
-+ if ((realname = realpath(fullname, NULL)) == (char*)0)
-+ continue;
-+
-+ if (strncmp(realname, name, MAXNAMLEN) == 0)
-+ found = true;
-+
-+ free(realname);
-+
-+ break;
-+ }
-+
-+ if (found) {
- do_list(pid,getsession(pid),false);
-- num++;
-- continue; /* Found */
-+ num++; /* Found */
- }
-
-- continue; /* No processes below (kernel 2.2) */
-+ continue; /* No processes below (kernel 2.2 and up) */
- }
-
- /*
-@@ -948,49 +974,69 @@
- len = xread(fp,ent,3);
- close(fp);
-
-- if (!len) {
-- free(swapname);
-- return 0;
-- }
-+ if (!len)
-+ goto out;
-
- thread = (strncmp(ent, "0 ", 2) == 0);
-
-- if ((flags & KTHREAD) && !thread) {
-- free(swapname);
-- return 0; /* Threads do not have any memory size in user space */
-- }
-+ if ((flags & KTHREAD) && !thread)
-+ goto out; /* Threads do not have any memory size in user space */
-
-- if (!(flags & KTHREAD) && thread) {
-- free(swapname);
-- return 0; /* Programs always show _memory_ size in user space */
-- }
-+ if (!(flags & KTHREAD) && thread)
-+ goto out; /* Programs always show _memory_ size in user space */
- }
-
- errno = 0;
- if (!(flags & (KTHREAD|KSHORT)) && !isscrpt &&
- (stat(exe_entry(tmp, buf), &pid_st) == 0)) {
-
-- if ( pid_st.st_dev == full_st.st_dev
-- && pid_st.st_ino == full_st.st_ino
-- && pid_st.st_nlink == 1
-- )
-- {
-- do_list(pid,getsession(pid),ignore);
-- free(swapname);
-- return 0; /* Done */
-+ const char *name;
-+ char *realname;
-+ boolean found;
-
-- } else if (
-- (readlink(exe_entry(tmp, buf),clean_buf(entry),MAXNAMLEN) != -1)
-- && (strlen(fullname) <= MAXNAMLEN)
-- && (strncmp(fullname,handl_buf(entry),MAXNAMLEN) == 0)
-- )
-- {
-- do_list(pid,getsession(pid),ignore);
-- free(swapname);
-- return 0; /* Done */
-+ if (pid_st.st_dev != full_st.st_dev)
-+ goto out;
-+
-+ found = false;
-+ switch (pid_st.st_nlink) {
-+ case 1: /* One file on disk */
-+
-+ if (pid_st.st_ino == full_st.st_ino)
-+ found = true;
-+ break;
-+
-+ case 0: /* file was deleted or */
-+ default: /* has several hard links */
-+
-+ if (strlen(fullname) > MAXNAMLEN)
-+ goto out;
-+
-+ if (readlink(exe_entry(tmp, buf),clean_buf(entry),MAXNAMLEN) < 0)
-+ goto out;
-+ name = handl_buf(entry);
-+
-+ if (strncmp(fullname, name, MAXNAMLEN) == 0) {
-+ found = true;
-+ break;
-+ }
-+
-+ if ((realname = realpath(fullname, NULL)) == (char*)0)
-+ goto out;
-+
-+ if (strncmp(realname, name, MAXNAMLEN) == 0)
-+ found = true;
-+
-+ free(realname);
-+
-+ break;
- }
-- return 0;
-+
-+ if (found)
-+ do_list(pid,getsession(pid),false);
-+
-+ goto out;
- }
-+
- if (errno && errno != ENOENT) {
- // int saveerr = errno;
- warn("Can not read %s: %s\n", tmp, strerror(errno));
-@@ -1008,15 +1054,12 @@
- close(fp);
-
- /* Seek for a script not for a binary */
-- if (!(scrpt = checkscripts(entry, root, len, buf))) {
-- free(swapname);
-- return 0; /* Nothing found */
-- }
-+ if (!(scrpt = checkscripts(entry, root, len, buf)))
-+ goto out; /* Nothing found */
-
- if (scrpt && strcmp(scrpt,fullname) == 0) {
- do_list(pid,getsession(pid),ignore);
-- free(swapname);
-- return 0; /* Done */
-+ goto out; /* Done */
- }
- }
-
-@@ -1026,29 +1069,25 @@
- len = xread(fp,entry,MAXNAMLEN);
- close(fp);
-
-- if (!len) {
-- free(swapname);
-- return 0;
-- }
-+ if (!len)
-+ goto out;
-
- comm = index(entry, ' ');
- state = index(++comm, ' ');
- *state++ = '\0';
-
-- if ( (flags & NZOMBIE) && state[0] == 'Z' ) {
-+ if ( (flags & NZOMBIE) && state[0] == 'Z' )
- /* This is a zombie, ignore it */
-- free(swapname);
-- return 0;
-- }
-+ goto out; /* This is a zombie, ignore it */
-
- if (strcmp(comm, swapname) == 0) {
- do_list(pid,getsession(pid),ignore);
-- free(swapname);
-- return 0; /* Done */
-+ goto out; /* Done */
- }
- }
--
-- free(swapname);
-+out:
-+ if (swapname)
-+ free(swapname);
- return 0; /* Nothing found */
- }
-
-@@ -1090,7 +1129,7 @@
- n = remember;
- l = (PROC*)0;
- for(p = remember; n; p = n) {
-- int skip = 0;
-+ boolean skip = false;
- l = p->prev;
- n = p->next;
-
-@@ -1110,11 +1149,12 @@
- char ent[3];
- int thread;
- ssize_t len;
-+
- len = xread(fp,ent,3);
- close(fp);
-
- if (!len)
-- continue;
-+ goto ignore; /* Bogus */
-
- thread = (strncmp(ent, "0 ", 2) == 0);
-
-@@ -1130,23 +1170,45 @@
- if (!(flags & (KTHREAD|KSHORT)) && !isscrpt &&
- (stat(exe_entry(tmp, strpid), &pid_st) == 0)) {
-
-- if ( pid_st.st_dev == full_st.st_dev
-- && pid_st.st_ino == full_st.st_ino
-- && pid_st.st_nlink == 1
-- )
-- {
-- continue; /* Found */
-+ const char *name;
-+ char *realname;
-
-- } else if (
-- (readlink(exe_entry(tmp, strpid),clean_buf(entry),MAXNAMLEN) != -1)
-- && (strlen(fullname) <= MAXNAMLEN)
-- && (strncmp(fullname,handl_buf(entry),MAXNAMLEN) == 0)
-- )
-- {
-- continue; /* Found */
-+ if (pid_st.st_dev != full_st.st_dev)
-+ goto ignore; /* Does not belong to rembered list */
-+
-+ switch (pid_st.st_nlink) {
-+ case 1: /* One file on disk */
-+
-+ if (pid_st.st_ino == full_st.st_ino)
-+ continue; /* Found */
-+ break;
-+
-+ case 0: /* file was deleted or */
-+ default: /* has several hard links */
-+
-+ if (strlen(fullname) > MAXNAMLEN)
-+ goto ignore; /* Bogus */
-+
-+ if (readlink(exe_entry(tmp, strpid),clean_buf(entry),MAXNAMLEN) < 0)
-+ goto ignore; /* Bogus */
-+ name = handl_buf(entry);
-+
-+ if (strncmp(fullname, name, MAXNAMLEN) == 0)
-+ continue; /* Found */
-+
-+ if ((realname = realpath(fullname, NULL)) == (char*)0)
-+ goto ignore; /* Bogus */
-+
-+ if (strncmp(realname, name, MAXNAMLEN) == 0) {
-+ free(realname);
-+ continue; /* Found */
-+ }
-+ free(realname);
-+
-+ break;
- }
-
-- skip = 1; /* No stat entry check needed */
-+ skip = true; /* No stat entry check needed */
- }
-
- if (!(flags & (KTHREAD|KSHORT)) && isscrpt &&
-@@ -1157,17 +1219,21 @@
- len = xread(fp,entry,MAXNAMLEN);
- close(fp);
-
-+ if (!len)
-+ goto ignore; /* Bogus */
-+
- /* Seek for a script not for a binary */
- if ((scrpt = checkscripts(entry, root, len, strpid))) {
- if (strcmp(scrpt,fullname) == 0)
- continue; /* Found */
-- skip = 1; /* No stat entry check needed */
-+ skip = true; /* No stat entry check needed */
- }
- }
-
- if (!skip && (fp = open(stat_entry(tmp, strpid),O_RDONLY,0)) != -1) {
- char *comm, *state;
- ssize_t len;
-+
- len = xread(fp,entry,MAXNAMLEN);
- close(fp);
-
+--- .touch
++++ .touch
+@@ -0,0 +1 @@
++This patch is empty
++++++ killproc-2.11.tar.bz2 -> killproc-2.12.tar.bz2 ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.11/Makefile new/killproc-2.12/Makefile
--- old/killproc-2.11/Makefile 2005-11-08 11:44:11.000000000 +0100
+++ new/killproc-2.12/Makefile 2006-12-14 17:18:31.000000000 +0100
@@ -12,7 +12,7 @@
PREFIX = /usr
DEBUG =
DESTDIR =
-VERSION = 2.11
+VERSION = 2.12
DATE = $(shell date +'%d%b%y' | tr '[:lower:]' '[:upper:]')
ifneq ($(INC),)
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.11/checkproc.8 new/killproc-2.12/checkproc.8
--- old/killproc-2.11/checkproc.8 2005-11-08 11:44:11.000000000 +0100
+++ new/killproc-2.12/checkproc.8 2006-12-14 17:18:31.000000000 +0100
@@ -15,7 +15,7 @@
.SH SYNOPSIS
.\"
.B checkproc
-.RB [ "-v" "] [" "-L" "] [" "-k" "] [" -p
+.RB [ "-v" "] [" "-L" "] [" "-k" "] [" "-N" "] [" -p
.IR pid_file ]
.RB [ -i
.IR ingnore_file ]
@@ -25,7 +25,7 @@
.I /full/path/to/executable
.PP
.B checkproc
-.RB [ "-v" "] [" "-k" "] [" "-n" ]
+.RB [ "-v" "] [" "-k" "] [" "-n" "]"
.I name_of_kernel_thread
.PP
.B pidofproc
@@ -198,6 +198,26 @@
In this case not the executable with its full path name is required
but the name of the kernel thread.
.TP
+.B \-N
+With this option
+the location of the executable is checked about NFS
+file system and if true the
+.BR stat (2)
+system call is not applied on the
+.B exe
+symbolic link under
+.BR /proc (5).
+Otherwise
+.B checkproc
+or
+.B pidofproc
+could be locked if the corresponding NFS server
+is currently not online or available.
+This implies that the inode number check between the exectuable
+on the command line and the exectuable of the
+.B exec
+symbolic link will be skipped.
+.TP
.B \-q
This option is ignored.
.TP
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.11/checkproc.c new/killproc-2.12/checkproc.c
--- old/killproc-2.11/checkproc.c 2005-11-08 11:44:11.000000000 +0100
+++ new/killproc-2.12/checkproc.c 2006-12-14 17:18:31.000000000 +0100
@@ -56,7 +56,7 @@
posixa = getenv("_POSIX_OPTION_ORDER"); unsetenv("_POSIX_OPTION_ORDER");
posixb = getenv("POSIXLY_CORRECT"); unsetenv("POSIXLY_CORRECT");
opterr = 0;
- while ((c = getopt(argc, argv, "c:kp:nhqvzLi:")) != -1) {
+ while ((c = getopt(argc, argv, "c:kp:nNhqvzLi:")) != -1) {
switch (c) {
case 'c':
if (optarg && optarg[0] != '-' && !root) {
@@ -79,13 +79,16 @@
case 'n':
flags |= KTHREAD;
break;
+ case 'N':
+ init_nfs();
+ break;
case 'z':
flags &= ~NZOMBIE;
break;
case 'p': /* Changed from -f to -p to fit startproc and LSB */
/* Allocate here: address optarg (current *argv) isn't freeable */
if (optarg && !pid_file) {
- pid_file = strdup(optarg);
+ pid_file = xstrdup(optarg);
pid_forced = true;
} else
error(WRGSYNTAX, "Option -p requires pid file to read pid from\n");
@@ -93,7 +96,7 @@
case 'i':
/* Allocate here: address optarg (current *argv) isn't freeable */
if (optarg && optarg[0] != '-') {
- ignore_file = strdup(optarg);
+ ignore_file = xstrdup(optarg);
} else
error(LSB_WRGSYN,"Option -i requires pid file to read pid from\n");
break;
@@ -130,6 +133,8 @@
if (*fullname != '/')
flags |= KSHORT;
+ else if (check4nfs(fullname))
+ flags |= (KSHORT|KBASE);;
if (!pid_file) { /* the default pid file */
if (root) {
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.11/killproc-2.11.lsm new/killproc-2.12/killproc-2.11.lsm
--- old/killproc-2.11/killproc-2.11.lsm 2005-11-08 11:44:11.000000000 +0100
+++ new/killproc-2.12/killproc-2.11.lsm 1970-01-01 01:00:00.000000000 +0100
@@ -1,18 +0,0 @@
-Begin3
-Title: killproc and assorted tools for boot scripts
-Version: 2.11
-Entered-date: 08NOV05
-Description: Some useful programs for a replacment of the shell functions
- daemom and killproc found in the Linux System V init suite.
- killproc(8) for signaling or terminating, checkproc(8) for
- checking and startproc(8) for starting processes.
- Each program has its own manual page.
-Keywords: killproc, startproc, checkproc, process control
-Author: Werner Fink
-Maintained-by: Werner Fink
-Primary-site: sunsite.unc.edu /pub/Linux/system/daemons/init
- @UNKNOWN killproc-2.11.tar.gz
-Alternate-site: ftp.suse.com /pub/projects/init
-Platforms: Linux with System VR2 or higher boot scheme
-Copying-policy: GPL
-End
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.11/killproc-2.12.lsm new/killproc-2.12/killproc-2.12.lsm
--- old/killproc-2.11/killproc-2.12.lsm 1970-01-01 01:00:00.000000000 +0100
+++ new/killproc-2.12/killproc-2.12.lsm 2006-12-14 17:18:31.000000000 +0100
@@ -0,0 +1,18 @@
+Begin3
+Title: killproc and assorted tools for boot scripts
+Version: 2.12
+Entered-date: 14DEC06
+Description: Some useful programs for a replacment of the shell functions
+ daemom and killproc found in the Linux System V init suite.
+ killproc(8) for signaling or terminating, checkproc(8) for
+ checking and startproc(8) for starting processes.
+ Each program has its own manual page.
+Keywords: killproc, startproc, checkproc, process control
+Author: Werner Fink
+Maintained-by: Werner Fink
+Primary-site: sunsite.unc.edu /pub/Linux/system/daemons/init
+ @UNKNOWN killproc-2.12.tar.gz
+Alternate-site: ftp.suse.com /pub/projects/init
+Platforms: Linux with System VR2 or higher boot scheme
+Copying-policy: GPL
+End
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.11/killproc.8 new/killproc-2.12/killproc.8
--- old/killproc-2.11/killproc.8 2005-11-08 11:44:11.000000000 +0100
+++ new/killproc-2.12/killproc.8 2006-12-14 17:18:31.000000000 +0100
@@ -13,7 +13,7 @@
.SH SYNOPSIS
.\"
.B killproc
-.RB [ "-v" "] [" "-q" "] [" "-L" "] [" "-g" | "-G" "] [" "-p
+.RB [ "-v" "] [" "-q" "] [" "-L" "] [" "-g" | "-G" "] [" "-N" "] [" "-p
.IR pid_file ]
.RB [ -i
.IR ingnore_file ]
@@ -198,6 +198,24 @@
signaled. In this case not the executable with its
full path name is required but the name of the kernel
thread.
+.TP
+.B \-N
+With this option
+the location of the executable is checked about NFS
+file system and if true the
+.BR stat (2)
+system call is not applied on the
+.B exe
+symbolic link under
+.BR /proc (5).
+Otherwise
+.B killproc
+could be locked if the corresponding NFS server
+is currently not online or available.
+This implies that the inode number check between the exectuable
+on the command line and the exectuable of the
+.B exec
+symbolic link will be skipped.
.\"
.TP
.B \-SIG
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.11/killproc.c new/killproc-2.12/killproc.c
--- old/killproc-2.11/killproc.c 2005-11-08 11:44:11.000000000 +0100
+++ new/killproc-2.12/killproc.c 2006-12-14 17:18:31.000000000 +0100
@@ -89,7 +89,7 @@
posixa = getenv("_POSIX_OPTION_ORDER"); unsetenv("_POSIX_OPTION_ORDER");
posixb = getenv("POSIXLY_CORRECT"); unsetenv("POSIXLY_CORRECT");
opterr = 0;
- while ((c = getopt(argc, argv, "c:p:gGnhlvqt:Li:")) != -1) {
+ while ((c = getopt(argc, argv, "c:p:gGnNhlvqt:Li:")) != -1) {
switch (c) {
case 'c':
if (optarg && optarg[0] != '-' && !root) {
@@ -125,10 +125,13 @@
case 'n':
flags |= KTHREAD;
break;
+ case 'N':
+ init_nfs();
+ break;
case 'p': /* Changed from -f to -p to fit startproc and LSB */
/* Allocate here: address optarg (current *argv) isn't freeable */
if (optarg && !pid_file) {
- pid_file = strdup(optarg);
+ pid_file = xstrdup(optarg);
pid_forced = true;
} else
error(LSB_WRGSYN,"Option -p requires pid file to read pid from\n");
@@ -139,7 +142,7 @@
case 'i':
/* Allocate here: address optarg (current *argv) isn't freeable */
if (optarg && optarg[0] != '-') {
- ignore_file = strdup(optarg);
+ ignore_file = xstrdup(optarg);
} else
error(LSB_WRGSYN,"Option -i requires pid file to read pid from\n");
break;
@@ -178,6 +181,8 @@
if (*fullname != '/')
flags |= KSHORT;
+ else if (check4nfs(fullname))
+ flags |= (KSHORT|KBASE);
if (!pid_file) { /* the default pid file */
if (root) {
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.11/libinit.c new/killproc-2.12/libinit.c
--- old/killproc-2.11/libinit.c 2005-11-08 11:44:11.000000000 +0100
+++ new/killproc-2.12/libinit.c 2006-12-14 17:18:31.000000000 +0100
@@ -488,9 +488,7 @@
ptr = strcat(strcpy(ptr,root),script_exe);
script_exe = ptr;
} else {
- script_exe = strdup(script_exe);
- if (!script_exe)
- error(100, "strdup(): %s\n", strerror(errno));
+ script_exe = xstrdup(script_exe);
}
}
ret = true;
@@ -697,7 +695,10 @@
}
if (flags & (KTHREAD|KSHORT)) {
- swapname = swap_name(fullname);
+ if (flags & KBASE)
+ swapname = swap_name(base_name(fullname));
+ else
+ swapname = swap_name(fullname);
} else {
isscrpt = isscript(fullname, root);
swapname = swap_name(base_name(fullname));
@@ -745,27 +746,53 @@
if (!(flags & (KTHREAD|KSHORT)) && !isscrpt &&
(stat(exe_entry(tmp, d->d_name), &pid_st) == 0)) {
- if ( pid_st.st_dev == full_st.st_dev
- && pid_st.st_ino == full_st.st_ino
- && pid_st.st_nlink == 1
- )
- {
- do_list(pid,getsession(pid),false);
- num++;
- continue; /* Found */
+ const char *name;
+ char *realname;
+ boolean found;
+
+ if (pid_st.st_dev != full_st.st_dev)
+ continue; /* No processes below (kernel 2.2 and up) */
+
+ found = false;
+ switch (pid_st.st_nlink) {
+ case 1: /* One file on disk */
+
+ if (pid_st.st_ino == full_st.st_ino)
+ found = true;
+ break;
+
+ case 0: /* file was deleted or */
+ default: /* has several hard links */
+
+ if (strlen(fullname) > MAXNAMLEN)
+ continue;
- } else if (
- (readlink(exe_entry(tmp, d->d_name),clean_buf(entry),MAXNAMLEN) != -1)
- && (strlen(fullname) <= MAXNAMLEN)
- && (strncmp(fullname,handl_buf(entry),MAXNAMLEN) == 0)
- )
- {
+ if (readlink(exe_entry(tmp, d->d_name),clean_buf(entry),MAXNAMLEN) < 0)
+ continue;
+ name = handl_buf(entry);
+
+ if (strncmp(fullname, name, MAXNAMLEN) == 0) {
+ found = true;
+ break;
+ }
+
+ if ((realname = realpath(fullname, NULL)) == (char*)0)
+ continue;
+
+ if (strncmp(realname, name, MAXNAMLEN) == 0)
+ found = true;
+
+ free(realname);
+
+ break;
+ }
+
+ if (found) {
do_list(pid,getsession(pid),false);
- num++;
- continue; /* Found */
+ num++; /* Found */
}
- continue; /* No processes below (kernel 2.2) */
+ continue; /* No processes below (kernel 2.2 and up) */
}
/*
@@ -934,7 +961,10 @@
}
if (flags & (KTHREAD|KSHORT)) {
- swapname = swap_name(fullname);
+ if (flags & KBASE)
+ swapname = swap_name(base_name(fullname));
+ else
+ swapname = swap_name(fullname);
} else {
isscrpt = isscript(fullname, root);
swapname = swap_name(base_name(fullname));
@@ -948,49 +978,69 @@
len = xread(fp,ent,3);
close(fp);
- if (!len) {
- free(swapname);
- return 0;
- }
+ if (!len)
+ goto out;
thread = (strncmp(ent, "0 ", 2) == 0);
- if ((flags & KTHREAD) && !thread) {
- free(swapname);
- return 0; /* Threads do not have any memory size in user space */
- }
+ if ((flags & KTHREAD) && !thread)
+ goto out; /* Threads do not have any memory size in user space */
- if (!(flags & KTHREAD) && thread) {
- free(swapname);
- return 0; /* Programs always show _memory_ size in user space */
- }
+ if (!(flags & KTHREAD) && thread)
+ goto out; /* Programs always show _memory_ size in user space */
}
errno = 0;
if (!(flags & (KTHREAD|KSHORT)) && !isscrpt &&
(stat(exe_entry(tmp, buf), &pid_st) == 0)) {
- if ( pid_st.st_dev == full_st.st_dev
- && pid_st.st_ino == full_st.st_ino
- && pid_st.st_nlink == 1
- )
- {
- do_list(pid,getsession(pid),ignore);
- free(swapname);
- return 0; /* Done */
+ const char *name;
+ char *realname;
+ boolean found;
- } else if (
- (readlink(exe_entry(tmp, buf),clean_buf(entry),MAXNAMLEN) != -1)
- && (strlen(fullname) <= MAXNAMLEN)
- && (strncmp(fullname,handl_buf(entry),MAXNAMLEN) == 0)
- )
- {
- do_list(pid,getsession(pid),ignore);
- free(swapname);
- return 0; /* Done */
+ if (pid_st.st_dev != full_st.st_dev)
+ goto out;
+
+ found = false;
+ switch (pid_st.st_nlink) {
+ case 1: /* One file on disk */
+
+ if (pid_st.st_ino == full_st.st_ino)
+ found = true;
+ break;
+
+ case 0: /* file was deleted or */
+ default: /* has several hard links */
+
+ if (strlen(fullname) > MAXNAMLEN)
+ goto out;
+
+ if (readlink(exe_entry(tmp, buf),clean_buf(entry),MAXNAMLEN) < 0)
+ goto out;
+ name = handl_buf(entry);
+
+ if (strncmp(fullname, name, MAXNAMLEN) == 0) {
+ found = true;
+ break;
+ }
+
+ if ((realname = realpath(fullname, NULL)) == (char*)0)
+ goto out;
+
+ if (strncmp(realname, name, MAXNAMLEN) == 0)
+ found = true;
+
+ free(realname);
+
+ break;
}
- return 0;
+
+ if (found)
+ do_list(pid,getsession(pid),ignore);
+
+ goto out;
}
+
if (errno && errno != ENOENT) {
// int saveerr = errno;
warn("Can not read %s: %s\n", tmp, strerror(errno));
@@ -1008,15 +1058,12 @@
close(fp);
/* Seek for a script not for a binary */
- if (!(scrpt = checkscripts(entry, root, len, buf))) {
- free(swapname);
- return 0; /* Nothing found */
- }
+ if (!(scrpt = checkscripts(entry, root, len, buf)))
+ goto out; /* Nothing found */
if (scrpt && strcmp(scrpt,fullname) == 0) {
do_list(pid,getsession(pid),ignore);
- free(swapname);
- return 0; /* Done */
+ goto out; /* Done */
}
}
@@ -1026,29 +1073,25 @@
len = xread(fp,entry,MAXNAMLEN);
close(fp);
- if (!len) {
- free(swapname);
- return 0;
- }
+ if (!len)
+ goto out;
comm = index(entry, ' ');
state = index(++comm, ' ');
*state++ = '\0';
- if ( (flags & NZOMBIE) && state[0] == 'Z' ) {
+ if ( (flags & NZOMBIE) && state[0] == 'Z' )
/* This is a zombie, ignore it */
- free(swapname);
- return 0;
- }
+ goto out; /* This is a zombie, ignore it */
if (strcmp(comm, swapname) == 0) {
do_list(pid,getsession(pid),ignore);
- free(swapname);
- return 0; /* Done */
+ goto out; /* Done */
}
}
-
- free(swapname);
+out:
+ if (swapname)
+ free(swapname);
return 0; /* Nothing found */
}
@@ -1081,7 +1124,10 @@
}
if (flags & (KTHREAD|KSHORT)) {
- swapname = swap_name(fullname);
+ if (flags & KBASE)
+ swapname = swap_name(base_name(fullname));
+ else
+ swapname = swap_name(fullname);
} else {
isscrpt = isscript(fullname, root);
swapname = swap_name(base_name(fullname));
@@ -1090,7 +1136,7 @@
n = remember;
l = (PROC*)0;
for(p = remember; n; p = n) {
- int skip = 0;
+ boolean skip = false;
l = p->prev;
n = p->next;
@@ -1110,11 +1156,12 @@
char ent[3];
int thread;
ssize_t len;
+
len = xread(fp,ent,3);
close(fp);
if (!len)
- continue;
+ goto ignore; /* Bogus */
thread = (strncmp(ent, "0 ", 2) == 0);
@@ -1130,23 +1177,45 @@
if (!(flags & (KTHREAD|KSHORT)) && !isscrpt &&
(stat(exe_entry(tmp, strpid), &pid_st) == 0)) {
- if ( pid_st.st_dev == full_st.st_dev
- && pid_st.st_ino == full_st.st_ino
- && pid_st.st_nlink == 1
- )
- {
- continue; /* Found */
+ const char *name;
+ char *realname;
- } else if (
- (readlink(exe_entry(tmp, strpid),clean_buf(entry),MAXNAMLEN) != -1)
- && (strlen(fullname) <= MAXNAMLEN)
- && (strncmp(fullname,handl_buf(entry),MAXNAMLEN) == 0)
- )
- {
- continue; /* Found */
+ if (pid_st.st_dev != full_st.st_dev)
+ goto ignore; /* Does not belong to rembered list */
+
+ switch (pid_st.st_nlink) {
+ case 1: /* One file on disk */
+
+ if (pid_st.st_ino == full_st.st_ino)
+ continue; /* Found */
+ break;
+
+ case 0: /* file was deleted or */
+ default: /* has several hard links */
+
+ if (strlen(fullname) > MAXNAMLEN)
+ goto ignore; /* Bogus */
+
+ if (readlink(exe_entry(tmp, strpid),clean_buf(entry),MAXNAMLEN) < 0)
+ goto ignore; /* Bogus */
+ name = handl_buf(entry);
+
+ if (strncmp(fullname, name, MAXNAMLEN) == 0)
+ continue; /* Found */
+
+ if ((realname = realpath(fullname, NULL)) == (char*)0)
+ goto ignore; /* Bogus */
+
+ if (strncmp(realname, name, MAXNAMLEN) == 0) {
+ free(realname);
+ continue; /* Found */
+ }
+ free(realname);
+
+ break;
}
- skip = 1; /* No stat entry check needed */
+ skip = true; /* No stat entry check needed */
}
if (!(flags & (KTHREAD|KSHORT)) && isscrpt &&
@@ -1157,17 +1226,21 @@
len = xread(fp,entry,MAXNAMLEN);
close(fp);
+ if (!len)
+ goto ignore; /* Bogus */
+
/* Seek for a script not for a binary */
if ((scrpt = checkscripts(entry, root, len, strpid))) {
if (strcmp(scrpt,fullname) == 0)
continue; /* Found */
- skip = 1; /* No stat entry check needed */
+ skip = true; /* No stat entry check needed */
}
}
if (!skip && (fp = open(stat_entry(tmp, strpid),O_RDONLY,0)) != -1) {
char *comm, *state;
ssize_t len;
+
len = xread(fp,entry,MAXNAMLEN);
close(fp);
@@ -1338,7 +1411,7 @@
int rlstat(char ** file, struct stat *st, const unsigned short flags)
{
int ret = -1;
- unsigned int deep = 0;
+ int deep = MAXSYMLINKS;
char * cur_file = *file;
if (lstat(cur_file, st) < 0)
@@ -1349,34 +1422,30 @@
goto out;
do {
- size_t cnt;
- char *prev_file;
+ const char *prev_file;
+ int cnt;
ret = 0;
if (!S_ISLNK(st->st_mode))
goto out;
ret = -1;
- if (deep++ > MAXSYMLINKS) {
- errno = EMLINK;
- goto out;
- }
-
- prev_file = strdupa(cur_file);
- if (!prev_file)
+ if ((prev_file = strdupa(cur_file)) == NULL)
error(100, "strdupa(): %s\n", strerror(errno));
- if ((cnt = readlink(cur_file, lnk, sizeof(lnk) - 1)) < 0)
+
+ if ((cnt = readlink(cur_file, lnk, PATH_MAX)) < 0)
goto out;
lnk[cnt] = '\0';
- if (lnk[0] != '/') {
- /* Construct a new valid file name */
- char *lastslash;
- lastslash = strrchr (prev_file, '/');
- if (lastslash != NULL) {
+ if (lnk[0] != '/') { /* Construct a new valid file name */
+ const char *lastslash;
+
+ if ((lastslash = strrchr(prev_file, '/'))) {
size_t dirname_len = lastslash - prev_file + 1;
+
if (dirname_len + cnt > PATH_MAX)
cnt = PATH_MAX - dirname_len;
+
memmove(&lnk[dirname_len], &lnk[0], cnt + 1);
memcpy(&lnk[0], prev_file, dirname_len);
}
@@ -1386,6 +1455,11 @@
if (lstat(cur_file, st) < 0)
goto out;
+ if (deep-- <= 0) {
+ errno = ELOOP;
+ goto out;
+ }
+
} while (S_ISLNK(st->st_mode));
ret = 0;
@@ -1396,4 +1470,108 @@
out:
return ret;
}
+
+/*
+ * Code below is for checking for binaries located on a NFS
+ * based file system. With this help we can switch off the
+ * the various stat()'s checks become dead locked if the
+ * corresponding NFS servers are not online.
+ */
+
+typedef struct _nfs_
+{
+ struct _nfs_ *next; /* Pointer to next struct. */
+ struct _nfs_ *prev; /* Pointer to previous st. */
+ char * name;
+ size_t nlen;
+} NFS;
+
+NFS * nfs = (NFS*)0;
+
+void init_nfs(void)
+{
+ struct stat st;
+ struct mntent * ent;
+ FILE * mnt;
+
+ /* Stat /proc/version to see if /proc is mounted. */
+ if (stat("/proc/version", &st) < 0)
+ getproc();
+
+ if ((mnt = setmntent("/proc/mounts", "r")) == (FILE*)0)
+ return;
+
+ while ((ent = getmntent(mnt))) {
+ if (!strcasecmp(MNTTYPE_NFS, ent->mnt_type)) {
+ NFS * p = (NFS*)xmalloc(sizeof(NFS));
+ p->name = xstrdup(ent->mnt_dir);
+ p->nlen = strlen(p->name);
+ if (nfs)
+ nfs->prev = p;
+ p->next = nfs;
+ p->prev = (NFS*)0;
+ nfs = p;
+ }
+ }
+
+ endmntent(mnt);
+}
+
+boolean check4nfs(const char * path)
+{
+ char buf[PATH_MAX+1];
+ const char *curr;
+ int deep = MAXSYMLINKS;
+
+ if (!nfs) goto out;
+
+ curr = path;
+ do {
+ const char *prev;
+ int len;
+
+ if ((prev = strdupa(curr)) == NULL)
+ error(100, "strdupa(): %s\n", strerror(errno));
+
+ errno = 0;
+ if ((len = readlink(curr, buf, PATH_MAX)) < 0)
+ break;
+ buf[len] = '\0';
+
+ if (buf[0] != '/') {
+ const char *slash;
+
+ if ((slash = strrchr(prev, '/'))) {
+ size_t off = slash - prev + 1;
+
+ if (off + len > PATH_MAX)
+ len = PATH_MAX - off;
+
+ memmove(&buf[off], &buf[0], len + 1);
+ memcpy(&buf[0], prev, off);
+ }
+ }
+ curr = &buf[0];
+
+ if (deep-- <= 0) {
+ errno = ELOOP;
+ return true;
+ }
+
+ } while (true);
+
+ if (errno == EINVAL) {
+ NFS *p, *n, *l;
+ n = nfs;
+ l = (NFS*)0;
+ for (p = nfs; n; p = n) {
+ l = p->prev;
+ n = p->next;
+ if (!strncmp(curr, p->name, p->nlen))
+ return true;
+ }
+ }
+out:
+ return false;
+}
/* libinit.c ends here */
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.11/libinit.h new/killproc-2.12/libinit.h
--- old/killproc-2.11/libinit.h 2005-11-08 11:44:11.000000000 +0100
+++ new/killproc-2.12/libinit.h 2006-12-14 17:18:31.000000000 +0100
@@ -28,6 +28,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -94,6 +95,7 @@
#define KSHORT 0x0020
#define FLWLINK 0x0040
#define KSTOP 0x0080
+#define KBASE 0x0100
#define MAXENV 20
#define CMDLLEN MAXNAMLEN /* The string length of /proc/12345/cmdline\0\0 + 1 */
@@ -126,6 +128,8 @@
extern void error(int stat, const char *fmt, ...);
extern void warn(const char *fmt, ...);
extern int rlstat(char ** file, struct stat *st, const unsigned short flag);
+extern void init_nfs(void);
+boolean check4nfs(const char * path);
/* Feature */
extern char *sys_signame [];
@@ -175,7 +179,18 @@
if (p == (void*)0) {
if (stopped) kill(-1, SIGCONT);
- error(1, "out of memory\n");
+ error(100, "malloc(): %s\n", strerror(errno));
+ }
+ return p;
+}
+
+static inline char *xstrdup(const char * string)
+{
+ char *p = strdup(string);
+
+ if (p == (char*)0) {
+ if (stopped) kill(-1, SIGCONT);
+ error(100, "strdup(): %s\n", strerror(errno));
}
return p;
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.11/startproc.c new/killproc-2.12/startproc.c
--- old/killproc-2.11/startproc.c 2005-11-08 11:44:11.000000000 +0100
+++ new/killproc-2.12/startproc.c 2006-12-14 17:18:31.000000000 +0100
@@ -102,7 +102,7 @@
case 'p': /* Former option -f */
/* Allocate here: address optarg (current *argv) isn't freeable */
if (optarg && optarg[0] != '-' && !pid_file) {
- pid_file = strdup(optarg);
+ pid_file = xstrdup(optarg);
} else
error(LSB_WRGSYN,"Option -p requires pid file to read pid from\n");
break;
@@ -201,7 +201,7 @@
case 'i':
/* Allocate here: address optarg (current *argv) isn't freeable */
if (optarg && optarg[0] != '-') {
- ignore_file = strdup(optarg);
+ ignore_file = xstrdup(optarg);
} else
error(LSB_WRGSYN,"Option -i requires pid file to read pid from\n");
break;
++++++ sysvinit-2.86-nfs4pidof.patch ++++++
--- src/killall5.c
+++ src/killall5.c 2006-12-14 15:53:19.000000000 +0100
@@ -40,6 +40,8 @@
#include
#include
#include
+#include
+#include
char *Version = "@(#)killall5 2.86 31-Jul-2004 miquels@cistron.nl";
@@ -56,7 +58,8 @@ typedef struct proc {
dev_t dev; /* Device it is on */
pid_t pid; /* Process ID. */
int sid; /* Session ID. */
- int kernel; /* Kernel thread or zombie. */
+ char kernel; /* Kernel thread or zombie. */
+ char nfs; /* Binary is loacted on NFS part. */
struct proc *next; /* Pointer to next struct. */
} PROC;
@@ -73,9 +76,20 @@ typedef struct {
PIDQ *next;
} PIDQ_HEAD;
+typedef struct nfs
+{
+ struct nfs *next; /* Pointer to next struct. */
+ struct nfs *prev; /* Pointer to previous st. */
+ char * name;
+ size_t nlen;
+} NFS;
+
/* List of processes. */
PROC *plist;
+/* List of NFS mountes partitions. */
+NFS *nlist;
+
/* Did we stop all processes ? */
int sent_sigstop;
@@ -152,6 +166,101 @@ int mount_proc(void)
return did_mount;
}
+/*
+ * Remember all NFS typed partitions.
+ */
+void init_nfs(void)
+{
+ struct stat st;
+ struct mntent * ent;
+ FILE * mnt;
+
+ nlist = (NFS*)0;
+
+ if (stat("/proc/version", &st) < 0)
+ return;
+ if ((mnt = setmntent("/proc/mounts", "r")) == (FILE*)0)
+ return;
+
+ while ((ent = getmntent(mnt))) {
+ if (!strcasecmp(MNTTYPE_NFS, ent->mnt_type)) {
+ NFS * p = (NFS*)xmalloc(sizeof(NFS));
+ p->name = (char*)xmalloc(strlen(ent->mnt_dir)+1);
+ strcpy(p->name, ent->mnt_dir);
+ p->nlen = strlen(p->name);
+ if (nlist)
+ nlist->prev = p;
+ p->next = nlist;
+ p->prev = (NFS*)0;
+ nlist = p;
+ }
+ }
+
+ endmntent(mnt);
+}
+
+/*
+ * Check path is located on a NFS partition.
+ */
+int check4nfs(const char * path, char * real)
+{
+ char buf[PATH_MAX+1];
+ const char *curr;
+ int deep = MAXSYMLINKS;
+
+ if (!nlist) return 0;
+
+ curr = path;
+ do {
+ const char *prev;
+ int len;
+
+ if ((prev = strdupa(curr)) == NULL) {
+ nsyslog(LOG_ERR, "strdupa(): %s\n", strerror(errno));
+ return 0;
+ }
+
+ errno = 0;
+ if ((len = readlink(curr, buf, PATH_MAX)) < 0)
+ break;
+ buf[len] = '\0';
+
+ if (buf[0] != '/') {
+ const char *slash;
+
+ if ((slash = strrchr(prev, '/'))) {
+ size_t off = slash - prev + 1;
+
+ if (off + len > PATH_MAX)
+ len = PATH_MAX - off;
+
+ memmove(&buf[off], &buf[0], len + 1);
+ memcpy(&buf[0], prev, off);
+ }
+ }
+ curr = &buf[0];
+
+ if (deep-- <= 0) return 0;
+
+ } while (1);
+
+ if (real) strcpy(real, curr);
+
+ if (errno == EINVAL) {
+ NFS *p, *n, *l;
+ n = nlist;
+ l = (NFS*)0;
+ for (p = nlist; n; p = n) {
+ l = p->prev;
+ n = p->next;
+ if (!strncmp(curr, p->name, p->nlen))
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
int readarg(FILE *fp, char *buf, int sz)
{
int c = 0, f = 0;
@@ -173,8 +282,8 @@ int readproc()
PROC *p, *n;
struct dirent *d;
struct stat st;
- char path[256];
- char buf[256];
+ char path[PATH_MAX+1];
+ char buf[PATH_MAX+1];
char *s, *q;
unsigned long startcode, endcode;
int pid, f;
@@ -191,6 +300,7 @@ int readproc()
n = p->next;
if (p->argv0) free(p->argv0);
if (p->argv1) free(p->argv1);
+ if (p->statname) free(p->statname);
free(p);
}
plist = NULL;
@@ -225,6 +335,9 @@ int readproc()
nsyslog(LOG_ERR,
"can't get program name from %s\n",
path);
+ if (p->argv0) free(p->argv0);
+ if (p->argv1) free(p->argv1);
+ if (p->statname) free(p->statname);
free(p);
continue;
}
@@ -248,6 +361,9 @@ int readproc()
p->sid = 0;
nsyslog(LOG_ERR, "can't read sid from %s\n",
path);
+ if (p->argv0) free(p->argv0);
+ if (p->argv1) free(p->argv1);
+ if (p->statname) free(p->statname);
free(p);
continue;
}
@@ -256,6 +372,9 @@ int readproc()
fclose(fp);
} else {
/* Process disappeared.. */
+ if (p->argv0) free(p->argv0);
+ if (p->argv1) free(p->argv1);
+ if (p->statname) free(p->statname);
free(p);
continue;
}
@@ -300,13 +419,18 @@ int readproc()
} else {
/* Process disappeared.. */
+ if (p->argv0) free(p->argv0);
+ if (p->argv1) free(p->argv1);
+ if (p->statname) free(p->statname);
free(p);
continue;
}
/* Try to stat the executable. */
snprintf(path, sizeof(path), "/proc/%s/exe", d->d_name);
- if (stat(path, &st) == 0) {
+ if (check4nfs(path, NULL))
+ p->nfs = 1;
+ if ((p->nfs == 0) && (stat(path, &st) == 0)) {
p->dev = st.st_dev;
p->ino = st.st_ino;
}
@@ -374,12 +498,25 @@ PIDQ_HEAD *pidof(char *prog)
PIDQ_HEAD *q;
struct stat st;
char *s;
+ int nfs = 0;
int dostat = 0;
int foundone = 0;
int ok = 0;
+ char real[PATH_MAX+1];
/* Try to stat the executable. */
- if (prog[0] == '/' && stat(prog, &st) == 0) dostat++;
+ if (prog[0] == '/') {
+ memset(&real[0], 0, sizeof(real));
+
+ if (check4nfs(prog, real))
+ nfs++; /* Binary located on NFS partition. */
+
+ if (real[0] != '\0')
+ prog = &real[0]; /* Binary or its symlink located on NFS. */
+
+ if ((nfs == 0) && (stat(prog, &st) == 0))
+ dostat++; /* Binary located on a local file system. */
+ }
/* Get basename of program. */
if ((s = strrchr(prog, '/')) == NULL)
@@ -393,10 +530,30 @@ PIDQ_HEAD *pidof(char *prog)
/* First try to find a match based on dev/ino pair. */
if (dostat) {
for (p = plist; p; p = p->next) {
- if (p->dev == st.st_dev && p->ino == st.st_ino) {
- add_pid_to_q(q, p);
- foundone++;
- }
+ if (p->nfs)
+ continue;
+ if (p->dev != st.st_dev || p->ino != st.st_ino)
+ continue;
+ add_pid_to_q(q, p);
+ foundone++;
+ }
+ }
+
+ /* Second try to find a match based on full path name on NFS located binaries */
+ if (!foundone && nfs) {
+ for (p = plist; p; p = p->next) {
+ char exe [PATH_MAX+1];
+ char path[PATH_MAX+1];
+ int len;
+
+ snprintf(exe, sizeof(exe), "/proc/%d/exe", p->pid);
+ if ((len = readlink(exe, path, PATH_MAX)) < 0)
+ continue;
+ path[len] = '\0';
+ if (strcmp(prog, path) != 0)
+ continue;
+ add_pid_to_q(q, p);
+ foundone++;
}
}
@@ -428,7 +585,7 @@ PIDQ_HEAD *pidof(char *prog)
if (ok) add_pid_to_q(q, p);
}
- return q;
+ return q;
}
/* Give usage message and exit. */
@@ -477,6 +634,9 @@ int main_pidof(int argc, char **argv)
int first = 1;
int i, oind, opt, flags = 0;
+ /* Which NFS partitions are online? */
+ init_nfs();
+
for (oind = PIDOF_OMITSZ-1; oind > 0; oind--)
opid[oind] = 0;
opterr = 0;
@@ -561,6 +721,7 @@ int main(int argc, char **argv)
PROC *p;
int pid, sid = -1;
int sig = SIGKILL;
+ int did_mount;
/* Get program name. */
if ((progname = strrchr(argv[0], '/')) == NULL)
@@ -583,7 +744,10 @@ int main(int argc, char **argv)
}
/* First get the /proc filesystem online. */
- mount_proc();
+ did_mount = mount_proc();
+
+ /* Which NFS partitions are online? */
+ init_nfs();
/*
* Ignoring SIGKILL and SIGSTOP do not make sense, but
@@ -608,9 +772,13 @@ int main(int argc, char **argv)
/* Now kill all processes except our session. */
sid = (int)getsid(0);
pid = (int)getpid();
- for (p = plist; p; p = p->next)
- if (p->pid != pid && p->sid != sid && !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) {
+ kill(p->pid, SIGCONT);
+ continue;
+ }
+ kill(p->pid, sig);
+ }
/* And let them continue. */
kill(-1, SIGCONT);
++++++ sysvinit-2.86.dif ++++++
--- /var/tmp/diff_new_pack.vnpGRH/_old 2006-12-14 18:05:49.000000000 +0100
+++ /var/tmp/diff_new_pack.vnpGRH/_new 2006-12-14 18:05:49.000000000 +0100
@@ -830,34 +830,6 @@
#if DEBUG
# define INITDBG(level, fmt, args...) initlog(level, fmt, ##args)
---- src/killall5.c
-+++ src/killall5.c 2006-08-18 14:45:28.000000000 +0200
-@@ -608,9 +608,13 @@ int main(int argc, char **argv)
- /* Now kill all processes except our session. */
- sid = (int)getsid(0);
- pid = (int)getpid();
-- for (p = plist; p; p = p->next)
-- if (p->pid != pid && p->sid != sid && !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) {
-+ kill(p->pid, SIGCONT);
-+ continue;
-+ }
-+ kill(p->pid, sig);
-+ }
-
- /* And let them continue. */
- kill(-1, SIGCONT);
-@@ -618,5 +622,8 @@ int main(int argc, char **argv)
- /* Done. */
- closelog();
-
-+ /* Force the kernel to run the scheduler */
-+ usleep(1);
-+
- return 0;
- }
--- src/shutdown.c
+++ src/shutdown.c 2006-08-18 14:45:28.000000000 +0200
@@ -60,6 +60,7 @@ char *clean_env[] = {
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org