summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/standard-conf.xml23
-rw-r--r--man/systemd-environment-d-generator.xml4
-rw-r--r--man/systemd.dnssd.xml37
-rw-r--r--man/systemd.network.xml26
-rw-r--r--man/udev.xml26
-rw-r--r--meson.build1
-rw-r--r--src/analyze/analyze.c40
-rw-r--r--src/basic/def.h20
-rw-r--r--src/core/main.c2
-rw-r--r--src/environment-d-generator/environment-d-generator.c2
-rw-r--r--src/libsystemd-network/network-internal.h4
-rw-r--r--src/network/netdev/netdev.c6
-rw-r--r--src/network/networkd-manager.c14
-rw-r--r--src/network/networkd-manager.h2
-rw-r--r--src/network/networkd-network.c4
-rw-r--r--src/resolve/resolved-dnssd.c16
-rw-r--r--src/shared/install.c42
-rw-r--r--src/shared/pretty-print.c75
-rw-r--r--src/udev/net/link-config.c18
-rw-r--r--src/udev/udev-rules.c13
20 files changed, 203 insertions, 172 deletions
diff --git a/man/standard-conf.xml b/man/standard-conf.xml
index f5c961a0c2..1db859ac2f 100644
--- a/man/standard-conf.xml
+++ b/man/standard-conf.xml
@@ -11,18 +11,16 @@
<refsection id='confd'>
<title>Configuration Directories and Precedence</title>
- <para>Configuration files are read from directories in
- <filename>/etc/</filename>, <filename>/run/</filename>, and
- <filename>/usr/lib/</filename>, in order of precedence.
- Each configuration file in these configuration directories shall be named in
- the style of <filename><replaceable>filename</replaceable>.conf</filename>.
- Files in <filename>/etc/</filename> override files with the same name in
- <filename>/run/</filename> and <filename>/usr/lib/</filename>. Files in
- <filename>/run/</filename> override files with the same name in
- <filename>/usr/lib/</filename>.</para>
+ <para>Configuration files are read from directories in <filename>/etc/</filename>, <filename>/run/</filename>,
+ <filename>/usr/local/lib/</filename>, and <filename>/usr/lib/</filename>, in order of precedence. Each
+ configuration file in these configuration directories shall be named in the style of
+ <filename><replaceable>filename</replaceable>.conf</filename>. Files in <filename>/etc/</filename> override files
+ with the same name in <filename>/run/</filename>, <filename>/usr/local/lib/</filename>, and
+ <filename>/usr/lib/</filename>. Files in <filename>/run/</filename> override files with the same name under
+ <filename>/usr/</filename>.</para>
- <para>Packages should install their configuration files in
- <filename>/usr/lib/</filename>. Files in <filename>/etc/</filename> are
+ <para>Packages should install their configuration files in <filename>/usr/lib/</filename> (distribution packages)
+ or <filename>/usr/local/lib/</filename> (local installs). Files in <filename>/etc/</filename> are
reserved for the local administrator, who may use this logic to override the
configuration files installed by vendor packages. All configuration files
are sorted by their filename in lexicographic order, regardless of which of
@@ -52,7 +50,8 @@
<para>When packages need to customize the configuration, they can
install configuration snippets in
- <filename>/usr/lib/systemd/*.conf.d/</filename>. Files in
+ <filename>/usr/lib/systemd/*.conf.d/</filename> or
+ <filename>/usr/local/lib/systemd/*.conf.d/</filename>. Files in
<filename>/etc/</filename> are reserved for the local
administrator, who may use this logic to override the
configuration files installed by vendor packages. The main
diff --git a/man/systemd-environment-d-generator.xml b/man/systemd-environment-d-generator.xml
index 44880e76e2..1df1388f4e 100644
--- a/man/systemd-environment-d-generator.xml
+++ b/man/systemd-environment-d-generator.xml
@@ -37,7 +37,7 @@
<para><filename>systemd-environment-d-generator</filename> is a
<citerefentry><refentrytitle>systemd.environment-generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>
that reads environment configuration specified by
- <citerefentry><refentrytitle>environment.d</refentrytitle><manvolnum>7</manvolnum></citerefentry>
+ <citerefentry><refentrytitle>environment.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>
configuration files and passes it to the
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
user manager instance.</para>
@@ -49,7 +49,7 @@
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.environment-generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>
+ <citerefentry><refentrytitle>systemd.generator</refentrytitle><manvolnum>5</manvolnum></citerefentry>
</para>
</refsect1>
diff --git a/man/systemd.dnssd.xml b/man/systemd.dnssd.xml
index dc00591fcd..1c05cffba6 100644
--- a/man/systemd.dnssd.xml
+++ b/man/systemd.dnssd.xml
@@ -1,9 +1,7 @@
<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
-
-<!--
--->
+<!-- SPDX-License-Identifier: LGPL-2.1+ -->
<refentry id="systemd.dnssd" conditional='ENABLE_RESOLVE'>
@@ -36,15 +34,16 @@
<para>The main network service file must have the extension <filename>.dnssd</filename>; other
extensions are ignored.</para>
- <para>The <filename>.dnssd</filename> files are read from the files located in the system
- network directory <filename>/usr/lib/systemd/dnssd</filename>, the volatile runtime network
- directory <filename>/run/systemd/dnssd</filename> and the local administration network
- directory <filename>/etc/systemd/dnssd</filename>. All configuration files are collectively
- sorted and processed in lexical order, regardless of the directories in which they live.
- However, files with identical filenames replace each other. Files in <filename>/etc</filename>
- have the highest priority, files in <filename>/run</filename> take precedence over files with
- the same name in <filename>/usr/lib</filename>. This can be used to override a system-supplied
- configuration file with a local file if needed.</para>
+ <para>The <filename>.dnssd</filename> files are read from the files located in the system network
+ directories <filename>/usr/lib/systemd/dnssd</filename> and
+ <filename>/usr/local/lib/systemd/dnssd</filename>, the volatile runtime network directory
+ <filename>/run/systemd/dnssd</filename> and the local administration network directory
+ <filename>/etc/systemd/dnssd</filename>. All configuration files are collectively sorted and processed in
+ lexical order, regardless of the directories in which they live. However, files with identical filenames
+ replace each other. Files in <filename>/etc</filename> have the highest priority, files in
+ <filename>/run</filename> take precedence over files with the same name in
+ <filename>/usr/lib</filename>. This can be used to override a system-supplied configuration file with a
+ local file if needed.</para>
<para>Along with the network service file <filename>foo.dnssd</filename>, a "drop-in" directory
<filename>foo.dnssd.d/</filename> may exist. All files with the suffix
@@ -52,14 +51,12 @@
parsed. This is useful to alter or add configuration settings, without having to modify the main
configuration file. Each drop-in file must have appropriate section headers.</para>
- <para>In addition to <filename>/etc/systemd/dnssd</filename>, drop-in <literal>.d</literal>
- directories can be placed in <filename>/usr/lib/systemd/dnssd</filename> or
- <filename>/run/systemd/dnssd</filename> directories. Drop-in files in
- <filename>/etc</filename> take precedence over those in <filename>/run</filename> which in turn
- take precedence over those in <filename>/usr/lib</filename>. Drop-in files under any of these
- directories take precedence over the main network service file wherever located. (Of course, since
- <filename>/run</filename> is temporary and <filename>/usr/lib</filename> is for vendors, it is
- unlikely drop-ins should be used in either of those places.)</para>
+ <para>In addition to <filename>/etc/systemd/dnssd</filename>, drop-in <literal>.d</literal> directories
+ can be placed in <filename>/usr/lib/systemd/dnssd</filename> or <filename>/run/systemd/dnssd</filename>
+ directories. Drop-in files in <filename>/etc</filename> take precedence over those in
+ <filename>/run</filename> which in turn take precedence over those in <filename>/usr/lib</filename> or
+ <filename>/usr/local/lib</filename>. Drop-in files under any of these directories take precedence over
+ the main network service file wherever located.</para>
</refsect1>
<refsect1>
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index 1a02672713..fc2ac4b505 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -37,17 +37,17 @@
<para>The main network file must have the extension <filename>.network</filename>; other
extensions are ignored. Networks are applied to links whenever the links appear.</para>
- <para>The <filename>.network</filename> files are read from the files located in the system
- network directory <filename>/usr/lib/systemd/network</filename>, the volatile runtime network
- directory <filename>/run/systemd/network</filename> and the local administration network
- directory <filename>/etc/systemd/network</filename>. All configuration files are collectively
- sorted and processed in lexical order, regardless of the directories in which they live.
- However, files with identical filenames replace each other. Files in <filename>/etc</filename>
- have the highest priority, files in <filename>/run</filename> take precedence over files with
- the same name in <filename>/usr/lib</filename>. This can be used to override a system-supplied
- configuration file with a local file if needed. As a special case, an empty file (file size 0)
- or symlink with the same name pointing to <filename>/dev/null</filename> disables the
- configuration file entirely (it is "masked").</para>
+ <para>The <filename>.network</filename> files are read from the files located in the system network
+ directories <filename>/usr/lib/systemd/network</filename> and
+ <filename>/usr/local/lib/systemd/network</filename>, the volatile runtime network directory
+ <filename>/run/systemd/network</filename> and the local administration network directory
+ <filename>/etc/systemd/network</filename>. All configuration files are collectively sorted and processed
+ in lexical order, regardless of the directories in which they live. However, files with identical
+ filenames replace each other. Files in <filename>/etc</filename> have the highest priority, files in
+ <filename>/run</filename> take precedence over files with the same name under
+ <filename>/usr</filename>. This can be used to override a system-supplied configuration file with a local
+ file if needed. As a special case, an empty file (file size 0) or symlink with the same name pointing to
+ <filename>/dev/null</filename> disables the configuration file entirely (it is "masked").</para>
<para>Along with the network file <filename>foo.network</filename>, a "drop-in" directory
<filename>foo.network.d/</filename> may exist. All files with the suffix
@@ -60,9 +60,7 @@
<filename>/run/systemd/network</filename> directories. Drop-in files in
<filename>/etc</filename> take precedence over those in <filename>/run</filename> which in turn
take precedence over those in <filename>/usr/lib</filename>. Drop-in files under any of these
- directories take precedence over the main netdev file wherever located. (Of course, since
- <filename>/run</filename> is temporary and <filename>/usr/lib</filename> is for vendors, it is
- unlikely drop-ins should be used in either of those places.)</para>
+ directories take precedence over the main netdev file wherever located.</para>
<para>Note that an interface without any static IPv6 addresses configured, and neither DHCPv6
nor IPv6LL enabled, shall be considered to have no IPv6 support. IPv6 will be automatically
diff --git a/man/udev.xml b/man/udev.xml
index 74aab8e024..c82a3998f4 100644
--- a/man/udev.xml
+++ b/man/udev.xml
@@ -45,20 +45,18 @@
</refsect1>
<refsect1><title>Rules Files</title>
- <para>The udev rules are read from the files located in the
- system rules directory <filename>/usr/lib/udev/rules.d</filename>,
- the volatile runtime directory <filename>/run/udev/rules.d</filename>
- and the local administration directory <filename>/etc/udev/rules.d</filename>.
- All rules files are collectively sorted and processed in lexical order,
- regardless of the directories in which they live. However, files with
- identical filenames replace each other. Files in <filename>/etc</filename>
- have the highest priority, files in <filename>/run</filename> take precedence
- over files with the same name in <filename>/usr/lib</filename>. This can be
- used to override a system-supplied rules file with a local file if needed;
- a symlink in <filename>/etc</filename> with the same name as a rules file in
- <filename>/usr/lib</filename>, pointing to <filename>/dev/null</filename>,
- disables the rules file entirely. Rule files must have the extension
- <filename>.rules</filename>; other extensions are ignored.</para>
+ <para>The udev rules are read from the files located in the system rules directories
+ <filename>/usr/lib/udev/rules.d</filename> and <filename>/usr/local/lib/udev/rules.d</filename>, the
+ volatile runtime directory <filename>/run/udev/rules.d</filename> and the local administration
+ directory <filename>/etc/udev/rules.d</filename>. All rules files are collectively sorted and
+ processed in lexical order, regardless of the directories in which they live. However, files with
+ identical filenames replace each other. Files in <filename>/etc</filename> have the highest priority,
+ files in <filename>/run</filename> take precedence over files with the same name under
+ <filename>/usr</filename>. This can be used to override a system-supplied rules file with a local
+ file if needed; a symlink in <filename>/etc</filename> with the same name as a rules file in
+ <filename>/usr/lib</filename>, pointing to <filename>/dev/null</filename>, disables the rules file
+ entirely. Rule files must have the extension <filename>.rules</filename>; other extensions are
+ ignored.</para>
<para>Every line in the rules file contains at least one key-value pair.
Except for empty lines or lines beginning with <literal>#</literal>, which are ignored.
diff --git a/meson.build b/meson.build
index 6d2e53a818..ed787d4749 100644
--- a/meson.build
+++ b/meson.build
@@ -135,7 +135,6 @@ systemsleepdir = join_paths(rootlibexecdir, 'system-sleep')
systemunitdir = join_paths(rootprefixdir, 'lib/systemd/system')
systempresetdir = join_paths(rootprefixdir, 'lib/systemd/system-preset')
udevlibexecdir = join_paths(rootprefixdir, 'lib/udev')
-udevhomedir = udevlibexecdir
udevrulesdir = join_paths(udevlibexecdir, 'rules.d')
udevhwdbdir = join_paths(udevlibexecdir, 'hwdb.d')
catalogdir = join_paths(prefixdir, 'lib/systemd/catalog')
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index 3915b66739..6fa6ef93cc 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -270,14 +270,13 @@ static int acquire_boot_times(sd_bus *bus, struct boot_times **bt) {
if (r < 0)
return log_error_errno(r, "Failed to get timestamp properties: %s", bus_error_message(&error, r));
- if (times.finish_time <= 0) {
- log_error("Bootup is not yet finished (org.freedesktop.systemd1.Manager.FinishTimestampMonotonic=%"PRIu64").\n"
- "Please try again later.\n"
- "Hint: Use 'systemctl%s list-jobs' to see active jobs",
- times.finish_time,
- arg_scope == UNIT_FILE_SYSTEM ? "" : " --user");
- return -EINPROGRESS;
- }
+ if (times.finish_time <= 0)
+ return log_error_errno(SYNTHETIC_ERRNO(EINPROGRESS),
+ "Bootup is not yet finished (org.freedesktop.systemd1.Manager.FinishTimestampMonotonic=%"PRIu64").\n"
+ "Please try again later.\n"
+ "Hint: Use 'systemctl%s list-jobs' to see active jobs",
+ times.finish_time,
+ arg_scope == UNIT_FILE_SYSTEM ? "" : " --user");
if (arg_scope == UNIT_FILE_SYSTEM && times.security_start_time > 0) {
/* security_start_time is set when systemd is not running under container environment. */
@@ -312,7 +311,6 @@ finish:
}
static void free_host_info(struct host_info *hi) {
-
if (!hi)
return;
@@ -385,7 +383,8 @@ static int acquire_time_data(sd_bus *bus, struct unit_times **out) {
NULL,
t);
if (r < 0)
- return log_error_errno(r, "Failed to get timestamp properties of unit %s: %s", u.id, bus_error_message(&error, r));
+ return log_error_errno(r, "Failed to get timestamp properties of unit %s: %s",
+ u.id, bus_error_message(&error, r));
subtract_timestamp(&t->activating, boot_times->reverse_offset);
subtract_timestamp(&t->activated, boot_times->reverse_offset);
@@ -458,7 +457,8 @@ static int acquire_host_info(sd_bus *bus, struct host_info **hi) {
NULL,
host);
if (r < 0) {
- log_debug_errno(r, "Failed to get host information from systemd-hostnamed, ignoring: %s", bus_error_message(&error, r));
+ log_debug_errno(r, "Failed to get host information from systemd-hostnamed, ignoring: %s",
+ bus_error_message(&error, r));
sd_bus_error_free(&error);
}
@@ -472,10 +472,10 @@ manager:
NULL,
host);
if (r < 0)
- return log_error_errno(r, "Failed to get host information from systemd: %s", bus_error_message(&error, r));
+ return log_error_errno(r, "Failed to get host information from systemd: %s",
+ bus_error_message(&error, r));
*hi = TAKE_PTR(host);
-
return 0;
}
@@ -1328,7 +1328,8 @@ static int dump(int argc, char *argv[], void *userdata) {
if (r < 0) {
/* fall back to Dump if DumpByFileDescriptor is not supported */
if (!IN_SET(r, -EACCES, -EBADR))
- return log_error_errno(r, "Failed to issue method call DumpByFileDescriptor: %s", bus_error_message(&error, r));
+ return log_error_errno(r, "Failed to issue method call DumpByFileDescriptor: %s",
+ bus_error_message(&error, r));
return dump_fallback(bus);
}
@@ -1365,8 +1366,7 @@ static int cat_config(int argc, char *argv[], void *userdata) {
if (!t)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "Path %s does not start with any known prefix.",
- *arg);
+ "Path %s does not start with any known prefix.", *arg);
} else
t = *arg;
@@ -1628,8 +1628,8 @@ static int dump_syscall_filters(int argc, char *argv[], void *userdata) {
/* make sure the error appears below normal output */
fflush(stdout);
- log_error("Filter set \"%s\" not found.", *name);
- return -ENOENT;
+ return log_error_errno(SYNTHETIC_ERRNO(ENOENT),
+ "Filter set \"%s\" not found.", *name);
}
dump_syscall_filter(set);
@@ -2000,6 +2000,10 @@ static int parse_argv(int argc, char *argv[]) {
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Option --global only makes sense with verbs dot, unit-paths, verify.");
+ if (streq_ptr(argv[optind], "cat-config") && arg_scope == UNIT_FILE_USER)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Option --user is not supported for cat-config right now.");
+
if (arg_root && !streq_ptr(argv[optind], "cat-config"))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Option --root is only supported for cat-config right now.");
diff --git a/src/basic/def.h b/src/basic/def.h
index 5be018d82e..929da726ae 100644
--- a/src/basic/def.h
+++ b/src/basic/def.h
@@ -66,12 +66,20 @@
"/usr/lib/" n "\0" \
_CONF_PATHS_SPLIT_USR_NULSTR(n)
+#define CONF_PATHS_USR(n) \
+ "/etc/" n, \
+ "/run/" n, \
+ "/usr/local/lib/" n, \
+ "/usr/lib/" n
+
+#define CONF_PATHS(n) \
+ CONF_PATHS_USR(n) \
+ _CONF_PATHS_SPLIT_USR(n)
+
+#define CONF_PATHS_USR_STRV(n) \
+ STRV_MAKE(CONF_PATHS_USR(n))
+
#define CONF_PATHS_STRV(n) \
- STRV_MAKE( \
- "/etc/" n, \
- "/run/" n, \
- "/usr/local/lib/" n, \
- "/usr/lib/" n \
- _CONF_PATHS_SPLIT_USR(n))
+ STRV_MAKE(CONF_PATHS(n))
#define HIGH_RLIMIT_MEMLOCK (1024ULL*1024ULL*64ULL)
diff --git a/src/core/main.c b/src/core/main.c
index 561f956f0a..47a976ad0f 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1382,7 +1382,7 @@ static int bump_rlimit_memlock(struct rlimit *saved_rlimit) {
static void test_usr(void) {
- /* Check that /usr is not a separate fs */
+ /* Check that /usr is either on the same file system as / or mounted already. */
if (dir_is_empty("/usr") <= 0)
return;
diff --git a/src/environment-d-generator/environment-d-generator.c b/src/environment-d-generator/environment-d-generator.c
index 9d64d95738..b2558f0c84 100644
--- a/src/environment-d-generator/environment-d-generator.c
+++ b/src/environment-d-generator/environment-d-generator.c
@@ -14,7 +14,7 @@ static int environment_dirs(char ***ret) {
_cleanup_free_ char *c = NULL;
int r;
- dirs = strv_split_nulstr(CONF_PATHS_NULSTR("environment.d"));
+ dirs = strv_new(CONF_PATHS_USR("environment.d"), NULL);
if (!dirs)
return -ENOMEM;
diff --git a/src/libsystemd-network/network-internal.h b/src/libsystemd-network/network-internal.h
index 022ea6bae0..9d30c52eea 100644
--- a/src/libsystemd-network/network-internal.h
+++ b/src/libsystemd-network/network-internal.h
@@ -8,7 +8,9 @@
#include "condition.h"
#include "conf-parser.h"
+#include "def.h"
#include "set.h"
+#include "strv.h"
#define LINK_BRIDGE_PORT_PRIORITY_INVALID 128
#define LINK_BRIDGE_PORT_PRIORITY_MAX 63
@@ -57,3 +59,5 @@ int deserialize_dhcp_routes(struct sd_dhcp_route **ret, size_t *ret_size, size_t
/* It is not necessary to add deserialize_dhcp_option(). Use unhexmem() instead. */
int serialize_dhcp_option(FILE *f, const char *key, const void *data, size_t size);
+
+#define NETWORK_DIRS ((const char* const*) CONF_PATHS_STRV("systemd/network"))
diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c
index ecd6cf4105..8d42e662f8 100644
--- a/src/network/netdev/netdev.c
+++ b/src/network/netdev/netdev.c
@@ -661,7 +661,7 @@ int netdev_load_one(Manager *manager, const char *filename) {
};
dropin_dirname = strjoina(basename(filename), ".d");
- r = config_parse_many(filename, network_dirs, dropin_dirname,
+ r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
"Match\0NetDev\0",
config_item_perf_lookup, network_netdev_gperf_lookup,
CONFIG_PARSE_WARN|CONFIG_PARSE_RELAXED, netdev_raw);
@@ -702,7 +702,7 @@ int netdev_load_one(Manager *manager, const char *filename) {
if (NETDEV_VTABLE(netdev)->init)
NETDEV_VTABLE(netdev)->init(netdev);
- r = config_parse_many(filename, network_dirs, dropin_dirname,
+ r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
NETDEV_VTABLE(netdev)->sections,
config_item_perf_lookup, network_netdev_gperf_lookup,
CONFIG_PARSE_WARN, netdev);
@@ -802,7 +802,7 @@ int netdev_load(Manager *manager) {
hashmap_clear_with_destructor(manager->netdevs, netdev_unref);
- r = conf_files_list_strv(&files, ".netdev", NULL, 0, network_dirs);
+ r = conf_files_list_strv(&files, ".netdev", NULL, 0, NETWORK_DIRS);
if (r < 0)
return log_error_errno(r, "Failed to enumerate netdev files: %m");
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index d4a692c86f..b7e15a5699 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -18,6 +18,7 @@
#include "fileio.h"
#include "local-addresses.h"
#include "netlink-util.h"
+#include "network-internal.h"
#include "networkd-manager.h"
#include "ordered-set.h"
#include "path-util.h"
@@ -29,15 +30,6 @@
/* use 8 MB for receive socket kernel queue. */
#define RCVBUF_SIZE (8*1024*1024)
-const char* const network_dirs[] = {
- "/etc/systemd/network",
- "/run/systemd/network",
- "/usr/lib/systemd/network",
-#if HAVE_SPLIT_USR
- "/lib/systemd/network",
-#endif
- NULL};
-
static int setup_default_address_pool(Manager *m) {
AddressPool *p;
int r;
@@ -1512,7 +1504,7 @@ int manager_load_config(Manager *m) {
int r;
/* update timestamp */
- paths_check_timestamp(network_dirs, &m->network_dirs_ts_usec, true);
+ paths_check_timestamp(NETWORK_DIRS, &m->network_dirs_ts_usec, true);
r = netdev_load(m);
if (r < 0)
@@ -1526,7 +1518,7 @@ int manager_load_config(Manager *m) {
}
bool manager_should_reload(Manager *m) {
- return paths_check_timestamp(network_dirs, &m->network_dirs_ts_usec, false);
+ return paths_check_timestamp(NETWORK_DIRS, &m->network_dirs_ts_usec, false);
}
int manager_rtnl_enumerate_links(Manager *m) {
diff --git a/src/network/networkd-manager.h b/src/network/networkd-manager.h
index 289ca96216..33f80bf19f 100644
--- a/src/network/networkd-manager.h
+++ b/src/network/networkd-manager.h
@@ -18,8 +18,6 @@
#include "networkd-link.h"
#include "networkd-network.h"
-extern const char* const network_dirs[];
-
struct Manager {
sd_netlink *rtnl;
/* lazy initialized */
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 0a7b825835..19dd031f29 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -212,7 +212,7 @@ int network_load_one(Manager *manager, const char *filename) {
.ipv6_accept_ra_route_table_set = false,
};
- r = config_parse_many(filename, network_dirs, dropin_dirname,
+ r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
"Match\0"
"Link\0"
"Network\0"
@@ -292,7 +292,7 @@ int network_load(Manager *manager) {
while ((network = manager->networks))
network_free(network);
- r = conf_files_list_strv(&files, ".network", NULL, 0, network_dirs);
+ r = conf_files_list_strv(&files, ".network", NULL, 0, NETWORK_DIRS);
if (r < 0)
return log_error_errno(r, "Failed to enumerate network files: %m");
diff --git a/src/resolve/resolved-dnssd.c b/src/resolve/resolved-dnssd.c
index b8e6a7abe1..0e6fa1d0c9 100644
--- a/src/resolve/resolved-dnssd.c
+++ b/src/resolve/resolved-dnssd.c
@@ -1,21 +1,15 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
#include "conf-files.h"
#include "conf-parser.h"
+#include "def.h"
#include "resolved-dnssd.h"
#include "resolved-dns-rr.h"
#include "resolved-manager.h"
#include "specifier.h"
#include "strv.h"
-const char* const dnssd_service_dirs[] = {
- "/etc/systemd/dnssd",
- "/run/systemd/dnssd",
- "/usr/lib/systemd/dnssd",
-#if HAVE_SPLIT_USR
- "/lib/systemd/dnssd",
-#endif
- NULL
-};
+#define DNSSD_SERVICE_DIRS ((const char* const*) CONF_PATHS_STRV("systemd/dnssd"))
DnssdTxtData *dnssd_txtdata_free(DnssdTxtData *txt_data) {
if (!txt_data)
@@ -92,7 +86,7 @@ static int dnssd_service_load(Manager *manager, const char *filename) {
dropin_dirname = strjoina(service->name, ".dnssd.d");
- r = config_parse_many(filename, dnssd_service_dirs, dropin_dirname,
+ r = config_parse_many(filename, DNSSD_SERVICE_DIRS, dropin_dirname,
"Service\0",
config_item_perf_lookup, resolved_dnssd_gperf_lookup,
false, service);
@@ -195,7 +189,7 @@ int dnssd_load(Manager *manager) {
if (manager->mdns_support != RESOLVE_SUPPORT_YES)
return 0;
- r = conf_files_list_strv(&files, ".dnssd", NULL, 0, dnssd_service_dirs);
+ r = conf_files_list_strv(&files, ".dnssd", NULL, 0, DNSSD_SERVICE_DIRS);
if (r < 0)
return log_error_errno(r, "Failed to enumerate .dnssd files: %m");
diff --git a/src/shared/install.c b/src/shared/install.c
index 8629304cef..9e88ac46bd 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -15,6 +15,7 @@
#include "alloc-util.h"
#include "conf-files.h"
#include "conf-parser.h"
+#include "def.h"
#include "dirent-util.h"
#include "extract-word.h"
#include "fd-util.h"
@@ -2820,44 +2821,41 @@ static int split_pattern_into_name_and_instances(const char *pattern, char **out
return 0;
}
-static int read_presets(UnitFileScope scope, const char *root_dir, Presets *presets) {
- _cleanup_(presets_freep) Presets ps = {};
- size_t n_allocated = 0;
- _cleanup_strv_free_ char **files = NULL;
- char **p;
- int r;
+static int presets_find_config(UnitFileScope scope, const char *root_dir, char ***files) {
+ const char* const* dirs;
assert(scope >= 0);
assert(scope < _UNIT_FILE_SCOPE_MAX);
- assert(presets);
switch (scope) {
case UNIT_FILE_SYSTEM:
- r = conf_files_list(&files, ".preset", root_dir, 0,
- "/etc/systemd/system-preset",
- "/run/systemd/system-preset",
- "/usr/local/lib/systemd/system-preset",
- "/usr/lib/systemd/system-preset",
-#if HAVE_SPLIT_USR
- "/lib/systemd/system-preset",
-#endif
- NULL);
+ dirs = (const char* const*) CONF_PATHS_STRV("systemd/system-preset");
break;
case UNIT_FILE_GLOBAL:
case UNIT_FILE_USER:
- r = conf_files_list(&files, ".preset", root_dir, 0,
- "/etc/systemd/user-preset",
- "/run/systemd/user-preset",
- "/usr/local/lib/systemd/user-preset",
- "/usr/lib/systemd/user-preset",
- NULL);
+ dirs = (const char* const*) CONF_PATHS_USR_STRV("systemd/user-preset");
break;
default:
assert_not_reached("Invalid unit file scope");
}
+ return conf_files_list_strv(files, ".preset", root_dir, 0, dirs);
+}
+
+static int read_presets(UnitFileScope scope, const char *root_dir, Presets *presets) {
+ _cleanup_(presets_freep) Presets ps = {};
+ size_t n_allocated = 0;
+ _cleanup_strv_free_ char **files = NULL;
+ char **p;
+ int r;
+
+ assert(scope >= 0);
+ assert(scope < _UNIT_FILE_SCOPE_MAX);
+ assert(presets);
+
+ r = presets_find_config(scope, root_dir, &files);
if (r < 0)
return r;
diff --git a/src/shared/pretty-print.c b/src/shared/pretty-print.c
index de6274a3da..ce71a7ef60 100644
--- a/src/shared/pretty-print.c
+++ b/src/shared/pretty-print.c
@@ -213,33 +213,88 @@ void print_separator(void) {
fputs("\n\n", stdout);
}
+static int guess_type(const char **name, bool *is_usr, bool *is_collection, const char **extension) {
+ /* Try to figure out if name is like tmpfiles.d/ or systemd/system-presets/,
+ * i.e. a collection of directories without a main config file. */
+
+ _cleanup_free_ char *n = NULL;
+ bool usr = false, coll = false;
+ const char *ext = ".conf";
+
+ if (path_equal(*name, "environment.d"))
+ /* Special case: we need to include /etc/environment in the search path, even
+ * though the whole concept is called environment.d. */
+ *name = "environment";
+
+ n = strdup(*name);
+ if (!n)
+ return log_oom();
+
+ delete_trailing_chars(n, "/");
+
+ if (endswith(n, ".d"))
+ coll = true;
+
+ if (path_equal(n, "environment"))
+ usr = true;
+
+ if (path_equal(n, "udev/hwdb.d"))
+ ext = ".hwdb";
+
+ if (path_equal(n, "udev/rules.d"))
+ ext = ".rules";
+
+ if (PATH_IN_SET(n, "systemd/system-preset", "systemd/user-preset")) {
+ coll = true;
+ ext = ".preset";
+ }
+
+ if (path_equal(n, "systemd/user-preset"))
+ usr = true;
+
+ *is_usr = usr;
+ *is_collection = coll;
+ *extension = ext;
+ return 0;
+}
+
int conf_files_cat(const char *root, const char *name) {
_cleanup_strv_free_ char **dirs = NULL, **files = NULL;
_cleanup_free_ char *path = NULL;
- const char *dir;
+ char **dir;
+ bool is_usr, is_collection;
+ const char *extension;
char **t;
int r;
- NULSTR_FOREACH(dir, CONF_PATHS_NULSTR("")) {
- assert(endswith(dir, "/"));
- r = strv_extendf(&dirs, "%s%s.d", dir, name);
+ r = guess_type(&name, &is_usr, &is_collection, &extension);
+ if (r < 0)
+ return r;
+
+ STRV_FOREACH(dir, is_usr ? CONF_PATHS_USR_STRV("") : CONF_PATHS_STRV("")) {
+ assert(endswith(*dir, "/"));
+ r = strv_extendf(&dirs, "%s%s%s", *dir, name,
+ is_collection ? "" : ".d");
if (r < 0)
return log_error_errno(r, "Failed to build directory list: %m");
}
- r = conf_files_list_strv(&files, ".conf", root, 0, (const char* const*) dirs);
+ r = conf_files_list_strv(&files, extension, root, 0, (const char* const*) dirs);
if (r < 0)
return log_error_errno(r, "Failed to query file list: %m");
- path = path_join(root, "/etc", name);
- if (!path)
- return log_oom();
+ if (!is_collection) {
+ path = path_join(root, "/etc", name);
+ if (!path)
+ return log_oom();
+ }
if (DEBUG_LOGGING) {
log_debug("Looking for configuration in:");
- log_debug(" %s", path);
+ if (path)
+ log_debug(" %s", path);
STRV_FOREACH(t, dirs)
- log_debug(" %s/*.conf", *t);
+ log_debug(" %s/*%s", *t, extension);
}
/* show */
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index 1b41b1f6a2..5141dae561 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -8,6 +8,7 @@
#include "alloc-util.h"
#include "conf-files.h"
#include "conf-parser.h"
+#include "def.h"
#include "device-util.h"
#include "ethtool-util.h"
#include "fd-util.h"
@@ -36,18 +37,9 @@ struct link_config_ctx {
sd_netlink *rtnl;
- usec_t link_dirs_ts_usec;
+ usec_t network_dirs_ts_usec;
};
-static const char* const link_dirs[] = {
- "/etc/systemd/network",
- "/run/systemd/network",
- "/usr/lib/systemd/network",
-#if HAVE_SPLIT_USR
- "/lib/systemd/network",
-#endif
- NULL};
-
static void link_config_free(link_config *link) {
if (!link)
return;
@@ -216,9 +208,9 @@ int link_config_load(link_config_ctx *ctx) {
}
/* update timestamp */
- paths_check_timestamp(link_dirs, &ctx->link_dirs_ts_usec, true);
+ paths_check_timestamp(NETWORK_DIRS, &ctx->network_dirs_ts_usec, true);
- r = conf_files_list_strv(&files, ".link", NULL, 0, link_dirs);
+ r = conf_files_list_strv(&files, ".link", NULL, 0, NETWORK_DIRS);
if (r < 0)
return log_error_errno(r, "failed to enumerate link files: %m");
@@ -232,7 +224,7 @@ int link_config_load(link_config_ctx *ctx) {
}
bool link_config_should_reload(link_config_ctx *ctx) {
- return paths_check_timestamp(link_dirs, &ctx->link_dirs_ts_usec, false);
+ return paths_check_timestamp(NETWORK_DIRS, &ctx->network_dirs_ts_usec, false);
}
int link_config_get(link_config_ctx *ctx, sd_device *device, link_config **ret) {
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index ce787786a6..e34ecc6ee9 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -15,6 +15,7 @@
#include "alloc-util.h"
#include "conf-files.h"
+#include "def.h"
#include "device-private.h"
#include "device-util.h"
#include "dirent-util.h"
@@ -41,6 +42,7 @@
#include "util.h"
#define PREALLOC_TOKEN 2048
+#define RULES_DIRS (const char* const*) CONF_PATHS_STRV("udev/rules.d")
struct uid_gid {
unsigned name_off;
@@ -50,13 +52,6 @@ struct uid_gid {
};
};
-static const char* const rules_dirs[] = {
- "/etc/udev/rules.d",
- "/run/udev/rules.d",
- UDEVLIBEXECDIR "/rules.d",
- NULL
-};
-
struct UdevRules {
usec_t dirs_ts_usec;
ResolveNameTiming resolve_name_timing;
@@ -1591,7 +1586,7 @@ int udev_rules_new(UdevRules **ret_rules, ResolveNameTiming resolve_name_timing)
udev_rules_check_timestamp(rules);
- r = conf_files_list_strv(&files, ".rules", NULL, 0, rules_dirs);
+ r = conf_files_list_strv(&files, ".rules", NULL, 0, RULES_DIRS);
if (r < 0)
return log_error_errno(r, "Failed to enumerate rules files: %m");
@@ -1643,7 +1638,7 @@ bool udev_rules_check_timestamp(UdevRules *rules) {
if (!rules)
return false;
- return paths_check_timestamp(rules_dirs, &rules->dirs_ts_usec, true);
+ return paths_check_timestamp(RULES_DIRS, &rules->dirs_ts_usec, true);
}
static bool match_key(UdevRules *rules, struct token *token, const char *val) {