Compare commits

...

29 Commits

Author SHA1 Message Date
Lennart Poettering cf3317f63a
Merge pull request #15906 from keszybz/busctl-stdout-stderr
Make busctl stdout/stderr split consistent
2020-05-26 15:38:14 +02:00
Lennart Poettering 47eeb381c8
Merge pull request #15909 from keszybz/sd-network-serialization
networkd link serialization fix
2020-05-26 15:37:57 +02:00
Andreas Rammhold 3544f65f0c editorconfig: add man configuration
My VIM usually defaults to tabs (8ch) on these XML files. With this
change it behaves as defined in the coding style documentation.
2020-05-26 15:37:05 +02:00
Norbert Lange 6589a56972 dont install systemd-initctl, runlevel, telinit if no SYSV compat
systemd-initctl executable is still built.
2020-05-26 15:04:36 +02:00
Evgeny Vereshchagin a53a85b35e
Merge pull request #15914 from poettering/ubsan-float-check
json: disable ubsan float checking
2020-05-26 15:11:16 +03:00
Zbigniew Jędrzejewski-Szmek d8bff5cc37 network: simplify how initial space is handled 2020-05-26 10:19:31 +02:00
Zbigniew Jędrzejewski-Szmek d5e172d2fb networkd: unfoobar serialization of links
We'd start writing an entry line, then another one, then another one,
and then output the rest of the first one, and then some other random
stuff, and the rest of some other lines... Results were ...eh... random.

Let's define a helper to avoid some of the copy&paste madness, and separate
blocks that output a single line with /**********************************/.

This rework doesn't change what data is written, it only tries to fix the
format of the output. The fact that some entries only write data from
link->network, and some from either link->network or link, some stuff only
for dhpc4 leases while some for both dhpc4 and dhcp6, etc, looks rather
suspicious too, but I didn't touch this.
2020-05-26 10:08:54 +02:00
Lennart Poettering 253acc229c
Merge pull request #15840 from Werkov/mkosi-opensuse
mkosi: openSUSE updates
2020-05-26 10:02:29 +02:00
Zbigniew Jędrzejewski-Szmek 00813316b0 sd-dhcp6: constify output arguments in get_{ntp,nds}_addr
This matches what we do for ipv4 and is in general better.
2020-05-26 09:47:45 +02:00
Zbigniew Jędrzejewski-Szmek dddc8d1e1e sd-network: reduce scope of some variables 2020-05-26 09:47:45 +02:00
Lennart Poettering ffec8658db
Merge pull request #15862 from hunger/master
repart: Add Uuid option to config files
2020-05-26 09:32:22 +02:00
Lennart Poettering 6ae8c6f5d7 update TODO 2020-05-26 09:21:40 +02:00
Zbigniew Jędrzejewski-Szmek 445bd57e39 busctl: drop unneeded param 2020-05-26 09:13:39 +02:00
Zbigniew Jędrzejewski-Szmek 50f20d1bc2 busctl: verify args early and always print results to stdout
We would print the error sometimes to stdout and sometimes to stderr. It *is*
useful to get the message if one of the names is not found on the bus to
stdout, so that this shows out in the pager. So let's do verification of args
early to catch invalid arguments, and then if we receive an error over the bus
(most likely that the name is not activatable), let's print to stdout so it
gets paged. E.g. 'busctl tree org.freedesktop.systemd1 org.freedesktop.systemd2'
gives a nicely usable output.
2020-05-26 09:07:27 +02:00
Evgeny Vereshchagin e5af586f49 add a test triggering https://github.com/systemd/systemd/issues/15907 2020-05-26 09:01:26 +02:00
Lennart Poettering 8e2fa6e223 json: turn off ubsan for json_variant_has_type()
Fixes: #15907
2020-05-26 09:01:26 +02:00
Lennart Poettering 6028d766d1 macro: introduce DISABLE_WARNING_TYPE_LIMITS and make use of it everywhere 2020-05-25 18:25:09 +02:00
Lennart Poettering 56e577c62f tree-wide: use DISABLE_WARNING_FORMAT_NONLITERAL where appropriate 2020-05-25 18:25:05 +02:00
Lennart Poettering 6a5b28def2 json: use our regular way to turn off compiler warnings 2020-05-25 18:23:50 +02:00
Tobias Hunger 7b5cb4ceb4 Repart: Add simple tests for Label="" and UUID=""
Make sure Labels and UUIDs taken from destination definitions are
taken into account when no Label/UUID is currently set already.
2020-05-25 15:48:59 +02:00
Tobias Hunger 129635333d repart: Add UUID option to config files
Add a option to provide a UUID for the partition that will get
created and document that.
2020-05-25 15:48:59 +02:00
Zbigniew Jędrzejewski-Szmek 2206aa5c35 sd-network: fix inverted error message
We get -ENOMSG when there is no lease.
2020-05-25 11:14:54 +02:00
Zbigniew Jędrzejewski-Szmek 062ac2ea85 sd-bus: internalize setting of bus is_system/is_user
Each of bus_set_address_{user,system} had two users, and each of the two users
would set the internal flag manually. We should do that internally in the
functions instead.

While at it, only set the flag when setting the address is actually successful.
This doesn't change anything for current users, but it seems more correct.
2020-05-25 11:09:21 +02:00
Zbigniew Jędrzejewski-Szmek 0406d1a843 man: add docs for the new functions 2020-05-25 11:09:21 +02:00
Zbigniew Jędrzejewski-Szmek 5453a4b1a8 tree-wide: use public sd-bus functions in more places 2020-05-25 11:09:21 +02:00
Zbigniew Jędrzejewski-Szmek d2916409ed sd-bus: make name validation functions public
Those are fairly trivial to reimplement, but any non-trivial user of sd-bus
is likely to need them. So let's expose them to save everyone the trouble.

I'm keeping the internal functions and making the public ones thin wrappers,
because for the internal uses we don't need the additional asserts, and also we
can't expose _pure_ annotation easily, and dropping it would likely make the
compiled code a bit less efficient.
2020-05-25 11:09:21 +02:00
Zbigniew Jędrzejewski-Szmek 4c163bf1f4 busctl: use set_put_strdup() 2020-05-25 11:09:21 +02:00
Michal Koutný a840ad5ae8 mkosi: Add explicit --bootable=no openSUSE dependencies
Many dependencies were pulled via dracut->systemd. Since we can build
stripped images without initrd and dracut, we need to add systemd
runtime dependencies explicitely.
2020-05-19 13:14:19 +02:00
Michal Koutný 498115c2b6 mkosi: Add openSUSE Tumbleweed packages
patterns-base-minimal_base is a moving target, so dependencies need to
be as explicit as possible.
2020-05-18 23:06:22 +02:00
44 changed files with 527 additions and 370 deletions

View File

