From 3669978577e460847cf2a6e010dc80503603cc47 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Tue, 30 Jul 2019 21:23:25 +0200 Subject: [PATCH] osbuild-run: remove any /etc/nsswitch.conf On some hosts, systemd-tmpfiles will generate an nsswitch.conf configuring DNS to be done via systemd-resolved, but this will require the container to be booted and resolved to be running. In other cases, a proper fall-back is configured, so this is not a problem, but on some hosts this means DNS does not work. Conversely, the default behavior with no nsswitch.conf at all works just fine, always using nss-dns. Let's simply delete the file if it is there, and rely on the default. Signed-off-by: Tom Gundersen --- osbuild-run | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/osbuild-run b/osbuild-run index b552b925..eda46430 100755 --- a/osbuild-run +++ b/osbuild-run @@ -60,12 +60,23 @@ def tmpfiles(): subprocess.run(["systemd-tmpfiles", "--create"]) +def nsswitch(): + # the default behavior is fine, but using nss-resolve does not + # necessarily work in a non-booted container, so make sure that + # is not configured. + try: + os.remove("/etc/nsswitch.conf") + except FileNotFoundError: + pass + + if __name__ == "__main__": ldconfig() sysusers() update_ca_trust() update_ca_certificates() tmpfiles() + nsswitch() r = subprocess.run(sys.argv[1:]) sys.exit(r.returncode)