1
0
mirror of https://github.com/systemd/systemd synced 2026-03-29 19:24:50 +02:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Yu Watanabe
f53ac7742f
clang-tidy: Enable misc-include-cleaner check (#39835)
The previous commit fixes all remaining violations of the check for
a very specific setup (Fedora Rawhide with as many dependencies as
possible installed). The linter job in CI runs that specific setup
so we enable the check in the clang-tidy config but do not yet enable
the clang-tidy test suite in meson by default as it will very likely
still fail in different setups than the one in CI.
2025-11-22 20:54:28 +09:00
Daan De Meyer
6d57f584de clang-tidy: Enable misc-include-cleaner check
The previous commit fixes all remaining violations of the check for
a very specific setup (Fedora Rawhide with as many dependencies as
possible installed). The linter job in CI runs that specific setup
so we enable the check in the clang-tidy config but do not yet enable
the clang-tidy test suite in meson by default as it will very likely
still fail in different setups than the one in CI.
2025-11-22 10:19:41 +01:00
Daan De Meyer
87fbd33372 clang-tidy: Fix all remaining misc-include-cleaner violations
- Remove unused includes
- Add common false positive headers to misc-include-cleaner.IgnoreHeaders
- Add IWYU pragma keep for uncommon false positive headers
2025-11-22 10:19:41 +01:00
Daan De Meyer
d11ce97386 test-journald-config: Modernize test 2025-11-22 10:19:07 +01:00
124 changed files with 209 additions and 231 deletions

View File

@ -4,7 +4,29 @@ Checks: '
-*,
misc-header-include-cycle,
readability-duplicate-include,
bugprone-argument-comment
bugprone-argument-comment,
misc-include-cleaner
'
CheckOptions:
misc-include-cleaner.MissingIncludes: 'false'
# These all lead to common false positives by clang-tidy where it tries to
# remove these includes even though they're required in some situations (many
# of them related to musl).
misc-include-cleaner.IgnoreHeaders: '
endian\.h;
getopt\.h;
sys/stat\.h;
sys/statvfs\.h;
sys/syscall\.h;
sys/timex\.h;
sys/uio\.h;
netinet/in\.h;
net/if\.h;
net/if_arp\.h;
runtime-scope\.h;
varlink-io\.systemd\..*;
varlink-idl-common\.h;
unistd\.h
'
WarningsAsErrors: '*'
HeaderFileExtensions:

View File

@ -7,7 +7,6 @@
#include "constants.h"
#include "format-table.h"
#include "hexdecoct.h"
#include "string-util.h"
#include "strv.h"
#include "tpm2-util.h"

View File

@ -4,7 +4,7 @@
#include <stdlib.h>
#include "basic-forward.h"
#include "memory-util.h"
#include "memory-util.h" /* IWYU pragma: keep */
#if HAS_FEATURE_MEMORY_SANITIZER
# include <sanitizer/msan_interface.h>

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <endian.h> /* IWYU pragma: keep */
#include <endian.h>
#include "basic-forward.h"

View File

@ -9,9 +9,9 @@
#include "confidential-virt.h"
#include "confidential-virt-fundamental.h"
#include "errno-util.h"
#include "errno-util.h" /* IWYU pragma: keep */
#include "fd-util.h"
#include "fileio.h"
#include "fileio.h" /* IWYU pragma: keep */
#include "log.h"
#include "string-table.h"
#include "string-util.h"

View File

@ -1,10 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <dirent.h> /* IWYU pragma: export */
#include <dirent.h> /* IWYU pragma: export */
#include "basic-forward.h"
#include "path-util.h"
#include "path-util.h" /* IWYU pragma: keep */
bool dirent_is_file(const struct dirent *de) _pure_;
bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) _pure_;

View File

@ -1,9 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "cgroup-util.h"
#include "basic-forward.h"
#include "stdio-util.h"
#include "cgroup-util.h"
#include "stdio-util.h" /* IWYU pragma: keep */
assert_cc(sizeof(pid_t) == sizeof(int32_t));
#define PID_PRI PRIi32

View File

@ -4,9 +4,9 @@
Copyright © 2016 Michael Karcher
***/
#include <errno.h>
#include <errno.h> /* IWYU pragma: keep */
#include <sched.h>
#include <sys/syscall.h>
#include <sys/syscall.h> /* IWYU pragma: keep */
#include <unistd.h>
#include "process-util.h"

View File

@ -1,7 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdio.h>
#include "basic-forward.h"
const char* string_table_lookup_to_string(const char * const *table, size_t len, ssize_t i) _const_;

View File

@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/timerfd.h>
#include <threads.h>
#include <unistd.h>
@ -10,15 +9,14 @@
#include "env-util.h"
#include "errno-util.h"
#include "extract-word.h"
#include "hexdecoct.h" /* IWYU pragma: keep */
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "hexdecoct.h"
#include "io-util.h"
#include "log.h"
#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"
#include "stat-util.h"
#include "stdio-util.h"
#include "string-table.h"

View File

@ -1,7 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdio.h>
#include "alloc-util.h"
#include "bus-label.h"
#include "glyph-util.h"

View File

@ -8,7 +8,7 @@
#include <unistd.h>
#include "alloc-util.h"
#include "dirent-util.h"
#include "dirent-util.h" /* IWYU pragma: keep */
#include "env-util.h"
#include "extract-word.h"
#include "fd-util.h"

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <getopt.h>
#include <sys/socket.h>
#include <sys/socket.h> /* IWYU pragma: keep */
#include "sd-messages.h"

