Dr. Werner Fink 2011-04-15 14:49:26 +00:00 committed by Git OBS Bridge
parent a6b89f0078
commit 3e1ddbda16
2 changed files with 64 additions and 12 deletions

View File

@ -1,6 +1,35 @@
--- libinit.c --- libinit.c
+++ libinit.c 2011-03-03 13:45:42.976427260 +0000 +++ libinit.c 2011-04-06 13:21:49.212425737 +0000
@@ -669,6 +669,7 @@ int pidof (const char * inname, const ch @@ -349,18 +349,24 @@ static int find_mount(const char * path,
{
const size_t nlen = strlen(path);
list_t *ptr;
+ int ret = 0;
list_for_each(ptr, &mounts) {
MNTINFO *m = list_entry(ptr, MNTINFO);
if (nlen < m->nlen)
continue;
- if (m->nlen == 1) /* root fs is the last entry */
- return (m == s);
+ if (m->nlen == 1 && (m == s)) { /* root fs is the last entry */
+ ret++;
+ break;
+ }
if (strncmp(path, m->point, m->nlen))
continue;
- return (m == s);
+ if (m == s) {
+ ret++;
+ break;
+ }
}
- return 0;
+ return ret;
}
extern inline char * handl_buf(char *restrict buf)
@@ -669,6 +675,7 @@ int pidof (const char * inname, const ch
boolean isscrpt = false; boolean isscrpt = false;
unsigned num = 0; unsigned num = 0;
pid_t pid; pid_t pid;
@ -8,7 +37,7 @@
char *swapname = NULL; char *swapname = NULL;
char *fullname = (char *)inname; char *fullname = (char *)inname;
char *realname = NULL; char *realname = NULL;
@@ -677,6 +678,7 @@ int pidof (const char * inname, const ch @@ -677,6 +684,7 @@ int pidof (const char * inname, const ch
p_pid = getpid(); p_pid = getpid();
p_ppid = getppid(); p_ppid = getppid();
@ -16,7 +45,7 @@
dir = openproc(); /* Open /proc and maybe do mount before */ dir = openproc(); /* Open /proc and maybe do mount before */
p_pppid = getpppid(p_ppid); /* Requires existence of /proc */ p_pppid = getpppid(p_ppid); /* Requires existence of /proc */
@@ -773,6 +775,13 @@ int pidof (const char * inname, const ch @@ -773,6 +781,13 @@ int pidof (const char * inname, const ch
if (prefix) { if (prefix) {
if ((rll = readlinkat(dfd, here(d->d_name, "exe"), entry, PATH_MAX)) < 0) { if ((rll = readlinkat(dfd, here(d->d_name, "exe"), entry, PATH_MAX)) < 0) {
@ -30,7 +59,7 @@
if (errno != EPERM && errno != EACCES) if (errno != EPERM && errno != EACCES)
goto risky; goto risky;
continue; continue;
@@ -809,6 +818,13 @@ int pidof (const char * inname, const ch @@ -809,6 +824,13 @@ int pidof (const char * inname, const ch
if (!name) { if (!name) {
if ((rll = readlinkat(dfd, here(d->d_name, "exe"), entry, PATH_MAX)) < 0) { if ((rll = readlinkat(dfd, here(d->d_name, "exe"), entry, PATH_MAX)) < 0) {
@ -44,7 +73,7 @@
if (errno != EPERM && errno != EACCES) if (errno != EPERM && errno != EACCES)
goto risky; goto risky;
continue; continue;
@@ -825,7 +841,6 @@ int pidof (const char * inname, const ch @@ -825,7 +847,6 @@ int pidof (const char * inname, const ch
if (realname && strncmp(realname, name, PATH_MAX) == 0) if (realname && strncmp(realname, name, PATH_MAX) == 0)
found = true; found = true;
@ -52,7 +81,7 @@
break; break;
} }
@@ -942,12 +957,15 @@ int verify_pidfile (const char * pid_fil @@ -942,12 +963,15 @@ int verify_pidfile (const char * pid_fil
ssize_t cnt; ssize_t cnt;
boolean isscrpt = false; boolean isscrpt = false;
pid_t pid; pid_t pid;
@ -68,7 +97,7 @@
if (!ignore) { if (!ignore) {
list_t *m, *n; list_t *m, *n;
list_for_each_safe(m, n, &remember) { list_for_each_safe(m, n, &remember) {
@@ -1041,14 +1059,23 @@ int verify_pidfile (const char * pid_fil @@ -1041,14 +1065,23 @@ int verify_pidfile (const char * pid_fil
} }
errno = 0; errno = 0;
@ -95,7 +124,7 @@
if (pid_st.st_dev != full_st.st_dev) if (pid_st.st_dev != full_st.st_dev)
goto out; goto out;
@@ -1087,6 +1114,7 @@ int verify_pidfile (const char * pid_fil @@ -1087,6 +1120,7 @@ int verify_pidfile (const char * pid_fil
goto out; goto out;
} }
@ -103,7 +132,7 @@
if (errno && errno != ENOENT) { if (errno && errno != ENOENT) {
warn("Can not read %s: %s\n", procbuf, strerror(errno)); warn("Can not read %s: %s\n", procbuf, strerror(errno));
@@ -1162,8 +1190,11 @@ int check_pids (const char * inname, con @@ -1162,8 +1196,11 @@ int check_pids (const char * inname, con
const char *pid; const char *pid;
struct stat pid_st, full_st; struct stat pid_st, full_st;
list_t *m, *n; list_t *m, *n;
@ -115,7 +144,7 @@
if (!fullname) { if (!fullname) {
warn("program or process name required\n"); warn("program or process name required\n");
return -1; return -1;
@@ -1228,13 +1259,22 @@ int check_pids (const char * inname, con @@ -1228,13 +1265,22 @@ int check_pids (const char * inname, con
/* killproc and daemon/startproc should use the full path */ /* killproc and daemon/startproc should use the full path */
errno = 0; errno = 0;
@ -141,7 +170,7 @@
if (pid_st.st_dev != full_st.st_dev) if (pid_st.st_dev != full_st.st_dev)
goto ignore; /* Does not belong to rembered list */ goto ignore; /* Does not belong to rembered list */
@@ -1267,6 +1307,7 @@ int check_pids (const char * inname, con @@ -1267,6 +1313,7 @@ int check_pids (const char * inname, con
skip = true; /* No stat entry check needed */ skip = true; /* No stat entry check needed */
} }
@ -149,3 +178,14 @@
if (!(flags & (KTHREAD|KSHORT)) && isscrpt && if (!(flags & (KTHREAD|KSHORT)) && isscrpt &&
(fp = open(proc(pid, "cmdline"), O_PROCMODE)) != -1) { (fp = open(proc(pid, "cmdline"), O_PROCMODE)) != -1) {
--- libinit.h
+++ libinit.h 2011-04-15 14:43:35.083926074 +0000
@@ -91,7 +91,7 @@
#define WRGSYNTAX 102 /* usage etc. */
#define NOPIDREAD 101 /* trouble */
-#define LSB_STATUS_PROOF ((errno == EPERM || errno == EACCES) ? LSB_NOPERM : NOPIDREAD )
+#define LSB_STATUS_PROOF ((errno == EPERM || errno == EACCES) ? LSB_NOPERM : LSB_STATUS_ISDEAD )
#define LSB_STATUS_PROOFX ((errno == ENOENT) ? (flags & KILL) ? LSB_NOENTR : 4 : LSB_STATUS_PROOF )
#define LOG_OPTIONS (LOG_ODELAY|LOG_CONS)

View File

@ -1,3 +1,15 @@
------------------------------------------------------------------
Fri Apr 15 16:47:43 CEST 2011 - werner@suse.de
- Fix exit code of checkproc in case of an existing pid file
without running process (bnc#687547)
------------------------------------------------------------------
Wed Apr 6 15:22:20 CEST 2011 - werner@suse.de
- Fix bug in killproc that is do not stop searching for a match if
a mountpoint does not match, reported by Friedrich Haubensak.
------------------------------------------------------------------ ------------------------------------------------------------------
Fri Apr 1 15:00:19 CEST 2011 - werner@suse.de Fri Apr 1 15:00:19 CEST 2011 - werner@suse.de