Dr. Werner Fink 2011-12-19 18:20:37 +00:00 committed by Git OBS Bridge
parent d81eb40368
commit a0414ccb1d
3 changed files with 115 additions and 7 deletions

View File

@ -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 */

View File

@ -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 @@

View File

@ -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