Blame SOURCES/0029-resolved-create-etc-resolv.conf-symlink-at-runtime.patch

a3e2b5
From e0f2dd42fb02aa5767d38714c95ac10fb683ad67 Mon Sep 17 00:00:00 2001
a3e2b5
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
a3e2b5
Date: Fri, 11 Mar 2016 17:06:17 -0500
a3e2b5
Subject: [PATCH] resolved: create /etc/resolv.conf symlink at runtime
a3e2b5
a3e2b5
If the symlink doesn't exists, and we are being started, let's
a3e2b5
create it to provie name resolution.
a3e2b5
a3e2b5
If it exists, do nothing. In particular, if it is a broken symlink,
a3e2b5
we cannot really know if the administator configured it to point to
a3e2b5
a location used by some service that hasn't started yet, so we
a3e2b5
don't touch it in that case either.
a3e2b5
a3e2b5
https://bugzilla.redhat.com/show_bug.cgi?id=1313085
a3e2b5
---
a3e2b5
 src/resolve/resolved.c | 4 ++++
a3e2b5
 tmpfiles.d/etc.conf.m4 | 3 ---
a3e2b5
 2 files changed, 4 insertions(+), 3 deletions(-)
a3e2b5
a3e2b5
diff --git a/src/resolve/resolved.c b/src/resolve/resolved.c
a3e2b5
index c01e53e9da..f3d96df458 100644
a3e2b5
--- a/src/resolve/resolved.c
a3e2b5
+++ b/src/resolve/resolved.c
a3e2b5
@@ -53,6 +53,10 @@ int main(int argc, char *argv[]) {
a3e2b5
         /* Drop privileges, but only if we have been started as root. If we are not running as root we assume all
a3e2b5
          * privileges are already dropped. */
a3e2b5
         if (getuid() == 0) {
a3e2b5
+                r = symlink("../run/systemd/resolve/resolv.conf", "/etc/resolv.conf");
a3e2b5
+                if (r < 0 && errno != EEXIST)
a3e2b5
+                        log_warning_errno(errno,
a3e2b5
+                                          "Could not create /etc/resolv.conf symlink: %m");
a3e2b5
 
a3e2b5
                 /* Drop privileges, but keep three caps. Note that we drop those too, later on (see below) */
a3e2b5
                 r = drop_privileges(uid, gid,
a3e2b5
diff --git a/tmpfiles.d/etc.conf.m4 b/tmpfiles.d/etc.conf.m4
a3e2b5
index df8d42101c..928105ea8d 100644
a3e2b5
--- a/tmpfiles.d/etc.conf.m4
a3e2b5
+++ b/tmpfiles.d/etc.conf.m4
a3e2b5
@@ -13,9 +13,6 @@ L+ /etc/mtab - - - - ../proc/self/mounts
a3e2b5
 m4_ifdef(`HAVE_SMACK_RUN_LABEL',
a3e2b5
 t /etc/mtab - - - - security.SMACK64=_
a3e2b5
 )m4_dnl
a3e2b5
-m4_ifdef(`ENABLE_RESOLVE',
a3e2b5
-L! /etc/resolv.conf - - - - ../run/systemd/resolve/stub-resolv.conf
a3e2b5
-)m4_dnl
a3e2b5
 C /etc/nsswitch.conf - - - -
a3e2b5
 m4_ifdef(`HAVE_PAM',
a3e2b5
 C /etc/pam.d - - - -