FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian dpkg

 
 
LinkBack Thread Tools
 
Old 03-01-2011, 09:45 PM
Steve Langasek
 
Default Correct passing of DPKG_ADMINDIR to maintainer scripts with --root

Fix up the DPKG_ADMINDIR env var being passed to maintainer scripts when
running with --root; we need to prune the root directory name from the front
of the admindir we set for chrooted processes, otherwise the directory won't
be found.
---
src/help.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/help.c b/src/help.c
index 551592a..ef9fa8d 100644
--- a/src/help.c
+++ b/src/help.c
@@ -186,6 +186,11 @@ preexecscript(struct command *cmd)
size_t instdirl;

if (*instdir) {
+ if (strstr(admindir, instdir) == admindir)
+ /* Already forked, safe to modify the environment; strip off the chroot
+ path from our admin dir so this works under the chroot */
+ if (setenv("DPKG_ADMINDIR", admindir+strlen(instdir), 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'"), "/");
--
1.7.1


--
To UNSUBSCRIBE, email to debian-dpkg-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 1299019547-31283-1-git-send-email-steve.langasek@linaro.org">http://lists.debian.org/1299019547-31283-1-git-send-email-steve.langasek@linaro.org
 
Old 03-01-2011, 10:11 PM
Jonathan Nieder
 
Default Correct passing of DPKG_ADMINDIR to maintainer scripts with --root

Hi Steve,

Steve Langasek wrote:

> --- a/src/help.c
> +++ b/src/help.c
> @@ -186,6 +186,11 @@ preexecscript(struct command *cmd)
> size_t instdirl;
>
> if (*instdir) {
> + if (strstr(admindir, instdir) == admindir)
> + /* Already forked, safe to modify the environment; strip off the chroot
> + path from our admin dir so this works under the chroot */
> + if (setenv("DPKG_ADMINDIR", admindir+strlen(instdir), 1) < 0)
> + ohshite(_("unable to setenv for subprocesses"));

strstr can be slow. Why not:

size_t instdirlen = strlen(instdir);
if (strncmp(admindir, instdir, instdirlen) == 0) {
/* ... explanatory comment ... */
if (setenv("DPKG_ADMINDIR", admindir + instdirlen, 1) < 0)
ohshite(_(...));
}

Thanks,
Jonathan


--
To UNSUBSCRIBE, email to debian-dpkg-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20110301231044.GA9490@elie">http://lists.debian.org/20110301231044.GA9490@elie
 
Old 03-01-2011, 10:18 PM
Steve Langasek
 
Default Correct passing of DPKG_ADMINDIR to maintainer scripts with --root

On Tue, Mar 01, 2011 at 05:11:05PM -0600, Jonathan Nieder wrote:
> Hi Steve,

> Steve Langasek wrote:

> > --- a/src/help.c
> > +++ b/src/help.c
> > @@ -186,6 +186,11 @@ preexecscript(struct command *cmd)
> > size_t instdirl;
> >
> > if (*instdir) {
> > + if (strstr(admindir, instdir) == admindir)
> > + /* Already forked, safe to modify the environment; strip off the chroot
> > + path from our admin dir so this works under the chroot */
> > + if (setenv("DPKG_ADMINDIR", admindir+strlen(instdir), 1) < 0)
> > + ohshite(_("unable to setenv for subprocesses"));

> strstr can be slow. Why not:

> size_t instdirlen = strlen(instdir);
> if (strncmp(admindir, instdir, instdirlen) == 0) {
> /* ... explanatory comment ... */
> if (setenv("DPKG_ADMINDIR", admindir + instdirlen, 1) < 0)
> ohshite(_(...));
> }

Agreed, that's better. strstr was just the closest hammer I had to hand
when trying to unbreak this quickly.

--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer http://www.debian.org/
slangasek@ubuntu.com vorlon@debian.org
 
Old 03-02-2011, 04:19 AM
Guillem Jover
 
Default Correct passing of DPKG_ADMINDIR to maintainer scripts with --root

Hi!

On Tue, 2011-03-01 at 17:11:05 -0600, Jonathan Nieder wrote:
> Steve Langasek wrote:
> > --- a/src/help.c
> > +++ b/src/help.c
> > @@ -186,6 +186,11 @@ preexecscript(struct command *cmd)
> > size_t instdirl;
> >
> > if (*instdir) {
> > + if (strstr(admindir, instdir) == admindir)
> > + /* Already forked, safe to modify the environment; strip off the chroot
> > + path from our admin dir so this works under the chroot */
> > + if (setenv("DPKG_ADMINDIR", admindir+strlen(instdir), 1) < 0)
> > + ohshite(_("unable to setenv for subprocesses"));
>
> strstr can be slow. Why not:
>
> size_t instdirlen = strlen(instdir);
> if (strncmp(admindir, instdir, instdirlen) == 0) {
> /* ... explanatory comment ... */
> if (setenv("DPKG_ADMINDIR", admindir + instdirlen, 1) < 0)
> ohshite(_(...));
> }

I've done some rearrangments and queued it for my next push, in few
minutes.

thanks,
guillem


--
To UNSUBSCRIBE, email to debian-dpkg-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20110302051926.GA11251@gaara.hadrons.org">http://lists.debian.org/20110302051926.GA11251@gaara.hadrons.org
 

Thread Tools




All times are GMT. The time now is 07:37 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org