Author: guillem Date: 2006-03-20 01:22:43 +0000 (Mon, 20 Mar 2006) New Revision: 198
Modified: trunk/ChangeLog trunk/debian/changelog trunk/utils/start-stop-daemon.c Log: Change start-stop-daemon's --exec behaviour again on GNU/Linux to compare the referred file pointed by the '/proc/<pid>/exe' symlink, stripping any ' (deleted)' string and stating the result. Closes: #354867 Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-19 18:43:33 UTC (rev 197) +++ trunk/ChangeLog 2006-03-20 01:22:43 UTC (rev 198) @@ -1,3 +1,10 @@ +2006-03-20 Guillem Jover <[EMAIL PROTECTED]> + + * utils/start-stop-daemon.c [OSLinux] (pid_is_exec): Revert back to + take a struct stat instead of an execname. Get the filename pointed + by the '/proc/<pid>/exe' symlink, strip any ' (deleted)' string, and + stat that filename comparing the result with the new argument. + 2006-03-15 Guillem Jover <[EMAIL PROTECTED]> * scripts/controllib.pl.in: Rename to ... Modified: trunk/debian/changelog =================================================================== --- trunk/debian/changelog 2006-03-19 18:43:33 UTC (rev 197) +++ trunk/debian/changelog 2006-03-20 01:22:43 UTC (rev 198) @@ -17,6 +17,9 @@ * Don't try to compile in SELinux support on GNU/kFreeBSD amd64. * Add new quiet option to dpkg-source to supress warnings. Closes: #355065 * Do not expand architecture aliases anymore in .dsc files. + * Change start-stop-daemon's --exec behaviour again on GNU/Linux to compare + the referred file pointed by the '/proc/<pid>/exe' symlink, stripping + any ' (deleted)' string and stating the result. Closes: #354867 [ Updated man pages translations ] * Polish (Robert Luberda). Closes: #353782 Modified: trunk/utils/start-stop-daemon.c =================================================================== --- trunk/utils/start-stop-daemon.c 2006-03-19 18:43:33 UTC (rev 197) +++ trunk/utils/start-stop-daemon.c 2006-03-20 01:22:43 UTC (rev 198) @@ -174,9 +174,7 @@ static void do_pidfile(const char *name); static void do_stop(int signal_nr, int quietmode, int *n_killed, int *n_notkilled, int retry_nr); -#if defined(OSLinux) -static int pid_is_exec(pid_t pid, const char *name); -#elif defined(OShpux) +#if defined(OSLinux) || defined(OShpux) static int pid_is_exec(pid_t pid, const struct stat *esb); #endif @@ -611,29 +609,27 @@ #if defined(OSLinux) static int -pid_is_exec(pid_t pid, const char *name) +pid_is_exec(pid_t pid, const struct stat *esb) { char lname[32]; - char *lcontents; - int lcontlen, nread, res; + char lcontents[_POSIX_PATH_MAX]; + const char deleted[] = " (deleted)"; + int nread; + struct stat sb; - /* Allow one extra character for the link contents, which should - * be enough to determine if the file names are the same. */ - lcontlen = strlen(name) + 1; - lcontents = xmalloc(lcontlen); sprintf(lname, "/proc/%d/exe", pid); - nread = readlink(lname, lcontents, lcontlen); - if (nread == -1) { - free(lcontents); + nread = readlink(lname, lcontents, sizeof(lcontents)); + if (nread == -1) return 0; - } - if (nread < lcontlen) - lcontents[nread] = '\0'; - res = (strncmp(lcontents, name, lcontlen) == 0); - free(lcontents); + lcontents[nread] = '\0'; + if (strcmp(lcontents + nread - strlen(deleted), deleted) == 0) + lcontents[nread - strlen(deleted)] = '\0'; - return res; + if (stat(lcontents, &sb) != 0) + return 0; + + return (sb.st_dev == esb->st_dev && sb.st_ino == esb->st_ino); } @@ -763,9 +759,7 @@ static void check(pid_t pid) { -#if defined(OSLinux) - if (execname && !pid_is_exec(pid, execname)) -#elif defined(OShpux) +#if defined(OSLinux) || defined(OShpux) if (execname && !pid_is_exec(pid, &exec_stat)) #elif defined(OSHURD) || defined(OSFreeBSD) || defined(OSNetBSD) /* I will try this to see if it works */ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]