浏览代码

s-s-d: Warn if --name argument is longer than supported by kernel

Most kernels have a length limit on the process name stored in-kernel.
For now the checks done on Linux compatible procfs might hit this limit
and be unable to properly track the correct process. So warn in that
case and recommend switching to the more reliable --exec.

Closes: #353015, #519128
Guillem Jover 17 年之前
父节点
当前提交
bfda32490d
共有 2 个文件被更改,包括 14 次插入0 次删除
  1. 2 0
      debian/changelog
  2. 12 0
      utils/start-stop-daemon.c

+ 2 - 0
debian/changelog

@@ -133,6 +133,8 @@ dpkg (1.15.1) UNRELEASED; urgency=low
   * Make deprecated dpkg-scanpackages --udeb option produce a warning.
   * Make deprecated dpkg-scanpackages --udeb option produce a warning.
   * Change dpkg-source --help output to state there's no default substvar
   * Change dpkg-source --help output to state there's no default substvar
     file to match reality.
     file to match reality.
+  * Warn in start-stop-daemon if the argument to --name is longer than the
+    supported kernel process name size. Closes: #353015, #519128
 
 
   [ Frank Lichtenheld ]
   [ Frank Lichtenheld ]
   * Dpkg::Version: Remove unnecessary function next_elem which just
   * Dpkg::Version: Remove unnecessary function next_elem which just

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

@@ -115,6 +115,11 @@
 #include <sys/syscall.h>
 #include <sys/syscall.h>
 #endif
 #endif
 
 
+#if defined(OSLinux)
+/* This comes from TASK_COMM_LEN defined in linux's include/linux/sched.h. */
+#define PROCESS_NAME_SIZE 15
+#endif
+
 #if defined(SYS_ioprio_set) && defined(linux)
 #if defined(SYS_ioprio_set) && defined(linux)
 #define HAVE_IOPRIO_SET
 #define HAVE_IOPRIO_SET
 #endif
 #endif
@@ -842,6 +847,13 @@ parse_options(int argc, char * const *argv)
 	if (!execname && !pidfile && !userspec && !cmdname)
 	if (!execname && !pidfile && !userspec && !cmdname)
 		badusage("need at least one of --exec, --pidfile, --user or --name");
 		badusage("need at least one of --exec, --pidfile, --user or --name");
 
 
+#ifdef PROCESS_NAME_SIZE
+	if (cmdname && strlen(cmdname) > PROCESS_NAME_SIZE)
+		warning("this system is not able to track process names\n"
+		        "longer than %d characters, please use --exec "
+		        "instead of --name.\n", PROCESS_NAME_SIZE);
+#endif
+
 	if (!startas)
 	if (!startas)
 		startas = execname;
 		startas = execname;