View File

@ -3,7 +3,7 @@
#include "efi.h"
#include "efi-string.h"
#include "proto/simple-text-io.h"
#include "proto/simple-text-io.h" /* IWYU pragma: keep */
#if defined __has_attribute
# if __has_attribute(no_stack_protector)

View File

@ -1,9 +1,11 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "apparmor-setup.h"
#if HAVE_APPARMOR
#include <unistd.h>
#include "alloc-util.h"
#include "apparmor-setup.h"
#include "apparmor-util.h"
#include "errno-util.h"
#include "fd-util.h"
@ -11,6 +13,7 @@
#include "log.h"
#include "string-util.h"
#include "strv.h"
#endif
int mac_apparmor_setup(void) {
#if HAVE_APPARMOR

View File

@ -2,7 +2,7 @@
#include <fcntl.h>
#include <linux/auto_dev-ioctl.h>
#include <sys/mount.h>
#include <sys/mount.h> /* IWYU pragma: keep */
#include <sys/stat.h>
#include <unistd.h>

View File

@ -7,11 +7,11 @@
* fine given that LGPL-2.1-or-later downgrades to GPL if needed.
*/
#include "bpf-dlopen.h"
#include "bpf-dlopen.h" /* IWYU pragma: keep */
/* libbpf is used via dlopen(), so rename symbols */
#define bpf_object__open_skeleton sym_bpf_object__open_skeleton
#define bpf_object__load_skeleton sym_bpf_object__load_skeleton
#define bpf_object__destroy_skeleton sym_bpf_object__destroy_skeleton
#include "bpf/restrict-fs/restrict-fs.skel.h"
#include "bpf/restrict-fs/restrict-fs.skel.h" /* IWYU pragma: export */

View File

@ -7,11 +7,11 @@
* fine given that LGPL-2.1-or-later downgrades to GPL if needed.
*/
#include "bpf-dlopen.h"
#include "bpf-dlopen.h" /* IWYU pragma: keep */
/* libbpf is used via dlopen(), so rename symbols */
#define bpf_object__open_skeleton sym_bpf_object__open_skeleton
#define bpf_object__load_skeleton sym_bpf_object__load_skeleton
#define bpf_object__destroy_skeleton sym_bpf_object__destroy_skeleton
#include "bpf/restrict-ifaces/restrict-ifaces.skel.h"
#include "bpf/restrict-ifaces/restrict-ifaces.skel.h" /* IWYU pragma: export */

View File

@ -7,11 +7,11 @@
* fine given that LGPL-2.1-or-later downgrades to GPL if needed.
*/
#include "bpf-dlopen.h"
#include "bpf-dlopen.h" /* IWYU pragma: keep */
/* libbpf is used via dlopen(), so rename symbols */
#define bpf_object__open_skeleton sym_bpf_object__open_skeleton
#define bpf_object__load_skeleton sym_bpf_object__load_skeleton
#define bpf_object__destroy_skeleton sym_bpf_object__destroy_skeleton
#include "bpf/socket-bind/socket-bind.skel.h"
#include "bpf/socket-bind/socket-bind.skel.h" /* IWYU pragma: export */

View File

@ -51,10 +51,8 @@
#include "virt.h"
#if BPF_FRAMEWORK
#include "bpf-dlopen.h"
#include "bpf-link.h"
#include "bpf-restrict-fs.h"
#include "bpf/restrict-fs/restrict-fs-skel.h"
#endif
#define CGROUP_CPU_QUOTA_DEFAULT_PERIOD_USEC (100 * USEC_PER_MSEC)

View File

@ -32,7 +32,7 @@
#include "special.h"
#include "string-util.h"
#include "strv.h"
#include "transaction.h"
#include "transaction.h" /* IWYU pragma: keep */
#include "unit-name.h"
#include "web-util.h"

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-bus.h"
#include "sd-bus.h" /* IWYU pragma: keep */
#include "core-forward.h"
#include "string-util.h"

View File

@ -22,12 +22,12 @@
#include "ordered-set.h"
#include "path-lookup.h"
#include "path-util.h"
#include "process-util.h"
#include "random-util.h"
#include "recurse-dir.h"
#include "rm-rf.h"
#include "siphash24.h"
#include "stat-util.h"
#include "string-util.h"
#include "strv.h"
#include "user-util.h"

View File

@ -1,9 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <grp.h>
#include <linux/sched.h>
#include <linux/securebits.h>
#include <poll.h>
#include <sched.h>
#include <sys/eventfd.h>
#include <sys/ioctl.h>
#include <sys/ioprio.h>
@ -15,7 +15,7 @@
#include "sd-messages.h"
#include "apparmor-util.h"
#include "apparmor-util.h" /* IWYU pragma: keep */
#include "argv-util.h"
#include "ask-password-api.h"
#include "barrier.h"

View File

@ -6,7 +6,6 @@
#include "sd-id128.h"
#include "bus-unit-util.h"
#include "cgroup-util.h"
#include "core-forward.h"
#include "cpu-set-util.h"
#include "exec-util.h"

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/audit.h>
#include <linux/audit.h> /* IWYU pragma: keep */
#include <math.h>
#include <sys/stat.h>
#include <unistd.h>

View File

@ -1,6 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <arpa/inet.h>
#include <fcntl.h>
#include <linux/sctp.h>
#include <mqueue.h>

View File

@ -11,7 +11,6 @@
#include "all-units.h"
#include "alloc-util.h"
#include "ansi-color.h"
#include "bpf-firewall.h"
#include "bpf-restrict-fs.h"
#include "bus-common-errors.h"
#include "bus-internal.h"

View File

@ -12,7 +12,6 @@
#include "json-util.h"
#include "manager.h"
#include "pidref.h"
#include "process-util.h"
#include "selinux-access.h"
#include "set.h"
#include "strv.h"

View File

@ -17,7 +17,6 @@
#include "strv.h"
#include "unit.h"
#include "varlink-cgroup.h"
#include "varlink-common.h"
#include "varlink-execute.h"
#include "varlink-unit.h"
#include "varlink-util.h"

View File

@ -10,8 +10,6 @@
#include "format-util.h"
#include "journal-importer.h"
#include "log.h"
#include "string-util.h"
#include "user-util.h"
int coredump_backtrace(int argc, char *argv[]) {
_cleanup_(journal_importer_cleanup) JournalImporter importer = JOURNAL_IMPORTER_INIT(STDIN_FILENO);

View File

@ -3,7 +3,6 @@
#include "sd-login.h"
#include "sd-messages.h"
#include "coredump-config.h"
#include "coredump-context.h"
#include "coredump-util.h"
#include "dirent-util.h"

View File

@ -10,7 +10,6 @@
#include "coredump-util.h"
#include "fd-util.h"
#include "format-util.h"
#include "iovec-wrapper.h"
#include "log.h"
#include "signal-util.h"

View File

@ -8,7 +8,6 @@
#include "coredump-submit.h"
#include "iovec-util.h"
#include "iovec-wrapper.h"
#include "fd-util.h"
#include "log.h"
#include "socket-util.h"

View File

@ -28,7 +28,6 @@
#include "extract-word.h"
#include "fileio.h"
#include "fs-util.h"
#include "fstab-util.h"
#include "hexdecoct.h"
#include "json-util.h"
#include "libfido2-util.h"
@ -36,7 +35,6 @@
#include "log.h"
#include "main-func.h"
#include "memory-util.h"
#include "mount-util.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "path-util.h"

View File

@ -29,7 +29,6 @@
#include "hostname-util.h"
#include "image-policy.h"
#include "kbd-util.h"
#include "label.h"
#include "label-util.h"
#include "libcrypt-util.h"
#include "locale-setup.h"

View File

@ -5,7 +5,7 @@
#include <sys/uio.h>
#endif
#include "assert-fundamental.h"
#include "assert-fundamental.h" /* IWYU pragma: keep */
#include "macro-fundamental.h"
#if SD_BOOT

View File

@ -77,7 +77,7 @@ modified for use with systemd
*/
#if SD_BOOT
# include "efi-string.h"
# include "efi-string.h" /* IWYU pragma: keep */
#else
# include <string.h>
#endif

View File

@ -22,7 +22,7 @@
<https://www.gnu.org/licenses/>. */
#if SD_BOOT
# include "efi-string.h"
# include "efi-string.h" /* IWYU pragma: keep */
#else
# include <string.h>
#endif

View File

@ -8,7 +8,7 @@
# include <string.h>
#endif
#include "assert-fundamental.h"
#include "assert-fundamental.h" /* IWYU pragma: keep */
#include "macro-fundamental.h"
/* What is interpreted as whitespace? */

View File

@ -1,7 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <dirent.h>
#include "sd-daemon.h"
#include "sd-event.h"

View File

@ -0,0 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* The kernel header depends on <arpa/inet.h> being included. */
#include <arpa/inet.h>
#include_next <linux/sctp.h> /* IWYU pragma: export */

View File

@ -4,7 +4,8 @@
/* sched.h includes linux/sched/types.h since glibc-2.41 (21571ca0d70302909cf72707b2a7736cf12190a0),
* to make struct sched_attr being defined.
* Note, this must be included before sched.h, otherwise the headers conflict with each other. */
#include <linux/sched/types.h>
#include <linux/sched.h> /* IWYU pragma: export */
#include <linux/sched/types.h> /* IWYU pragma: export */
#include_next <sched.h> /* IWYU pragma: export */

View File

@ -5,90 +5,76 @@
#include <sys/un.h>
#include "alloc-util.h"
#include "journald-manager.h"
#include "journald-config.h"
#include "log.h"
#include "socket-util.h"
#include "sparse-endian.h"
#include "tests.h"
#define _COMPRESS_PARSE_CHECK(str, enab, thresh, varname) \
do { \
JournalCompressOptions varname = {-222, 111}; \
config_parse_compress("", "", 0, "", 0, "", 0, str, \
&varname, NULL); \
assert_se((enab) == varname.enabled); \
if (varname.enabled) \
assert_se((thresh) == varname.threshold_bytes); \
} while (0)
static void compress_parse_check(const char *str, int expected_enabled, uint64_t expected_threshold) {
JournalCompressOptions conf = { .enabled = -222, .threshold_bytes = 111 };
#define COMPRESS_PARSE_CHECK(str, enabled, threshold) \
_COMPRESS_PARSE_CHECK(str, enabled, threshold, conf##__COUNTER__)
ASSERT_OK(config_parse_compress("", "", 0, "", 0, "", 0, str, &conf, NULL));
ASSERT_EQ(expected_enabled, conf.enabled);
if (conf.enabled)
ASSERT_EQ(expected_threshold, conf.threshold_bytes);
}
TEST(config_compress) {
COMPRESS_PARSE_CHECK("yes", true, UINT64_MAX);
COMPRESS_PARSE_CHECK("no", false, UINT64_MAX);
COMPRESS_PARSE_CHECK("y", true, UINT64_MAX);
COMPRESS_PARSE_CHECK("n", false, UINT64_MAX);
COMPRESS_PARSE_CHECK("true", true, UINT64_MAX);
COMPRESS_PARSE_CHECK("false", false, UINT64_MAX);
COMPRESS_PARSE_CHECK("t", true, UINT64_MAX);
COMPRESS_PARSE_CHECK("f", false, UINT64_MAX);
COMPRESS_PARSE_CHECK("on", true, UINT64_MAX);
COMPRESS_PARSE_CHECK("off", false, UINT64_MAX);
compress_parse_check("yes", true, UINT64_MAX);
compress_parse_check("no", false, UINT64_MAX);
compress_parse_check("y", true, UINT64_MAX);
compress_parse_check("n", false, UINT64_MAX);
compress_parse_check("true", true, UINT64_MAX);
compress_parse_check("false", false, UINT64_MAX);
compress_parse_check("t", true, UINT64_MAX);
compress_parse_check("f", false, UINT64_MAX);
compress_parse_check("on", true, UINT64_MAX);
compress_parse_check("off", false, UINT64_MAX);
/* Weird size/bool overlapping case. We preserve backward compatibility instead of assuming these are byte
* counts. */
COMPRESS_PARSE_CHECK("1", true, UINT64_MAX);
COMPRESS_PARSE_CHECK("0", false, UINT64_MAX);
compress_parse_check("1", true, UINT64_MAX);
compress_parse_check("0", false, UINT64_MAX);
/* IEC sizing */
COMPRESS_PARSE_CHECK("1B", true, 1);
COMPRESS_PARSE_CHECK("1K", true, 1024);
COMPRESS_PARSE_CHECK("1M", true, 1024 * 1024);
COMPRESS_PARSE_CHECK("1G", true, 1024 * 1024 * 1024);
compress_parse_check("1B", true, 1);
compress_parse_check("1K", true, 1024);
compress_parse_check("1M", true, 1024 * 1024);
compress_parse_check("1G", true, 1024 * 1024 * 1024);
/* Invalid Case */
COMPRESS_PARSE_CHECK("-1", -222, 111);
COMPRESS_PARSE_CHECK("blah blah", -222, 111);
COMPRESS_PARSE_CHECK("", -1, UINT64_MAX);
compress_parse_check("-1", -222, 111);
compress_parse_check("blah blah", -222, 111);
compress_parse_check("", -1, UINT64_MAX);
}
#define _FORWARD_TO_SOCKET_PARSE_CHECK_FAILS(str, addr, varname) \
do { \
SocketAddress varname = {}; \
config_parse_forward_to_socket("", "", 0, "", 0, "", 0, str, \
&varname, NULL); \
assert_se(socket_address_verify(&varname, true) < 0); \
} while (0)
static void forward_to_socket_parse_check_fails(const char *str) {
SocketAddress conf = {};
#define FORWARD_TO_SOCKET_PARSE_CHECK_FAILS(str) \
_FORWARD_TO_SOCKET_PARSE_CHECK_FAILS(str, addr, conf##__COUNTER__)
ASSERT_OK(config_parse_forward_to_socket("", "", 0, "", 0, "", 0, str, &conf, NULL));
ASSERT_FAIL(socket_address_verify(&conf, true));
}
#define _FORWARD_TO_SOCKET_PARSE_CHECK(str, addr, varname) \
do { \
SocketAddress varname = {}; \
config_parse_forward_to_socket("", "", 0, "", 0, "", 0, str, \
&varname, NULL); \
buf = mfree(buf); \
buf2 = mfree(buf2); \
socket_address_print(&varname, &buf); \
socket_address_print(&addr, &buf2); \
log_info("\"%s\" parsed as \"%s\", should be \"%s\"", str, buf, buf2); \
log_info("socket_address_verify(&addr, false) = %d", socket_address_verify(&addr, false)); \
log_info("socket_address_verify(&varname, false) = %d", socket_address_verify(&varname, false)); \
log_info("socket_address_family(&addr) = %d", socket_address_family(&addr)); \
log_info("socket_address_family(&varname) = %d", socket_address_family(&varname)); \
log_info("addr.size = %u", addr.size); \
log_info("varname.size = %u", varname.size); \
assert_se(socket_address_equal(&varname, &addr)); \
} while (0)
static void forward_to_socket_parse_check(const char *str, const SocketAddress *expected_addr) {
_cleanup_free_ char *buf = NULL, *buf2 = NULL;
SocketAddress conf = {};
#define FORWARD_TO_SOCKET_PARSE_CHECK(str, addr) \
_FORWARD_TO_SOCKET_PARSE_CHECK(str, addr, conf##__COUNTER__)
ASSERT_OK(config_parse_forward_to_socket("", "", 0, "", 0, "", 0, str, &conf, NULL));
ASSERT_OK(socket_address_print(&conf, &buf));
ASSERT_OK(socket_address_print(expected_addr, &buf2));
log_info("\"%s\" parsed as \"%s\", should be \"%s\"", str, buf, buf2);
log_info("socket_address_verify(&expected_addr, false) = %d", socket_address_verify(expected_addr, false));
log_info("socket_address_verify(&conf, false) = %d", socket_address_verify(&conf, false));
log_info("socket_address_family(&expected_addr) = %d", socket_address_family(expected_addr));
log_info("socket_address_family(&conf) = %d", socket_address_family(&conf));
log_info("expected_addr.size = %u", expected_addr->size);
log_info("conf.size = %u", conf.size);
ASSERT_TRUE(socket_address_equal(&conf, expected_addr));
}
TEST(config_forward_to_socket) {
SocketAddress addr;
_cleanup_free_ char *buf = NULL, *buf2 = NULL;
/* Valid AF_UNIX */
addr = (SocketAddress) {
@ -98,11 +84,11 @@ TEST(config_forward_to_socket) {
},
.size = offsetof(struct sockaddr_un, sun_path) + strlen("/run/host/journal/socket") + 1,
};
FORWARD_TO_SOCKET_PARSE_CHECK("/run/host/journal/socket", addr);
forward_to_socket_parse_check("/run/host/journal/socket", &addr);
addr.size -= 1;
memcpy(addr.sockaddr.un.sun_path, "\0run/host/journal/socket", sizeof("\0run/host/journal/socket"));
FORWARD_TO_SOCKET_PARSE_CHECK("@run/host/journal/socket", addr);
forward_to_socket_parse_check("@run/host/journal/socket", &addr);
/* Valid AF_INET */
addr = (SocketAddress) {
@ -113,7 +99,7 @@ TEST(config_forward_to_socket) {
},
.size = sizeof(struct sockaddr_in),
};
FORWARD_TO_SOCKET_PARSE_CHECK("192.168.0.1:1234", addr);
forward_to_socket_parse_check("192.168.0.1:1234", &addr);
/* Valid AF_INET6 */
addr = (SocketAddress) {
@ -133,7 +119,7 @@ TEST(config_forward_to_socket) {
},
.size = sizeof(struct sockaddr_in6),
};
FORWARD_TO_SOCKET_PARSE_CHECK("[2001:db8:4006:812::200e]:8080", addr);
forward_to_socket_parse_check("[2001:db8:4006:812::200e]:8080", &addr);
/* Valid AF_VSOCK */
addr = (SocketAddress) {
@ -144,34 +130,34 @@ TEST(config_forward_to_socket) {
},
.size = sizeof(struct sockaddr_vm),
};
FORWARD_TO_SOCKET_PARSE_CHECK("vsock:123456:654321", addr);
forward_to_socket_parse_check("vsock:123456:654321", &addr);
/* Invalid IPv4 */
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("256.123.45.12:1235");
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("252.123.45.12:123500");
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("252.123.45.12:0");
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("252.123.45.12:-1");
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("-1.123.45.12:22");
forward_to_socket_parse_check_fails("256.123.45.12:1235");
forward_to_socket_parse_check_fails("252.123.45.12:123500");
forward_to_socket_parse_check_fails("252.123.45.12:0");
forward_to_socket_parse_check_fails("252.123.45.12:-1");
forward_to_socket_parse_check_fails("-1.123.45.12:22");
/* Invalid IPv6 */
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("[2001:db8:4006:812::200e]:80800");
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("[1ffff:db8:4006:812::200e]:8080");
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("[-1:db8:4006:812::200e]:8080");
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("[2001:db8:4006:812::200e]:-1");
forward_to_socket_parse_check_fails("[2001:db8:4006:812::200e]:80800");
forward_to_socket_parse_check_fails("[1ffff:db8:4006:812::200e]:8080");
forward_to_socket_parse_check_fails("[-1:db8:4006:812::200e]:8080");
forward_to_socket_parse_check_fails("[2001:db8:4006:812::200e]:-1");
/* Invalid UNIX */
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("a/b/c");
forward_to_socket_parse_check_fails("a/b/c");
/* Invalid VSock */
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("vsock:4294967296:1234");
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("vsock:1234:4294967296");
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("vsock:abcd:1234");
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("vsock:1234:abcd");
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("vsock:1234");
forward_to_socket_parse_check_fails("vsock:4294967296:1234");
forward_to_socket_parse_check_fails("vsock:1234:4294967296");
forward_to_socket_parse_check_fails("vsock:abcd:1234");
forward_to_socket_parse_check_fails("vsock:1234:abcd");
forward_to_socket_parse_check_fails("vsock:1234");
/* Invalid Case */
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("");
FORWARD_TO_SOCKET_PARSE_CHECK_FAILS("ahh yes sockets, mmh");
forward_to_socket_parse_check_fails("");
forward_to_socket_parse_check_fails("ahh yes sockets, mmh");
}
DEFINE_TEST_MAIN(LOG_INFO);

View File

@ -6,8 +6,6 @@
#include "errno-util.h"
#include "siphash24.h"
#include "socket-netlink.h"
#include "stdio-util.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "unaligned.h"

View File

@ -1,7 +1,3 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/audit.h>
#include "audit-type.h"
#include "audit_type-to-name.inc"

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdio.h>
#include <stdio.h> /* IWYU pragma: keep */
#include "sd-forward.h"

View File

@ -1,6 +1,9 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
BEGIN{
print "#include <linux/audit.h>"
print ""
print "#include \"audit-type.h\""
print "const char *audit_type_to_string(int type) {"
print " switch (type) {"
}

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "syslog-util.h"
#include "syslog-util.h" /* IWYU pragma: keep */
int journal_fd_nonblock(bool nonblock);
void close_journal_fd(void);

View File

@ -10,7 +10,6 @@
#include "iovec-util.h"
#include "journal-file-util.h"
#include "journal-internal.h"
#include "log.h"
#include "parse-util.h"
#include "rm-rf.h"
#include "tests.h"

View File

@ -7,7 +7,7 @@
#include "sd-forward.h"
#include "log.h"
#include "string-util.h"
#include "string-util.h" /* IWYU pragma: keep */
#define JSON_VARIANT_REPLACE(v, q) \
do { \

View File

@ -3,7 +3,7 @@
#include <linux/if.h>
#include <linux/netfilter/nf_tables.h>
#include <linux/netfilter/nfnetlink.h>
#include <linux/netlink.h>
#include <linux/netlink.h> /* IWYU pragma: keep */
#include "netlink-types-internal.h"

View File

@ -2,13 +2,13 @@
#include "sd-json.h"
#include "alloc-util.h"
#include "dns-answer.h"
#include "dns-domain.h"
#include "dns-packet.h"
#include "dns-question.h"
#include "dns-rr.h"
#include "hashmap.h"
#include "json-util.h"
#include "local-addresses.h"
#include "log.h"
#include "machine.h"

View File

@ -19,7 +19,6 @@
#include "set.h"
#include "signal-util.h"
#include "socket-util.h"
#include "stdio-util.h"
#include "string-util.h"
#include "time-util.h"
#include "umask-util.h"

View File

@ -7,11 +7,11 @@
* fine given that LGPL-2.1-or-later downgrades to GPL if needed.
*/
#include "bpf-dlopen.h"
#include "bpf-dlopen.h" /* IWYU pragma: keep */
/* libbpf is used via dlopen(), so rename symbols */
#define bpf_object__destroy_skeleton sym_bpf_object__destroy_skeleton
#define bpf_object__load_skeleton sym_bpf_object__load_skeleton
#define bpf_object__open_skeleton sym_bpf_object__open_skeleton
#include "bpf/sysctl-monitor/sysctl-monitor.skel.h"
#include "bpf/sysctl-monitor/sysctl-monitor.skel.h" /* IWYU pragma: export */

View File

@ -11,7 +11,6 @@
#include "dns-packet.h"
#include "dns-question.h"
#include "dns-rr.h"
#include "env-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "networkd-link.h"

View File

@ -5,6 +5,7 @@
#include "sd-messages.h"
#include "af-list.h"
#include "bpf-dlopen.h"
#include "conf-parser.h"
#include "alloc-util.h"
#include "cgroup-util.h"

View File

@ -9,7 +9,6 @@
#include "network-internal.h"
#include "networkd-manager.h"
#include "networkd-route-util.h"
#include "string-util.h"
#include "strv.h"
#include "tests.h"

View File

@ -13,7 +13,6 @@
#include "cpu-set-util.h"
#include "device-util.h"
#include "devnum-util.h"
#include "env-util.h"
#include "hostname-util.h"
#include "json-util.h"
#include "nspawn-mount.h"

View File

@ -7,7 +7,7 @@
* fine given that LGPL-2.1-or-later downgrades to GPL if needed.
*/
#include "bpf-dlopen.h"
#include "bpf-dlopen.h" /* IWYU pragma: keep */
/* libbpf is used via dlopen(), so rename symbols */
#define bpf_object__attach_skeleton sym_bpf_object__attach_skeleton
@ -15,4 +15,4 @@
#define bpf_object__load_skeleton sym_bpf_object__load_skeleton
#define bpf_object__open_skeleton sym_bpf_object__open_skeleton
#include "bpf/userns-restrict/userns-restrict.skel.h"
#include "bpf/userns-restrict/userns-restrict.skel.h" /* IWYU pragma: export */

View File

@ -8,6 +8,7 @@
#include "bpf-dlopen.h"
#if HAVE_VMLINUX_H
#include "bpf-link.h"
#include "bpf/userns-restrict/userns-restrict-skel.h"
#endif
#include "build-path.h"
#include "common-signal.h"
@ -26,7 +27,6 @@
#include "set.h"
#include "signal-util.h"
#include "socket-util.h"
#include "stdio-util.h"
#include "string-util.h"
#include "strv.h"
#include "time-util.h"

View File

@ -2,6 +2,10 @@
#include <sys/stat.h>
#if HAVE_VMLINUX_H
#include "bpf/userns-restrict/userns-restrict-skel.h"
#endif
#include "bpf-dlopen.h"
#include "bpf-link.h"
#include "fd-util.h"

View File

@ -3,11 +3,7 @@
#include "shared-forward.h"
#if HAVE_VMLINUX_H
#include "bpf/userns-restrict/userns-restrict-skel.h"
#else
struct userns_restrict_bpf;
#endif
int userns_restrict_install(bool pin, struct userns_restrict_bpf **ret);
struct userns_restrict_bpf *userns_restrict_bpf_free(struct userns_restrict_bpf *obj);

View File

@ -6,6 +6,7 @@
#include "alloc-util.h"
#include "cgroup-setup.h"
#include "cgroup-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "oomd-util.h"

View File

@ -14,7 +14,6 @@
#include "log.h"
#include "main-func.h"
#include "mount-setup.h"
#include "mount-util.h"
#include "path-util.h"
#include "process-util.h"
#include "signal-util.h"

View File

@ -10,7 +10,7 @@
#include "resolved-dns-delegate.h"
#include "resolved-dns-delegate-bus.h"
#include "resolved-dns-search-domain.h"
#include "resolved-dns-server.h"
#include "resolved-dns-server.h" /* IWYU pragma: keep */
#include "resolved-manager.h"
#include "strv.h"

View File

@ -1,13 +1,12 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <resolv.h>
#include <resolv.h> /* IWYU pragma: keep */
#include <sys/stat.h>
#include "alloc-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "label-util.h"
#include "log.h"
#include "ordered-set.h"
#include "path-util.h"

View File

@ -16,6 +16,7 @@
#include "dns-packet.h"
#include "dns-question.h"
#include "dns-rr.h"
#include "errno-util.h"
#include "fd-util.h"
#include "log.h"
#include "path-util.h"

View File

@ -1,13 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sys/stat.h>
#include <sys/syslog.h>
#include "acl-util.h"
#include "alloc-util.h"
#include "errno-util.h"
#include "extract-word.h"
#include "fd-util.h"
#include "log.h"
#include "string-util.h"
#include "strv.h"
#include "user-util.h"

View File

@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#if HAVE_APPARMOR
#include <syslog.h>
#include "alloc-util.h"
@ -8,7 +10,6 @@
#include "log.h"
#include "parse-util.h"
#if HAVE_APPARMOR
static void *libapparmor_dl = NULL;
DLSYM_PROTOTYPE(aa_change_onexec) = NULL;

View File

@ -1,9 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sys/syslog.h>
#include "sd-id128.h"
#include "blkid-util.h"
#include "log.h"
#include "parse-util.h"
#include "string-util.h"

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-bus.h"
#include "sd-bus.h" /* IWYU pragma: keep */
#include "shared-forward.h"

View File

@ -2,7 +2,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>
#include "alloc-util.h"
@ -11,7 +10,6 @@
#include "log.h"
#include "memstream-util.h"
#include "parse-util.h"
#include "process-util.h"
#include "sort-util.h"
#include "string-util.h"
#include "strv.h"

View File

@ -27,7 +27,6 @@
#include "path-util.h"
#include "rm-rf.h"
#include "selinux-util.h"
#include "set.h"
#include "signal-util.h"
#include "stat-util.h"
#include "stdio-util.h"

View File

@ -13,7 +13,7 @@
#include "stdio-util.h"
#include "string-table.h"
#include "string-util.h"
#include "unaligned.h"
#include "unaligned.h" /* IWYU pragma: keep */
#include "virt.h"
int set_dumpable(SuidDumpMode mode) {

View File

@ -7,7 +7,6 @@
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <unistd.h>
#include "sd-json.h"
@ -32,11 +31,9 @@
#include "hashmap.h"
#include "hostname-setup.h"
#include "id128-util.h"
#include "initrd-util.h"
#include "lock-util.h"
#include "log.h"
#include "loop-util.h"
#include "mkdir.h"
#include "namespace-util.h"
#include "nsresource.h"
#include "nulstr-util.h"

View File

@ -4,7 +4,7 @@
#include "alloc-util.h"
#include "bitmap.h"
#include "dns-answer.h"
#include "dns-answer.h" /* IWYU pragma: keep */
#include "dns-domain.h"
#include "dns-packet.h"
#include "dns-rr.h"

View File

@ -15,7 +15,7 @@
#include "stat-util.h"
#include "stdio-util.h"
#include "string-util.h"
#include "tpm2-util.h"
#include "tpm2-util.h" /* IWYU pragma: keep */
#include "utf8.h"
#define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x01

View File

@ -9,7 +9,7 @@
#include "dlfcn-util.h"
#include "idn-util.h"
#include "log.h"
#include "log.h" /* IWYU pragma: keep */
#if HAVE_LIBIDN || HAVE_LIBIDN2
static void* idn_dl = NULL;

View File

@ -3,7 +3,7 @@
#include <syslog.h>
#include "libarchive-util.h"
#include "user-util.h"
#include "user-util.h" /* IWYU pragma: keep */
#if HAVE_LIBARCHIVE
static void *libarchive_dl = NULL;

View File

@ -7,7 +7,7 @@
#include "errno-util.h"
#include "libcrypt-util.h"
#include "log.h"
#include "random-util.h"
#include "random-util.h" /* IWYU pragma: keep */
#include "string-util.h"
#include "strv.h"

View File

@ -2,7 +2,7 @@
#pragma once
#include "shared-forward.h"
#include "static-destruct.h"
#include "static-destruct.h" /* IWYU pragma: keep */
void main_prepare(int argc, char *argv[]);

View File

@ -3,7 +3,7 @@
#include <sys/stat.h>
#include "errno-util.h"
#include "label-util.h"
#include "label-util.h" /* IWYU pragma: keep */
#include "mkdir-label.h"
#include "selinux-util.h"
#include "smack-util.h"

View File

@ -1,15 +1,18 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "password-quality-util-passwdqc.h"
#if HAVE_PASSWDQC
#include <passwdqc.h>
#include "alloc-util.h"
#include "dlfcn-util.h"
#include "errno-util.h"
#include "log.h"
#include "memory-util.h"
#include "password-quality-util-passwdqc.h"
#include "strv.h"
#if HAVE_PASSWDQC
static void *passwdqc_dl = NULL;
DLSYM_PROTOTYPE(passwdqc_params_reset) = NULL;

View File

@ -4,8 +4,6 @@
#include "shared-forward.h"
#if HAVE_PASSWDQC
#include <passwdqc.h>
int suggest_passwords(void);
int check_password_quality(const char *password, const char *old, const char *username, char **ret_error);
#endif

View File

@ -1,5 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "password-quality-util-pwquality.h"
#if HAVE_PWQUALITY
#include <pwquality.h>
#include <stdio.h>
#include <unistd.h>
@ -8,12 +13,9 @@
#include "errno-util.h"
#include "log.h"
#include "password-quality-util.h"
#include "password-quality-util-pwquality.h"
#include "string-util.h"
#include "strv.h"
#if HAVE_PWQUALITY
static void *pwquality_dl = NULL;
DLSYM_PROTOTYPE(pwquality_check) = NULL;

View File

@ -4,8 +4,6 @@
#include "shared-forward.h"
#if HAVE_PWQUALITY
#include <pwquality.h>
int suggest_passwords(void);
int check_password_quality(const char *password, const char *old, const char *username, char **ret_error);
#endif

View File

@ -14,7 +14,6 @@
#include "errno-util.h"
#include "fd-util.h"
#include "log.h"
#include "parse-util.h"
#include "reread-partition-table.h"
#include "set.h"
#include "string-util.h"

View File

@ -1,7 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdio.h>
#include "alloc-util.h"
#include "extract-word.h"
#include "securebits-util.h"

View File

@ -1,6 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sched.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>

View File

@ -4,14 +4,13 @@
#include <unistd.h>
#include "errno-list.h"
#include "errno-util.h"
#include "shared-forward.h"
#include "log.h"
#include "log-assert-critical.h"
#include "static-destruct.h"
#include "signal-util.h"
#include "static-destruct.h" /* IWYU pragma: keep*/
#include "signal-util.h" /* IWYU pragma: keep*/
#include "stdio-util.h"
#include "string-util.h"
#include "string-util.h" /* IWYU pragma: keep */
static inline void log_set_assert_return_is_criticalp(bool *p) {
log_set_assert_return_is_critical(*p);

View File

@ -2,7 +2,7 @@
#pragma once
#include "shared-forward.h"
#include "tpm2-util.h"
#include "tpm2-util.h" /* IWYU pragma: keep */
/* Definitions as per "TCG PC Client Specific Platform Firmware Profile Specification"
* (https://trustedcomputinggroup.org/resource/pc-client-specific-platform-firmware-profile-specification/),

View File

@ -6,7 +6,6 @@
#include "alloc-util.h"
#include "ansi-color.h"
#include "bitfield.h"
#include "bootspec.h"
#include "boot-entry.h"
#include "constants.h"
#include "creds-util.h"
@ -14,7 +13,6 @@
#include "dirent-util.h"
#include "dlfcn-util.h"
#include "efi-api.h"
#include "errno-util.h"
#include "extract-word.h"
#include "fd-util.h"
#include "fileio.h"
@ -42,7 +40,6 @@
#include "sync-util.h"
#include "time-util.h"
#include "tpm2-pcr.h"
#include "tmpfile-util.h"
#include "tpm2-util.h"
#include "virt.h"

View File

@ -1,8 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "build.h"
#include "varlink-idl-common.h"
#include "varlink-io.systemd.Unit.h"
/* CGroupContext */
static SD_VARLINK_DEFINE_STRUCT_TYPE(

View File

@ -3,7 +3,7 @@
Copyright © 2010 ProFUSION embedded systems
***/
#include <linux/major.h>
#include <linux/major.h> /* IWYU pragma: keep */
#include <linux/raid/md_u.h>
#include <sys/ioctl.h>

View File

@ -26,7 +26,6 @@
#include "detach-swap.h"
#include "errno-util.h"
#include "exec-util.h"
#include "extract-word.h"
#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
@ -44,7 +43,6 @@
#include "signal-util.h"
#include "string-util.h"
#include "switch-root.h"
#include "sysctl-util.h"
#include "terminal-util.h"
#include "time-util.h"
#include "umount.h"

View File

@ -7,7 +7,6 @@
#include "alloc-util.h"
#include "ansi-color.h"
#include "build.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fs-util.h"
#include "log.h"

View File

@ -10,8 +10,6 @@
#include "constants.h"
#include "creds-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "glob-util.h"
#include "hashmap.h"
#include "log.h"

View File

@ -32,7 +32,7 @@
#include "hashmap.h"
#include "image-policy.h"
#include "initrd-util.h"
#include "label-util.h"
#include "label-util.h" /* IWYU pragma: keep */
#include "log.h"
#include "loop-util.h"
#include "main-func.h"

View File

@ -17,7 +17,6 @@
#include "errno-util.h"
#include "exec-util.h"
#include "exit-status.h"
#include "extract-word.h"
#include "format-util.h"
#include "hexdecoct.h"
#include "hostname-setup.h"

Some files were not shown because too many files have changed in this diff Show More