The following commit has been merged in the master branch:
commit 873c0d7d717ae97ea3cc4309c1df6993137b3e21
Author: Guillem Jover <[email protected]>
Date:   Wed Mar 2 06:06:33 2011 +0100

    dpkg: Pass correct DPKG_ADMINDIR to maintainer scripts with --root
    
    When passing the DPKG_ADMINDIR environment variable to the maintainer
    scripts we need to trim the installation directory name from admindir,
    otherwise the directory won't be found.
    
    Regression introduced in commit e63e1fa4a4afdf98847f13f2506a0aeea68c33c7.
    
    Based-on-patch-by: Steve Langasek <[email protected]>
    Improved-by: Jonathan Nieder <[email protected]>

diff --git a/src/help.c b/src/help.c
index f232891..9bbe3be 100644
--- a/src/help.c
+++ b/src/help.c
@@ -176,16 +176,18 @@ force_conflicts(struct deppossi *possi)
 
 /**
  * Returns the path to the script inside the chroot.
- *
- * FIXME: None of the stuff here will work if admindir isn't inside
- * instdir as expected.
  */
 static const char *
 preexecscript(struct command *cmd)
 {
-  size_t instdirl;
+  size_t instdirl = strlen(instdir);
 
   if (*instdir) {
+    if (strncmp(admindir, instdir, instdirl) != 0)
+      ohshit(_("admindir must be inside instdir for dpkg to work properly"));
+    if (setenv("DPKG_ADMINDIR", admindir + instdirl, 1) < 0)
+      ohshite(_("unable to setenv for subprocesses"));
+
     if (chroot(instdir)) ohshite(_("failed to chroot to `%.250s'"),instdir);
     if (chdir("/"))
       ohshite(_("failed to chdir to `%.255s'"), "/");
@@ -202,7 +204,6 @@ preexecscript(struct command *cmd)
     debug(dbg_scripts, "fork/exec %s (%s )", cmd->filename, args.buf);
     varbuf_destroy(&args);
   }
-  instdirl= strlen(instdir);
   if (!instdirl)
     return cmd->filename;
   assert(strlen(cmd->filename) >= instdirl);

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to