From: Guillem Jover Date: Tue, 4 Apr 2006 01:55:37 +0000 (+0000) Subject: Prefix any chroot path to the exec file name when stating it in X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d091d9298baab78cb068097e1533b812336df232;p=dpkg Prefix any chroot path to the exec file name when stating it in start-stop-daemon. Closes: #318771, #333066 --- diff --git a/ChangeLog b/ChangeLog index 234e1ebd..0af650c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-04-04 Guillem Jover + + * utils/start-stop-daemon.c (main): Prefix the chroot path, if any, + when stating the exec file. + 2006-03-30 Guillem Jover * src/main.c (setforce): Add a '[!]' next to 'all' to denote that diff --git a/debian/changelog b/debian/changelog index 31531842..7262d743 100644 --- a/debian/changelog +++ b/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 Tue, 21 Mar 2006 20:46:24 +0100 diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c index 86075fa1..3bfc03d9 100644 --- a/utils/start-stop-daemon.c +++ b/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;