[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: PATCH: dpkg: allow missing /etc/dpkg/dpkg.d directory



Anders Oleson writes ("PATCH: dpkg: allow missing /etc/dpkg/dpkg.d directory"):
> This patch removes the error and message when /etc/dpkg/dpkg.d is missing and
> instead acts the same as if it were empty.

I think you are confused somehow.

scandir(3) says:

    ENOENT   The path in dirp does not exist.
    ENOTDIR  The path in dirp is not a directory.

If you are getting ENOTDIR from scandir, I think that means that
/etc/dpkg/dpkg.d is a file, or something.  If it is simply missing you
should get ENOENT which dpkg should tolerate.

I compiled a lightly modified version of the example program from
scandir(3) and found that indeed,
  scandir("this does not exist", ...)
fails with ENOENT.

>    dlist_n = scandir(dirname, &dlist, valid_config_filename, alphasort);
>    if (dlist_n < 0) {
> -    if (errno == ENOENT) {
>        free(dirname);
>        return;
> -    } else
> -      ohshite(_("error opening configuration directory '%s'"), dirname);
>    }

Certainly this patch is entirely wrong.  Before treating an error as
"thing does not exist, carry on", programs should indeed check errno.
If the manpage scandir(3) is accurate, I don't think ENOTDIR is a
reasonable situation for dpkg to tolerate.

Also,

> The dpkg utility does not currently allow a command line or environment
> override of CONFIGDIR,

This seems like an obvious missing feature.  I imagine a good patch to
provide such a change would be accepted.  If I were you I would
propose the name and semantics here before writing the code.

Regards,
Ian.

-- 
Ian Jackson <ijackson@chiark.greenend.org.uk>   These opinions are my own.

If I emailed you from an address @fyvzl.net or @evade.org.uk, that is
a private address which bypasses my fierce spamfilter.


Reply to: