Bug#200701: dpkg fails if $HOME/.dpkg.cfg is unreadable
Hi Nicolas,
I had the same problem with an NFS-mounted $HOME. The culprit is in
lib/libmyopt.c: void myfileopt() which is called by loadcfgfile()
and exits with ohshite() upon failure.
As I understand it, both the system-wide and the user config are
optional, so errors opening either should not be any more grave than
a non-existing file.
The attached patch changes that behaviour: It changes the ohshite()
fatal error to a warning and continues should the config not exist or
be readable.
Does it fix your problem too?
Adam, dpkg is pretty new territory for me. I've tested the patch for a
while but I'm not totally confident it doesnt break anything, including
style :)
Greets,
Max
diff -ur dpkg-1.10.10-ORIG/include/dpkg.h.in dpkg-1.10.10/include/dpkg.h.in
--- dpkg-1.10.10-ORIG/include/dpkg.h.in 2002-09-01 06:47:05.000000000 +0200
+++ dpkg-1.10.10/include/dpkg.h.in 2003-07-26 17:02:26.000000000 +0200
@@ -196,6 +196,7 @@
void ohshitvb(struct varbuf*) NONRETURNING;
void badusage(const char *fmt, ...) NONRETURNPRINTFFORMAT(1,2);
void werr(const char *what) NONRETURNING;
+void warningf(const char *fmt, ...);
/*** from mlib.c ***/
diff -ur dpkg-1.10.10-ORIG/lib/ehandle.c dpkg-1.10.10/lib/ehandle.c
--- dpkg-1.10.10-ORIG/lib/ehandle.c 2002-05-06 18:18:15.000000000 +0200
+++ dpkg-1.10.10/lib/ehandle.c 2003-07-26 17:02:18.000000000 +0200
@@ -256,6 +256,19 @@
longjmp(*econtext->jbufp,1);
}
+void warningf(const char *fmt, ...) {
+ int e;
+ va_list al;
+ char buf[1024];
+
+ e=errno;
+ va_start(al,fmt);
+ vsnprintf(buf,sizeof(buf),fmt,al);
+ va_end(al);
+
+ fprintf(stderr,"%s: %s",buf,strerror(e));
+}
+
void badusage(const char *fmt, ...) {
char buf[1024];
va_list al;
diff -ur dpkg-1.10.10-ORIG/lib/myopt.c dpkg-1.10.10/lib/myopt.c
--- dpkg-1.10.10-ORIG/lib/myopt.c 2002-07-02 12:39:55.000000000 +0200
+++ dpkg-1.10.10/lib/myopt.c 2003-07-26 17:02:34.000000000 +0200
@@ -37,7 +37,8 @@
if (!file) {
if (errno==ENOENT)
return;
- ohshite(_("failed to open configuration file `%.255s' for reading"), fn);
+ warningf(_("failed to open configuration file `%.255s' for reading"),fn);
+ return;
}
while (fgets(linebuf, sizeof(linebuf), file)) {
Reply to: