From a0414ccb1db1391aaad78d0a47a2e2e2725738f1e572a44fd088f318d4e4ae1d Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Mon, 19 Dec 2011 18:20:37 +0000 Subject: [PATCH] . OBS-URL: https://build.opensuse.org/package/show/Base:System/sysvinit?expand=0&rev=160 --- killproc-2.20.dif | 44 ++++++++++++++++++++++----- showconsole-1.15.dif | 72 ++++++++++++++++++++++++++++++++++++++++++++ sysvinit.changes | 6 ++++ 3 files changed, 115 insertions(+), 7 deletions(-) diff --git a/killproc-2.20.dif b/killproc-2.20.dif index b315108..4ad78bb 100644 --- a/killproc-2.20.dif +++ b/killproc-2.20.dif @@ -112,8 +112,38 @@ /* Allocate here: address optarg (current *argv) isn't freeable */ if (optarg && !pid_file) { --- libinit.c -+++ libinit.c 2011-10-18 09:06:23.471646253 +0000 -@@ -570,13 +570,12 @@ static const char * checkscripts(char* e ++++ libinit.c 2011-10-24 10:27:48.559146999 +0000 +@@ -430,7 +430,19 @@ void logprogress(int prio, const char *f + va_end(args); + } + +-/* For mounting the /proc file system */ ++/* ++ * For mounting the /proc file system if missed ++ * and run umount() at exit() for this case. ++ */ ++static void undo_proc(void) ++{ ++#ifdef MNT_DETACH ++ umount2("/proc", MNT_DETACH); ++#else ++ umount("/proc"); ++#endif ++} ++ + void getproc(void) + { + struct stat st; +@@ -441,6 +453,8 @@ void getproc(void) + errno = 0; + if (stat("/proc/version", &st) < 0) + error(100, "/proc not mounted, failed to mount: %s\n", strerror(errno)); ++ ++ atexit(undo_proc); + } + + /* Open the /proc directory, if necessary mounts it */ +@@ -570,13 +584,12 @@ static const char * checkscripts(char* e */ scrpt = (char *)memchr(scrpt, 0, cnt); if (!scrpt || (cnt = len - (++scrpt - ent)) <= 0) @@ -128,7 +158,7 @@ out: if (scrpt && root) { char *ptr = strdupa(scrpt); -@@ -877,8 +876,11 @@ int pidof (const char * inname, const ch +@@ -877,8 +890,11 @@ int pidof (const char * inname, const ch continue; /* Seek for a script not for a binary */ @@ -141,7 +171,7 @@ /* Don't blame our boot scripts having the same name */ if ( (flags & (KILL|DAEMON)) -@@ -1128,7 +1130,7 @@ risky: +@@ -1128,7 +1144,7 @@ risky: return -1; } @@ -150,7 +180,7 @@ (fp = open(proc(buf, "cmdline"), O_PROCMODE)) != -1) { char entry[PATH_MAX+1]; -@@ -1142,15 +1144,18 @@ risky: +@@ -1142,15 +1158,18 @@ risky: goto out; /* Seek for a script not for a binary */ @@ -171,7 +201,7 @@ if ((fp = open(proc(buf, "stat"), O_PROCMODE)) != -1) { char entry[PATH_MAX+1]; -@@ -1313,7 +1318,7 @@ int check_pids (const char * inname, con +@@ -1313,7 +1332,7 @@ int check_pids (const char * inname, con skip = true; /* No stat entry check needed */ } @@ -180,7 +210,7 @@ if (!(flags & (KTHREAD|KSHORT)) && isscrpt && (fp = open(proc(pid, "cmdline"), O_PROCMODE)) != -1) { -@@ -1332,7 +1337,8 @@ risky: +@@ -1332,7 +1351,8 @@ risky: if ((scrpt = checkscripts(entry, root, len, pid))) { if (strcmp(scrpt,fullname) == 0) continue; /* Found */ diff --git a/showconsole-1.15.dif b/showconsole-1.15.dif index 6e3c772..678e0ce 100644 --- a/showconsole-1.15.dif +++ b/showconsole-1.15.dif @@ -1,3 +1,75 @@ +--- libconsole.c ++++ libconsole.c 2011-12-19 18:11:00.323146490 +0000 +@@ -1154,14 +1154,45 @@ static dev_t fallback(const pid_t pid, c + + static int checkdev(char ** retname, const dev_t dev, DIR * ddev) + { +- int found = 0; +- struct dirent * d; +- struct stat st; ++ int found = 0, fd; ++ struct dirent *d; + static int deep; + +- memset(&st, 0, sizeof(struct stat)); +- while ((d = readdir(ddev))) { +- char * name = d->d_name; ++ if (deep == 0) { ++ ++ fd = dirfd(ddev); ++ rewinddir(ddev); ++ ++ while ((d = readdir(ddev))) { /* First scan all devices direct in /dev/ of devtmpfs */ ++ struct stat st; ++ char *name = d->d_name; ++ char path[PATH_MAX+1]; ++ ++ if (*name == '.') ++ continue; ++ if (fstatat(fd, name, &st, 0) < 0) ++ continue; ++ if (!S_ISCHR(st.st_mode)) ++ continue; ++ if (dev != st.st_rdev) ++ continue; ++ if ((size_t)snprintf(path, sizeof(path), "/dev/%s", name) >= sizeof(path)) ++ continue; ++ name = realpath(path, NULL); ++ if (!name) ++ break; ++ *retname = name; ++ found++; ++ break; ++ } ++ if (found) ++ goto out; ++ } ++ ++ rewinddir(ddev); ++ while ((d = readdir(ddev))) { /* now allow also deeper entries of none devtmpfs */ ++ struct stat st; ++ char *name = d->d_name; + + if (*name == '.') + continue; +@@ -1306,7 +1337,7 @@ static int checkdev(char ** retname, con + *retname = name; + break; + } +- ++out: + return found; + } + +@@ -1448,7 +1479,7 @@ char * fetchtty(const pid_t pid, const p + if (!(name = ttyname(0)) || !strcmp(name, "/dev/console")) + dev = fallback(pid, ppid); + else { +- name = strdup(name); ++ name = realpath(name, NULL); + if (!name) + error("fetchtty(): %m\n"); + goto out; --- showconsole.8 +++ showconsole.8 2011-09-08 15:13:48.000000000 +0000 @@ -8,7 +8,6 @@ diff --git a/sysvinit.changes b/sysvinit.changes index 9e6c82f..7f370eb 100644 --- a/sysvinit.changes +++ b/sysvinit.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon Dec 19 18:13:19 UTC 2011 - werner@suse.de + +- Avoid trouble with indirect console names (bnc#731563) +- Unmount proc file system if initial not mounted (bnc#718385) + ------------------------------------------------------------------- Thu Oct 20 12:31:09 UTC 2011 - werner@suse.de