mirror of
https://github.com/systemd/systemd.git
synced 2025-03-24 14:50:17 +03:00
Merge pull request #5369 from poettering/nspawn-resolved
fixes for running nspawn+resolved in combination
This commit is contained in:
commit
581a07f9f0
@ -5565,14 +5565,12 @@ dist_dbuspolicy_DATA += \
|
||||
dist_dbussystemservice_DATA += \
|
||||
src/resolve/org.freedesktop.resolve1.service
|
||||
|
||||
SYSTEM_UNIT_ALIASES += \
|
||||
systemd-resolved.service dbus-org.freedesktop.resolve1.service
|
||||
|
||||
BUSNAMES_TARGET_WANTS += \
|
||||
org.freedesktop.resolve1.busname
|
||||
|
||||
GENERAL_ALIASES += \
|
||||
$(systemunitdir)/systemd-resolved.service $(pkgsysconfdir)/system/multi-user.target.wants/systemd-resolved.service
|
||||
$(systemunitdir)/systemd-resolved.service $(pkgsysconfdir)/system/multi-user.target.wants/systemd-resolved.service \
|
||||
$(systemunitdir)/systemd-resolved.service $(pkgsysconfdir)/system/dbus-org.freedesktop.resolve1.service
|
||||
|
||||
nodist_pkgsysconf_DATA += \
|
||||
src/resolve/resolved.conf
|
||||
|
@ -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
|
||||
|
@ -10,7 +10,7 @@ Description=Container %i
|
||||
Documentation=man:systemd-nspawn(1)
|
||||
PartOf=machines.target
|
||||
Before=machines.target
|
||||
After=network.target
|
||||
After=network.target systemd-resolved.service
|
||||
|
||||
[Service]
|
||||
ExecStart=@bindir@/systemd-nspawn --quiet --keep-unit --boot --link-journal=try-guest --network-veth -U --settings=override --machine=%i
|
||||
|
@ -38,3 +38,4 @@ SystemCallFilter=~@clock @cpu-emulation @debug @keyring @module @mount @obsolete
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Alias=dbus-org.freedesktop.resolve1.service
|
||||
|
Loading…
x
Reference in New Issue
Block a user