naccyde / rpms / systemd

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