[OE-core] [PATCH] dpkg: workaround for sstate contamination

Anders Oleson anders at openpuma.org
Thu Jan 12 05:02:47 UTC 2017


The dpkg binary contains a hard-coded CONFIGDIR path which normally points to
/etc/dpkg. If /etc/dpkg/dpkg.cfg.d cannot be accessed and scandir returns
EACCESS, or any error other than ENOTDIR, it is treated as a fatal error.

Normally this is not an issue for dpkg, and indeed has been confirmed to be
the developers' design intent. But when dpkg-native is built for OpenEmbedded,
the hard-coded CONFIGDIR "leaks" the build specific location information into
the sstate-cache. Later on, if another user or machine picks up and reuses the
dpkg-native binary, it will fail if the original sysroot does not exist, is
not a directory, or is otherwise inaccessible.

The dpkg utility does not currently allow a command line or environment
override of CONFIGDIR, so this is a workaround that patches dpkg such that any
failure to access CONFIGDIR is tolerated and treated the same as if the
directory were empty. In OpenEmbedded, dpkg-native is always passed command
line arguments and the CONFIGDIR is empty, so this does not cause an issue for
the way OpenEmbedded uses dpkg-native.

This is a workaround that can be removed when dpkg grows the ability to
override the CONFIGDIR at runtime, which has been discussed.

Signed-off-by: Anders Oleson <anders at openpuma.org>
---
 .../dpkg/dpkg/allow-inaccessible-config-dir.patch  | 26 ++++++++++++++++++++++
 meta/recipes-devtools/dpkg/dpkg_1.18.7.bb          |  4 +++-
 2 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-devtools/dpkg/dpkg/allow-inaccessible-config-dir.patch

diff --git a/meta/recipes-devtools/dpkg/dpkg/allow-inaccessible-config-dir.patch b/meta/recipes-devtools/dpkg/dpkg/allow-inaccessible-config-dir.patch
new file mode 100644
index 0000000..fca0c16
--- /dev/null
+++ b/meta/recipes-devtools/dpkg/dpkg/allow-inaccessible-config-dir.patch
@@ -0,0 +1,26 @@
+continue rather than fail if unable to access CONFIGDIR
+
+Signed-off-by: Anders Oleson <anders at openpuma.org>
+
+Upstream-Status: Inappropriate [embedded specific]
+
+Note: a more comprehensive fix to dpkg will be to add a feature that allows a
+command line override of the hard-coded CONFIGDIR (/etc/dpkg/dpkg.cfg.d).
+Once that happens, this patch should be removed.
+
+Index: dpkg-1.18.7/lib/dpkg/options.c
+===================================================================
+--- dpkg-1.18.7.orig/lib/dpkg/options.c
++++ dpkg-1.18.7/lib/dpkg/options.c
+@@ -172,11 +172,8 @@ dpkg_options_load_dir(const char *prog,
+ 
+   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);
+   }
+ 
+   for (i = 0; i < dlist_n; i++) {
diff --git a/meta/recipes-devtools/dpkg/dpkg_1.18.7.bb b/meta/recipes-devtools/dpkg/dpkg_1.18.7.bb
index 28fdc13..73d1064 100644
--- a/meta/recipes-devtools/dpkg/dpkg_1.18.7.bb
+++ b/meta/recipes-devtools/dpkg/dpkg_1.18.7.bb
@@ -13,7 +13,9 @@ SRC_URI = "http://snapshot.debian.org/archive/debian/20160509T100042Z/pool/main/
            file://0005-dpkg-compiler.m4-remove-Wvla.patch \
            file://0006-add-musleabi-to-known-target-tripets.patch \
            "
-SRC_URI_append_class-native = " file://glibc2.5-sync_file_range.patch "
+SRC_URI_append_class-native = " file://glibc2.5-sync_file_range.patch \
+           file://allow-inaccessible-config-dir.patch \
+           "
 
 SRC_URI[md5sum] = "073dbf2129a54b0fc627464bf8af4a1b"
 SRC_URI[sha256sum] = "ace36d3a6dc750a42baf797f9e75ec580a21f92bb9ff96b482100755d6d9b87b"
-- 
1.9.1




More information about the Openembedded-core mailing list