mirror of
https://github.com/systemd/systemd
synced 2025-09-29 16:54:46 +02:00
Compare commits
12 Commits
2ef2376d83
...
5623600c6e
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5623600c6e | ||
![]() |
436cde839f | ||
![]() |
d8f9686c0f | ||
![]() |
5d80583d5d | ||
![]() |
245f4b384d | ||
![]() |
150dcaf248 | ||
![]() |
fb934d53f9 | ||
![]() |
99d97afcec | ||
![]() |
57f1b61b76 | ||
![]() |
ad612eba51 | ||
![]() |
69988fee43 | ||
![]() |
d8067d4041 |
@ -115,6 +115,7 @@ node /org/freedesktop/resolve1 {
|
||||
ResetStatistics();
|
||||
FlushCaches();
|
||||
ResetServerFeatures();
|
||||
GetMulticastHosts(out a(stiiay) UNNAMED);
|
||||
properties:
|
||||
readonly s LLMNRHostname = '...';
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
@ -164,6 +165,8 @@ node /org/freedesktop/resolve1 {
|
||||
|
||||
<!--method ResetServerFeatures is not documented!-->
|
||||
|
||||
<!--method GetMulticastHosts is not documented!-->
|
||||
|
||||
<!--property DNSSECNegativeTrustAnchors is not documented!-->
|
||||
|
||||
<!--Autogenerated cross-references for systemd.directives, do not edit-->
|
||||
@ -212,6 +215,8 @@ node /org/freedesktop/resolve1 {
|
||||
|
||||
<variablelist class="dbus-method" generated="True" extra-ref="ResetServerFeatures()"/>
|
||||
|
||||
<variablelist class="dbus-method" generated="True" extra-ref="GetMulticastHosts()"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="LLMNRHostname"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="LLMNR"/>
|
||||
|
@ -180,6 +180,13 @@
|
||||
automatically, an explicit reverting is not necessary in that case.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><command>show-multicast</command></term>
|
||||
|
||||
<listitem><para>Display the discovered LLMNR and mDNS hostnames along with their IPv4/IPv6 addresses.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<xi:include href="systemctl.xml" xpointer="log-level" />
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
5
mkosi.postinst
Executable file
5
mkosi.postinst
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
mkdir -p /root/build
|
||||
echo "directory /root/build" > ~/.gdbinit
|
@ -391,9 +391,10 @@ static int fd_copy_symlink(
|
||||
uid_is_valid(override_uid) ? override_uid : st->st_uid,
|
||||
gid_is_valid(override_gid) ? override_gid : st->st_gid,
|
||||
AT_SYMLINK_NOFOLLOW) < 0)
|
||||
return -errno;
|
||||
r = -errno;
|
||||
|
||||
return 0;
|
||||
(void) utimensat(dt, to, (struct timespec[]) { st->st_atim, st->st_mtim }, AT_SYMLINK_NOFOLLOW);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Encapsulates the database we store potential hardlink targets in */
|
||||
@ -592,7 +593,6 @@ static int fd_copy_regular(
|
||||
void *userdata) {
|
||||
|
||||
_cleanup_close_ int fdf = -1, fdt = -1;
|
||||
struct timespec ts[2];
|
||||
int r, q;
|
||||
|
||||
assert(from);
|
||||
@ -634,9 +634,7 @@ static int fd_copy_regular(
|
||||
if (fchmod(fdt, st->st_mode & 07777) < 0)
|
||||
r = -errno;
|
||||
|
||||
ts[0] = st->st_atim;
|
||||
ts[1] = st->st_mtim;
|
||||
(void) futimens(fdt, ts);
|
||||
(void) futimens(fdt, (struct timespec[]) { st->st_atim, st->st_mtim });
|
||||
(void) copy_xattr(fdf, fdt);
|
||||
|
||||
q = close(fdt);
|
||||
@ -693,6 +691,8 @@ static int fd_copy_fifo(
|
||||
if (fchmodat(dt, to, st->st_mode & 07777, 0) < 0)
|
||||
r = -errno;
|
||||
|
||||
(void) utimensat(dt, to, (struct timespec[]) { st->st_atim, st->st_mtim }, AT_SYMLINK_NOFOLLOW);
|
||||
|
||||
(void) memorize_hardlink(hardlink_context, st, dt, to);
|
||||
return r;
|
||||
}
|
||||
@ -739,6 +739,8 @@ static int fd_copy_node(
|
||||
if (fchmodat(dt, to, st->st_mode & 07777, 0) < 0)
|
||||
r = -errno;
|
||||
|
||||
(void) utimensat(dt, to, (struct timespec[]) { st->st_atim, st->st_mtim }, AT_SYMLINK_NOFOLLOW);
|
||||
|
||||
(void) memorize_hardlink(hardlink_context, st, dt, to);
|
||||
return r;
|
||||
}
|
||||
@ -913,11 +915,6 @@ static int fd_copy_directory(
|
||||
}
|
||||
|
||||
if (created) {
|
||||
struct timespec ut[2] = {
|
||||
st->st_atim,
|
||||
st->st_mtim
|
||||
};
|
||||
|
||||
if (fchown(fdt,
|
||||
uid_is_valid(override_uid) ? override_uid : st->st_uid,
|
||||
gid_is_valid(override_gid) ? override_gid : st->st_gid) < 0)
|
||||
@ -927,7 +924,7 @@ static int fd_copy_directory(
|
||||
r = -errno;
|
||||
|
||||
(void) copy_xattr(dirfd(d), fdt);
|
||||
(void) futimens(fdt, ut);
|
||||
(void) futimens(fdt, (struct timespec[]) { st->st_atim, st->st_mtim });
|
||||
}
|
||||
|
||||
return r;
|
||||
@ -1182,7 +1179,6 @@ int copy_file_atomic_full(
|
||||
}
|
||||
|
||||
int copy_times(int fdf, int fdt, CopyFlags flags) {
|
||||
struct timespec ut[2];
|
||||
struct stat st;
|
||||
|
||||
assert(fdf >= 0);
|
||||
@ -1191,10 +1187,7 @@ int copy_times(int fdf, int fdt, CopyFlags flags) {
|
||||
if (fstat(fdf, &st) < 0)
|
||||
return -errno;
|
||||
|
||||
ut[0] = st.st_atim;
|
||||
ut[1] = st.st_mtim;
|
||||
|
||||
if (futimens(fdt, ut) < 0)
|
||||
if (futimens(fdt, (struct timespec[2]) { st.st_atim, st.st_mtim }) < 0)
|
||||
return -errno;
|
||||
|
||||
if (FLAGS_SET(flags, COPY_CRTIME)) {
|
||||
|
@ -7,13 +7,13 @@
|
||||
#include "sd-id128.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "discover-image.h"
|
||||
#include "export-raw.h"
|
||||
#include "export-tar.h"
|
||||
#include "fd-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "import-util.h"
|
||||
#include "machine-image.h"
|
||||
#include "main-func.h"
|
||||
#include "signal-util.h"
|
||||
#include "string-util.h"
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "alloc-util.h"
|
||||
#include "btrfs-util.h"
|
||||
#include "capability-util.h"
|
||||
#include "chattr-util.h"
|
||||
#include "dirent-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
@ -22,6 +23,7 @@
|
||||
#include "util.h"
|
||||
|
||||
int import_make_read_only_fd(int fd) {
|
||||
struct stat st;
|
||||
int r;
|
||||
|
||||
assert(fd >= 0);
|
||||
@ -29,26 +31,35 @@ int import_make_read_only_fd(int fd) {
|
||||
/* First, let's make this a read-only subvolume if it refers
|
||||
* to a subvolume */
|
||||
r = btrfs_subvol_set_read_only_fd(fd, true);
|
||||
if (IN_SET(r, -ENOTTY, -ENOTDIR, -EINVAL)) {
|
||||
struct stat st;
|
||||
|
||||
/* This doesn't refer to a subvolume, or the file
|
||||
* system isn't even btrfs. In that, case fall back to
|
||||
* chmod()ing */
|
||||
|
||||
r = fstat(fd, &st);
|
||||
if (r < 0)
|
||||
return log_error_errno(errno, "Failed to stat temporary image: %m");
|
||||
|
||||
/* Drop "w" flag */
|
||||
if (fchmod(fd, st.st_mode & 07555) < 0)
|
||||
return log_error_errno(errno, "Failed to chmod() final image: %m");
|
||||
|
||||
if (r >= 0)
|
||||
return 0;
|
||||
|
||||
} else if (r < 0)
|
||||
if (!ERRNO_IS_NOT_SUPPORTED(r) && !IN_SET(r, -ENOTDIR, -EINVAL))
|
||||
return log_error_errno(r, "Failed to make subvolume read-only: %m");
|
||||
|
||||
/* This doesn't refer to a subvolume, or the file system isn't even btrfs. In that, case fall back to
|
||||
* chmod()ing */
|
||||
|
||||
r = fstat(fd, &st);
|
||||
if (r < 0)
|
||||
return log_error_errno(errno, "Failed to stat image: %m");
|
||||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
/* For directories set the immutable flag on the dir itself */
|
||||
|
||||
r = chattr_fd(fd, FS_IMMUTABLE_FL, FS_IMMUTABLE_FL, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set +i attribute on directory image: %m");
|
||||
|
||||
} else if (S_ISREG(st.st_mode)) {
|
||||
/* For regular files drop "w" flags */
|
||||
|
||||
if ((st.st_mode & 0222) != 0)
|
||||
if (fchmod(fd, st.st_mode & 07555) < 0)
|
||||
return log_error_errno(errno, "Failed to chmod() image: %m");
|
||||
} else
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EBADFD), "Image of unexpected type");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -5,13 +5,13 @@
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "btrfs-util.h"
|
||||
#include "discover-image.h"
|
||||
#include "fd-util.h"
|
||||
#include "format-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "import-common.h"
|
||||
#include "import-util.h"
|
||||
#include "machine-image.h"
|
||||
#include "mkdir.h"
|
||||
#include "ratelimit.h"
|
||||
#include "rm-rf.h"
|
||||
|
@ -7,13 +7,13 @@
|
||||
#include "sd-id128.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "discover-image.h"
|
||||
#include "fd-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "import-raw.h"
|
||||
#include "import-tar.h"
|
||||
#include "import-util.h"
|
||||
#include "machine-image.h"
|
||||
#include "main-func.h"
|
||||
#include "signal-util.h"
|
||||
#include "string-util.h"
|
||||
|
@ -433,6 +433,16 @@ fail:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int http_status_ok(CURLcode status) {
|
||||
/* Consider all HTTP status code in the 2xx range as OK */
|
||||
return status >= 200 && status <= 299;
|
||||
}
|
||||
|
||||
static int http_status_etag_exists(CURLcode status) {
|
||||
/* This one is special, it's triggered by our etag mgmt logic */
|
||||
return status == 304;
|
||||
}
|
||||
|
||||
static size_t pull_job_header_callback(void *contents, size_t size, size_t nmemb, void *userdata) {
|
||||
_cleanup_free_ char *length = NULL, *last_modified = NULL, *etag = NULL;
|
||||
size_t sz = size * nmemb;
|
||||
@ -458,29 +468,32 @@ static size_t pull_job_header_callback(void *contents, size_t size, size_t nmemb
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (status < 200 || status >= 300)
|
||||
/* If this is not HTTP 2xx, let's skip these headers, they are probably for
|
||||
* some redirect or so, and we are not interested in the headers of those. */
|
||||
return sz;
|
||||
if (http_status_ok(status) || http_status_etag_exists(status)) {
|
||||
/* Check Etag on OK and etag exists responses. */
|
||||
|
||||
r = curl_header_strdup(contents, sz, "ETag:", &etag);
|
||||
if (r < 0) {
|
||||
log_oom();
|
||||
goto fail;
|
||||
}
|
||||
if (r > 0) {
|
||||
free_and_replace(j->etag, etag);
|
||||
r = curl_header_strdup(contents, sz, "ETag:", &etag);
|
||||
if (r < 0) {
|
||||
log_oom();
|
||||
goto fail;
|
||||
}
|
||||
if (r > 0) {
|
||||
free_and_replace(j->etag, etag);
|
||||
|
||||
if (strv_contains(j->old_etags, j->etag)) {
|
||||
log_info("Image already downloaded. Skipping download. (%s)", j->etag);
|
||||
j->etag_exists = true;
|
||||
pull_job_finish(j, 0);
|
||||
return sz;
|
||||
}
|
||||
|
||||
if (strv_contains(j->old_etags, j->etag)) {
|
||||
log_info("Image already downloaded. Skipping download.");
|
||||
j->etag_exists = true;
|
||||
pull_job_finish(j, 0);
|
||||
return sz;
|
||||
}
|
||||
|
||||
return sz;
|
||||
}
|
||||
|
||||
if (!http_status_ok(status)) /* Let's ignore the rest here, these requests are probably redirects and
|
||||
* stuff where the headers aren't interesting to us */
|
||||
return sz;
|
||||
|
||||
r = curl_header_strdup(contents, sz, "Content-Length:", &length);
|
||||
if (r < 0) {
|
||||
log_oom();
|
||||
|
@ -7,9 +7,9 @@
|
||||
#include "sd-id128.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "discover-image.h"
|
||||
#include "hostname-util.h"
|
||||
#include "import-util.h"
|
||||
#include "machine-image.h"
|
||||
#include "main-func.h"
|
||||
#include "parse-util.h"
|
||||
#include "pull-raw.h"
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "bus-label.h"
|
||||
#include "bus-polkit.h"
|
||||
#include "copy.h"
|
||||
#include "discover-image.h"
|
||||
#include "dissect-image.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
@ -15,7 +16,6 @@
|
||||
#include "image-dbus.h"
|
||||
#include "io-util.h"
|
||||
#include "loop-util.h"
|
||||
#include "machine-image.h"
|
||||
#include "missing_capability.h"
|
||||
#include "mount-util.h"
|
||||
#include "process-util.h"
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "bus-locator.h"
|
||||
#include "bus-polkit.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "discover-image.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
@ -20,7 +21,6 @@
|
||||
#include "image-dbus.h"
|
||||
#include "io-util.h"
|
||||
#include "machine-dbus.h"
|
||||
#include "machine-image.h"
|
||||
#include "machine-pool.h"
|
||||
#include "machined.h"
|
||||
#include "missing_capability.h"
|
||||
|
@ -15,11 +15,11 @@
|
||||
#include "bus-polkit.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "dirent-util.h"
|
||||
#include "discover-image.h"
|
||||
#include "fd-util.h"
|
||||
#include "format-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "label.h"
|
||||
#include "machine-image.h"
|
||||
#include "machined-varlink.h"
|
||||
#include "machined.h"
|
||||
#include "main-func.h"
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "copy.h"
|
||||
#include "cpu-set-util.h"
|
||||
#include "dev-setup.h"
|
||||
#include "discover-image.h"
|
||||
#include "dissect-image.h"
|
||||
#include "env-util.h"
|
||||
#include "escape.h"
|
||||
@ -53,7 +54,6 @@
|
||||
#include "log.h"
|
||||
#include "loop-util.h"
|
||||
#include "loopback-setup.h"
|
||||
#include "machine-image.h"
|
||||
#include "macro.h"
|
||||
#include "main-func.h"
|
||||
#include "missing_sched.h"
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "copy.h"
|
||||
#include "def.h"
|
||||
#include "dirent-util.h"
|
||||
#include "discover-image.h"
|
||||
#include "dissect-image.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
@ -16,7 +17,6 @@
|
||||
#include "io-util.h"
|
||||
#include "locale-util.h"
|
||||
#include "loop-util.h"
|
||||
#include "machine-image.h"
|
||||
#include "mkdir.h"
|
||||
#include "nulstr-util.h"
|
||||
#include "os-util.h"
|
||||
|
@ -12,13 +12,13 @@
|
||||
#include "bus-wait-for-jobs.h"
|
||||
#include "def.h"
|
||||
#include "dirent-util.h"
|
||||
#include "discover-image.h"
|
||||
#include "env-file.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "format-table.h"
|
||||
#include "fs-util.h"
|
||||
#include "locale-util.h"
|
||||
#include "machine-image.h"
|
||||
#include "main-func.h"
|
||||
#include "pager.h"
|
||||
#include "parse-util.h"
|
||||
|
@ -4,9 +4,9 @@
|
||||
#include "btrfs-util.h"
|
||||
#include "bus-common-errors.h"
|
||||
#include "bus-polkit.h"
|
||||
#include "discover-image.h"
|
||||
#include "fd-util.h"
|
||||
#include "io-util.h"
|
||||
#include "machine-image.h"
|
||||
#include "missing_capability.h"
|
||||
#include "portable.h"
|
||||
#include "portabled-bus.h"
|
||||
|
@ -11,10 +11,10 @@
|
||||
#include "bus-label.h"
|
||||
#include "bus-polkit.h"
|
||||
#include "bus-util.h"
|
||||
#include "discover-image.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "io-util.h"
|
||||
#include "machine-image.h"
|
||||
#include "missing_capability.h"
|
||||
#include "portable.h"
|
||||
#include "portabled-bus.h"
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "sd-bus.h"
|
||||
|
||||
#include "machine-image.h"
|
||||
#include "discover-image.h"
|
||||
#include "portabled.h"
|
||||
|
||||
int bus_image_common_get_os_release(Manager *m, sd_bus_message *message, const char *name_or_path, Image *image, sd_bus_error *error);
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "discover-image.h"
|
||||
#include "hashmap.h"
|
||||
#include "machine-image.h"
|
||||
#include "portabled.h"
|
||||
|
||||
Image *manager_image_cache_get(Manager *m, const char *name_or_path);
|
||||
|
@ -2500,6 +2500,90 @@ static int verb_log_level(int argc, char *argv[], void *userdata) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *resolve_flags_to_string(uint64_t flags) {
|
||||
return flags & SD_RESOLVED_DNS ? "DNS" :
|
||||
flags & SD_RESOLVED_LLMNR_IPV4 ? "LLMNR/IPv4" :
|
||||
flags & SD_RESOLVED_LLMNR_IPV6 ? "LLMNR/IPv6" :
|
||||
flags & SD_RESOLVED_MDNS_IPV4 ? "mDNS/IPv4" :
|
||||
flags & SD_RESOLVED_MDNS_IPV6 ? "mDNS/IPv6" :
|
||||
"";
|
||||
}
|
||||
|
||||
static int verb_show_multicast(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
||||
_cleanup_(table_unrefp) Table *table = NULL;
|
||||
sd_bus *bus = userdata;
|
||||
int r;
|
||||
|
||||
assert(bus);
|
||||
|
||||
table = table_new("Hostname", "Address", "Source");
|
||||
if (!table)
|
||||
return log_oom();
|
||||
|
||||
r = bus_call_method(bus, bus_resolve_mgr, "GetMulticastHosts", &error, &reply, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to query systemd-resolved: %s", bus_error_message(&error, r));
|
||||
|
||||
r = sd_bus_message_enter_container(reply, 'a', "(stiiay)");
|
||||
if (r < 0)
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
while ((r = sd_bus_message_enter_container(reply, 'r', "stiiay")) > 0) {
|
||||
char *canonical;
|
||||
uint64_t flags;
|
||||
_cleanup_free_ char *pretty = NULL;
|
||||
int ifindex, family;
|
||||
union in_addr_union a;
|
||||
|
||||
r = sd_bus_message_read(reply, "st", &canonical, &flags);
|
||||
if (r < 0)
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
r = sd_bus_message_read(reply, "i", &ifindex);
|
||||
if (r < 0)
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
sd_bus_error_free(&error);
|
||||
r = bus_message_read_in_addr_auto(reply, &error, &family, &a);
|
||||
if (r < 0)
|
||||
return log_error_errno(
|
||||
r,
|
||||
"systemd-resolved returned invalid result: %s",
|
||||
bus_error_message(&error, r));
|
||||
|
||||
r = sd_bus_message_exit_container(reply);
|
||||
if (r < 0)
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
r = in_addr_ifindex_to_string(family, &a, ifindex, &pretty);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to print address: %m");
|
||||
|
||||
r = table_add_many(
|
||||
table,
|
||||
TABLE_STRING,
|
||||
canonical,
|
||||
TABLE_STRING,
|
||||
pretty,
|
||||
TABLE_STRING,
|
||||
resolve_flags_to_string(flags));
|
||||
if (r < 0)
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = sd_bus_message_exit_container(reply);
|
||||
if (r < 0)
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
r = table_print(table, NULL);
|
||||
if (r < 0)
|
||||
return table_log_print_error(r);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void help_protocol_types(void) {
|
||||
if (arg_legend)
|
||||
puts("Known protocol types:");
|
||||
@ -2609,6 +2693,7 @@ static int native_help(void) {
|
||||
" nta [LINK [DOMAIN...]] Get/set per-interface DNSSEC NTA\n"
|
||||
" revert LINK Revert per-interface configuration\n"
|
||||
" log-level [LEVEL] Get/set logging threshold for systemd-resolved\n"
|
||||
" show-multicast Show domain names discovered via LLMNR/mDNS\n"
|
||||
"\nOptions:\n"
|
||||
" -h --help Show this help\n"
|
||||
" --version Show package version\n"
|
||||
@ -3152,7 +3237,7 @@ static int native_parse_argv(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
static int native_main(int argc, char *argv[], sd_bus *bus) {
|
||||
|
||||
/* clang-format off */
|
||||
static const Verb verbs[] = {
|
||||
{ "help", VERB_ANY, VERB_ANY, 0, verb_help },
|
||||
{ "status", VERB_ANY, VERB_ANY, VERB_DEFAULT, verb_status },
|
||||
@ -3174,8 +3259,10 @@ static int native_main(int argc, char *argv[], sd_bus *bus) {
|
||||
{ "nta", VERB_ANY, VERB_ANY, 0, verb_nta },
|
||||
{ "revert", VERB_ANY, 2, 0, verb_revert_link },
|
||||
{ "log-level", VERB_ANY, 2, 0, verb_log_level },
|
||||
{ "show-multicast", VERB_ANY, VERB_ANY, 0, verb_show_multicast },
|
||||
{}
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
return dispatch_verb(argc, argv, verbs, bus);
|
||||
}
|
||||
|
@ -132,15 +132,17 @@ static int reply_query_state(DnsQuery *q) {
|
||||
}
|
||||
}
|
||||
|
||||
static int append_address(sd_bus_message *reply, DnsResourceRecord *rr, int ifindex) {
|
||||
static int append_address(sd_bus_message *reply, DnsResourceRecord *rr, int ifindex, bool is_container) {
|
||||
int r;
|
||||
|
||||
assert(reply);
|
||||
assert(rr);
|
||||
|
||||
r = sd_bus_message_open_container(reply, 'r', "iiay");
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (is_container) {
|
||||
r = sd_bus_message_open_container(reply, 'r', "iiay");
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = sd_bus_message_append(reply, "i", ifindex);
|
||||
if (r < 0)
|
||||
@ -165,9 +167,11 @@ static int append_address(sd_bus_message *reply, DnsResourceRecord *rr, int ifin
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_bus_message_close_container(reply);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (is_container) {
|
||||
r = sd_bus_message_close_container(reply);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -216,7 +220,7 @@ static void bus_method_resolve_hostname_complete(DnsQuery *q) {
|
||||
if (r == 0)
|
||||
continue;
|
||||
|
||||
r = append_address(reply, rr, ifindex);
|
||||
r = append_address(reply, rr, ifindex, true);
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
|
||||
@ -851,7 +855,7 @@ static int append_srv(DnsQuery *q, sd_bus_message *reply, DnsResourceRecord *rr)
|
||||
if (r == 0)
|
||||
continue;
|
||||
|
||||
r = append_address(reply, zz, ifindex);
|
||||
r = append_address(reply, zz, ifindex, true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@ -2000,6 +2004,76 @@ static int bus_method_unregister_service(sd_bus_message *message, void *userdata
|
||||
return call_dnssd_method(m, message, bus_dnssd_method_unregister, error);
|
||||
}
|
||||
|
||||
static int bus_method_get_multicast_hosts(sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
||||
DnsScope *s;
|
||||
Manager *m = userdata;
|
||||
int r;
|
||||
|
||||
assert(message);
|
||||
assert(m);
|
||||
|
||||
r = sd_bus_message_new_method_return(message, &reply);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_bus_message_open_container(reply, 'a', "(stiiay)");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
LIST_FOREACH(scopes, s, m->dns_scopes) {
|
||||
_cleanup_(dns_answer_unrefp) DnsAnswer *answer = NULL;
|
||||
DnsResourceRecord *rr;
|
||||
DnsAnswerFlags flags;
|
||||
int ifindex;
|
||||
|
||||
if (s->protocol == DNS_PROTOCOL_DNS)
|
||||
continue;
|
||||
|
||||
r = dns_cache_dump_to_answer(&s->cache, &answer);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
continue;
|
||||
|
||||
DNS_ANSWER_FOREACH_FULL(rr, ifindex, flags, answer) {
|
||||
_cleanup_free_ char *normalized = NULL;
|
||||
bool authenticated = FLAGS_SET(flags, DNS_ANSWER_AUTHENTICATED);
|
||||
|
||||
r = dns_name_normalize(dns_resource_key_name(rr->key), 0, &normalized);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_bus_message_open_container(reply, 'r', "stiiay");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_bus_message_append(
|
||||
reply,
|
||||
"st",
|
||||
normalized,
|
||||
SD_RESOLVED_FLAGS_MAKE(s->protocol, s->family, authenticated));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = append_address(reply, rr, ifindex, false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_bus_message_close_container(reply);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
r = sd_bus_message_close_container(reply);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return sd_bus_reply(message, reply);
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
static const sd_bus_vtable resolve_vtable[] = {
|
||||
SD_BUS_VTABLE_START(0),
|
||||
SD_BUS_PROPERTY("LLMNRHostname", "s", NULL, offsetof(Manager, llmnr_hostname), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
@ -2138,9 +2212,14 @@ static const sd_bus_vtable resolve_vtable[] = {
|
||||
SD_BUS_NO_RESULT,
|
||||
bus_method_reset_server_features,
|
||||
SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
|
||||
SD_BUS_METHOD_WITH_ARGS("GetMulticastHosts",
|
||||
SD_BUS_NO_ARGS,
|
||||
SD_BUS_RESULT("a(stiiay)", addresses),
|
||||
bus_method_get_multicast_hosts,
|
||||
SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
SD_BUS_VTABLE_END,
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
const BusObjectImplementation manager_object = {
|
||||
"/org/freedesktop/resolve1",
|
||||
|
@ -1066,7 +1066,55 @@ int dns_cache_export_shared_to_packet(DnsCache *cache, DnsPacket *p) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dns_cache_dump(DnsCache *cache, FILE *f) {
|
||||
int dns_cache_dump_to_answer(DnsCache *cache, DnsAnswer **ret) {
|
||||
_cleanup_(dns_answer_unrefp) DnsAnswer *answer = NULL;
|
||||
DnsCacheItem *i;
|
||||
size_t n = 0;
|
||||
int r;
|
||||
|
||||
assert(cache);
|
||||
assert(ret);
|
||||
|
||||
HASHMAP_FOREACH(i, cache->by_key) {
|
||||
DnsCacheItem *j;
|
||||
|
||||
LIST_FOREACH(by_key, j, i) {
|
||||
if (!j->rr)
|
||||
continue;
|
||||
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
if (n == 0) {
|
||||
*ret = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
answer = dns_answer_new(n);
|
||||
if (!answer)
|
||||
return -ENOMEM;
|
||||
|
||||
HASHMAP_FOREACH(i, cache->by_key) {
|
||||
DnsCacheItem *j;
|
||||
|
||||
LIST_FOREACH(by_key, j, i) {
|
||||
if (!j->rr)
|
||||
continue;
|
||||
|
||||
r = dns_answer_add(
|
||||
answer, j->rr, j->ifindex, j->authenticated ? DNS_ANSWER_AUTHENTICATED : 0);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
*ret = TAKE_PTR(answer);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void dns_cache_dump_to_file(DnsCache *cache, FILE *f) {
|
||||
DnsCacheItem *i;
|
||||
|
||||
if (!cache)
|
||||
|
@ -27,7 +27,8 @@ int dns_cache_lookup(DnsCache *c, DnsResourceKey *key, bool clamp_ttl, int *rcod
|
||||
|
||||
int dns_cache_check_conflicts(DnsCache *cache, DnsResourceRecord *rr, int owner_family, const union in_addr_union *owner_address);
|
||||
|
||||
void dns_cache_dump(DnsCache *cache, FILE *f);
|
||||
void dns_cache_dump_to_file(DnsCache *cache, FILE *f);
|
||||
int dns_cache_dump_to_answer(DnsCache *cache, DnsAnswer **answer);
|
||||
bool dns_cache_is_empty(DnsCache *cache);
|
||||
|
||||
unsigned dns_cache_size(DnsCache *cache);
|
||||
|
@ -1159,7 +1159,7 @@ void dns_scope_dump(DnsScope *s, FILE *f) {
|
||||
|
||||
if (!dns_cache_is_empty(&s->cache)) {
|
||||
fputs("CACHE:\n", f);
|
||||
dns_cache_dump(&s->cache, f);
|
||||
dns_cache_dump_to_file(&s->cache, f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "chattr-util.h"
|
||||
#include "copy.h"
|
||||
#include "dirent-util.h"
|
||||
#include "discover-image.h"
|
||||
#include "dissect-image.h"
|
||||
#include "env-file.h"
|
||||
#include "env-util.h"
|
||||
@ -27,7 +28,6 @@
|
||||
#include "lockfile-util.h"
|
||||
#include "log.h"
|
||||
#include "loop-util.h"
|
||||
#include "machine-image.h"
|
||||
#include "macro.h"
|
||||
#include "mkdir.h"
|
||||
#include "nulstr-util.h"
|
||||
@ -1065,7 +1065,6 @@ int image_path_lock(const char *path, int operation, LockFile *global, LockFile
|
||||
r = asprintf(&p, "/run/systemd/nspawn/locks/inode-%lu:%lu", (unsigned long) st.st_dev, (unsigned long) st.st_ino);
|
||||
else
|
||||
return -ENOTTY;
|
||||
|
||||
if (r < 0)
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -1220,11 +1219,16 @@ int image_read_metadata(Image *i) {
|
||||
}
|
||||
|
||||
int image_name_lock(const char *name, int operation, LockFile *ret) {
|
||||
const char *p;
|
||||
|
||||
assert(name);
|
||||
assert(ret);
|
||||
|
||||
/* Locks an image name, regardless of the precise path used. */
|
||||
|
||||
if (streq(name, ".host"))
|
||||
return -EBUSY;
|
||||
|
||||
if (!image_name_is_valid(name))
|
||||
return -EINVAL;
|
||||
|
||||
@ -1233,11 +1237,9 @@ int image_name_lock(const char *name, int operation, LockFile *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (streq(name, ".host"))
|
||||
return -EBUSY;
|
||||
|
||||
const char *p = strjoina("/run/systemd/nspawn/locks/name-", name);
|
||||
(void) mkdir_p("/run/systemd/nspawn/locks", 0700);
|
||||
|
||||
p = strjoina("/run/systemd/nspawn/locks/name-", name);
|
||||
return make_lock_file(p, operation, ret);
|
||||
}
|
||||
|
@ -79,6 +79,8 @@ shared_sources = files('''
|
||||
dev-setup.c
|
||||
dev-setup.h
|
||||
devnode-acl.h
|
||||
discover-image.c
|
||||
discover-image.h
|
||||
dissect-image.c
|
||||
dissect-image.h
|
||||
dm-util.c
|
||||
@ -172,8 +174,6 @@ shared_sources = files('''
|
||||
loopback-setup.h
|
||||
machine-id-setup.c
|
||||
machine-id-setup.h
|
||||
machine-image.c
|
||||
machine-image.h
|
||||
machine-pool.c
|
||||
machine-pool.h
|
||||
macvlan-util.c
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "discover-image.h"
|
||||
#include "env-file.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
#include "macro.h"
|
||||
#include "machine-image.h"
|
||||
#include "os-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "capability-util.h"
|
||||
#include "discover-image.h"
|
||||
#include "dissect-image.h"
|
||||
#include "escape.h"
|
||||
#include "fd-util.h"
|
||||
@ -14,7 +15,6 @@
|
||||
#include "fs-util.h"
|
||||
#include "hashmap.h"
|
||||
#include "log.h"
|
||||
#include "machine-image.h"
|
||||
#include "main-func.h"
|
||||
#include "missing_magic.h"
|
||||
#include "mkdir.h"
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "condition.h"
|
||||
#include "device-private.h"
|
||||
#include "device.h"
|
||||
#include "discover-image.h"
|
||||
#include "execute.h"
|
||||
#include "import-util.h"
|
||||
#include "install.h"
|
||||
@ -18,7 +19,6 @@
|
||||
#include "locale-util.h"
|
||||
#include "log.h"
|
||||
#include "logs-show.h"
|
||||
#include "machine-image.h"
|
||||
#include "mount.h"
|
||||
#include "path.h"
|
||||
#include "process-util.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user