From 8bb2146fd5a3b333422f30621eb344e0ec2dfc1a7876f9fa7cc1b7de91e22e5e Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Fri, 21 Jan 2011 18:32:25 +0000 Subject: [PATCH] . OBS-URL: https://build.opensuse.org/package/show/Base:System/sysvinit?expand=0&rev=86 --- killproc-2.17.dif | 31 +++++++++++++++++++++++++++---- sysvinit.changes | 7 ++++++- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/killproc-2.17.dif b/killproc-2.17.dif index e7dc6c7..404f75e 100644 --- a/killproc-2.17.dif +++ b/killproc-2.17.dif @@ -1,6 +1,29 @@ --- libinit.c -+++ libinit.c 2010-10-27 08:17:06.371926813 +0000 -@@ -728,19 +728,21 @@ int pidof (const char * inname, const ch ++++ libinit.c 2011-01-21 18:25:49.019926024 +0000 +@@ -307,15 +307,16 @@ static void init_mounts(void) + } + } + +-static MNTINFO *find_mount(const char * path) ++static int find_mount(const char * path, MNTINFO *s) + { +- MNTINFO *m; ++ MNTINFO *m, *p = s->parent; + for (m = mounts; m; m = m->next) { +- if (strncmp(path, m->point, m->nlen)) +- continue; +- break; ++ if (s == m && strncmp(path, m->point, m->nlen) == 0) ++ return 1; ++ if (p == m && strncmp(path, p->point, p->nlen) == 0) ++ return 1; + } +- return m; ++ return 0; + } + + extern inline char * handl_buf(char *restrict buf) +@@ -728,19 +729,21 @@ int pidof (const char * inname, const ch if (!(flags & (KTHREAD|KSHORT)) && !isscrpt) { char entry[PATH_MAX+1]; char *realname = NULL; @@ -26,13 +49,13 @@ - if (prefix && find_mount(name) != prefix) - continue; -+ if (find_mount(name) != prefix) ++ if (!find_mount(name, prefix)) + continue; + } if (fstatat(dfd, here(d->d_name, "exe"), &pid_st, 0) < 0) { if (errno != EPERM && errno != EACCES) -@@ -765,12 +767,22 @@ int pidof (const char * inname, const ch +@@ -765,12 +768,22 @@ int pidof (const char * inname, const ch if (strlen(fullname) > PATH_MAX) continue; diff --git a/sysvinit.changes b/sysvinit.changes index e72ecdc..d1227c6 100644 --- a/sysvinit.changes +++ b/sysvinit.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Jan 21 19:26:44 CET 2011 - werner@suse.de + +- Killproc: Do not be fooled if a device is mounted several times + ------------------------------------------------------------------- Tue Nov 9 16:30:56 CET 2010 - werner@suse.de @@ -16,7 +21,7 @@ Wed Oct 27 12:46:16 CEST 2010 - werner@suse.de ------------------------------------------------------------------- Thu Oct 21 12:00:26 CEST 2010 - werner@suse.de -- New killporc version 2.17 +- New killproc version 2.17 * Use /proc/self/mountinfo to avoid system call stat(2) on running binaries not located on the mount point of the current handled program