Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Anders Oleson <anders@openpuma.org>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH] dpkg: workaround for sstate contamination
Date: Wed, 11 Jan 2017 21:02:47 -0800	[thread overview]
Message-ID: <1484197367-11314-1-git-send-email-anders@openpuma.org> (raw)
In-Reply-To: <1484123040.4367.172.camel@linuxfoundation.org>

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@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@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



  reply	other threads:[~2017-01-12  5:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-16 19:31 bug with dpkg-native and sstate-cache mirrors Anders Oleson
2016-12-21  3:45 ` Anders Oleson
2017-01-09 16:45   ` Anders Oleson
2017-01-11  8:24   ` Richard Purdie
2017-01-12  5:02     ` Anders Oleson [this message]
2017-01-11  8:22 ` Richard Purdie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1484197367-11314-1-git-send-email-anders@openpuma.org \
    --to=anders@openpuma.org \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox