1
0
mirror of https://github.com/systemd/systemd synced 2026-04-10 17:15:03 +02:00

Compare commits

...

20 Commits

Author SHA1 Message Date
Michael Biebl
5c18815dc0 test: mark TEST-46-HOMED as skipped if feature is disabled
See https://github.com/systemd/systemd/pull/21253#issuecomment-995721856
2021-12-16 21:41:49 +00:00
Michael Biebl
85e3a3a832 test: record missing openssl as a failure
The openssl binary is an optional dependency.
If systemd has been built with OpenSSL support, we want to test its
OpenSSL functionality.
So record a failure message in /failed if the binary is missing.

See https://github.com/systemd/systemd/pull/21724#issuecomment-992707614
2021-12-16 21:18:38 +00:00
Yu Watanabe
b0b1edc29b NEWS: fix typo 2021-12-17 04:12:14 +09:00
Yu Watanabe
616f51c16d boot: fix typo 2021-12-17 04:11:41 +09:00
Yu Watanabe
d9338387d9
Merge pull request #21786 from keszybz/dirent-work
Make FOREACH_DIRENT and FOREACH_DIRENT_ALL declare the iterator variables
2021-12-17 04:07:35 +09:00
Yu Watanabe
75e1378c0d
Merge pull request #21736 from yuwata/network-cleanups-for-drop-foreign-configs
network: cleanups for dropping foreign configs
2021-12-17 04:07:00 +09:00
Luca Boccassi
c6837e4e86
Merge pull request #21790 from keszybz/network-generator-always
Enable systemd-network-generator by default
2021-12-16 15:50:39 +00:00
Yu Watanabe
2347b6b94e test-network: wait for veth99 being configured
As the address, which should be kept, may not be just removed yet.
Let's check that the address is actually kept.
2021-12-17 00:14:30 +09:00
Yu Watanabe
8a20a8438f network: route: link_drop_foreign_routes() must be called only for managed interfaces 2021-12-17 00:14:30 +09:00
Yu Watanabe
f974f17ae7 networkd: check the existence of the route 2021-12-17 00:13:42 +09:00
Yu Watanabe
a71c5c44f7 network: address: minor optimization for link_drop_foreign_addresses()
link_address_is_dynamic() is costful in general. Call it only when
KeepConfiguration= is set.

Note, it is not necessary to check link->network in the loop, as we have
the assertion for that in the beginning of the function.
2021-12-16 22:43:18 +09:00
Yu Watanabe
9e86dba94b network: drop IPv6LL addresses manually configured in .network file 2021-12-16 22:43:18 +09:00
Zbigniew Jędrzejewski-Szmek
c01543fdd5 meson: drop three more single-use convenience libraries
The way that the cryptsetup plugins were built was unnecessarilly complicated.
We would build three static libraries that would then be linked into dynamic
libraries. No need to do this.

While at it, let's use a convenience library to avoid compiling the shared code
more than once.

We want the output .so files to be located in the main build directory,
like with all consumable build artifacts, so we need to maintain the split
between src/cryptsetup/cryptsetup-token/meson.build and the main meson.build
file.

AFAICT, the build artifacts are the same: exported and undefined symbols are
identical. There is a tiny difference in size, but I think it might be caused
by a different build directory name.
2021-12-16 11:51:40 +01:00
Zbigniew Jędrzejewski-Szmek
3a4524116a meson: drop convenience library that was only used in one place
It doesn't make much sense to do this, the result is very similar to including
to objects directly in the output binary without going through an intermediate
target.

The linkage of test-libudev was rather strange too: udev_link_with is used to
allow udev to be linked to a static version of libshared, so that udev is not
linked to libshared.so. But here we were using both, defeating the purpose of
udev_link_with. I don't think it matters what the test is linked to, so let's
use the non-static linkage to save space.
2021-12-16 11:09:51 +01:00
Zbigniew Jędrzejewski-Szmek
03f7ddf0bf meson: stop building out convenience libraries by default
The meson default for static_library() are:
build_by_default=true, install=false. We never interact with the
static libraries, and we only care about them as a stepping-stone towards
the installable executables or libraries. Thus let's only build them if
they are a dependency of something else we are building.

While at it, let's drop install:false, since this appears to be the default.

This change would have fixed the issue with lib_import_common failing
to build too: we wouldn't attempt to build it.

In practice this changes very little, because we generally only declare static
libraries where there's something in the default target that will make use of
them. But it seems to be a better pattern to set build_by_default to false.
2021-12-16 11:01:08 +01:00
Zbigniew Jędrzejewski-Szmek
b93f018f57 meson: don't compile import sources four times
Use a 'convenience library' to do the compilation once and then link the
objects into all the files that need it. Those files are small, so this probably
doesn't matter too much for speed, but has the advantage that we don't get the
same error four times if something goes wrong.

The library is conditionalized in the same way importd itself, because we
cannot build it without the deps.
2021-12-16 10:54:46 +01:00
Zbigniew Jędrzejewski-Szmek
66aaca688f man: split out a paragraph and shorten the text about sd-network-generator
The ordering of the service wrt. to udevd is enforced by unit configuration,
so no need to tell the user about this. From users' POV, the only thing that
counts is that the unit is enabled and then the right thing happens.
2021-12-16 09:56:13 +01:00
Zbigniew Jędrzejewski-Szmek
e053f49272 units: enable systemd-network-generator by default
It is used by udevd and networkd. Since udevd is enabled statically, let's also
change the preset to "on". networkd is opt-in, so let's pull in the generator
when enabling networkd too.
2021-12-16 09:49:39 +01:00
Zbigniew Jędrzejewski-Szmek
af3b864d76 Define FOREACH_DIRENT through FOREACH_DIRENT_ALL
As in the previous commit, 'de' is used as the iterator variable name.
2021-12-15 22:50:00 +01:00
Zbigniew Jędrzejewski-Szmek
c7f0d9e5ac tree-wide: make FOREACH_DIRENT_ALL define the iterator variable
The variable is not useful outside of the loop (it'll always be null
after the loop is finished), so we can declare it inline in the loop.
This saves one variable declaration and reduces the chances that somebody
tries to use the variable outside of the loop.

For consistency, 'de' is used everywhere for the var name.
2021-12-15 16:19:13 +01:00
89 changed files with 257 additions and 353 deletions

2
NEWS
View File

@ -688,7 +688,7 @@ CHANGES WITH 250 in spe:
are now ordered the same as other units. Effectively, they will be
started earlier (if something actually pulled them in) and stopped
later, similarly to normal mount units that are part of
fs-local.target. This change should be invisibile to users, but
fs-local.target. This change should be invisible to users, but
should prevent those units from being stopped too early during
shutdown.

View File

@ -234,13 +234,14 @@
<citerefentry><refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum></citerefentry>
for more details. When the MAC address is specified, the policies are applied to the
interface which has the address. When no MAC address is specified, the policies are applied
to all interfaces. This kernel command line argument can be specified multiple times. This
argument is not directly read from <command>systemd-udevd</command>, but read and converted
to a .link file by <command>systemd-network-generator</command>. So, to make this argument
take effect, <filename>systemd-network-generator.service</filename> must be enabled and
started before starting <filename>systemd-udevd.service</filename>. See
<citerefentry><refentrytitle>systemd-network-generator.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
for more details about the service.</para>
to all interfaces. This kernel command line argument can be specified multiple times.</para>
<para>This argument is not directly read by <command>systemd-udevd</command>, but is instead
converted to a .link file by
<citerefentry><refentrytitle>systemd-network-generator.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
For this argument to take effect, <filename>systemd-network-generator.service</filename> must be
enabled.</para>
<para>Example:
<programlisting>net.ifname-policy=keep,kernel,path,slot,onboard,01:23:45:67:89:ab
net.ifname-policy=keep,kernel,path,slot,onboard,mac</programlisting>

View File

@ -1836,11 +1836,15 @@ if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
if conf.get('HAVE_TPM2') == 1
cryptsetup_token_systemd_tpm2 = shared_library(
'cryptsetup-token-systemd-tpm2',
cryptsetup_token_systemd_tpm2_sources,
include_directories : includes,
link_args : ['-shared',
'-Wl,--version-script=' + cryptsetup_token_sym_path],
dependencies : libshared_deps + [libcryptsetup, versiondep],
link_with : [libshared],
link_whole : [cryptsetup_token_systemd_tpm2_static],
link_with : [lib_cryptsetup_token_common,
libshared],
dependencies : [libcryptsetup,
tpm2,
versiondep],
link_depends : cryptsetup_token_sym,
install_rpath : rootlibexecdir,
install : true,
@ -1850,11 +1854,15 @@ if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
if conf.get('HAVE_LIBFIDO2') == 1
cryptsetup_token_systemd_fido2 = shared_library(
'cryptsetup-token-systemd-fido2',
cryptsetup_token_systemd_fido2_sources,
include_directories : includes,
link_args : ['-shared',
'-Wl,--version-script=' + cryptsetup_token_sym_path],
dependencies : libshared_deps + [libcryptsetup, versiondep],
link_with : [libshared],
link_whole : [cryptsetup_token_systemd_fido2_static],
link_with : [lib_cryptsetup_token_common,
libshared],
dependencies : [libcryptsetup,
libfido2,
versiondep],
link_depends : cryptsetup_token_sym,
install_rpath : rootlibexecdir,
install : true,
@ -1864,11 +1872,15 @@ if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
if conf.get('HAVE_P11KIT') == 1
cryptsetup_token_systemd_pkcs11 = shared_library(
'cryptsetup-token-systemd-pkcs11',
cryptsetup_token_systemd_pkcs11_sources,
include_directories : includes,
link_args : ['-shared',
'-Wl,--version-script=' + cryptsetup_token_sym_path],
dependencies : libshared_deps + [libcryptsetup, versiondep],
link_with : [libshared],
link_whole : [cryptsetup_token_systemd_pkcs11_static],
link_with : [lib_cryptsetup_token_common,
libshared],
dependencies : [libcryptsetup,
libp11kit,
versiondep],
link_depends : cryptsetup_token_sym,
install_rpath : rootlibexecdir,
install : true,
@ -2764,7 +2776,8 @@ if conf.get('ENABLE_IMPORTD') == 1
'systemd-pull',
systemd_pull_sources,
include_directories : includes,
link_with : [libshared],
link_with : [libshared,
lib_import_common],
dependencies : [versiondep,
libcurl,
lib_openssl_or_gcrypt,
@ -2779,7 +2792,8 @@ if conf.get('ENABLE_IMPORTD') == 1
'systemd-import',
systemd_import_sources,
include_directories : includes,
link_with : [libshared],
link_with : [libshared,
lib_import_common],
dependencies : [libcurl,
libz,
libbzip2,
@ -2792,7 +2806,8 @@ if conf.get('ENABLE_IMPORTD') == 1
'systemd-import-fs',
systemd_import_fs_sources,
include_directories : includes,
link_with : [libshared],
link_with : [libshared,
lib_import_common],
install_rpath : rootlibexecdir,
install : true,
install_dir : rootlibexecdir)
@ -2801,7 +2816,8 @@ if conf.get('ENABLE_IMPORTD') == 1
'systemd-export',
systemd_export_sources,
include_directories : includes,
link_with : [libshared],
link_with : [libshared,
lib_import_common],
dependencies : [libcurl,
libz,
libbzip2,

View File

@ -18,6 +18,7 @@ enable machines.target
enable getty@.service
enable systemd-timesyncd.service
enable systemd-networkd.service
enable systemd-network-generator.service
enable systemd-resolved.service
enable systemd-homed.service
enable systemd-userdbd.socket
@ -37,7 +38,6 @@ disable exit.target
disable systemd-networkd-wait-online.service
disable systemd-time-wait-sync.service
disable systemd-boot-check-no-failures.service
disable systemd-network-generator.service
disable proc-sys-fs-binfmt_misc.mount
disable syslog.socket

View File

@ -199,8 +199,6 @@ int cg_enumerate_subgroups(const char *controller, const char *path, DIR **_d) {
}
int cg_read_subgroup(DIR *d, char **fn) {
struct dirent *de;
assert(d);
assert(fn);

View File

@ -30,7 +30,6 @@ static int files_add(
_cleanup_closedir_ DIR *dir = NULL;
const char *dirpath;
struct dirent *de;
int r;
assert(h);

View File

@ -14,19 +14,8 @@ bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) _pu
struct dirent *readdir_ensure_type(DIR *d);
struct dirent *readdir_no_dot(DIR *dirp);
#define FOREACH_DIRENT(de, d, on_error) \
for (de = readdir_ensure_type(d);; de = readdir_ensure_type(d)) \
if (!de) { \
if (errno > 0) { \
on_error; \
} \
break; \
} else if (hidden_or_backup_file((de)->d_name)) \
continue; \
else
#define FOREACH_DIRENT_ALL(de, d, on_error) \
for (de = readdir_ensure_type(d);; de = readdir_ensure_type(d)) \
for (struct dirent *(de) = readdir_ensure_type(d);; (de) = readdir_ensure_type(d)) \
if (!de) { \
if (errno > 0) { \
on_error; \
@ -34,6 +23,12 @@ struct dirent *readdir_no_dot(DIR *dirp);
break; \
} else
#define FOREACH_DIRENT(de, d, on_error) \
FOREACH_DIRENT_ALL(de, d, on_error) \
if (hidden_or_backup_file((de)->d_name)) \
continue; \
else
/* Maximum space one dirent structure might require at most */
#define DIRENT_SIZE_MAX CONST_MAX(sizeof(struct dirent), offsetof(struct dirent, d_name) + NAME_MAX + 1)

View File

@ -300,7 +300,6 @@ int close_all_fds_without_malloc(const int except[], size_t n_except) {
int close_all_fds(const int except[], size_t n_except) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0;
assert(n_except == 0 || except);

View File

@ -533,7 +533,6 @@ int mkfifoat_atomic(int dirfd, const char *path, mode_t mode) {
int get_files_in_directory(const char *path, char ***list) {
_cleanup_strv_free_ char **l = NULL;
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
size_t n = 0;
assert(path);

View File

@ -158,20 +158,19 @@ static int add_locales_from_archive(Set *locales) {
static int add_locales_from_libdir (Set *locales) {
_cleanup_closedir_ DIR *dir = NULL;
struct dirent *entry;
int r;
dir = opendir("/usr/lib/locale");
if (!dir)
return errno == ENOENT ? 0 : -errno;
FOREACH_DIRENT(entry, dir, return -errno) {
FOREACH_DIRENT(de, dir, return -errno) {
char *z;
if (entry->d_type != DT_DIR)
if (de->d_type != DT_DIR)
continue;
z = normalize_locale(entry->d_name);
z = normalize_locale(de->d_name);
if (!z)
return -ENOMEM;

View File

@ -428,7 +428,7 @@ libbasic = static_library(
libcap,
libm],
c_args : ['-fvisibility=default'],
install : false)
build_by_default : false)
############################################################
@ -443,4 +443,5 @@ libbasic_gcrypt = static_library(
basic_gcrypt_sources,
include_directories : basic_includes,
dependencies : [libgcrypt],
c_args : ['-fvisibility=default'])
c_args : ['-fvisibility=default'],
build_by_default : false)

View File

@ -89,7 +89,6 @@ int open_extension_release(const char *root, const char *extension, char **ret_p
return log_debug_errno(r, "Cannot open %s/usr/lib/extension-release.d/, ignoring: %m", root);
r = -ENOENT;
struct dirent *de;
FOREACH_DIRENT(de, extension_release_dir, return -errno) {
int k;

View File

@ -276,7 +276,6 @@ int unit_file_build_name_map(
STRV_FOREACH(dir, (char**) lp->search_path) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
d = opendir(*dir);
if (!d) {

View File

@ -118,7 +118,6 @@ void in_initrd_force(bool value) {
int on_ac_power(void) {
bool found_offline = false, found_online = false;
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r;
d = opendir("/sys/class/power_supply");

View File

@ -98,7 +98,6 @@ static int detect_vm_device_tree(void) {
r = read_one_line_file("/proc/device-tree/hypervisor/compatible", &hvtype);
if (r == -ENOENT) {
_cleanup_closedir_ DIR *dir = NULL;
struct dirent *dent;
if (access("/proc/device-tree/ibm,partition-name", F_OK) == 0 &&
access("/proc/device-tree/hmc-managed?", F_OK) == 0 &&
@ -114,9 +113,9 @@ static int detect_vm_device_tree(void) {
return -errno;
}
FOREACH_DIRENT(dent, dir, return -errno)
if (strstr(dent->d_name, "fw-cfg")) {
log_debug("Virtualization QEMU: \"fw-cfg\" present in /proc/device-tree/%s", dent->d_name);
FOREACH_DIRENT(de, dir, return -errno)
if (strstr(de->d_name, "fw-cfg")) {
log_debug("Virtualization QEMU: \"fw-cfg\" present in /proc/device-tree/%s", de->d_name);
return VIRTUALIZATION_QEMU;
}

View File

@ -184,7 +184,6 @@ finish:
static int enumerate_binaries(const char *esp_path, const char *path, const char *prefix) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
const char *p;
int c = 0, r;
@ -658,7 +657,6 @@ static int copy_one_file(const char *esp_path, const char *name, bool force) {
}
static int install_binaries(const char *esp_path, bool force) {
struct dirent *de;
_cleanup_closedir_ DIR *d = NULL;
int r = 0;
@ -850,7 +848,6 @@ static int install_variables(const char *esp_path,
static int remove_boot_efi(const char *esp_path) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
const char *p;
int r, c = 0;

View File

@ -6,7 +6,7 @@
#include "tests.h"
#include "utf8.h"
/* Inlcude the implementation directly, so we can poke at some internals. */
/* Include the implementation directly, so we can poke at some internals. */
#include "bcd.c"
static void load_bcd(const char *path, void **ret_bcd, size_t *ret_bcd_len) {

View File

@ -287,7 +287,6 @@ static void manager_print_jobs_in_progress(Manager *m) {
static int have_ask_password(void) {
_cleanup_closedir_ DIR *dir = NULL;
struct dirent *de;
dir = opendir("/run/systemd/ask-password");
if (!dir) {
@ -297,10 +296,9 @@ static int have_ask_password(void) {
return -errno;
}
FOREACH_DIRENT_ALL(de, dir, return -errno) {
FOREACH_DIRENT_ALL(de, dir, return -errno)
if (startswith(de->d_name, "ask."))
return true;
}
return false;
}

View File

@ -184,7 +184,8 @@ libcore = static_library(
libapparmor,
libselinux,
libmount,
libacl])
libacl],
build_by_default : false)
core_includes = [includes, include_directories('.')]

View File

@ -51,7 +51,6 @@ static int fdopen_unlocked_at(int dfd, const char *dir, const char *name, int *s
static int write_access2_rules(const char *srcdir) {
_cleanup_close_ int load2_fd = -1, change_fd = -1;
_cleanup_closedir_ DIR *dir = NULL;
struct dirent *entry;
int dfd = -1, r = 0;
load2_fd = open("/sys/fs/smackfs/load2", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
@ -124,7 +123,6 @@ static int write_access2_rules(const char *srcdir) {
static int write_cipso2_rules(const char *srcdir) {
_cleanup_close_ int cipso2_fd = -1;
_cleanup_closedir_ DIR *dir = NULL;
struct dirent *entry;
int dfd = -1, r = 0;
cipso2_fd = open("/sys/fs/smackfs/cipso2", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
@ -184,7 +182,6 @@ static int write_cipso2_rules(const char *srcdir) {
static int write_netlabel_rules(const char *srcdir) {
_cleanup_fclose_ FILE *dst = NULL;
_cleanup_closedir_ DIR *dir = NULL;
struct dirent *entry;
int dfd = -1, r = 0;
dst = fopen("/sys/fs/smackfs/netlabel", "we");

View File

@ -142,7 +142,6 @@ int coredump_vacuum(int exclude_fd, uint64_t keep_free, uint64_t max_use) {
for (;;) {
_cleanup_(vacuum_candidate_hashmap_freep) Hashmap *h = NULL;
VacuumCandidate *worst = NULL;
struct dirent *de;
uint64_t sum = 0;
rewinddir(d);

View File

@ -580,7 +580,6 @@ static int compose_open_fds(pid_t pid, char **open_fds) {
_cleanup_free_ char *buffer = NULL;
_cleanup_fclose_ FILE *stream = NULL;
const char *fddelim = "", *path;
struct dirent *dent = NULL;
size_t size = 0;
int r;
@ -600,20 +599,20 @@ static int compose_open_fds(pid_t pid, char **open_fds) {
if (!stream)
return -ENOMEM;
FOREACH_DIRENT(dent, proc_fd_dir, return -errno) {
FOREACH_DIRENT(de, proc_fd_dir, return -errno) {
_cleanup_fclose_ FILE *fdinfo = NULL;
_cleanup_free_ char *fdname = NULL;
_cleanup_close_ int fd = -1;
r = readlinkat_malloc(dirfd(proc_fd_dir), dent->d_name, &fdname);
r = readlinkat_malloc(dirfd(proc_fd_dir), de->d_name, &fdname);
if (r < 0)
return r;
fprintf(stream, "%s%s:%s\n", fddelim, dent->d_name, fdname);
fprintf(stream, "%s%s:%s\n", fddelim, de->d_name, fdname);
fddelim = "\n";
/* Use the directory entry from /proc/[pid]/fd with /proc/[pid]/fdinfo */
fd = openat(proc_fdinfo_fd, dent->d_name, O_NOFOLLOW|O_CLOEXEC|O_RDONLY);
fd = openat(proc_fdinfo_fd, de->d_name, O_NOFOLLOW|O_CLOEXEC|O_RDONLY);
if (fd < 0)
continue;

View File

@ -1,64 +1,28 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
cryptsetup_token_c_args = ['-fvisibility=hidden']
cryptsetup_token_sym = files('cryptsetup-token.sym')
cryptsetup_token_sym_path = meson.current_source_dir() / 'cryptsetup-token.sym'
if conf.get('HAVE_TPM2') == 1
cryptsetup_token_systemd_tpm2_sources = files('''
cryptsetup-token-systemd-tpm2.c
cryptsetup-token.h
cryptsetup-token-util.h
cryptsetup-token-util.c
luks2-tpm2.c
luks2-tpm2.h
'''.split())
lib_cryptsetup_token_common = static_library(
'cryptsetup-token-common',
'cryptsetup-token.h',
'cryptsetup-token-util.h',
'cryptsetup-token-util.c',
include_directories : includes,
link_with : libshared,
build_by_default : false)
cryptsetup_token_systemd_tpm2_static = static_library(
'cryptsetup-token-systemd-tpm2_static',
cryptsetup_token_systemd_tpm2_sources,
include_directories : includes,
dependencies : libshared_deps + [libcryptsetup, versiondep],
c_args : cryptsetup_token_c_args)
endif
cryptsetup_token_systemd_tpm2_sources = files(
'cryptsetup-token-systemd-tpm2.c',
'luks2-tpm2.c',
'luks2-tpm2.h')
if conf.get('HAVE_LIBFIDO2') == 1
cryptsetup_token_systemd_fido2_sources = files('''
cryptsetup-token-systemd-fido2.c
cryptsetup-token.h
cryptsetup-token-util.h
cryptsetup-token-util.c
luks2-fido2.c
luks2-fido2.h
'''.split())
cryptsetup_token_systemd_fido2_sources = files(
'cryptsetup-token-systemd-fido2.c',
'luks2-fido2.c',
'luks2-fido2.h')
cryptsetup_token_systemd_fido2_static = static_library(
'cryptsetup-token-systemd-fido2_static',
cryptsetup_token_systemd_fido2_sources,
include_directories : includes,
dependencies : libshared_deps + [libcryptsetup, versiondep],
c_args : cryptsetup_token_c_args)
endif
if conf.get('HAVE_P11KIT') == 1
cryptsetup_token_systemd_pkcs11_sources = files('''
cryptsetup-token-systemd-pkcs11.c
cryptsetup-token.h
cryptsetup-token-util.h
cryptsetup-token-util.c
luks2-pkcs11.c
luks2-pkcs11.h
'''.split())
cryptsetup_token_systemd_pkcs11_static = static_library(
'cryptsetup-token-systemd-pkcs11_static',
cryptsetup_token_systemd_pkcs11_sources,
include_directories : includes,
dependencies : libshared_deps + [libcryptsetup, versiondep],
c_args : cryptsetup_token_c_args)
endif
endif
cryptsetup_token_systemd_pkcs11_sources = files(
'cryptsetup-token-systemd-pkcs11.c',
'luks2-pkcs11.c',
'luks2-pkcs11.h')

View File

@ -290,7 +290,6 @@ static int enumerate_dir(
const char *path, bool dropins) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
_cleanup_strv_free_ char **files = NULL, **dirs = NULL;
size_t n_files = 0, n_dirs = 0;
char **t;

View File

@ -447,7 +447,6 @@ unlink_this_file:
static int manager_enumerate_records(Manager *m) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
assert(m);
@ -919,7 +918,6 @@ static int manager_assess_image(
int manager_enumerate_images(Manager *m) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
assert(m);

View File

@ -159,7 +159,7 @@ int import_fork_tar_c(const char *path, pid_t *ret) {
int import_mangle_os_tree(const char *path) {
_cleanup_free_ char *child = NULL, *t = NULL, *joined = NULL;
_cleanup_closedir_ DIR *d = NULL, *cd = NULL;
struct dirent *de;
struct dirent *dent;
struct stat st;
int r;
@ -183,8 +183,8 @@ int import_mangle_os_tree(const char *path) {
return log_error_errno(r, "Failed to open directory '%s': %m", path);
errno = 0;
de = readdir_no_dot(d);
if (!de) {
dent = readdir_no_dot(d);
if (!dent) {
if (errno != 0)
return log_error_errno(errno, "Failed to iterate through directory '%s': %m", path);
@ -192,13 +192,13 @@ int import_mangle_os_tree(const char *path) {
return 0;
}
child = strdup(de->d_name);
child = strdup(dent->d_name);
if (!child)
return log_oom();
errno = 0;
de = readdir_no_dot(d);
if (de) {
dent = readdir_no_dot(d);
if (dent) {
if (errno != 0)
return log_error_errno(errno, "Failed to iterate through directory '%s': %m", path);

View File

@ -1,62 +1,53 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
systemd_importd_sources = files('''
importd.c
'''.split())
systemd_importd_sources = files(
'importd.c')
systemd_pull_sources = files('''
pull.c
pull-raw.c
pull-raw.h
pull-tar.c
pull-tar.h
pull-job.c
pull-job.h
pull-common.c
pull-common.h
import-common.c
import-common.h
import-compress.c
import-compress.h
curl-util.c
curl-util.h
qcow2-util.c
qcow2-util.h
'''.split())
systemd_pull_sources = files(
'pull.c',
'pull-raw.c',
'pull-raw.h',
'pull-tar.c',
'pull-tar.h',
'pull-job.c',
'pull-job.h',
'pull-common.c',
'pull-common.h',
'curl-util.c',
'curl-util.h')
systemd_import_sources = files('''
import.c
import-raw.c
import-raw.h
import-tar.c
import-tar.h
import-common.c
import-common.h
import-compress.c
import-compress.h
qcow2-util.c
qcow2-util.h
'''.split())
systemd_import_sources = files(
'import.c',
'import-raw.c',
'import-raw.h',
'import-tar.c',
'import-tar.h')
systemd_import_fs_sources = files('''
import-fs.c
import-common.c
import-common.h
'''.split())
systemd_import_fs_sources = files(
'import-fs.c')
systemd_export_sources = files('''
export.c
export-tar.c
export-tar.h
export-raw.c
export-raw.h
import-common.c
import-common.h
import-compress.c
import-compress.h
'''.split())
systemd_export_sources = files(
'export.c',
'export-tar.c',
'export-tar.h',
'export-raw.c',
'export-raw.h')
if conf.get('ENABLE_IMPORTD') == 1
lib_import_common = static_library(
'import-common',
'import-common.c',
'import-common.h',
'import-compress.c',
'import-compress.h',
'qcow2-util.c',
'qcow2-util.h',
include_directories : includes,
dependencies : [libbzip2,
libxz,
libz],
build_by_default : false)
install_data('org.freedesktop.import1.conf',
install_dir : dbuspolicydir)
install_data('org.freedesktop.import1.service',

View File

@ -59,7 +59,6 @@ int pull_find_old_etags(
}
_cleanup_strv_free_ char **ans = NULL;
struct dirent *de;
FOREACH_DIRENT_ALL(de, d, return -errno) {
_cleanup_free_ char *u = NULL;

View File

@ -31,7 +31,7 @@ libsystemd_journal_remote = static_library(
libgnutls,
libxz,
liblz4],
install : false)
build_by_default : false)
systemd_journal_remote_sources = files('''
journal-remote-main.c

View File

@ -90,7 +90,6 @@ static int determine_path_usage(
uint64_t *ret_free) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
struct statvfs ss;
assert(s);

View File

@ -848,7 +848,6 @@ static int stdout_stream_restore(Server *s, const char *fname, int fd) {
int server_restore_streams(Server *s, FDSet *fds) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
const char *path;
int r;

View File

@ -36,7 +36,7 @@ libjournal_core = static_library(
sources,
include_directories : includes,
dependencies: threads,
install : false)
build_by_default : false)
journal_includes = [includes, include_directories('.')]

View File

@ -49,7 +49,8 @@ sources = files('''
libsystemd_network = static_library(
'systemd-network',
sources,
include_directories : includes)
include_directories : includes,
build_by_default : false)
libsystemd_network_includes = [includes, include_directories('.')]

View File

@ -166,12 +166,12 @@ libsystemd_c_args = ['-fvisibility=default']
libsystemd_static = static_library(
'systemd_static',
libsystemd_sources,
install : false,
include_directories : libsystemd_includes,
c_args : libsystemd_c_args,
link_with : libbasic,
dependencies : [threads,
librt],
c_args : libsystemd_c_args)
build_by_default : false)
libsystemd_sym = files('libsystemd.sym')
libsystemd_sym_path = meson.current_source_dir() / 'libsystemd.sym'

View File

@ -350,7 +350,6 @@ static bool match_sysname(sd_device_enumerator *enumerator, const char *sysname)
static int enumerator_scan_dir_and_add_devices(sd_device_enumerator *enumerator, const char *basedir, const char *subdir1, const char *subdir2) {
_cleanup_closedir_ DIR *dir = NULL;
char *path;
struct dirent *dent;
int r = 0;
assert(enumerator);
@ -369,18 +368,18 @@ static int enumerator_scan_dir_and_add_devices(sd_device_enumerator *enumerator,
/* this is necessarily racey, so ignore missing directories */
return (errno == ENOENT && (subdir1 || subdir2)) ? 0 : -errno;
FOREACH_DIRENT_ALL(dent, dir, return -errno) {
FOREACH_DIRENT_ALL(de, dir, return -errno) {
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
char syspath[strlen(path) + 1 + strlen(dent->d_name) + 1];
char syspath[strlen(path) + 1 + strlen(de->d_name) + 1];
int initialized, k;
if (dent->d_name[0] == '.')
if (de->d_name[0] == '.')
continue;
if (!match_sysname(enumerator, dent->d_name))
if (!match_sysname(enumerator, de->d_name))
continue;
(void) sprintf(syspath, "%s%s", path, dent->d_name);
(void) sprintf(syspath, "%s%s", path, de->d_name);
k = sd_device_new_from_syspath(&device, syspath);
if (k < 0) {
@ -461,7 +460,6 @@ static bool match_subsystem(sd_device_enumerator *enumerator, const char *subsys
static int enumerator_scan_dir(sd_device_enumerator *enumerator, const char *basedir, const char *subdir, const char *subsystem) {
_cleanup_closedir_ DIR *dir = NULL;
char *path;
struct dirent *dent;
int r = 0;
path = strjoina("/sys/", basedir);
@ -472,16 +470,16 @@ static int enumerator_scan_dir(sd_device_enumerator *enumerator, const char *bas
log_debug("sd-device-enumerator: Scanning %s", path);
FOREACH_DIRENT_ALL(dent, dir, return -errno) {
FOREACH_DIRENT_ALL(de, dir, return -errno) {
int k;
if (dent->d_name[0] == '.')
if (de->d_name[0] == '.')
continue;
if (!match_subsystem(enumerator, subsystem ? : dent->d_name))
if (!match_subsystem(enumerator, subsystem ? : de->d_name))
continue;
k = enumerator_scan_dir_and_add_devices(enumerator, basedir, dent->d_name, subdir);
k = enumerator_scan_dir_and_add_devices(enumerator, basedir, de->d_name, subdir);
if (k < 0)
r = k;
}
@ -492,7 +490,6 @@ static int enumerator_scan_dir(sd_device_enumerator *enumerator, const char *bas
static int enumerator_scan_devices_tag(sd_device_enumerator *enumerator, const char *tag) {
_cleanup_closedir_ DIR *dir = NULL;
char *path;
struct dirent *dent;
int r = 0;
assert(enumerator);
@ -509,15 +506,15 @@ static int enumerator_scan_devices_tag(sd_device_enumerator *enumerator, const c
/* TODO: filter away subsystems? */
FOREACH_DIRENT_ALL(dent, dir, return -errno) {
FOREACH_DIRENT_ALL(de, dir, return -errno) {
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
const char *subsystem, *sysname;
int k;
if (dent->d_name[0] == '.')
if (de->d_name[0] == '.')
continue;
k = sd_device_new_from_device_id(&device, dent->d_name);
k = sd_device_new_from_device_id(&device, de->d_name);
if (k < 0) {
if (k != -ENODEV)
/* this is necessarily racy, so ignore missing devices */
@ -625,24 +622,23 @@ static int parent_add_child(sd_device_enumerator *enumerator, const char *path)
static int parent_crawl_children(sd_device_enumerator *enumerator, const char *path, unsigned maxdepth) {
_cleanup_closedir_ DIR *dir = NULL;
struct dirent *dent;
int r = 0;
dir = opendir(path);
if (!dir)
return log_debug_errno(errno, "sd-device-enumerator: Failed to open parent directory %s: %m", path);
FOREACH_DIRENT_ALL(dent, dir, return -errno) {
FOREACH_DIRENT_ALL(de, dir, return -errno) {
_cleanup_free_ char *child = NULL;
int k;
if (dent->d_name[0] == '.')
if (de->d_name[0] == '.')
continue;
if (dent->d_type != DT_DIR)
if (de->d_type != DT_DIR)
continue;
child = path_join(path, dent->d_name);
child = path_join(path, de->d_name);
if (!child)
return -ENOMEM;

View File

@ -1747,7 +1747,6 @@ _public_ const char *sd_device_get_property_next(sd_device *device, const char *
static int device_sysattrs_read_all_internal(sd_device *device, const char *subdir) {
_cleanup_free_ char *path_dir = NULL;
_cleanup_closedir_ DIR *dir = NULL;
struct dirent *dent;
const char *syspath;
int r;
@ -1779,33 +1778,33 @@ static int device_sysattrs_read_all_internal(sd_device *device, const char *subd
if (!dir)
return -errno;
FOREACH_DIRENT_ALL(dent, dir, return -errno) {
FOREACH_DIRENT_ALL(de, dir, return -errno) {
_cleanup_free_ char *path = NULL, *p = NULL;
struct stat statbuf;
if (dot_or_dot_dot(dent->d_name))
if (dot_or_dot_dot(de->d_name))
continue;
/* only handle symlinks, regular files, and directories */
if (!IN_SET(dent->d_type, DT_LNK, DT_REG, DT_DIR))
if (!IN_SET(de->d_type, DT_LNK, DT_REG, DT_DIR))
continue;
if (subdir) {
p = path_join(subdir, dent->d_name);
p = path_join(subdir, de->d_name);
if (!p)
return -ENOMEM;
}
if (dent->d_type == DT_DIR) {
if (de->d_type == DT_DIR) {
/* read subdirectory */
r = device_sysattrs_read_all_internal(device, p ?: dent->d_name);
r = device_sysattrs_read_all_internal(device, p ?: de->d_name);
if (r < 0)
return r;
continue;
}
path = path_join(syspath, p ?: dent->d_name);
path = path_join(syspath, p ?: de->d_name);
if (!path)
return -ENOMEM;
@ -1815,7 +1814,7 @@ static int device_sysattrs_read_all_internal(sd_device *device, const char *subd
if ((statbuf.st_mode & (S_IRUSR | S_IWUSR)) == 0)
continue;
r = set_put_strdup(&device->sysattrs, p ?: dent->d_name);
r = set_put_strdup(&device->sysattrs, p ?: de->d_name);
if (r < 0)
return r;
}

View File

@ -127,7 +127,6 @@ int journal_directory_vacuum(
_cleanup_closedir_ DIR *d = NULL;
struct vacuum_info *list = NULL;
usec_t retention_limit = 0;
struct dirent *de;
int r;
assert(directory);

View File

@ -1560,14 +1560,11 @@ static int directory_open(sd_journal *j, const char *path, DIR **ret) {
static int add_directory(sd_journal *j, const char *prefix, const char *dirname);
static void directory_enumerate(sd_journal *j, Directory *m, DIR *d) {
struct dirent *de;
assert(j);
assert(m);
assert(d);
FOREACH_DIRENT_ALL(de, d, goto fail) {
if (dirent_is_journal_file(de))
(void) add_file_by_name(j, m->path, de->d_name);
@ -1576,7 +1573,6 @@ static void directory_enumerate(sd_journal *j, Directory *m, DIR *d) {
}
return;
fail:
log_debug_errno(errno, "Failed to enumerate directory %s, ignoring: %m", m->path);
}

View File

@ -774,7 +774,6 @@ _public_ int sd_get_sessions(char ***sessions) {
_public_ int sd_get_uids(uid_t **users) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0;
unsigned n = 0;
_cleanup_free_ uid_t *l = NULL;

View File

@ -28,13 +28,8 @@ libudev_basic = static_library(
'udev-basic',
libudev_sources,
include_directories : includes,
c_args : ['-fvisibility=default'])
libudev_static = static_library(
'udev_static',
include_directories : includes,
link_with : udev_link_with,
link_whole : libudev_basic)
c_args : ['-fvisibility=default'],
build_by_default : false)
static_libudev = get_option('static-libudev')
static_libudev_pic = static_libudev == 'true' or static_libudev == 'pic'
@ -52,5 +47,5 @@ custom_target(
tests += [
[['src/libudev/test-libudev.c'],
[libshared,
libudev_static]],
libudev_basic]],
]

View File

@ -1370,9 +1370,7 @@ static int flush_devices(Manager *m) {
if (!d) {
if (errno != ENOENT)
log_warning_errno(errno, "Failed to open /etc/udev/rules.d: %m");
} else {
struct dirent *de;
} else
FOREACH_DIRENT_ALL(de, d, break) {
if (!dirent_is_file(de))
continue;
@ -1386,7 +1384,6 @@ static int flush_devices(Manager *m) {
if (unlinkat(dirfd(d), de->d_name, 0) < 0)
log_warning_errno(errno, "Failed to unlink %s: %m", de->d_name);
}
}
return trigger_device(m, NULL);
}

View File

@ -244,7 +244,6 @@ static int manager_enumerate_buttons(Manager *m) {
static int manager_enumerate_seats(Manager *m) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0;
assert(m);
@ -286,7 +285,6 @@ static int manager_enumerate_seats(Manager *m) {
static int manager_enumerate_linger_users(Manager *m) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0;
assert(m);
@ -315,7 +313,6 @@ static int manager_enumerate_linger_users(Manager *m) {
static int manager_enumerate_users(Manager *m) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r, k;
assert(m);
@ -474,7 +471,6 @@ static int manager_attach_fds(Manager *m) {
static int manager_enumerate_sessions(Manager *m) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0, k;
assert(m);
@ -516,7 +512,6 @@ static int manager_enumerate_sessions(Manager *m) {
static int manager_enumerate_inhibitors(Manager *m) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0;
assert(m);

View File

@ -50,7 +50,8 @@ liblogind_core = static_library(
'logind-core',
liblogind_core_sources,
include_directories : includes,
dependencies : [libacl])
dependencies : libacl,
build_by_default : false)
loginctl_sources = files('''
loginctl.c

View File

@ -136,7 +136,6 @@ static int manager_add_host_machine(Manager *m) {
static int manager_enumerate_machines(Manager *m) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r;
assert(m);

View File

@ -24,7 +24,8 @@ libmachine_core = static_library(
'machine-core',
libmachine_core_sources,
include_directories : includes,
dependencies : [threads])
dependencies : threads,
build_by_default : false)
if conf.get('ENABLE_MACHINED') == 1
install_data('org.freedesktop.machine1.conf',

View File

@ -777,7 +777,6 @@ static int find_mount_points(const char *what, char ***list) {
static int find_loop_device(const char *backing_file, char **loop_dev) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
_cleanup_free_ char *l = NULL;
assert(backing_file);

View File

@ -235,7 +235,8 @@ libnetworkd_core = static_library(
'networkd-core',
sources,
include_directories : network_includes,
link_with : [networkd_link_with])
link_with : networkd_link_with,
build_by_default : false)
if conf.get('ENABLE_NETWORKD') == 1
install_data('org.freedesktop.network1.conf',

View File

@ -728,6 +728,10 @@ bool link_address_is_dynamic(const Link *link, const Address *address) {
if (route->source != NETWORK_CONFIG_SOURCE_FOREIGN)
continue;
/* The route is not assigned yet, or already removed. Ignoring. */
if (!route_exists(route))
continue;
if (route->protocol != RTPROT_DHCP)
continue;
@ -840,6 +844,10 @@ int link_drop_foreign_addresses(Link *link) {
assert(link);
assert(link->network);
/* Keep all addresses when KeepConfiguration=yes. */
if (link->network->keep_configuration == KEEP_CONFIGURATION_YES)
return 0;
/* First, mark all addresses. */
SET_FOREACH(address, link->addresses) {
/* We consider IPv6LL addresses to be managed by the kernel, or dropped in link_drop_ipv6ll_addresses() */
@ -854,10 +862,9 @@ int link_drop_foreign_addresses(Link *link) {
if (!address_exists(address))
continue;
if (link_address_is_dynamic(link, address)) {
if (link->network && FLAGS_SET(link->network->keep_configuration, KEEP_CONFIGURATION_DHCP))
continue;
} else if (link->network && FLAGS_SET(link->network->keep_configuration, KEEP_CONFIGURATION_STATIC))
/* link_address_is_dynamic() is slightly heavy. Let's call the function only when KeepConfiguration= is set. */
if (IN_SET(link->network->keep_configuration, KEEP_CONFIGURATION_DHCP, KEEP_CONFIGURATION_STATIC) &&
link_address_is_dynamic(link, address) == (link->network->keep_configuration == KEEP_CONFIGURATION_DHCP))
continue;
address_mark(address);
@ -895,8 +902,11 @@ int link_drop_addresses(Link *link) {
if (!address_exists(address))
continue;
/* We consider IPv6LL addresses to be managed by the kernel, or dropped in link_drop_ipv6ll_addresses() */
if (address->family == AF_INET6 && in6_addr_is_link_local(&address->in_addr.in6))
/* Do not drop IPv6LL addresses assigned by the kernel here. They will be dropped in
* link_drop_ipv6ll_addresses() if IPv6LL addressing is disabled. */
if (address->source == NETWORK_CONFIG_SOURCE_FOREIGN &&
address->family == AF_INET6 &&
in6_addr_is_link_local(&address->in_addr.in6))
continue;
k = address_remove(address);

View File

@ -893,6 +893,7 @@ int link_drop_foreign_routes(Link *link) {
assert(link);
assert(link->manager);
assert(link->network);
SET_FOREACH(route, link->routes) {
/* do not touch routes managed by the kernel */
@ -907,11 +908,11 @@ int link_drop_foreign_routes(Link *link) {
if (!route_exists(route))
continue;
if (route->protocol == RTPROT_STATIC && link->network &&
if (route->protocol == RTPROT_STATIC &&
FLAGS_SET(link->network->keep_configuration, KEEP_CONFIGURATION_STATIC))
continue;
if (route->protocol == RTPROT_DHCP && link->network &&
if (route->protocol == RTPROT_DHCP &&
FLAGS_SET(link->network->keep_configuration, KEEP_CONFIGURATION_DHCP))
continue;

View File

@ -45,7 +45,8 @@ libnspawn_core = static_library(
include_directories : includes,
dependencies : [libacl,
libseccomp,
libselinux])
libselinux],
build_by_default : false)
systemd_nspawn_sources = files('nspawn.c')

View File

@ -313,8 +313,6 @@ static int recurse_fd(int fd, bool donate_fd, const struct stat *st, uid_t shift
goto read_only;
if (S_ISDIR(st->st_mode)) {
struct dirent *de;
if (!donate_fd) {
int copy;

View File

@ -244,7 +244,6 @@ static int extract_now(
STRV_FOREACH(i, paths.search_path) {
_cleanup_free_ char *resolved = NULL;
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
r = chase_symlinks_and_opendir(*i, where, 0, &resolved, &d);
if (r < 0) {
@ -1492,7 +1491,6 @@ int portable_detach(
_cleanup_set_free_ Set *unit_files = NULL, *markers = NULL;
_cleanup_closedir_ DIR *d = NULL;
const char *where, *item;
struct dirent *de;
int ret = 0;
int r;
@ -1662,7 +1660,6 @@ static int portable_get_state_internal(
_cleanup_set_free_ Set *unit_files = NULL;
_cleanup_closedir_ DIR *d = NULL;
const char *where;
struct dirent *de;
int r;
assert(name_or_path);

View File

@ -323,7 +323,6 @@ static void process_dmesg_files(PStoreList *list) {
static int list_files(PStoreList *list, const char *sourcepath) {
_cleanup_(closedirp) DIR *dirp = NULL;
struct dirent *de;
int r;
dirp = opendir(sourcepath);

View File

@ -120,7 +120,8 @@ basic_dns_sources += custom_target(
libsystemd_resolve_core = static_library(
'systemd-resolve-core',
basic_dns_sources,
include_directories : includes)
include_directories : includes,
build_by_default : false)
systemd_resolved_sources += custom_target(
'resolved_gperf.c',

View File

@ -1536,7 +1536,6 @@ void manager_reset_server_features(Manager *m) {
void manager_cleanup_saved_user(Manager *m) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
assert(m);

View File

@ -103,7 +103,6 @@ int block_get_originating(dev_t dt, dev_t *ret) {
_cleanup_free_ char *t = NULL;
char p[SYS_BLOCK_PATH_MAX("/slaves")];
_cleanup_free_ char *first_found = NULL;
struct dirent *de;
const char *q;
dev_t devt;
int r;

View File

@ -488,7 +488,6 @@ static int boot_entries_find_unified(
size_t *n_entries) {
_cleanup_(closedirp) DIR *d = NULL;
struct dirent *de;
int r;
assert(root);

View File

@ -52,7 +52,6 @@ static int chown_recursive_internal(
_cleanup_closedir_ DIR *d = NULL;
bool changed = false;
struct dirent *de;
int r;
assert(fd >= 0);

View File

@ -219,7 +219,6 @@ static int clean_sysvipc_msg(uid_t delete_uid, gid_t delete_gid, bool rm) {
}
static int clean_posix_shm_internal(const char *dirname, DIR *dir, uid_t uid, gid_t gid, bool rm) {
struct dirent *de;
int ret = 0, r;
assert(dir);
@ -315,7 +314,6 @@ static int clean_posix_shm(uid_t uid, gid_t gid, bool rm) {
static int clean_posix_mq(uid_t uid, gid_t gid, bool rm) {
_cleanup_closedir_ DIR *dir = NULL;
struct dirent *de;
int ret = 0;
dir = opendir("/dev/mqueue");

View File

@ -789,7 +789,6 @@ static int fd_copy_directory(
_cleanup_close_ int fdf = -1, fdt = -1;
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
bool exists, created;
int r;

View File

@ -166,7 +166,6 @@ int devnode_acl_all(const char *seat,
_cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
_cleanup_set_free_free_ Set *nodes = NULL;
_cleanup_closedir_ DIR *dir = NULL;
struct dirent *dent;
sd_device *d;
char *n;
int r;
@ -218,11 +217,11 @@ int devnode_acl_all(const char *seat,
* these devices are not known to the kernel at this moment */
dir = opendir("/run/udev/static_node-tags/uaccess");
if (dir) {
FOREACH_DIRENT(dent, dir, return -errno) {
FOREACH_DIRENT(de, dir, return -errno) {
_cleanup_free_ char *unescaped_devname = NULL;
ssize_t l;
l = cunescape(dent->d_name, UNESCAPE_RELAX, &unescaped_devname);
l = cunescape(de->d_name, UNESCAPE_RELAX, &unescaped_devname);
if (l < 0)
return l;

View File

@ -543,7 +543,6 @@ int image_discover(
NULSTR_FOREACH(path, image_search_path[class]) {
_cleanup_free_ char *resolved = NULL;
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
r = chase_symlinks_and_opendir(path, root, CHASE_PREFIX_ROOT, &resolved, &d);
if (r == -ENOENT)

View File

@ -485,7 +485,6 @@ static int cmp_uint16(const uint16_t *a, const uint16_t *b) {
int efi_get_boot_options(uint16_t **options) {
_cleanup_closedir_ DIR *dir = NULL;
_cleanup_free_ uint16_t *list = NULL;
struct dirent *de;
int count = 0;
assert(options);

View File

@ -112,7 +112,6 @@ int fdset_remove(FDSet *s, int fd) {
int fdset_new_fill(FDSet **_s) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0;
FDSet *s;

View File

@ -549,7 +549,6 @@ static int remove_marked_symlinks_fd(
size_t *n_changes) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0;
assert(remove_symlinks_to);
@ -729,7 +728,6 @@ static int find_symlinks_in_directory(
const char *config_path,
bool *same_name_link) {
struct dirent *de;
int r = 0;
FOREACH_DIRENT(de, dir, return -errno) {
@ -814,7 +812,6 @@ static int find_symlinks(
bool *same_name_link) {
_cleanup_closedir_ DIR *config_dir = NULL;
struct dirent *de;
int r = 0;
assert(i);
@ -3369,7 +3366,6 @@ int unit_file_preset_all(
STRV_FOREACH(i, paths.search_path) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
d = opendir(*i);
if (!d) {
@ -3434,7 +3430,6 @@ int unit_file_get_list(
STRV_FOREACH(dirname, paths.search_path) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
d = opendir(*dirname);
if (!d) {

View File

@ -188,7 +188,6 @@ static int wait_for_children(Set *pids, sigset_t *mask, usec_t timeout) {
static int killall(int sig, Set *pids, bool send_sighup) {
_cleanup_closedir_ DIR *dir = NULL;
struct dirent *d;
int n_killed = 0;
/* Send the specified signal to all remaining processes, if not excluded by ignore_proc().
@ -198,14 +197,14 @@ static int killall(int sig, Set *pids, bool send_sighup) {
if (!dir)
return log_warning_errno(errno, "opendir(/proc) failed: %m");
FOREACH_DIRENT_ALL(d, dir, break) {
FOREACH_DIRENT_ALL(de, dir, break) {
pid_t pid;
int r;
if (!IN_SET(d->d_type, DT_DIR, DT_UNKNOWN))
if (!IN_SET(de->d_type, DT_DIR, DT_UNKNOWN))
continue;
if (parse_pid(d->d_name, &pid) < 0)
if (parse_pid(de->d_name, &pid) < 0)
continue;
if (ignore_proc(pid, sig == SIGKILL && !in_initrd()))

View File

@ -459,7 +459,8 @@ libshared_static = static_library(
shared_sources,
include_directories : includes,
dependencies : libshared_deps,
c_args : ['-fvisibility=default'])
c_args : ['-fvisibility=default'],
build_by_default : false)
libshared = shared_library(
libshared_name,

View File

@ -128,7 +128,6 @@ int numa_to_cpu_set(const NUMAPolicy *policy, CPUSet *ret) {
static int numa_max_node(void) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r, max_node = 0;
d = opendir("/sys/devices/system/node");

View File

@ -203,7 +203,6 @@ int rm_rf_children(
const struct stat *root_dev) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int ret = 0, r;
assert(fd >= 0);

View File

@ -405,7 +405,6 @@ static int userdb_start_query(
_cleanup_(strv_freep) char **except = NULL, **only = NULL;
_cleanup_(closedirp) DIR *d = NULL;
struct dirent *de;
const char *e;
int r, ret = 0;

View File

@ -718,7 +718,6 @@ static int enumerate_sysv(const LookupPaths *lp, Hashmap *all_services) {
STRV_FOREACH(path, sysvinit_path) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
d = opendir(*path);
if (!d) {
@ -805,7 +804,6 @@ static int set_dependencies_from_rcnd(const LookupPaths *lp, Hashmap *all_servic
for (unsigned i = 0; i < ELEMENTSOF(rcnd_table); i ++) {
_cleanup_closedir_ DIR *d = NULL;
_cleanup_free_ char *path = NULL;
struct dirent *de;
path = path_join(*p, rcnd_table[i].path);
if (!path) {

View File

@ -167,7 +167,6 @@ TEST(get_paths, .sd_booted = true) {
TEST(proc) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r;
d = opendir("/proc");

View File

@ -135,7 +135,6 @@ static void test_get_process_cmdline_one(pid_t pid) {
TEST(get_process_cmdline) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
assert_se(d = opendir("/proc"));

View File

@ -32,7 +32,8 @@ libtimesyncd_core = static_library(
'timesyncd-core',
sources,
include_directories : includes,
link_with : [timesyncd_link_with])
link_with : timesyncd_link_with,
build_by_default : false)
custom_target(
'timesyncd.conf',

View File

@ -590,14 +590,13 @@ static int dir_cleanup(
AgeBy age_by_dir) {
bool deleted = false;
struct dirent *dent;
int r = 0;
FOREACH_DIRENT_ALL(dent, d, break) {
FOREACH_DIRENT_ALL(de, d, break) {
_cleanup_free_ char *sub_path = NULL;
nsec_t atime_nsec, mtime_nsec, ctime_nsec, btime_nsec;
if (dot_or_dot_dot(dent->d_name))
if (dot_or_dot_dot(de->d_name))
continue;
/* If statx() is supported, use it. It's preferable over fstatat() since it tells us
@ -614,7 +613,7 @@ static int dir_cleanup(
STRUCT_STATX_DEFINE(sx);
r = statx_fallback(
dirfd(d), dent->d_name,
dirfd(d), de->d_name,
AT_SYMLINK_NOFOLLOW|AT_NO_AUTOMOUNT,
STATX_TYPE|STATX_MODE|STATX_UID|STATX_ATIME|STATX_MTIME|STATX_CTIME|STATX_BTIME,
&sx);
@ -623,14 +622,14 @@ static int dir_cleanup(
if (r < 0) {
/* FUSE, NFS mounts, SELinux might return EACCES */
r = log_full_errno(errno == EACCES ? LOG_DEBUG : LOG_ERR, errno,
"statx(%s/%s) failed: %m", p, dent->d_name);
"statx(%s/%s) failed: %m", p, de->d_name);
continue;
}
if (FLAGS_SET(sx.stx_attributes_mask, STATX_ATTR_MOUNT_ROOT)) {
/* Yay, we have the mount point API, use it */
if (FLAGS_SET(sx.stx_attributes, STATX_ATTR_MOUNT_ROOT)) {
log_debug("Ignoring \"%s/%s\": different mount points.", p, dent->d_name);
log_debug("Ignoring \"%s/%s\": different mount points.", p, de->d_name);
continue;
}
} else {
@ -638,7 +637,7 @@ static int dir_cleanup(
* back to traditional stx_dev checking. */
if (sx.stx_dev_major != rootdev_major ||
sx.stx_dev_minor != rootdev_minor) {
log_debug("Ignoring \"%s/%s\": different filesystem.", p, dent->d_name);
log_debug("Ignoring \"%s/%s\": different filesystem.", p, de->d_name);
continue;
}
@ -648,11 +647,11 @@ static int dir_cleanup(
if (S_ISDIR(sx.stx_mode)) {
int q;
q = fd_is_mount_point(dirfd(d), dent->d_name, 0);
q = fd_is_mount_point(dirfd(d), de->d_name, 0);
if (q < 0)
log_debug_errno(q, "Failed to determine whether \"%s/%s\" is a mount point, ignoring: %m", p, dent->d_name);
log_debug_errno(q, "Failed to determine whether \"%s/%s\" is a mount point, ignoring: %m", p, de->d_name);
else if (q > 0) {
log_debug("Ignoring \"%s/%s\": different mount of the same filesystem.", p, dent->d_name);
log_debug("Ignoring \"%s/%s\": different mount of the same filesystem.", p, de->d_name);
continue;
}
}
@ -663,7 +662,7 @@ static int dir_cleanup(
ctime_nsec = FLAGS_SET(sx.stx_mask, STATX_CTIME) ? load_statx_timestamp_nsec(&sx.stx_ctime) : 0;
btime_nsec = FLAGS_SET(sx.stx_mask, STATX_BTIME) ? load_statx_timestamp_nsec(&sx.stx_btime) : 0;
sub_path = path_join(p, dent->d_name);
sub_path = path_join(p, de->d_name);
if (!sub_path) {
r = log_oom();
goto finish;
@ -684,7 +683,7 @@ static int dir_cleanup(
_cleanup_closedir_ DIR *sub_dir = NULL;
if (mountpoint &&
streq(dent->d_name, "lost+found") &&
streq(de->d_name, "lost+found") &&
sx.stx_uid == 0) {
log_debug("Ignoring directory \"%s\".", sub_path);
continue;
@ -695,7 +694,7 @@ static int dir_cleanup(
else {
int q;
sub_dir = xopendirat_nomod(dirfd(d), dent->d_name);
sub_dir = xopendirat_nomod(dirfd(d), de->d_name);
if (!sub_dir) {
if (errno != ENOENT)
r = log_warning_errno(errno, "Opening directory \"%s\" failed, ignoring: %m", sub_path);
@ -737,7 +736,7 @@ static int dir_cleanup(
continue;
log_debug("Removing directory \"%s\".", sub_path);
if (unlinkat(dirfd(d), dent->d_name, AT_REMOVEDIR) < 0)
if (unlinkat(dirfd(d), de->d_name, AT_REMOVEDIR) < 0)
if (!IN_SET(errno, ENOENT, ENOTEMPTY))
r = log_warning_errno(errno, "Failed to remove directory \"%s\", ignoring: %m", sub_path);
@ -752,7 +751,7 @@ static int dir_cleanup(
if (mountpoint &&
S_ISREG(sx.stx_mode) &&
sx.stx_uid == 0 &&
STR_IN_SET(dent->d_name,
STR_IN_SET(de->d_name,
".journal",
"aquota.user",
"aquota.group")) {
@ -783,7 +782,7 @@ static int dir_cleanup(
continue;
log_debug("Removing \"%s\".", sub_path);
if (unlinkat(dirfd(d), dent->d_name, 0) < 0)
if (unlinkat(dirfd(d), de->d_name, 0) < 0)
if (errno != ENOENT)
r = log_warning_errno(errno, "Failed to remove \"%s\", ignoring: %m", sub_path);
@ -1920,7 +1919,6 @@ static int item_do(Item *i, int fd, const char *path, fdaction_t action) {
if (S_ISDIR(st.st_mode)) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
/* The passed 'fd' was opened with O_PATH. We need to convert it into a 'regular' fd before
* reading the directory content. */

View File

@ -295,7 +295,6 @@ static int wall_tty_block(void) {
static int process_password_files(void) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0;
d = opendir("/run/systemd/ask-password");

View File

@ -115,7 +115,9 @@ libudevd_core = static_library(
keyboard_keys_from_name_h,
include_directories : udev_includes,
link_with : udev_link_with,
dependencies : [libblkid, libkmod])
dependencies : [libblkid,
libkmod],
build_by_default : false)
udev_progs = [['ata_id/ata_id.c'],
['cdrom_id/cdrom_id.c'],

View File

@ -97,7 +97,6 @@ static int get_virtfn_info(sd_device *pcidev, sd_device **ret_physfn_pcidev, cha
_cleanup_(sd_device_unrefp) sd_device *physfn_pcidev = NULL;
const char *physfn_syspath, *syspath;
_cleanup_closedir_ DIR *dir = NULL;
struct dirent *dent;
int r;
assert(pcidev);
@ -123,15 +122,15 @@ static int get_virtfn_info(sd_device *pcidev, sd_device **ret_physfn_pcidev, cha
if (!dir)
return -errno;
FOREACH_DIRENT_ALL(dent, dir, break) {
FOREACH_DIRENT_ALL(de, dir, break) {
_cleanup_free_ char *virtfn_link_file = NULL, *virtfn_pci_syspath = NULL;
const char *n;
n = startswith(dent->d_name, "virtfn");
n = startswith(de->d_name, "virtfn");
if (!n)
continue;
virtfn_link_file = path_join(physfn_syspath, dent->d_name);
virtfn_link_file = path_join(physfn_syspath, de->d_name);
if (!virtfn_link_file)
return -ENOMEM;
@ -390,8 +389,6 @@ static int dev_pci_slot(sd_device *dev, const LinkInfo *info, NetNames *names) {
hotplug_slot_dev = names->pcidev;
while (hotplug_slot_dev) {
struct dirent *dent;
r = parse_hotplug_slot_from_function_id(hotplug_slot_dev, slots, &hotplug_slot);
if (r < 0)
return 0;
@ -404,20 +401,20 @@ static int dev_pci_slot(sd_device *dev, const LinkInfo *info, NetNames *names) {
if (r < 0)
return log_device_debug_errno(hotplug_slot_dev, r, "Failed to get sysname: %m");
FOREACH_DIRENT_ALL(dent, dir, break) {
FOREACH_DIRENT_ALL(de, dir, break) {
_cleanup_free_ char *address = NULL;
char str[PATH_MAX];
uint32_t i;
if (dot_or_dot_dot(dent->d_name))
if (dot_or_dot_dot(de->d_name))
continue;
r = safe_atou32(dent->d_name, &i);
r = safe_atou32(de->d_name, &i);
if (r < 0 || i <= 0)
continue;
/* match slot address with device by stripping the function */
if (snprintf_ok(str, sizeof str, "%s/%s/address", slots, dent->d_name) &&
if (snprintf_ok(str, sizeof str, "%s/%s/address", slots, de->d_name) &&
read_one_line_file(str, &address) >= 0 &&
startswith(sysname, address)) {
hotplug_slot = i;

View File

@ -309,7 +309,6 @@ static sd_device *handle_scsi_default(sd_device *parent, char **path) {
int host, bus, target, lun;
const char *name, *base, *pos;
_cleanup_closedir_ DIR *dir = NULL;
struct dirent *dent;
int basenum = -1;
assert(parent);
@ -352,16 +351,16 @@ static sd_device *handle_scsi_default(sd_device *parent, char **path) {
if (!dir)
return NULL;
FOREACH_DIRENT_ALL(dent, dir, break) {
FOREACH_DIRENT_ALL(de, dir, break) {
unsigned i;
if (dent->d_name[0] == '.')
if (de->d_name[0] == '.')
continue;
if (!IN_SET(dent->d_type, DT_DIR, DT_LNK))
if (!IN_SET(de->d_type, DT_DIR, DT_LNK))
continue;
if (!startswith(dent->d_name, "host"))
if (!startswith(de->d_name, "host"))
continue;
if (safe_atou_full(&dent->d_name[4], 10, &i) < 0)
if (safe_atou_full(&de->d_name[4], 10, &i) < 0)
continue;
/*
* find the smallest number; the host really needs to export its

View File

@ -111,7 +111,6 @@ static int node_symlink(sd_device *dev, const char *node, const char *slink) {
static int link_find_prioritized(sd_device *dev, bool add, const char *stackdir, char **ret) {
_cleanup_closedir_ DIR *dir = NULL;
_cleanup_free_ char *target = NULL;
struct dirent *dent;
int r, priority = 0;
const char *id;
@ -153,18 +152,18 @@ static int link_find_prioritized(sd_device *dev, bool add, const char *stackdir,
if (r < 0)
return r;
FOREACH_DIRENT_ALL(dent, dir, break) {
FOREACH_DIRENT_ALL(de, dir, break) {
_cleanup_free_ char *path = NULL, *buf = NULL;
int tmp_prio;
if (dent->d_name[0] == '.')
if (de->d_name[0] == '.')
continue;
/* skip ourself */
if (streq(dent->d_name, id))
if (streq(de->d_name, id))
continue;
path = path_join(stackdir, dent->d_name);
path = path_join(stackdir, de->d_name);
if (!path)
return -ENOMEM;
@ -197,7 +196,7 @@ static int link_find_prioritized(sd_device *dev, bool add, const char *stackdir,
/* Old format. The devnode and priority must be obtained from uevent and
* udev database files. */
if (sd_device_new_from_device_id(&tmp_dev, dent->d_name) < 0)
if (sd_device_new_from_device_id(&tmp_dev, de->d_name) < 0)
continue;
if (device_get_devlink_priority(tmp_dev, &tmp_prio) < 0)

View File

@ -1494,7 +1494,6 @@ static int import_parent_into_properties(sd_device *dev, const char *filter) {
static int attr_subst_subdir(char attr[static UDEV_PATH_SIZE]) {
_cleanup_closedir_ DIR *dir = NULL;
struct dirent *dent;
char buf[UDEV_PATH_SIZE], *p;
const char *tail;
size_t len, size;
@ -1516,11 +1515,11 @@ static int attr_subst_subdir(char attr[static UDEV_PATH_SIZE]) {
if (!dir)
return -errno;
FOREACH_DIRENT_ALL(dent, dir, break) {
if (dent->d_name[0] == '.')
FOREACH_DIRENT_ALL(de, dir, break) {
if (de->d_name[0] == '.')
continue;
strscpyl(p, size, dent->d_name, tail, NULL);
strscpyl(p, size, de->d_name, tail, NULL);
if (faccessat(dirfd(dir), p, F_OK, 0) < 0)
continue;

View File

@ -20,7 +20,6 @@
#define MIN_RANDOM_DELAY ( 10 * USEC_PER_MSEC)
int udev_watch_restore(int inotify_fd) {
struct dirent *ent;
DIR *dir;
int r;

View File

@ -229,8 +229,6 @@ static int export_devices(void) {
}
static void cleanup_dir(DIR *dir, mode_t mask, int depth) {
struct dirent *dent;
if (depth <= 0)
return;

View File

@ -518,7 +518,6 @@ static int display_memberships(int argc, char *argv[], void *userdata) {
static int display_services(int argc, char *argv[], void *userdata) {
_cleanup_(table_unrefp) Table *t = NULL;
_cleanup_(closedirp) DIR *d = NULL;
struct dirent *de;
int r;
d = opendir("/run/systemd/userdb/");

View File

@ -43,7 +43,6 @@ static int enumerate_xdg_autostart(Hashmap *all_services) {
STRV_FOREACH(path, autostart_dirs) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
d = opendir(*path);
if (!d) {

View File

@ -4588,12 +4588,11 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
print(output)
self.assertRegex(output, r'192.168.5.*')
output = check_output(*networkctl_cmd, '-n', '0', 'status', 'veth99', env=env)
print(output)
self.assertRegex(output, r'192.168.5.*')
with open(os.path.join(network_unit_file_path, 'dhcp-client-keep-configuration-dhcp.network'), mode='a') as f:
f.write('[Network]\nDHCP=no\n')
start_networkd(3)
self.wait_online(['veth-peer:routable'])
start_networkd()
self.wait_online(['veth99:routable', 'veth-peer:routable'])
print('Still the lease address should be kept after networkd restarted')
output = check_output('ip address show dev veth99 scope global')

View File

@ -5,7 +5,7 @@ set -o pipefail
# Check if homectl is installed, and if it isn't bail out early instead of failing
if ! test -x /usr/bin/homectl ; then
echo OK >/testok
echo "no homed" >/skipped
exit 0
fi

View File

@ -128,6 +128,13 @@ signature_size="$((signature_size * 2))KiB"
HAVE_OPENSSL=0
if systemctl --version | grep -q -- +OPENSSL ; then
# The openssl binary is installed conditionally.
# If we have OpenSSL support enabled and openssl is missing, fail early
# with a proper error message.
if ! command -v openssl >/dev/null 2>&1; then
echo "openssl missing" >/failed
exit 1
fi
HAVE_OPENSSL=1
# Unfortunately OpenSSL insists on reading some config file, hence provide one with mostly placeholder contents
cat >> "${image}.openssl.cnf" <<EOF

View File

@ -56,6 +56,10 @@ WantedBy=multi-user.target
Also=systemd-networkd.socket
Alias=dbus-org.freedesktop.network1.service
# The output from this generator is used by udevd and networkd. Enable it by
# default when enabling systemd-networkd.service.
Also=systemd-network-generator.service
# We want to enable systemd-networkd-wait-online.service whenever this service
# is enabled. systemd-networkd-wait-online.service has
# WantedBy=network-online.target, so enabling it only has an effect if