Dr. Werner Fink 2011-01-21 18:32:25 +00:00 committed by Git OBS Bridge
parent 9ff6380882
commit 8bb2146fd5
2 changed files with 33 additions and 5 deletions

View File

@ -1,6 +1,29 @@
--- libinit.c --- libinit.c
+++ libinit.c 2010-10-27 08:17:06.371926813 +0000 +++ libinit.c 2011-01-21 18:25:49.019926024 +0000
@@ -728,19 +728,21 @@ int pidof (const char * inname, const ch @@ -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) { if (!(flags & (KTHREAD|KSHORT)) && !isscrpt) {
char entry[PATH_MAX+1]; char entry[PATH_MAX+1];
char *realname = NULL; char *realname = NULL;
@ -26,13 +49,13 @@
- if (prefix && find_mount(name) != prefix) - if (prefix && find_mount(name) != prefix)
- continue; - continue;
+ if (find_mount(name) != prefix) + if (!find_mount(name, prefix))
+ continue; + continue;
+ } + }
if (fstatat(dfd, here(d->d_name, "exe"), &pid_st, 0) < 0) { if (fstatat(dfd, here(d->d_name, "exe"), &pid_st, 0) < 0) {
if (errno != EPERM && errno != EACCES) 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) if (strlen(fullname) > PATH_MAX)
continue; continue;

View File

@ -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 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 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 * Use /proc/self/mountinfo to avoid system call stat(2) on
running binaries not located on the mount point of the running binaries not located on the mount point of the
current handled program current handled program