From 7824f773110be8a0cecb89f650e13db03b58d1e1 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 7 Jul 2014 08:27:43 -0400 Subject: [PATCH] resolved: Move symlink creation from tmpfiles to daemon runtime At least Fedora right now doesn't by default use resolved; the service is disabled by default in the 90-default.preset file. The change to unconditionally create the resolv.conf symlink broke Anaconda and related tools (lorax) which expect it to be a regular file. In particular, Anaconda expects to be able to persist networking state from the installation environment to the target system. A simple fix is to just have resolved itself create it at runtime. --- src/resolve/resolved-manager.c | 12 +++++++++++- tmpfiles.d/etc.conf | 1 - 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index 3ed0603..1a6b3ac 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -192,9 +192,11 @@ static void append_dns(FILE *f, void *dns, unsigned char family, unsigned *count int manager_update_resolv_conf(Manager *m) { const char *path = "/run/systemd/resolve/resolv.conf"; + const char *etcresolv_path = "/etc/resolv.conf"; _cleanup_free_ char *temp_path = NULL; _cleanup_fclose_ FILE *f = NULL; - _cleanup_free_ unsigned *indices = NULL; + _cleanup_free_ unsigned *indices = NULL; + struct stat st; Address *address; unsigned count = 0; int n, r, i; @@ -270,6 +272,14 @@ int manager_update_resolv_conf(Manager *m) { return r; } + /* Create /etc/resolv.conf as a link only if it doesn't exist */ + if (lstat(etcresolv_path, &st) < 0) { + r = symlink(path, etcresolv_path); + if (r < 0 && errno != EEXIST) { + return r; + } + } + return 0; } diff --git a/tmpfiles.d/etc.conf b/tmpfiles.d/etc.conf index e809dff..4937719 100644 --- a/tmpfiles.d/etc.conf +++ b/tmpfiles.d/etc.conf @@ -10,4 +10,3 @@ L /etc/os-release - - - - ../usr/lib/os-release L /etc/localtime - - - - ../usr/share/zoneinfo/UTC L+ /etc/mtab - - - - ../proc/self/mounts -L /etc/resolv.conf - - - - ../run/systemd/resolve/resolv.conf -- 1.8.3.1