Explorar el Código

Prefix any chroot path to the exec file name when stating it in
start-stop-daemon. Closes: #318771, #333066

Guillem Jover hace 20 años
padre
commit
d091d9298b
Se han modificado 3 ficheros con 26 adiciones y 2 borrados
  1. 5 0
      ChangeLog
  2. 2 0
      debian/changelog
  3. 19 2
      utils/start-stop-daemon.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2006-04-04  Guillem Jover  <guillem@debian.org>
+
+	* utils/start-stop-daemon.c (main): Prefix the chroot path, if any,
+	when stating the exec file.
+
 2006-03-30  Guillem Jover  <guillem@debian.org>
 
 	* src/main.c (setforce): Add a '[!]' next to 'all' to denote that

+ 2 - 0
debian/changelog

@@ -21,6 +21,8 @@ dpkg (1.13.18~) UNRELEASED; urgency=low
   [ Guillem Jover ]
   * Add a '[!]' in --force-all help denoting that it is a dangerous option.
     Closes: #359935
+  * Prefix any chroot path to the exec file name when stating it in
+    start-stop-daemon. Closes: #318771, #333066
 
  -- Christian Perrier <bubulle@debian.org>  Tue, 21 Mar 2006 20:46:24 +0100
 

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

@@ -1193,8 +1193,25 @@ main(int argc, char **argv)
 	argc -= optind;
 	argv += optind;
 
-	if (execname && stat(execname, &exec_stat))
-		fatal("stat %s: %s", execname, strerror(errno));
+	if (execname) {
+		char *fullexecname;
+
+		if (changeroot) {
+			int fullexecname_len = strlen(changeroot) + 1 +
+					       strlen(execname) + 1;
+
+			fullexecname = xmalloc(fullexecname_len);
+			snprintf(fullexecname, fullexecname_len, "%s/%s",
+				 changeroot, execname);
+		} else
+			fullexecname = execname;
+
+		if (stat(fullexecname, &exec_stat))
+			fatal("stat %s: %s", fullexecname, strerror(errno));
+
+		if (fullexecname != execname)
+			free(fullexecname);
+	}
 
 	if (userspec && sscanf(userspec, "%d", &user_id) != 1) {
 		struct passwd *pw;