+2006-03-20 Guillem Jover <guillem@debian.org>
+
+ * 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 <guillem@debian.org>
* scripts/controllib.pl.in: Rename to ...
* 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
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
#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';
+
+ if (stat(lcontents, &sb) != 0)
+ return 0;
- return res;
+ return (sb.st_dev == esb->st_dev && sb.st_ino == esb->st_ino);
}
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 */