summaryrefslogtreecommitdiff
path: root/src/nspawn
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-02-18 11:54:34 -0500
committerGitHub <noreply@github.com>2017-02-18 11:54:34 -0500
commit581a07f9f0e32923f42aaccf58d11cd96f0d95f1 (patch)
tree9b574c0844f643cf482fa8a2bad09f6d4eff5d4a /src/nspawn
parentcc39016131a535382ca6bc4c5eb018ff7643ed83 (diff)
parentdec718065b59babdbc502e87149c310a7a297172 (diff)
Merge pull request #5369 from poettering/nspawn-resolved
fixes for running nspawn+resolved in combination
Diffstat (limited to 'src/nspawn')
-rw-r--r--src/nspawn/nspawn.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index efd3b014a3..751f26272b 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -41,6 +41,7 @@
#include <sys/wait.h>
#include <unistd.h>
+#include "sd-bus.h"
#include "sd-daemon.h"
#include "sd-id128.h"
@@ -49,6 +50,7 @@
#include "base-filesystem.h"
#include "blkid-util.h"
#include "btrfs-util.h"
+#include "bus-util.h"
#include "cap-list.h"
#include "capability-util.h"
#include "cgroup-util.h"
@@ -1323,6 +1325,19 @@ static int setup_timezone(const char *dest) {
return 0;
}
+static int resolved_running(void) {
+ _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
+ int r;
+
+ /* Check if resolved is running */
+
+ r = sd_bus_open_system(&bus);
+ if (r < 0)
+ return r;
+
+ return bus_name_has_owner(bus, "org.freedesktop.resolve1", NULL);
+}
+
static int setup_resolv_conf(const char *dest) {
_cleanup_free_ char *resolved = NULL, *etc = NULL;
const char *where;
@@ -1346,8 +1361,8 @@ static int setup_resolv_conf(const char *dest) {
return 0;
}
- if (access("/run/systemd/resolve/resolv.conf", F_OK) >= 0 &&
- access("/usr/lib/systemd/resolv.conf", F_OK) >= 0) {
+ if (access("/usr/lib/systemd/resolv.conf", F_OK) >= 0 &&
+ resolved_running() > 0) {
/* resolved is enabled on the host. In this, case bind mount its static resolv.conf file into the
* container, so that the container can use the host's resolver. Given that network namespacing is