[dpkg] 105/200: s-s-d: Use the new process executable support in GNU/Hurd

Ximin Luo infinity0 at debian.org
Wed Apr 5 15:17:25 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository dpkg.

commit 10b38de76c904bedc2aa6776248bcc1085bad6f0
Author: Guillem Jover <guillem at debian.org>
Date:   Wed Jan 18 01:33:18 2017 +0100

    s-s-d: Use the new process executable support in GNU/Hurd
    
    This gives the actual executable name instead of having to look into
    argv[0], which is not really correct, as the program doing execve()
    can set that to anything it likes.
    
    We have to check for the name being NULL or empty due to an initial
    implementation bug.
---
 debian/changelog          |  3 +++
 utils/start-stop-daemon.c | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index cbf37b4..3f83250 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,9 @@
 dpkg (1.18.19) UNRELEASED; urgency=medium
 
   [ Guillem Jover ]
+  * Portability:
+    - On GNU/Hurd try to use the new process executable name attribute from
+      libps, to properly match on start-stop-daemon --exec.
   * Perl modules:
     - Fix Debian architecture wildcard parsing so that matching four-tuple
       matchings work. Missed in dpkg 1.18.11.
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c
index 9d127ec..b641bc6 100644
--- a/utils/start-stop-daemon.c
+++ b/utils/start-stop-daemon.c
@@ -1422,7 +1422,19 @@ pid_is_exec(pid_t pid, const struct stat *esb)
 	if (ps == NULL)
 		return false;
 
+	/* On old Hurd systems we have to use the argv[0] value, because
+	 * there is nothing better. */
 	filename = proc_stat_args(ps);
+#ifdef PSTAT_EXE
+	/* On new Hurd systems we can use the correct value, as long
+	 * as it's not NULL nor empty, as it was the case on the first
+	 * implementation. */
+	if (proc_stat_set_flags(ps, PSTAT_EXE) == 0 &&
+	    proc_stat_flags(ps) & PSTAT_EXE &&
+	    proc_stat_exe(ps) != NULL &&
+	    proc_stat_exe(ps)[0] != '\0')
+		filename = proc_stat_exe(ps);
+#endif
 
 	if (stat(filename, &sb) != 0)
 		return false;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list