]> err.no Git - dpkg/commitdiff
Prefix any chroot path to the exec file name when stating it in
authorGuillem Jover <guillem@debian.org>
Tue, 4 Apr 2006 01:55:37 +0000 (01:55 +0000)
committerGuillem Jover <guillem@debian.org>
Tue, 4 Apr 2006 01:55:37 +0000 (01:55 +0000)
start-stop-daemon. Closes: #318771, #333066

ChangeLog
debian/changelog
utils/start-stop-daemon.c

index 234e1ebd25cc87536b9186533ae0555820479985..0af650c41d89ce0971c395cb6a61f08e45b60a1a 100644 (file)
--- a/ChangeLog
+++ b/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
index 31531842b9a8a8de4e55e1c515a1acd7460e4547..7262d743fc58b0229e04f2968635dd1a009b5ba5 100644 (file)
@@ -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
 
index 86075fa171159e374ce8462dffff5a33c09c1001..3bfc03d95b4461ac5f0501b2bdf88927117ef8d4 100644 (file)
@@ -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;