@ -26,3 +26,7 @@ indent_size = 4
[meson.build]
indent_style = space
indent_size = 8
[man/*.xml]
indent_size = 2
indent_style = space

View File

@ -49,9 +49,11 @@ BuildPackages=
python3-lxml
qrencode-devel
system-user-nobody
systemd-sysvinit
zlib-devel
# to satisfy tests
acl
diffutils
glibc-locale
system-group-obsolete
system-user-bin
@ -62,3 +64,15 @@ BuildPackages=
Packages=
# brought in via meson->python3
libp11-kit0
# --bootable=no
dbus-1
libapparmor1
libcrypt1
libcryptsetup12
libkmod2
liblz4-1
libmount1
libqrencode4
libseccomp2
pam
util-linux

8
TODO
View File

@ -4,9 +4,6 @@ Bugfixes:
manager or system manager can be always set. It would be better to reject
them when parsing config.
* busctl prints errors to stdout:
busctl tree org.freedesktop.systemd1 /org/freedesktop/systemd1
External:
* Fedora: add an rpmlint check that verifies that all unit files in the RPM are listed in %systemd_post macros.
@ -22,6 +19,9 @@ Janitorial Clean-ups:
Features:
* build short web pages out of each catalog entry, build them along with man
pages, and include hyperlinks to them in the journal output
* machined: add API to acquire UID range. add API to mount/dissect loopback
file. Both protected by PK. Then make nspawn use these APIs to run
unprivileged containers. i.e. push the truly privileged bits into machined,
@ -1227,6 +1227,8 @@ Features:
- duplicate address check for static IPs (like ARPCHECK in network-scripts)
- whenever uplink info changes, make DHCP server send out FORCERENEW
* Figure out how to do unittests of networkd's state serialization
* dhcp:
- figure out how much we can increase Maximum Message Size

View File

@ -217,6 +217,16 @@
automatically used.</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>UUID=</varname></term>
<listitem><para>The UUID to assign to the partition if none is assigned yet. Note that this
setting is not used for matching. It is also not used when a UUID is already set for an existing
partition. It is thus only used when a partition is newly created or when an existing one had a
all-zero UUID set. If not specified a UUID derived from the partition type is automatically
used.</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>Priority=</varname></term>

View File

@ -267,6 +267,12 @@ manpages = [
['sd_bus_get_n_queued_read', '3', ['sd_bus_get_n_queued_write'], ''],
['sd_bus_get_name_creds', '3', ['sd_bus_get_owner_creds'], ''],
['sd_bus_get_name_machine_id', '3', [], ''],
['sd_bus_interface_name_is_valid',
'3',
['sd_bus_member_name_is_valid',
'sd_bus_object_path_is_valid',
'sd_bus_service_name_is_valid'],
''],
['sd_bus_is_open', '3', ['sd_bus_is_ready'], ''],
['sd_bus_list_names', '3', [], ''],
['sd_bus_message_append', '3', ['sd_bus_message_appendv'], ''],

View File

@ -89,6 +89,7 @@
<citerefentry><refentrytitle>sd_bus_get_scope</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_tid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_unique_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_interface_name_is_valid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_is_monitor</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_is_bus_client</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_is_server</refentrytitle><manvolnum>3</manvolnum></citerefentry>,

View File

@ -0,0 +1,98 @@
<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!-- SPDX-License-Identifier: LGPL-2.1+ -->
<refentry id="sd_bus_interface_name_is_valid" xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>sd_bus_interface_name_is_valid</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>sd_bus_interface_name_is_valid</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_bus_interface_name_is_valid</refname>
<refname>sd_bus_service_name_is_valid</refname>
<refname>sd_bus_member_name_is_valid</refname>
<refname>sd_bus_object_path_is_valid</refname>
<refpurpose>Check if a string is a valid bus name or object path</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_bus_interface_name_is_valid</function></funcdef>
<paramdef>const char* <parameter>p</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_service_name_is_valid</function></funcdef>
<paramdef>const char* <parameter>p</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_member_name_is_valid</function></funcdef>
<paramdef>const char* <parameter>p</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_object_path_is_valid</function></funcdef>
<paramdef>const char* <parameter>p</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_bus_interface_name_is_valid()</function> checks if a given string
<parameter>p</parameter> is a syntactically valid bus interface name. Similarly,
<function>sd_bus_service_name_is_valid()</function> checks if the argument is a valid bus service name,
<function>sd_bus_member_name_is_valid()</function> checks if the argument is a valid bus interface member
name, and <function>sd_bus_object_path_is_valid()</function> checks if the argument is a valid bus object
path. Those functions generally check that only allowed characters are used and that the length of the
string is within limits.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>Those functions return 1 if the argument is a valid interface / service / member name or object
path, and 0 if it is not. If the argument is NULL, an error is returned.</para>
<refsect2>
<title>Errors</title>
<para>Returned errors may indicate the following problems:</para>
<variablelist>
<varlistentry>
<term><constant>-EINVAL</constant></term>
<listitem><para>The <parameter>p</parameter> parameter is
<constant>NULL</constant>.</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
</refsect1>
<xi:include href="libsystemd-pkgconfig.xml" />
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_call_method</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@ -2189,7 +2189,8 @@ if conf.get('ENABLE_HOMED') == 1
endif
endif
foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
(conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
meson.add_install_script(meson_make_symlink,
join_paths(rootbindir, 'systemctl'),
join_paths(rootsbindir, alias))
@ -2851,7 +2852,7 @@ executable(
include_directories : includes,
link_with : [libshared],
install_rpath : rootlibexecdir,
install : true,
install : (conf.get('HAVE_SYSV_COMPAT') == 1),
install_dir : rootlibexecdir)
public_programs += executable(

View File

@ -84,6 +84,14 @@
#define _variable_no_sanitize_address_
#endif
/* Apparently there's no has_feature() call defined to check for ubsan, hence let's define this
* unconditionally on llvm */
#if defined(__clang__)
#define _function_no_sanitize_float_cast_overflow_ __attribute__((no_sanitize("float-cast-overflow")))
#else
#define _function_no_sanitize_float_cast_overflow_
#endif
/* Temporarily disable some warnings */
#define DISABLE_WARNING_FORMAT_NONLITERAL \
_Pragma("GCC diagnostic push"); \
@ -114,6 +122,14 @@
_Pragma("GCC diagnostic push")
#endif
#define DISABLE_WARNING_FLOAT_EQUAL \
_Pragma("GCC diagnostic push"); \
_Pragma("GCC diagnostic ignored \"-Wfloat-equal\"")
#define DISABLE_WARNING_TYPE_LIMITS \
_Pragma("GCC diagnostic push"); \
_Pragma("GCC diagnostic ignored \"-Wtype-limits\"")
#define REENABLE_WARNING \
_Pragma("GCC diagnostic pop")

View File

@ -110,13 +110,10 @@ static int acquire_bus(bool set_monitor, sd_bus **ret) {
switch (arg_transport) {
case BUS_TRANSPORT_LOCAL:
if (arg_user) {
bus->is_user = true;
if (arg_user)
r = bus_set_address_user(bus);
} else {
bus->is_system = true;
else
r = bus_set_address_system(bus);
}
break;
case BUS_TRANSPORT_REMOTE:
@ -427,29 +424,15 @@ static void print_subtree(const char *prefix, const char *path, char **l) {
}
}
static void print_tree(const char *prefix, char **l) {
prefix = strempty(prefix);
if (arg_list) {
char **i;
STRV_FOREACH(i, l)
printf("%s%s\n", prefix, *i);
return;
}
if (strv_isempty(l)) {
static void print_tree(char **l) {
if (arg_list)
strv_print(l);
else if (strv_isempty(l))
printf("No objects discovered.\n");
return;
}
if (streq(l[0], "/") && !l[1]) {
else if (streq(l[0], "/") && !l[1])
printf("Only root object discovered.\n");
return;
}
print_subtree(prefix, "/", l);
else
print_subtree("", "/", l);
}
static int on_path(const char *path, void *userdata) {
@ -465,7 +448,7 @@ static int on_path(const char *path, void *userdata) {
return 0;
}
static int find_nodes(sd_bus *bus, const char *service, const char *path, Set *paths, bool many) {
static int find_nodes(sd_bus *bus, const char *service, const char *path, Set *paths) {
static const XMLIntrospectOps ops = {
.on_path = on_path,
};
@ -479,12 +462,10 @@ static int find_nodes(sd_bus *bus, const char *service, const char *path, Set *p
"org.freedesktop.DBus.Introspectable", "Introspect",
&error, &reply, "");
if (r < 0) {
if (many)
printf("Failed to introspect object %s of service %s: %s\n",
path, service, bus_error_message(&error, r));
else
log_error_errno(r, "Failed to introspect object %s of service %s: %s",
path, service, bus_error_message(&error, r));
printf("%sFailed to introspect object %s of service %s: %s%s\n",
ansi_highlight_red(),
path, service, bus_error_message(&error, r),
ansi_normal());
return r;
}
@ -495,34 +476,23 @@ static int find_nodes(sd_bus *bus, const char *service, const char *path, Set *p
return parse_xml_introspect(path, xml, &ops, paths);
}
static int tree_one(sd_bus *bus, const char *service, const char *prefix, bool many) {
_cleanup_set_free_free_ Set *paths = NULL, *done = NULL, *failed = NULL;
static int tree_one(sd_bus *bus, const char *service) {
_cleanup_set_free_ Set *paths = NULL, *done = NULL, *failed = NULL;
_cleanup_free_ char **l = NULL;
char *m;
int r;
paths = set_new(&string_hash_ops);
if (!paths)
r = set_put_strdup(&paths, "/");
if (r < 0)
return log_oom();
done = set_new(&string_hash_ops);
done = set_new(&string_hash_ops_free);
if (!done)
return log_oom();
failed = set_new(&string_hash_ops);
failed = set_new(&string_hash_ops_free);
if (!failed)
return log_oom();
m = strdup("/");
if (!m)
return log_oom();
r = set_put(paths, m);
if (r < 0) {
free(m);
return log_oom();
}
for (;;) {
_cleanup_free_ char *p = NULL;
int q;
@ -535,20 +505,14 @@ static int tree_one(sd_bus *bus, const char *service, const char *prefix, bool m
set_contains(failed, p))
continue;
q = find_nodes(bus, service, p, paths, many);
if (q < 0) {
if (r >= 0)
q = find_nodes(bus, service, p, paths);
if (q < 0 && r >= 0)
r = q;
q = set_put(failed, p);
} else
q = set_put(done, p);
q = set_consume(q < 0 ? failed : done, TAKE_PTR(p));
assert(q != 0);
if (q < 0)
return log_oom();
assert(q != 0);
p = NULL;
}
(void) pager_open(arg_pager_flags);
@ -558,7 +522,7 @@ static int tree_one(sd_bus *bus, const char *service, const char *prefix, bool m
return log_oom();
strv_sort(l);
print_tree(prefix, l);
print_tree(l);
fflush(stdout);
@ -570,6 +534,12 @@ static int tree(int argc, char **argv, void *userdata) {
char **i;
int r = 0;
/* Do superficial verification of arguments before even opening the bus */
STRV_FOREACH(i, strv_skip(argv, 1))
if (!sd_bus_service_name_is_valid(*i))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Invalid bus service name: %s", *i);
if (!arg_unique && !arg_acquired)
arg_acquired = true;
@ -601,14 +571,14 @@ static int tree(int argc, char **argv, void *userdata) {
printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_normal());
q = tree_one(bus, *i, NULL, true);
q = tree_one(bus, *i);
if (q < 0 && r >= 0)
r = q;
not_first = true;
}
} else {
STRV_FOREACH(i, argv+1) {
} else
STRV_FOREACH(i, strv_skip(argv, 1)) {
int q;
if (i > argv+1)
@ -619,11 +589,10 @@ static int tree(int argc, char **argv, void *userdata) {
printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_normal());
}
q = tree_one(bus, *i, NULL, !!argv[2]);
q = tree_one(bus, *i);
if (q < 0 && r >= 0)
r = q;
}
}
return r;
}
@ -1291,7 +1260,7 @@ static int monitor(int argc, char **argv, int (*dump)(sd_bus_message *m, FILE *f
STRV_FOREACH(i, argv+1) {
_cleanup_free_ char *m = NULL;
if (!service_name_is_valid(*i))
if (!sd_bus_service_name_is_valid(*i))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid service name '%s'", *i);
m = strjoin("sender='", *i, "'");
@ -2608,7 +2577,6 @@ static int parse_argv(int argc, char *argv[]) {
}
static int busctl_main(int argc, char *argv[]) {
static const Verb verbs[] = {
{ "list", VERB_ANY, 1, VERB_DEFAULT, list_bus_names },
{ "status", VERB_ANY, 2, 0, status },

View File

@ -707,8 +707,7 @@ static int bus_cgroup_set_boolean(
return 1; \
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wtype-limits"
DISABLE_WARNING_TYPE_LIMITS;
BUS_DEFINE_SET_CGROUP_WEIGHT(cpu_weight, CGROUP_MASK_CPU, CGROUP_WEIGHT_IS_OK, CGROUP_WEIGHT_INVALID);
BUS_DEFINE_SET_CGROUP_WEIGHT(cpu_shares, CGROUP_MASK_CPU, CGROUP_CPU_SHARES_IS_OK, CGROUP_CPU_SHARES_INVALID);
BUS_DEFINE_SET_CGROUP_WEIGHT(io_weight, CGROUP_MASK_IO, CGROUP_WEIGHT_IS_OK, CGROUP_WEIGHT_INVALID);
@ -716,7 +715,7 @@ BUS_DEFINE_SET_CGROUP_WEIGHT(blockio_weight, CGROUP_MASK_BLKIO, CGROUP_BLKIO_WEI
BUS_DEFINE_SET_CGROUP_LIMIT(memory, CGROUP_MASK_MEMORY, physical_memory_scale, 1);
BUS_DEFINE_SET_CGROUP_LIMIT(memory_protection, CGROUP_MASK_MEMORY, physical_memory_scale, 0);
BUS_DEFINE_SET_CGROUP_LIMIT(swap, CGROUP_MASK_MEMORY, physical_memory_scale, 0);
#pragma GCC diagnostic pop
REENABLE_WARNING;
static int bus_cgroup_set_tasks_max(
Unit *u,

View File

@ -2,7 +2,6 @@
#include "alloc-util.h"
#include "bus-common-errors.h"
#include "bus-internal.h"
#include "bus-util.h"
#include "dbus-cgroup.h"
#include "dbus-kill.h"
@ -140,7 +139,7 @@ static int bus_scope_set_transient_property(
if (r < 0)
return r;
if (!isempty(controller) && !service_name_is_valid(controller))
if (!isempty(controller) && !sd_bus_service_name_is_valid(controller))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Controller '%s' is not a valid bus name.", controller);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {

View File

@ -4,7 +4,6 @@
#include "alloc-util.h"
#include "async.h"
#include "bus-internal.h"
#include "bus-util.h"
#include "dbus-cgroup.h"
#include "dbus-execute.h"
@ -258,7 +257,7 @@ static BUS_DEFINE_SET_TRANSIENT_PARSE(notify_access, NotifyAccess, notify_access
static BUS_DEFINE_SET_TRANSIENT_PARSE(service_type, ServiceType, service_type_from_string);
static BUS_DEFINE_SET_TRANSIENT_PARSE(service_restart, ServiceRestart, service_restart_from_string);
static BUS_DEFINE_SET_TRANSIENT_PARSE(oom_policy, OOMPolicy, oom_policy_from_string);
static BUS_DEFINE_SET_TRANSIENT_STRING_WITH_CHECK(bus_name, service_name_is_valid);
static BUS_DEFINE_SET_TRANSIENT_STRING_WITH_CHECK(bus_name, sd_bus_service_name_is_valid);
static int bus_service_set_transient_property(
Service *s,

View File

@ -1948,7 +1948,7 @@ int config_parse_bus_name(
return 0;
}
if (!service_name_is_valid(k)) {
if (!sd_bus_service_name_is_valid(k)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid bus name, ignoring: %s", k);
return 0;
}

View File

@ -123,12 +123,12 @@ _printf_(2, 3) static int log_callback(int type, const char *fmt, ...) {
fmt2 = strjoina("selinux: ", fmt);
va_start(ap, fmt);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
DISABLE_WARNING_FORMAT_NONLITERAL;
log_internalv(LOG_AUTH | callback_type_to_priority(type),
0, PROJECT_FILE, __LINE__, __FUNCTION__,
fmt2, ap);
#pragma GCC diagnostic pop
REENABLE_WARNING;
va_end(ap);
return 0;

View File

@ -263,10 +263,10 @@ static int write_dependency(
res = strv_join(units, " ");
if (!res)
return log_oom();
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
DISABLE_WARNING_FORMAT_NONLITERAL;
fprintf(f, format, res);
#pragma GCC diagnostic pop
REENABLE_WARNING;
}
return 0;

View File

@ -78,10 +78,9 @@ int mhd_respondf(struct MHD_Connection *connection,
errno = -error;
fmt = strjoina(format, "\n");
va_start(ap, format);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
DISABLE_WARNING_FORMAT_NONLITERAL;
r = vasprintf(&m, fmt, ap);
#pragma GCC diagnostic pop
REENABLE_WARNING;
va_end(ap);
if (r < 0)

View File

@ -656,27 +656,27 @@ int config_parse_bridge_port_priority(
size_t serialize_in_addrs(FILE *f,
const struct in_addr *addresses,
size_t size,
bool with_leading_space,
bool *with_leading_space,
bool (*predicate)(const struct in_addr *addr)) {
size_t count;
size_t i;
assert(f);
assert(addresses);
count = 0;
size_t count = 0;
bool _space = false;
if (!with_leading_space)
with_leading_space = &_space;
for (i = 0; i < size; i++) {
for (size_t i = 0; i < size; i++) {
char sbuf[INET_ADDRSTRLEN];
if (predicate && !predicate(&addresses[i]))
continue;
if (with_leading_space)
if (*with_leading_space)
fputc(' ', f);
else
with_leading_space = true;
fputs(inet_ntop(AF_INET, &addresses[i], sbuf, sizeof(sbuf)), f);
count++;
*with_leading_space = true;
}
return count;
@ -718,20 +718,22 @@ int deserialize_in_addrs(struct in_addr **ret, const char *string) {
return size;
}
void serialize_in6_addrs(FILE *f, const struct in6_addr *addresses, size_t size) {
unsigned i;
void serialize_in6_addrs(FILE *f, const struct in6_addr *addresses, size_t size, bool *with_leading_space) {
assert(f);
assert(addresses);
assert(size);
for (i = 0; i < size; i++) {
bool _space = false;
if (!with_leading_space)
with_leading_space = &_space;
for (size_t i = 0; i < size; i++) {
char buffer[INET6_ADDRSTRLEN];
fputs(inet_ntop(AF_INET6, addresses+i, buffer, sizeof(buffer)), f);
if (i < size - 1)
if (*with_leading_space)
fputc(' ', f);
fputs(inet_ntop(AF_INET6, addresses+i, buffer, sizeof(buffer)), f);
*with_leading_space = true;
}
}
@ -772,8 +774,6 @@ int deserialize_in6_addrs(struct in6_addr **ret, const char *string) {
}
void serialize_dhcp_routes(FILE *f, const char *key, sd_dhcp_route **routes, size_t size) {
unsigned i;
assert(f);
assert(key);
assert(routes);
@ -781,7 +781,7 @@ void serialize_dhcp_routes(FILE *f, const char *key, sd_dhcp_route **routes, siz
fprintf(f, "%s=", key);
for (i = 0; i < size; i++) {
for (size_t i = 0; i < size; i++) {
char sbuf[INET_ADDRSTRLEN];
struct in_addr dest, gw;
uint8_t length;
@ -790,8 +790,8 @@ void serialize_dhcp_routes(FILE *f, const char *key, sd_dhcp_route **routes, siz
assert_se(sd_dhcp_route_get_gateway(routes[i], &gw) >= 0);
assert_se(sd_dhcp_route_get_destination_prefix_length(routes[i], &length) >= 0);
fprintf(f, "%s/%" PRIu8, inet_ntop(AF_INET, &dest, sbuf, sizeof(sbuf)), length);
fprintf(f, ",%s%s", inet_ntop(AF_INET, &gw, sbuf, sizeof(sbuf)), (i < (size - 1)) ? " ": "");
fprintf(f, "%s/%" PRIu8, inet_ntop(AF_INET, &dest, sbuf, sizeof sbuf), length);
fprintf(f, ",%s%s", inet_ntop(AF_INET, &gw, sbuf, sizeof sbuf), i < size - 1 ? " ": "");
}
fputs("\n", f);

View File

@ -50,11 +50,12 @@ const char *net_get_name_persistent(sd_device *device);
size_t serialize_in_addrs(FILE *f,
const struct in_addr *addresses,
size_t size,
bool with_leading_space,
bool *with_leading_space,
bool (*predicate)(const struct in_addr *addr));
int deserialize_in_addrs(struct in_addr **addresses, const char *string);
void serialize_in6_addrs(FILE *f, const struct in6_addr *addresses,
size_t size);
size_t size,
bool *with_leading_space);
int deserialize_in6_addrs(struct in6_addr **addresses, const char *string);
/* don't include "dhcp-lease-internal.h" as it causes conflicts between netinet/ip.h and linux/ip.h */

View File

@ -213,7 +213,7 @@ int dhcp6_lease_set_dns(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) {
return 0;
}
int sd_dhcp6_lease_get_dns(sd_dhcp6_lease *lease, struct in6_addr **addrs) {
int sd_dhcp6_lease_get_dns(sd_dhcp6_lease *lease, const struct in6_addr **addrs) {
assert_return(lease, -EINVAL);
assert_return(addrs, -EINVAL);
@ -341,7 +341,7 @@ int dhcp6_lease_set_sntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen)
}
int sd_dhcp6_lease_get_ntp_addrs(sd_dhcp6_lease *lease,
struct in6_addr **addrs) {
const struct in6_addr **addrs) {
assert_return(lease, -EINVAL);
assert_return(addrs, -EINVAL);

View File

@ -371,7 +371,7 @@ static int test_advertise_option(sd_event *e) {
int r;
uint8_t *opt;
bool opt_clientid = false;
struct in6_addr *addrs;
const struct in6_addr *addrs;
char **domains;
log_debug("/* %s */", __func__);
@ -518,7 +518,7 @@ static void test_client_solicit_cb(sd_dhcp6_client *client, int event,
void *userdata) {
sd_event *e = userdata;
sd_dhcp6_lease *lease;
struct in6_addr *addrs;
const struct in6_addr *addrs;
char **domains;
log_debug("/* %s */", __func__);
@ -744,7 +744,7 @@ static void test_client_information_cb(sd_dhcp6_client *client, int event,
void *userdata) {
sd_event *e = userdata;
sd_dhcp6_lease *lease;
struct in6_addr *addrs;
const struct in6_addr *addrs;
struct in6_addr address = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01 } } };
char **domains;

View File

@ -700,6 +700,11 @@ global:
LIBSYSTEMD_246 {
global:
sd_bus_interface_name_is_valid;
sd_bus_service_name_is_valid;
sd_bus_member_name_is_valid;
sd_bus_object_path_is_valid;
sd_bus_call_methodv;
sd_bus_call_method_asyncv;
sd_bus_emit_signalv;
@ -707,6 +712,7 @@ global:
sd_bus_reply_method_errorfv;
sd_bus_reply_method_returnv;
sd_bus_set_propertyv;
sd_path_lookup;
sd_path_lookup_strv;
} LIBSYSTEMD_245;

View File

@ -354,6 +354,7 @@ bool interface_name_is_valid(const char *p) _pure_;
bool service_name_is_valid(const char *p) _pure_;
bool member_name_is_valid(const char *p) _pure_;
bool object_path_is_valid(const char *p) _pure_;
char *object_path_startswith(const char *a, const char *b) _pure_;
bool namespace_complex_pattern(const char *pattern, const char *value) _pure_;

View File

@ -4,6 +4,7 @@
#include "sd-bus.h"
#include "bus-internal.h"
#include "bus-type.h"
bool bus_type_is_valid(char c) {
@ -135,3 +136,27 @@ int bus_type_get_size(char c) {
return -EINVAL;
}
_public_ int sd_bus_interface_name_is_valid(const char *p) {
assert_return(p, -EINVAL);
return interface_name_is_valid(p);
}
_public_ int sd_bus_service_name_is_valid(const char *p) {
assert_return(p, -EINVAL);
return service_name_is_valid(p);
}
_public_ int sd_bus_member_name_is_valid(const char *p) {
assert_return(p, -EINVAL);
return member_name_is_valid(p);
}
_public_ int sd_bus_object_path_is_valid(const char *p) {
assert_return(p, -EINVAL);
return object_path_is_valid(p);
}

View File

@ -1266,10 +1266,16 @@ _public_ int sd_bus_open(sd_bus **ret) {
int bus_set_address_system(sd_bus *b) {
const char *e;
int r;
assert(b);
e = secure_getenv("DBUS_SYSTEM_BUS_ADDRESS");
return sd_bus_set_address(b, e ?: DEFAULT_SYSTEM_BUS_ADDRESS);
r = sd_bus_set_address(b, e ?: DEFAULT_SYSTEM_BUS_ADDRESS);
if (r >= 0)
b->is_system = true;
return r;
}
_public_ int sd_bus_open_system_with_description(sd_bus **ret, const char *description) {
@ -1293,7 +1299,6 @@ _public_ int sd_bus_open_system_with_description(sd_bus **ret, const char *descr
return r;
b->bus_client = true;
b->is_system = true;
/* Let's do per-method access control on the system bus. We
* need the caller's UID and capability set for that. */
@ -1316,6 +1321,7 @@ _public_ int sd_bus_open_system(sd_bus **ret) {
int bus_set_address_user(sd_bus *b) {
const char *a;
_cleanup_free_ char *_a = NULL;
int r;
assert(b);
@ -1337,7 +1343,10 @@ int bus_set_address_user(sd_bus *b) {
a = _a;
}
return sd_bus_set_address(b, a);
r = sd_bus_set_address(b, a);
if (r >= 0)
b->is_user = true;
return r;
}
_public_ int sd_bus_open_user_with_description(sd_bus **ret, const char *description) {
@ -1361,7 +1370,6 @@ _public_ int sd_bus_open_user_with_description(sd_bus **ret, const char *descrip
return r;
b->bus_client = true;
b->is_user = true;
/* We don't do any per-method access control on the user bus. */
b->trusted = true;

View File

@ -499,10 +499,9 @@ static void log_xkb(struct xkb_context *ctx, enum xkb_log_level lvl, const char
const char *fmt;
fmt = strjoina("libxkbcommon: ", format);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
DISABLE_WARNING_FORMAT_NONLITERAL;
log_internalv(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, fmt, args);
#pragma GCC diagnostic pop
REENABLE_WARNING;
}
#define LOAD_SYMBOL(symbol, dl, name) \

View File

@ -3988,11 +3988,9 @@ static void print_link_hashmap(FILE *f, const char *prefix, Hashmap* h) {
}
static void link_save_dns(FILE *f, struct in_addr_data *dns, unsigned n_dns, bool *space) {
unsigned j;
int r;
for (j = 0; j < n_dns; j++) {
for (unsigned j = 0; j < n_dns; j++) {
_cleanup_free_ char *b = NULL;
int r;
r = in_addr_to_string(dns[j].family, &dns[j].address, &b);
if (r < 0) {
@ -4007,6 +4005,56 @@ static void link_save_dns(FILE *f, struct in_addr_data *dns, unsigned n_dns, boo
}
}
static void serialize_addresses(
FILE *f,
const char *lvalue,
bool *space,
char **addresses,
sd_dhcp_lease *lease,
bool conditional,
sd_dhcp_lease_info what,
sd_dhcp6_lease *lease6,
bool conditional6,
int (*lease6_get_addr)(sd_dhcp6_lease*, const struct in6_addr**),
int (*lease6_get_fqdn)(sd_dhcp6_lease*, char ***)) {
int r;
bool _space = false;
if (!space)
space = &_space;
if (lvalue)
fprintf(f, "%s=", lvalue);
fputstrv(f, addresses, NULL, space);
if (lease && conditional) {
const struct in_addr *lease_addresses;
r = sd_dhcp_lease_get_servers(lease, what, &lease_addresses);
if (r > 0)
serialize_in_addrs(f, lease_addresses, r, space, in4_addr_is_non_local);
}
if (lease6 && conditional6 && lease6_get_addr) {
const struct in6_addr *in6_addrs;
r = lease6_get_addr(lease6, &in6_addrs);
if (r > 0)
serialize_in6_addrs(f, in6_addrs, r, space);
}
if (lease6 && conditional6 && lease6_get_fqdn) {
char **in6_hosts;
r = lease6_get_fqdn(lease6, &in6_hosts);
if (r > 0)
fputstrv(f, in6_hosts, NULL, space);
}
if (lvalue)
fputc('\n', f);
}
int link_save(Link *link) {
const char *admin_state, *oper_state, *carrier_state, *address_state;
_cleanup_free_ char *temp_path = NULL;
@ -4063,52 +4111,38 @@ int link_save(Link *link) {
fprintf(f, "REQUIRED_FOR_ONLINE=%s\n",
yes_no(link->network->required_for_online));
fprintf(f, "REQUIRED_OPER_STATE_FOR_ONLINE=%s",
strempty(link_operstate_to_string(link->network->required_operstate_for_online.min)));
if (link->network->required_operstate_for_online.max != LINK_OPERSTATE_RANGE_DEFAULT.max)
fprintf(f, ":%s",
strempty(link_operstate_to_string(link->network->required_operstate_for_online.max)));
fprintf(f, "\n");
LinkOperationalStateRange st = link->network->required_operstate_for_online;
fprintf(f, "REQUIRED_OPER_STATE_FOR_ONLINE=%s%s%s\n",
strempty(link_operstate_to_string(st.min)),
st.max != LINK_OPERSTATE_RANGE_DEFAULT.max ? ":" : "",
st.max != LINK_OPERSTATE_RANGE_DEFAULT.max ? strempty(link_operstate_to_string(st.max)) : "");
if (link->dhcp6_client) {
r = sd_dhcp6_client_get_lease(link->dhcp6_client, &dhcp6_lease);
if (r < 0 && r != -ENOMSG)
log_link_debug(link, "No DHCPv6 lease");
log_link_debug_errno(link, r, "Failed to get DHCPv6 lease: %m");
}
fprintf(f, "NETWORK_FILE=%s\n", link->network->filename);
/************************************************************/
fputs("DNS=", f);
space = false;
if (link->n_dns != (unsigned) -1)
link_save_dns(f, link->dns, link->n_dns, &space);
else
link_save_dns(f, link->network->dns, link->network->n_dns, &space);
if (link->network->dhcp_use_dns &&
link->dhcp_lease) {
const struct in_addr *addresses;
r = sd_dhcp_lease_get_dns(link->dhcp_lease, &addresses);
if (r > 0)
if (serialize_in_addrs(f, addresses, r, space, in4_addr_is_non_local) > 0)
space = true;
}
if (link->network->dhcp6_use_dns && dhcp6_lease) {
struct in6_addr *in6_addrs;
r = sd_dhcp6_lease_get_dns(dhcp6_lease, &in6_addrs);
if (r > 0) {
if (space)
fputc(' ', f);
serialize_in6_addrs(f, in6_addrs, r);
space = true;
}
}
serialize_addresses(f, NULL, &space,
NULL,
link->dhcp_lease,
link->network->dhcp_use_dns,
SD_DHCP_LEASE_DNS_SERVERS,
dhcp6_lease,
link->network->dhcp6_use_dns,
sd_dhcp6_lease_get_dns,
NULL);
/* Make sure to flush out old entries before we use the NDISC data */
ndisc_vacuum(link);
@ -4116,111 +4150,53 @@ int link_save(Link *link) {
if (link->network->ipv6_accept_ra_use_dns && link->ndisc_rdnss) {
NDiscRDNSS *dd;
SET_FOREACH(dd, link->ndisc_rdnss, i) {
if (space)
fputc(' ', f);
serialize_in6_addrs(f, &dd->address, 1);
space = true;
}
SET_FOREACH(dd, link->ndisc_rdnss, i)
serialize_in6_addrs(f, &dd->address, 1, &space);
}
fputc('\n', f);
fputs("NTP=", f);
space = false;
fputstrv(f, link->ntp ?: link->network->ntp, NULL, &space);
/************************************************************/
if (link->network->dhcp_use_ntp &&
link->dhcp_lease) {
const struct in_addr *addresses;
serialize_addresses(f, "NTP", NULL,
link->ntp ?: link->network->ntp,
link->dhcp_lease,
link->network->dhcp_use_ntp,
SD_DHCP_LEASE_NTP_SERVERS,
dhcp6_lease,
link->network->dhcp6_use_ntp,
sd_dhcp6_lease_get_ntp_addrs,
sd_dhcp6_lease_get_ntp_fqdn);
r = sd_dhcp_lease_get_ntp(link->dhcp_lease, &addresses);
if (r > 0)
if (serialize_in_addrs(f, addresses, r, space, in4_addr_is_non_local) > 0)
space = true;
}
serialize_addresses(f, "SIP", NULL,
link->network->sip,
link->dhcp_lease,
link->network->dhcp_use_sip,
SD_DHCP_LEASE_SIP_SERVERS,
false, NULL, NULL, NULL);
fputc('\n', f);
serialize_addresses(f, "POP3_SERVERS", NULL,
link->network->pop3,
link->dhcp_lease,
true,
SD_DHCP_LEASE_POP3_SERVERS,
false, NULL, NULL, NULL);
fputs("SIP=", f);
space = false;
fputstrv(f, link->network->sip, NULL, &space);
serialize_addresses(f, "SMTP_SERVERS", NULL,
link->network->smtp,
link->dhcp_lease,
true,
SD_DHCP_LEASE_SMTP_SERVERS,
false, NULL, NULL, NULL);
if (link->network->dhcp_use_sip &&
link->dhcp_lease) {
const struct in_addr *addresses;
serialize_addresses(f, "LPR_SERVERS", NULL,
link->network->lpr,
link->dhcp_lease,
true,
SD_DHCP_LEASE_LPR_SERVERS,
false, NULL, NULL, NULL);
r = sd_dhcp_lease_get_sip(link->dhcp_lease, &addresses);
if (r > 0)
if (serialize_in_addrs(f, addresses, r, space, in4_addr_is_non_local) > 0)
space = true;
}
fputc('\n', f);
fputs("POP3_SERVERS=", f);
space = false;
fputstrv(f, link->network->pop3, NULL, &space);
fputc('\n', f);
fputs("SMTP_SERVERS=", f);
space = false;
fputstrv(f, link->network->smtp, NULL, &space);
fputc('\n', f);
fputs("LPR_SERVERS=", f);
space = false;
fputstrv(f, link->network->lpr, NULL, &space);
if (link->dhcp_lease) {
const struct in_addr *addresses;
r = sd_dhcp_lease_get_pop3_server(link->dhcp_lease, &addresses);
if (r > 0)
if (serialize_in_addrs(f, addresses, r, space, in4_addr_is_non_local) > 0)
space = true;
}
if (link->dhcp_lease) {
const struct in_addr *addresses;
r = sd_dhcp_lease_get_smtp_server(link->dhcp_lease, &addresses);
if (r > 0)
if (serialize_in_addrs(f, addresses, r, space, in4_addr_is_non_local) > 0)
space = true;
}
if (link->dhcp_lease) {
const struct in_addr *addresses;
r = sd_dhcp_lease_get_lpr_servers(link->dhcp_lease, &addresses);
if (r > 0)
if (serialize_in_addrs(f, addresses, r, space, in4_addr_is_non_local) > 0)
space = true;
}
if (link->network->dhcp6_use_ntp && dhcp6_lease) {
struct in6_addr *in6_addrs;
char **hosts;
r = sd_dhcp6_lease_get_ntp_addrs(dhcp6_lease,
&in6_addrs);
if (r > 0) {
if (space)
fputc(' ', f);
serialize_in6_addrs(f, in6_addrs, r);
space = true;
}
r = sd_dhcp6_lease_get_ntp_fqdn(dhcp6_lease, &hosts);
if (r > 0)
fputstrv(f, hosts, NULL, &space);
}
fputc('\n', f);
/************************************************************/
if (link->network->dhcp_use_domains != DHCP_USE_DOMAINS_NO) {
if (link->dhcp_lease) {
@ -4254,6 +4230,8 @@ int link_save(Link *link) {
fputc('\n', f);
/************************************************************/
fputs("ROUTE_DOMAINS=", f);
space = false;
ORDERED_SET_FOREACH(p, link->route_domains ?: link->network->route_domains, i)
@ -4277,47 +4255,58 @@ int link_save(Link *link) {
fputc('\n', f);
/************************************************************/
fprintf(f, "LLMNR=%s\n",
resolve_support_to_string(link->llmnr >= 0 ? link->llmnr : link->network->llmnr));
/************************************************************/
fprintf(f, "MDNS=%s\n",
resolve_support_to_string(link->mdns >= 0 ? link->mdns : link->network->mdns));
if (link->dns_default_route >= 0)
fprintf(f, "DNS_DEFAULT_ROUTE=%s\n", yes_no(link->dns_default_route));
else if (link->network->dns_default_route >= 0)
fprintf(f, "DNS_DEFAULT_ROUTE=%s\n", yes_no(link->network->dns_default_route));
if (link->dns_over_tls_mode != _DNS_OVER_TLS_MODE_INVALID)
fprintf(f, "DNS_OVER_TLS=%s\n",
dns_over_tls_mode_to_string(link->dns_over_tls_mode));
else if (link->network->dns_over_tls_mode != _DNS_OVER_TLS_MODE_INVALID)
fprintf(f, "DNS_OVER_TLS=%s\n",
dns_over_tls_mode_to_string(link->network->dns_over_tls_mode));
/************************************************************/
if (link->dnssec_mode != _DNSSEC_MODE_INVALID)
fprintf(f, "DNSSEC=%s\n",
dnssec_mode_to_string(link->dnssec_mode));
else if (link->network->dnssec_mode != _DNSSEC_MODE_INVALID)
fprintf(f, "DNSSEC=%s\n",
dnssec_mode_to_string(link->network->dnssec_mode));
int dns_default_route =
link->dns_default_route >= 0 ? link->dns_default_route :
link->network->dns_default_route;
if (dns_default_route >= 0)
fprintf(f, "DNS_DEFAULT_ROUTE=%s\n", yes_no(dns_default_route));
if (!set_isempty(link->dnssec_negative_trust_anchors)) {
/************************************************************/
DnsOverTlsMode dns_over_tls_mode =
link->dns_over_tls_mode != _DNS_OVER_TLS_MODE_INVALID ? link->dns_over_tls_mode :
link->network->dns_over_tls_mode;
if (dns_over_tls_mode != _DNS_OVER_TLS_MODE_INVALID)
fprintf(f, "DNS_OVER_TLS=%s\n", dns_over_tls_mode_to_string(dns_over_tls_mode));
/************************************************************/
DnssecMode dnssec_mode =
link->dnssec_mode != _DNSSEC_MODE_INVALID ? link->dnssec_mode :
link->network->dnssec_mode;
if (dnssec_mode != _DNSSEC_MODE_INVALID)
fprintf(f, "DNSSEC=%s\n", dnssec_mode_to_string(dnssec_mode));
/************************************************************/
Set *nta_anchors = link->dnssec_negative_trust_anchors;
if (set_isempty(nta_anchors))
nta_anchors = link->network->dnssec_negative_trust_anchors;
if (!set_isempty(nta_anchors)) {
const char *n;
fputs("DNSSEC_NTA=", f);
space = false;
SET_FOREACH(n, link->dnssec_negative_trust_anchors, i)
fputs_with_space(f, n, NULL, &space);
fputc('\n', f);
} else if (!set_isempty(link->network->dnssec_negative_trust_anchors)) {
const char *n;
fputs("DNSSEC_NTA=", f);
space = false;
SET_FOREACH(n, link->network->dnssec_negative_trust_anchors, i)
SET_FOREACH(n, nta_anchors, i)
fputs_with_space(f, n, NULL, &space);
fputc('\n', f);
}
/************************************************************/
fputs("ADDRESSES=", f);
space = false;
SET_FOREACH(a, link->addresses, i) {
@ -4332,6 +4321,8 @@ int link_save(Link *link) {
}
fputc('\n', f);
/************************************************************/
fputs("ROUTES=", f);
space = false;
SET_FOREACH(route, link->routes, i) {
@ -4366,7 +4357,7 @@ int link_save(Link *link) {
r = sd_dhcp_lease_get_address(link->dhcp_lease, &address);
if (r >= 0) {
fputs("DHCP4_ADDRESS=", f);
serialize_in_addrs(f, &address, 1, false, NULL);
serialize_in_addrs(f, &address, 1, NULL, NULL);
fputc('\n', f);
}

View File

@ -295,35 +295,6 @@ int config_parse_capability(
return 0;
}
int config_parse_id128(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
sd_id128_t t, *result = data;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
r = sd_id128_from_string(rvalue, &t);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse 128bit ID/UUID, ignoring: %s", rvalue);
return 0;
}
*result = t;
return 0;
}
int config_parse_pivot_root(
const char *unit,
const char *filename,

View File

@ -234,7 +234,6 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Settings*, settings_free);
const struct ConfigPerfItem* nspawn_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
CONFIG_PARSER_PROTOTYPE(config_parse_capability);
CONFIG_PARSER_PROTOTYPE(config_parse_id128);
CONFIG_PARSER_PROTOTYPE(config_parse_expose_port);
CONFIG_PARSER_PROTOTYPE(config_parse_volatile_mode);
CONFIG_PARSER_PROTOTYPE(config_parse_pivot_root);

View File

@ -963,6 +963,7 @@ static int partition_read_definition(Partition *p, const char *path) {
ConfigTableItem table[] = {
{ "Partition", "Type", config_parse_type, 0, &p->type_uuid },
{ "Partition", "Label", config_parse_label, 0, &p->new_label },
{ "Partition", "UUID", config_parse_id128, 0, &p->new_uuid },
{ "Partition", "Priority", config_parse_int32, 0, &p->priority },
{ "Partition", "Weight", config_parse_weight, 0, &p->weight },
{ "Partition", "PaddingWeight", config_parse_weight, 0, &p->padding_weight },
@ -2232,13 +2233,12 @@ static int context_acquire_partition_uuids_and_labels(Context *context) {
assert(context);
LIST_FOREACH(partitions, p, context->partitions) {
assert(sd_id128_is_null(p->new_uuid));
/* Never touch foreign partitions */
if (PARTITION_IS_FOREIGN(p)) {
p->new_uuid = p->current_uuid;
if (p->current_label) {
free(p->new_label);
p->new_label = strdup(p->current_label);
if (!p->new_label)
return log_oom();
@ -2249,20 +2249,21 @@ static int context_acquire_partition_uuids_and_labels(Context *context) {
if (!sd_id128_is_null(p->current_uuid))
p->new_uuid = p->current_uuid; /* Never change initialized UUIDs */
else {
else if (sd_id128_is_null(p->new_uuid)) {
/* Not explicitly set by user! */
r = partition_acquire_uuid(context, p, &p->new_uuid);
if (r < 0)
return r;
}
if (p->new_label) /* Explicitly set by user? */
continue;
if (!isempty(p->current_label)) {
free(p->new_label);
p->new_label = strdup(p->current_label); /* never change initialized labels */
if (!p->new_label)
return log_oom();
} else {
} else if (!p->new_label) {
/* Not explicitly set by user! */
r = partition_acquire_label(context, p, &p->new_label);
if (r < 0)
return r;

View File

@ -68,8 +68,13 @@ EOF
cat >$D/definitions/extra.conf <<EOF
[Partition]
Type=linux-generic
Label=custom_label
UUID=a0a1a2a3a4a5a6a7a8a9aaabacadaeaf
EOF
echo "Label=ignored_label" >> $D/definitions/home.conf
echo "UUID=b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" >> $D/definitions/home.conf
$repart $D/zzz --dry-run=no --seed=$SEED --definitions=$D/definitions
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' >$D/populated2
@ -85,7 +90,7 @@ $D/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E
$D/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
$D/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
$D/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
$D/zzz5 : start= 1908696, size= 188416, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=03477476-06AD-44E8-9EF4-BC2BD7771289, name="linux-generic"
$D/zzz5 : start= 1908696, size= 188416, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=A0A1A2A3-A4A5-A6A7-A8A9-AAABACADAEAF, name="custom_label"
EOF
$repart $D/zzz --size=2G --dry-run=no --seed=$SEED --definitions=$D/definitions
@ -103,5 +108,5 @@ $D/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E
$D/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
$D/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
$D/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
$D/zzz5 : start= 1908696, size= 2285568, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=03477476-06AD-44E8-9EF4-BC2BD7771289, name="linux-generic"
$D/zzz5 : start= 1908696, size= 2285568, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=A0A1A2A3-A4A5-A6A7-A8A9-AAABACADAEAF, name="custom_label"
EOF

View File

@ -1156,7 +1156,7 @@ int bus_path_encode_unique(sd_bus *b, const char *prefix, const char *sender_id,
int r;
assert_return(b || (sender_id && external_id), -EINVAL);
assert_return(object_path_is_valid(prefix), -EINVAL);
assert_return(sd_bus_object_path_is_valid(prefix), -EINVAL);
assert_return(ret_path, -EINVAL);
if (!sender_id) {
@ -1208,8 +1208,8 @@ int bus_path_decode_unique(const char *path, const char *prefix, char **ret_send
const char *p, *q;
char *sender, *external;
assert(object_path_is_valid(path));
assert(object_path_is_valid(prefix));
assert(sd_bus_object_path_is_valid(path));
assert(sd_bus_object_path_is_valid(prefix));
assert(ret_sender);
assert(ret_external);
@ -1670,7 +1670,7 @@ int bus_introspect_implementations(
}
struct introspect intro = {};
bool is_interface = interface_name_is_valid(pattern);
bool is_interface = sd_bus_interface_name_is_valid(pattern);
impl = find_implementation(pattern, bus_objects);
if (!impl)

View File

@ -23,6 +23,7 @@
#include "path-util.h"
#include "process-util.h"
#include "rlimit-util.h"
#include "sd-id128.h"
#include "signal-util.h"
#include "socket-util.h"
#include "string-util.h"
@ -648,6 +649,35 @@ int config_parse_bool(const char* unit,
return 0;
}
int config_parse_id128(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
sd_id128_t t, *result = data;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
r = sd_id128_from_string(rvalue, &t);
if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse 128bit ID/UUID, ignoring: %s", rvalue);
else if (sd_id128_is_null(t))
log_syntax(unit, LOG_ERR, filename, line, 0, "128bit ID/UUID is all 0, ignoring: %s", rvalue);
*result = t;
return 0;
}
int config_parse_tristate(
const char* unit,
const char *filename,

View File

@ -122,6 +122,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_iec_size);
CONFIG_PARSER_PROTOTYPE(config_parse_si_uint64);
CONFIG_PARSER_PROTOTYPE(config_parse_iec_uint64);
CONFIG_PARSER_PROTOTYPE(config_parse_bool);
CONFIG_PARSER_PROTOTYPE(config_parse_id128);
CONFIG_PARSER_PROTOTYPE(config_parse_tristate);
CONFIG_PARSER_PROTOTYPE(config_parse_string);
CONFIG_PARSER_PROTOTYPE(config_parse_path);

View File

@ -253,10 +253,9 @@ static JsonVariant *json_variant_formalize(JsonVariant *v) {
return json_variant_unsigned(v) == 0 ? JSON_VARIANT_MAGIC_ZERO_UNSIGNED : v;
case JSON_VARIANT_REAL:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
DISABLE_WARNING_FLOAT_EQUAL;
return json_variant_real(v) == 0.0 ? JSON_VARIANT_MAGIC_ZERO_REAL : v;
#pragma GCC diagnostic pop
REENABLE_WARNING;
case JSON_VARIANT_STRING:
return isempty(json_variant_string(v)) ? JSON_VARIANT_MAGIC_EMPTY_STRING : v;
@ -353,13 +352,12 @@ int json_variant_new_real(JsonVariant **ret, long double d) {
assert_return(ret, -EINVAL);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
DISABLE_WARNING_FLOAT_EQUAL;
if (d == 0.0) {
#pragma GCC diagnostic pop
*ret = JSON_VARIANT_MAGIC_ZERO_REAL;
return 0;
}
REENABLE_WARNING;
r = json_variant_new(&v, JSON_VARIANT_REAL, sizeof(d));
if (r < 0)
@ -896,11 +894,10 @@ intmax_t json_variant_integer(JsonVariant *v) {
converted = (intmax_t) v->value.real;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
DISABLE_WARNING_FLOAT_EQUAL;
if ((long double) converted == v->value.real)
#pragma GCC diagnostic pop
return converted;
REENABLE_WARNING;
log_debug("Real %Lg requested as integer, and cannot be converted losslessly, returning 0.", v->value.real);
return 0;
@ -944,11 +941,10 @@ uintmax_t json_variant_unsigned(JsonVariant *v) {
converted = (uintmax_t) v->value.real;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
DISABLE_WARNING_FLOAT_EQUAL;
if ((long double) converted == v->value.real)
#pragma GCC diagnostic pop
return converted;
REENABLE_WARNING;
log_debug("Real %Lg requested as unsigned integer, and cannot be converted losslessly, returning 0.", v->value.real);
return 0;
@ -1097,9 +1093,12 @@ JsonVariantType json_variant_type(JsonVariant *v) {
return v->type;
}
bool json_variant_has_type(JsonVariant *v, JsonVariantType type) {
_function_no_sanitize_float_cast_overflow_ bool json_variant_has_type(JsonVariant *v, JsonVariantType type) {
JsonVariantType rt;
/* Note: we turn off ubsan float cast overflo detection for this function, since it would complain
* about our float casts but we do them explicitly to detect conversion errors. */
v = json_variant_dereference(v);
if (!v)
return false;
@ -1137,14 +1136,15 @@ bool json_variant_has_type(JsonVariant *v, JsonVariantType type) {
if (rt == JSON_VARIANT_UNSIGNED && type == JSON_VARIANT_REAL)
return (uintmax_t) (long double) v->value.unsig == v->value.unsig;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
DISABLE_WARNING_FLOAT_EQUAL;
/* Any real that can be converted losslessly to an integer and back may also be considered an integer */
if (rt == JSON_VARIANT_REAL && type == JSON_VARIANT_INTEGER)
return (long double) (intmax_t) v->value.real == v->value.real;
if (rt == JSON_VARIANT_REAL && type == JSON_VARIANT_UNSIGNED)
return (long double) (uintmax_t) v->value.real == v->value.real;
#pragma GCC diagnostic pop
REENABLE_WARNING;
return false;
}
@ -1298,10 +1298,9 @@ bool json_variant_equal(JsonVariant *a, JsonVariant *b) {
return json_variant_unsigned(a) == json_variant_unsigned(b);
case JSON_VARIANT_REAL:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
DISABLE_WARNING_FLOAT_EQUAL;
return json_variant_real(a) == json_variant_real(b);
#pragma GCC diagnostic pop
REENABLE_WARNING;
case JSON_VARIANT_BOOLEAN:
return json_variant_boolean(a) == json_variant_boolean(b);
@ -4095,10 +4094,9 @@ int json_dispatch_uid_gid(const char *name, JsonVariant *variant, JsonDispatchFl
assert_cc(sizeof(uid_t) == sizeof(uint32_t));
assert_cc(sizeof(gid_t) == sizeof(uint32_t));
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wtype-limits"
DISABLE_WARNING_TYPE_LIMITS;
assert_cc(((uid_t) -1 < (uid_t) 0) == ((gid_t) -1 < (gid_t) 0));
#pragma GCC diagnostic pop
REENABLE_WARNING;
if (json_variant_is_null(variant)) {
*uid = UID_INVALID;

View File

@ -124,6 +124,13 @@ typedef _sd_destroy_t sd_bus_destroy_t;
#include "sd-bus-protocol.h"
#include "sd-bus-vtable.h"
/* Naming */
int sd_bus_interface_name_is_valid(const char *p);
int sd_bus_service_name_is_valid(const char *p);
int sd_bus_member_name_is_valid(const char *p);
int sd_bus_object_path_is_valid(const char *p);
/* Connections */
int sd_bus_default(sd_bus **ret);

View File

@ -39,10 +39,9 @@ int sd_dhcp6_lease_get_pd(sd_dhcp6_lease *lease, struct in6_addr *prefix,
uint32_t *lifetime_preferred,
uint32_t *lifetime_valid);
int sd_dhcp6_lease_get_dns(sd_dhcp6_lease *lease, struct in6_addr **addrs);
int sd_dhcp6_lease_get_dns(sd_dhcp6_lease *lease, const struct in6_addr **addrs);
int sd_dhcp6_lease_get_domains(sd_dhcp6_lease *lease, char ***domains);
int sd_dhcp6_lease_get_ntp_addrs(sd_dhcp6_lease *lease,
struct in6_addr **addrs);
int sd_dhcp6_lease_get_ntp_addrs(sd_dhcp6_lease *lease, const struct in6_addr **addrs);
int sd_dhcp6_lease_get_ntp_fqdn(sd_dhcp6_lease *lease, char ***ntp_fqdn);
sd_dhcp6_lease *sd_dhcp6_lease_ref(sd_dhcp6_lease *lease);

View File

@ -633,8 +633,7 @@ static void test_tempfn(void) {
static const char chars[] =
"Aąę„”\n\377";
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wtype-limits"
DISABLE_WARNING_TYPE_LIMITS;
static void test_fgetc(void) {
_cleanup_fclose_ FILE *f = NULL;
@ -665,7 +664,7 @@ static void test_fgetc(void) {
assert_se(safe_fgetc(f, &c) == 0);
}
#pragma GCC diagnostic pop
REENABLE_WARNING;
static const char buffer[] =
"Some test data\n"

View File

@ -231,10 +231,9 @@ static void test_zeroes(JsonVariant *v) {
assert_se(json_variant_integer(w) == 0);
assert_se(json_variant_unsigned(w) == 0U);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
DISABLE_WARNING_FLOAT_EQUAL;
assert_se(json_variant_real(w) == 0.0L);
#pragma GCC diagnostic pop
REENABLE_WARNING;
assert_se(json_variant_is_integer(w));
assert_se(json_variant_is_unsigned(w));

View File

@ -14,7 +14,7 @@
/* Print information about various types. Useful when diagnosing
* gcc diagnostics on an unfamiliar architecture. */
#pragma GCC diagnostic ignored "-Wtype-limits"
DISABLE_WARNING_TYPE_LIMITS;
#define info(t) \
printf("%s → %zu bits%s, %zu byte alignment\n", STRINGIFY(t), \

View File

@ -363,10 +363,9 @@ static const char * const ntp_leap_table[4] = {
[3] = "not synchronized",
};
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wtype-limits"
DISABLE_WARNING_TYPE_LIMITS;
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(ntp_leap, uint32_t);
#pragma GCC diagnostic pop
REENABLE_WARNING;
static int print_ntp_status_info(NTPStatusInfo *i) {
char ts[FORMAT_TIMESPAN_MAX], jitter[FORMAT_TIMESPAN_MAX],

View File

@ -449,11 +449,10 @@ static int names_platform(sd_device *dev, struct netnames *names, bool test) {
* The Vendor (3 or 4 char), followed by hexdecimal model number : instance id.
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
DISABLE_WARNING_FORMAT_NONLITERAL;
if (sscanf(syspath, pattern, vendor, &model, &instance, &ethid) != 4)
return -EINVAL;
#pragma GCC diagnostic pop
REENABLE_WARNING;
if (!in_charset(vendor, validchars))
return -ENOENT;

View File

@ -0,0 +1 @@
[7E73]

View File

@ -1,5 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1+
with_runlevels = conf.get('HAVE_SYSV_COMPAT') == 1
units = [
['basic.target', ''],
['blockdev@.target', ''],
@ -19,7 +21,7 @@ units = [
'multi-user.target.wants/'],
['getty-pre.target', ''],
['graphical.target', '',
'runlevel5.target default.target'],
(with_runlevels ? 'runlevel5.target default.target' : 'default.target')],
['halt.target', ''],
['hibernate.target', 'ENABLE_HIBERNATE'],
['hybrid-sleep.target', 'ENABLE_HIBERNATE'],
@ -42,7 +44,7 @@ units = [
['machines.target', 'ENABLE_MACHINED'],
['modprobe@.service', ''],
['multi-user.target', '',
'runlevel2.target runlevel3.target runlevel4.target'],
(with_runlevels ? 'runlevel2.target runlevel3.target runlevel4.target' : '')],
['network-online.target', ''],
['network-pre.target', ''],
['network.target', ''],
@ -50,18 +52,18 @@ units = [
['nss-user-lookup.target', ''],
['paths.target', ''],
['poweroff.target', '',
'runlevel0.target'],
(with_runlevels ? 'runlevel0.target' : '')],
['printer.target', ''],
['proc-sys-fs-binfmt_misc.automount', 'ENABLE_BINFMT',
'sysinit.target.wants/'],
['proc-sys-fs-binfmt_misc.mount', 'ENABLE_BINFMT'],
['reboot.target', '',
'runlevel6.target ctrl-alt-del.target'],
(with_runlevels ? 'runlevel6.target ctrl-alt-del.target' : 'ctrl-alt-del.target')],
['remote-cryptsetup.target', 'HAVE_LIBCRYPTSETUP'],
['remote-fs-pre.target', ''],
['remote-fs.target', ''],
['rescue.target', '',
'runlevel1.target'],
(with_runlevels ? 'runlevel1.target' : '')],
['rpcbind.target', ''],
['shutdown.target', ''],
['sigpwr.target', ''],
@ -100,7 +102,7 @@ units = [
['systemd-firstboot.service', 'ENABLE_FIRSTBOOT',
'sysinit.target.wants/'],
['systemd-halt.service', ''],
['systemd-initctl.socket', '',
['systemd-initctl.socket', 'HAVE_SYSV_COMPAT',
'sockets.target.wants/'],
['systemd-journal-catalog-update.service', '',
'sysinit.target.wants/'],