This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=63b5e9b5cbc4023b3d3fbec9823bfbaf270fd261

commit 63b5e9b5cbc4023b3d3fbec9823bfbaf270fd261
Author: Guillem Jover <[email protected]>
AuthorDate: Sat Nov 30 22:17:55 2019 +0100

    u-a: Cope with a missing administrative directory
    
    When trying to scan the administrative directory, we should gracefully
    cope with it being missing, which can be the case when bootstrapping
    this package on a new system. Or when using a different administrative
    directory.
---
 debian/changelog            |  1 +
 t/cppcheck/cppcheck.supp    | 12 ++++++------
 utils/update-alternatives.c |  9 +++++++--
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 869e7314f..43f99e457 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -37,6 +37,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium
   * dpkg-source: Remove backwards compatibility code for legacy build-profiles.
   * perl: Give more context on field parsing errors. Closes: #637060
   * dpkg-buildpackage: Add option to sanitize environment. Closes: #843776
+  * update-alternatives: Cope with a missing administrative directory.
   * Perl modules:
     - Dpkg::Source::Package: Verify original tarball signatures at build time.
     - Dpkg::BuildFlags: Add new unset() method.
diff --git a/t/cppcheck/cppcheck.supp b/t/cppcheck/cppcheck.supp
index e672908e6..f790e7e2d 100644
--- a/t/cppcheck/cppcheck.supp
+++ b/t/cppcheck/cppcheck.supp
@@ -35,7 +35,7 @@ knownConditionTrueFalse:src/depcon.c:668
 identicalInnerCondition:lib/dpkg/fsys-hash.c:100
 
 // BUG: False positive, this is an enum not a boolean.
-redundantCondition:utils/update-alternatives.c:2711
+redundantCondition:utils/update-alternatives.c:2716
 
 // BUG: False positive, the macros from lib/dpkg/dlist.h use the tail member.
 unusedStructMember:lib/dpkg/triglib.c:378
@@ -53,15 +53,15 @@ nullPointerArithmeticRedundantCheck:lib/dpkg/pkg-format.c:82
 // BUG: False positive, does not understand setjmp-style error handling.
 redundantAssignment:lib/compat/selinux.c:73
 redundantAssignment:lib/dpkg/t/t-ehandle.c:108
-nullPointerRedundantCheck:utils/update-alternatives.c:1158
-uninitStructMember:utils/update-alternatives.c:1305
-uninitStructMember:utils/update-alternatives.c:1306
-uninitStructMember:utils/update-alternatives.c:1307
+nullPointerRedundantCheck:utils/update-alternatives.c:1163
+uninitStructMember:utils/update-alternatives.c:1310
+uninitStructMember:utils/update-alternatives.c:1311
+uninitStructMember:utils/update-alternatives.c:1312
 
 // BUG: False positive, does not understand ohshit(), ohshite() and
 //      bad_format as error terminators.
 doubleFree:src/script.c
-doubleFree:utils/update-alternatives.c:1213
+doubleFree:utils/update-alternatives.c:1218
 va_end_missing:lib/dpkg/parsehelp.c:68
 
 // BUG: False positive, due to our local va_copy().
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index a9180705b..ab2c6ba55 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1107,8 +1107,13 @@ altdb_get_namelist(struct dirent ***table)
        int count;
 
        count = scandir(admdir, table, altdb_filter_namelist, alphasort);
-       if (count < 0)
-               syserr(_("cannot scan directory '%.255s'"), admdir);
+       if (count < 0) {
+               if (errno != ENOENT)
+                       syserr(_("cannot scan directory '%.255s'"), admdir);
+               /* The directory does not exist, proceed anyway. */
+               *table = NULL;
+               count = 0;
+       }
 
        return count;
 }

-- 
Dpkg.Org's dpkg

Reply via email to