ryantimwilson / rpms / systemd

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