From 1149ce5018413b3fe1f3db96c8c98d6dc410efeb7e371dac3fef0b74c87e9ed8 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Wed, 9 Feb 2011 09:30:06 +0000 Subject: [PATCH] . OBS-URL: https://build.opensuse.org/package/show/Base:System/sysvinit?expand=0&rev=96 --- killproc-2.18.dif | 82 +++++++++++++++++++++++++++++++++++++++++++++++ sysvinit.changes | 1 + 2 files changed, 83 insertions(+) diff --git a/killproc-2.18.dif b/killproc-2.18.dif index 02b8658..91454f7 100644 --- a/killproc-2.18.dif +++ b/killproc-2.18.dif @@ -74,3 +74,85 @@ } } +--- mkill.c ++++ mkill.c 2011-02-09 09:21:58.369993020 +0000 +@@ -172,7 +172,7 @@ int main(int argc, char* argv[]) + const size_t alen = strlen(argv[num]); + char * astr = argv[num]; + +- if (alen == 0) ++ if (alen <= 1) + continue; + + if (*(astr+(alen-1)) == '/') +@@ -192,8 +192,9 @@ int main(int argc, char* argv[]) + char line[BUFSIZ+1]; + char path[256]; + char * slash; ++ char * pline; + ssize_t len; +- FILE * maps; ++ FILE * file; + DIR * fdir; + int order; + int dffd; +@@ -222,6 +223,16 @@ int main(int argc, char* argv[]) + slash = &path[len]; + + *slash = '\0'; ++ strcat(slash, "/statm"); ++ ++ if ((file = fopenat(dfd, path)) == (FILE*)0) ++ continue; ++ pline = fgets(line, BUFSIZ, file); ++ fclose(file); ++ if (!pline || line[0] == '0') ++ continue; ++ ++ *slash = '\0'; + strcat(slash, "/root"); + + errno = 0; +@@ -262,9 +273,9 @@ int main(int argc, char* argv[]) + *slash = '\0'; + strcat(slash, "/maps"); + +- if ((maps = fopenat(dfd, path)) == (FILE*)0) ++ if ((file = fopenat(dfd, path)) == (FILE*)0) + continue; +- while (fgets(line, BUFSIZ, maps)) { ++ while (fgets(line, BUFSIZ, file)) { + if (sscanf(line, "%*s %*s %*s %*x:%*x %*d %s", name) == 1) { + + if (name[0] == '\0' || name[0] == '[') +@@ -277,7 +288,7 @@ int main(int argc, char* argv[]) + } + if (found) break; + } +- (void)fclose(maps); ++ (void)fclose(file); + + if (found) { + add_proc(curr, order); +@@ -469,7 +480,6 @@ static void init_mnt(int argc, char* arg + return; + } + +- + if ((mnt = setmntent("/proc/mounts", "r")) == (FILE*)0) + error(100, "cannot open /proc/mounts: %s\n", strerror(errno)); + +@@ -619,6 +629,13 @@ static int check(const char *restrict na + mntent_t *p = list_entry(ptr, mntent_t); + if (nlen < p->nlen) + continue; ++ if (p->nlen == 1) { ++ if (nlen == 1) ++ return p->order; ++ if (shadow(&p->shadow.this, name, nlen)) ++ continue; ++ return p->order; ++ } + if (name[p->nlen] != '\0' && name[p->nlen] != '/') + continue; + if (strncmp(name, p->name, p->nlen) == 0) { diff --git a/sysvinit.changes b/sysvinit.changes index d21a14c..0f0a5ff 100644 --- a/sysvinit.changes +++ b/sysvinit.changes @@ -3,6 +3,7 @@ Tue Feb 8 18:55:21 UTC 2011 - werner@suse.de - Make real device comparision in killproc/checkproc to fix bnc#644171 - Also make ignore mode in checkproc work +- Enhance mkill to work on root fs and ignore kernel threads ------------------------------------------------------------------- Mon Feb 7 13:26:19 CET 2011 - werner@novell.com