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