Bug#271041: --admindir ignored when spawning dpkg-query
Package: dpkg
Version: 1.10.25
Followup-For: Bug #271041
It appears that someone decided that it was unnecessary to pass the
common "--admindir" option from dpkg to dpkg-query in the new version
of dpkg. I think this is bad form, as I have many scripts that rely
on this behavior. The attached patch restores this functionality.
-- System Information:
Debian Release: 3.1
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.8-1-k7
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Versions of packages dpkg depends on:
ii dselect 1.10.21 a user tool to manage Debian packa
ii libc6 2.3.2.ds1-19 GNU C Library: Shared libraries an
-- no debconf information
--- main/main.c.orig Wed Dec 22 00:27:02 2004
+++ main/main.c Wed Dec 22 00:41:04 2004
@@ -433,23 +441,31 @@
void execbackend(const char *const *argv) {
char **nargv;
- int i, argc = 1;
+ int i, n = 0, argc = 1;
const char *const *arg = argv;
while(*arg != 0) { arg++; argc++; }
- nargv= malloc(sizeof(char *) * (argc + 2));
+ nargv= malloc(sizeof(char *) * (argc + 3));
if (!nargv) ohshite(_("couldn't malloc in execbackend"));
nargv[0]= strdup(cipaction->parg);
if (!nargv[0]) ohshite(_("couldn't strdup in execbackend"));
- nargv[1]= malloc(strlen(cipaction->olong) + 3);
- if (!nargv[1]) ohshite(_("couldn't malloc in execbackend"));
- strcpy(nargv[1], "--");
- strcat(nargv[1], cipaction->olong);
+ if( !strcmp( cipaction->parg, "dpkg-query" ))
+ { n++;
+ nargv[n] = malloc( strlen( admindir ) + 12 );
+ if( !nargv[n] ) ohshite(_("couldn't malloc in execbackend"));
+ strcpy( nargv[n], "--admindir=" );
+ strcat( nargv[n], admindir );
+ }
+ nargv[n+1]= malloc(strlen(cipaction->olong) + 3);
+ if (!nargv[n+1]) ohshite(_("couldn't malloc in execbackend"));
+ strcpy(nargv[n+1], "--");
+ strcat(nargv[n+1], cipaction->olong);
for (i= 2; i <= argc; i++) {
- nargv[i]= strdup(argv[i-2]);
- if (!nargv[i]) ohshite(_("couldn't strdup in execbackend"));
+ nargv[i+n]= strdup(argv[i-2]);
+ if (!nargv[i+n]) ohshite(_("couldn't strdup in execbackend"));
}
- nargv[i]= 0;
+
+ nargv[i+n]= 0;
execvp(cipaction->parg, nargv);
ohshite(_("failed to exec %s"),(char *)cipaction->parg);
}
Reply to: