mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-10 00:58:20 +03:00
Merge pull request #15804 from poettering/hostnamed-instant-part1
four likely safe commits split out of #15624
This commit is contained in:
commit
b3d15d90c0
@ -544,6 +544,25 @@
|
||||
This corresponds to the <constant>org.freedesktop.systemd1.Explicit</constant> annotation
|
||||
in introspection data.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><constant>SD_BUS_VTABLE_SENSITIVE</constant></term>
|
||||
|
||||
<listitem><para>Mark this vtable method entry as processing sensitive data. When set,
|
||||
incoming method call messages and their outgoing reply messages are marked as sensitive using
|
||||
<citerefentry><refentrytitle>sd_bus_message_sensitive</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
so that they are erased from memory when freed.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><constant>SD_BUS_VTABLE_ABSOLUTE_OFFSET</constant></term>
|
||||
|
||||
<listitem><para>Mark this vtable method or property entry so that the user data pointer passed to
|
||||
its associated handler functions is determined slightly differently: instead of adding the offset
|
||||
parameter of the entry to the user data pointer specified during vtable registration, the offset is
|
||||
passed directly, converted to a pointer, without taking the user data pointer specified during
|
||||
vtable registration into account.</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect2>
|
||||
</refsect1>
|
||||
|
@ -388,3 +388,24 @@ int proc_mounted(void) {
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
bool stat_inode_unmodified(const struct stat *a, const struct stat *b) {
|
||||
|
||||
/* Returns if the specified stat structures reference the same, unmodified inode. This check tries to
|
||||
* be reasonably careful when detecting changes: we check both inode and mtime, to cater for file
|
||||
* systems where mtimes are fixed to 0 (think: ostree/nixos type installations). We also check file
|
||||
* size, backing device, inode type and if this refers to a device not the major/minor.
|
||||
*
|
||||
* Note that we don't care if file attributes such as ownership or access mode change, this here is
|
||||
* about contents of the file. The purpose here is to detect file contents changes, and nothing
|
||||
* else. */
|
||||
|
||||
return a && b &&
|
||||
(a->st_mode & S_IFMT) != 0 && /* We use the check for .st_mode if the structure was ever initialized */
|
||||
((a->st_mode ^ b->st_mode) & S_IFMT) == 0 && /* same inode type */
|
||||
a->st_mtime == b->st_mtime &&
|
||||
(!S_ISREG(a->st_mode) || a->st_size == b->st_size) && /* if regular file, compare file size */
|
||||
a->st_dev == b->st_dev &&
|
||||
a->st_ino == b->st_ino &&
|
||||
(!(S_ISCHR(a->st_mode) || S_ISBLK(a->st_mode)) || a->st_rdev == b->st_rdev); /* if device node, also compare major/minor, because we can */
|
||||
}
|
||||
|
@ -89,3 +89,5 @@ int device_path_make_canonical(mode_t mode, dev_t devno, char **ret);
|
||||
int device_path_parse_major_minor(const char *path, mode_t *ret_mode, dev_t *ret_devno);
|
||||
|
||||
int proc_mounted(void);
|
||||
|
||||
bool stat_inode_unmodified(const struct stat *a, const struct stat *b);
|
||||
|
@ -56,7 +56,7 @@ static int node_vtable_get_userdata(
|
||||
static void *vtable_method_convert_userdata(const sd_bus_vtable *p, void *u) {
|
||||
assert(p);
|
||||
|
||||
if (!u)
|
||||
if (!u || FLAGS_SET(p->flags, SD_BUS_VTABLE_ABSOLUTE_OFFSET))
|
||||
return SIZE_TO_PTR(p->x.method.offset); /* don't add offset on NULL, to make ubsan happy */
|
||||
|
||||
return (uint8_t*) u + p->x.method.offset;
|
||||
@ -65,7 +65,7 @@ static void *vtable_method_convert_userdata(const sd_bus_vtable *p, void *u) {
|
||||
static void *vtable_property_convert_userdata(const sd_bus_vtable *p, void *u) {
|
||||
assert(p);
|
||||
|
||||
if (!u)
|
||||
if (!u || FLAGS_SET(p->flags, SD_BUS_VTABLE_ABSOLUTE_OFFSET))
|
||||
return SIZE_TO_PTR(p->x.property.offset); /* as above */
|
||||
|
||||
return (uint8_t*) u + p->x.property.offset;
|
||||
|
@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "sd-event.h"
|
||||
#include "sd-netlink.h"
|
||||
#include "sd-network.h"
|
||||
@ -71,7 +73,7 @@ struct Manager {
|
||||
bool need_builtin_fallbacks:1;
|
||||
|
||||
bool read_resolv_conf:1;
|
||||
usec_t resolv_conf_mtime;
|
||||
struct stat resolv_conf_stat;
|
||||
|
||||
DnsTrustAnchor trust_anchor;
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "resolved-conf.h"
|
||||
#include "resolved-dns-server.h"
|
||||
#include "resolved-resolv-conf.h"
|
||||
#include "stat-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "tmpfile-util-label.h"
|
||||
@ -93,7 +94,7 @@ int manager_read_resolv_conf(Manager *m) {
|
||||
}
|
||||
|
||||
/* Have we already seen the file? */
|
||||
if (timespec_load(&st.st_mtim) == m->resolv_conf_mtime)
|
||||
if (stat_inode_unmodified(&st, &m->resolv_conf_stat))
|
||||
return 0;
|
||||
|
||||
if (file_is_our_own(&st))
|
||||
@ -159,7 +160,7 @@ int manager_read_resolv_conf(Manager *m) {
|
||||
log_syntax(NULL, LOG_DEBUG, "/etc/resolv.conf", n, 0, "Ignoring resolv.conf line: %s", l);
|
||||
}
|
||||
|
||||
m->resolv_conf_mtime = timespec_load(&st.st_mtim);
|
||||
m->resolv_conf_stat = st;
|
||||
|
||||
/* Flush out all servers and search domains that are still
|
||||
* marked. Those are then ones that didn't appear in the new
|
||||
|
@ -44,6 +44,7 @@ enum {
|
||||
SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION = 1ULL << 6,
|
||||
SD_BUS_VTABLE_PROPERTY_EXPLICIT = 1ULL << 7,
|
||||
SD_BUS_VTABLE_SENSITIVE = 1ULL << 8, /* covers both directions: method call + reply */
|
||||
SD_BUS_VTABLE_ABSOLUTE_OFFSET = 1ULL << 9,
|
||||
_SD_BUS_VTABLE_CAPABILITY_MASK = 0xFFFFULL << 40
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user