Просмотр исходного кода

s-s-d: Fix --name matching on GNU/Hurd

The pid_is_cmd() function was not stripping the prefix directories from
the process argv[0] pathname.
Guillem Jover лет назад: 14
Родитель
Сommit
fb560a34ef
2 измененных файлов с 13 добавлено и 2 удалено
  1. 1 0
      debian/changelog
  2. 12 2
      utils/start-stop-daemon.c

+ 1 - 0
debian/changelog

@@ -52,6 +52,7 @@ dpkg (1.16.2) UNRELEASED; urgency=low
     Reported by Daniel Ruoso <daniel@ruoso.com>. Closes: #655411
   * Fix start-stop-daemon --exec and --name options on FreeBSD, NetBSD and
     OpenBSD by swapping the process matching implementations.
+  * Fix start-stop-daemon --name option on GNU/Hurd to match the process name.
 
   [ Raphaël Hertzog ]
   * Update Dpkg::Shlibs to look into multiarch paths when cross-building

+ 12 - 2
utils/start-stop-daemon.c

@@ -1064,9 +1064,13 @@ static bool pid_is_cmd(pid_t pid, const char *name);
 static bool
 pid_is_exec(pid_t pid, const char *name)
 {
+	char *filename;
 	bool ret;
 
-	ret = pid_is_cmd(pid, name);
+	filename = xstrdup(name);
+	basename(filename);
+	ret = pid_is_cmd(pid, filename);
+	free(filename);
 
 	return ret;
 }
@@ -1157,9 +1161,15 @@ static bool
 pid_is_cmd(pid_t pid, const char *name)
 {
 	struct proc_stat *ps;
+	const char *process_name;
 
 	ps = get_proc_stat(pid, PSTAT_ARGS);
-	return ps && !strcmp(proc_stat_args(ps), name);
+	if (ps == NULL)
+		return false;
+
+	process_name = basename(proc_stat_args(ps));
+
+	return strcmp(process_name, name) == 0;
 }
 #elif defined(OShpux)
 static bool