mirror of
https://github.com/systemd/systemd.git
synced 2026-11-06 05:17:24 +00:00
Automatically detect and fix missing parameter comments (#44621)
I'm tired of reviews that constantly point out to add `/* parameter_name= */` comments to functions calls where `NULL`, `0`, or `true`, or `false` are passed. Let's add automated checking for this so people have a reliable way to test this and the CI warns about it. This is #43725 again. GitHub closed it when its base branch was deleted after the tree-wide comments in #44532 were merged. Since #44532 went in 23 pull requests added 232 new bare literals. The checker also got stricter in the meantime. It now checks calls through the shims in `src/include/override`, literals that have a comment after them and `/* name */` comments that lost their `=`. That's 342 arguments on current main and they're all fixed up here, one commit per top-level source directory like in #44532, before the CI step is switched on. The fixups are comments only. The `fsmount()` shim now uses the parameter names from fsmount(2), so its last argument is commented as `attr_flags` instead of glibc's misleading `ms_flags`. The checker needs libclang 19 or newer. On four CPUs the whole suite takes about a minute and a half.
This commit is contained in:
78 files changed
+1329
-275
No files matched your search
@@ -43,7 +43,7 @@ jobs:
|
||||
- uses: systemd/mkosi@131adaca5eb5f1551bc564ae4497ff940890a374
|
||||
|
||||
- name: Check that tabs are not used in Python code
|
||||
run: sh -c '! git grep -P "\\t" -- src/core/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py'
|
||||
run: sh -c '! git grep -P "\\t" -- src/core/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py tools/check-argument-comments.py'
|
||||
|
||||
- name: Build tools tree
|
||||
run: |
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
- name: Run mypy
|
||||
run: |
|
||||
mkosi box -- mypy --version
|
||||
mkosi box -- mypy src/core/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
|
||||
mkosi box -- mypy src/core/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py tools/check-argument-comments.py
|
||||
|
||||
- name: Run ruff format
|
||||
run: |
|
||||
@@ -86,6 +86,11 @@ jobs:
|
||||
- name: Run clang-tidy
|
||||
run: mkosi box -- meson test -C build --suite=clang-tidy --print-errorlogs --no-stdsplit --quiet
|
||||
|
||||
- name: Run argument comment checks
|
||||
run: |
|
||||
mkosi box -- python3 -c 'import clang.cindex'
|
||||
mkosi box -- meson test -C build --suite=argument-comments --print-errorlogs --no-stdsplit --quiet
|
||||
|
||||
- name: Run coccinelle checks
|
||||
run: mkosi box -- meson test -C build --suite=coccinelle --print-errorlogs --no-stdsplit
|
||||
|
||||
|
||||
@@ -286,6 +286,16 @@ SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
```
|
||||
|
||||
This guidance should be applied tree-wide, including in test files.
|
||||
`tools/check-argument-comments.py` enforces it for every bare `NULL`, `0`,
|
||||
`true` and `false`, not only the ones meaning "unset", passed for a parameter
|
||||
with a telling name. Single-letter names, `argN`, reserved `__names`, calls
|
||||
into libc and other code outside the tree, and calls produced by macro bodies
|
||||
are exempt. Calls through the `sym_*` pointers of the dlopen() wrappers use
|
||||
the names from the library's header. It also checks that an existing comment
|
||||
names the right parameter. `meson test -C build --suite=argument-comments`
|
||||
checks the whole tree. Once `meson compile -C build gensources` has run,
|
||||
`tools/check-argument-comments.py -p build --diff "$(git merge-base main HEAD)" src`
|
||||
checks only what a branch changed, and `--fix` inserts the missing comments.
|
||||
|
||||
- Please do not introduce new circular dependencies between header files.
|
||||
Effectively this means that if a.h includes b.h, then b.h cannot include a.h,
|
||||
|
||||
+34
-1
@@ -16,7 +16,7 @@ project('systemd', 'c',
|
||||
|
||||
add_test_setup(
|
||||
'default',
|
||||
exclude_suites : ['clang-tidy', 'coccinelle', 'unused-symbols', 'integration-tests'],
|
||||
exclude_suites : ['clang-tidy', 'coccinelle', 'argument-comments', 'unused-symbols', 'integration-tests'],
|
||||
exe_wrapper : find_program('tools/test-crash-trace.sh'),
|
||||
is_default : true,
|
||||
)
|
||||
@@ -2889,6 +2889,7 @@ test_dlopen = executables_by_name.get('test-dlopen')
|
||||
nss_targets = []
|
||||
pam_targets = []
|
||||
module_targets = []
|
||||
module_sources = []
|
||||
modules_by_name = {}
|
||||
foreach dict : modules
|
||||
name = dict.get('name')
|
||||
@@ -2906,6 +2907,8 @@ foreach dict : modules
|
||||
continue
|
||||
endif
|
||||
|
||||
module_sources += dict.get('sources', [])
|
||||
|
||||
kwargs = {}
|
||||
foreach key, val : dict
|
||||
if key in ['name', 'conditions', 'version-script']
|
||||
@@ -3275,6 +3278,36 @@ if meson.version().version_compare('>=1.4.0')
|
||||
endif
|
||||
endforeach
|
||||
endforeach
|
||||
|
||||
# One test per top-level source directory over the compiled .c files, which covers the headers
|
||||
# they include. Generated sources are not below src/ relative to the source directory. The NSS,
|
||||
# PAM and cryptsetup token modules are not in sources.
|
||||
argument_comments_sources = {}
|
||||
foreach source : sources + module_sources
|
||||
if not source.full_path().endswith('.c') or source.full_path().endswith('.bpf.c')
|
||||
continue
|
||||
endif
|
||||
|
||||
source_parts = fs.relative_to(source.full_path(), meson.project_source_root()).split('/')
|
||||
if source_parts.length() > 2 and source_parts[0] == 'src'
|
||||
argument_comments_sources += {
|
||||
source_parts[1] : argument_comments_sources.get(source_parts[1], []) + [source],
|
||||
}
|
||||
endif
|
||||
endforeach
|
||||
|
||||
argument_comments_args = ['-p', meson.project_build_root(), '--root', meson.project_source_root()]
|
||||
foreach source_dir, source_dir_sources : argument_comments_sources
|
||||
test(
|
||||
'argument-comments-@0@'.format(source_dir),
|
||||
check_argument_comments_py,
|
||||
args : argument_comments_args + source_dir_sources,
|
||||
suite : 'argument-comments',
|
||||
depends : generated_sources,
|
||||
is_parallel : false, # the script parallelizes over its files by itself
|
||||
timeout : 300,
|
||||
)
|
||||
endforeach
|
||||
endif
|
||||
|
||||
spatch = find_program('spatch', required : false)
|
||||
|
||||
@@ -10,6 +10,7 @@ Packages=
|
||||
bindgen-cli
|
||||
clang-tools-extra
|
||||
clippy
|
||||
python3-clang
|
||||
python3-mypy
|
||||
rpm-build
|
||||
libasan
|
||||
|
||||
@@ -10,6 +10,7 @@ Packages=
|
||||
bindgen
|
||||
clang-tidy
|
||||
coccinelle
|
||||
python3-clang
|
||||
lcov
|
||||
mypy
|
||||
rust-clippy
|
||||
|
||||
@@ -12,6 +12,7 @@ Packages=
|
||||
lcov
|
||||
libtss2-tcti-device0
|
||||
mypy
|
||||
python3-clang
|
||||
python3-ruff
|
||||
rpm-build
|
||||
rust
|
||||
|
||||
@@ -129,7 +129,7 @@ static int show_never_restarted(const RestartSettings *rs, const char *setting)
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
return sd_json_variant_dump(v, arg_json_format_flags, stdout, NULL);
|
||||
return sd_json_variant_dump(v, arg_json_format_flags, stdout, /* prefix= */ NULL);
|
||||
}
|
||||
|
||||
static int show_restart_delays(const RestartSettings *rs, bool *printed) {
|
||||
@@ -207,7 +207,7 @@ static int show_restart_delays(const RestartSettings *rs, bool *printed) {
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
return sd_json_variant_dump(v, arg_json_format_flags, stdout, NULL);
|
||||
return sd_json_variant_dump(v, arg_json_format_flags, stdout, /* prefix= */ NULL);
|
||||
}
|
||||
|
||||
r = table_print_with_pager(table, SD_JSON_FORMAT_OFF, arg_pager_flags, arg_legend);
|
||||
@@ -289,7 +289,7 @@ static int restart_delays_online(sd_bus *bus, const char *arg, bool *printed) {
|
||||
assert(arg);
|
||||
assert(printed);
|
||||
|
||||
r = unit_name_mangle_with_suffix(arg, NULL, UNIT_NAME_MANGLE_WARN, ".service", &unit);
|
||||
r = unit_name_mangle_with_suffix(arg, /* operation= */ NULL, UNIT_NAME_MANGLE_WARN, ".service", &unit);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to mangle name '%s': %m", arg);
|
||||
|
||||
@@ -317,7 +317,7 @@ static int restart_delays_online(sd_bus *bus, const char *arg, bool *printed) {
|
||||
map,
|
||||
BUS_MAP_STRDUP,
|
||||
&error,
|
||||
NULL,
|
||||
/* ret_reply= */ NULL,
|
||||
&rs);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get properties of %s: %s", unit, bus_error_message(&error, r));
|
||||
@@ -403,7 +403,7 @@ int verb_restart_delays(int argc, char *argv[], uintptr_t _data, void *userdata)
|
||||
int r, ret = 0;
|
||||
|
||||
if (!arg_offline) {
|
||||
r = acquire_bus(&bus, NULL);
|
||||
r = acquire_bus(&bus, /* use_full_bus= */ NULL);
|
||||
if (r < 0)
|
||||
return bus_log_connect_error(r, arg_transport, arg_runtime_scope);
|
||||
}
|
||||
|
||||
@@ -110,11 +110,11 @@ static inline void io_uring_prep_rw(
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_nop(struct io_uring_sqe *sqe) {
|
||||
io_uring_prep_rw(sqe, IORING_OP_NOP, -EBADF, NULL, 0, 0);
|
||||
io_uring_prep_rw(sqe, IORING_OP_NOP, -EBADF, /* addr= */ NULL, /* len= */ 0, /* offset= */ 0);
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_cancel(struct io_uring_sqe *sqe, const void *user_data, uint32_t flags) {
|
||||
io_uring_prep_rw(sqe, IORING_OP_ASYNC_CANCEL, -EBADF, user_data, 0, 0);
|
||||
io_uring_prep_rw(sqe, IORING_OP_ASYNC_CANCEL, -EBADF, user_data, /* len= */ 0, /* offset= */ 0);
|
||||
sqe->cancel_flags = flags;
|
||||
}
|
||||
|
||||
@@ -135,30 +135,30 @@ static inline void io_uring_prep_writev(struct io_uring_sqe *sqe, int fd, const
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_connect(struct io_uring_sqe *sqe, int fd, const struct sockaddr *addr, socklen_t addrlen) {
|
||||
io_uring_prep_rw(sqe, IORING_OP_CONNECT, fd, addr, 0, addrlen);
|
||||
io_uring_prep_rw(sqe, IORING_OP_CONNECT, fd, addr, /* len= */ 0, addrlen);
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_recv(struct io_uring_sqe *sqe, int fd, void *buf, uint32_t n, int flags) {
|
||||
io_uring_prep_rw(sqe, IORING_OP_RECV, fd, buf, n, 0);
|
||||
io_uring_prep_rw(sqe, IORING_OP_RECV, fd, buf, n, /* offset= */ 0);
|
||||
sqe->msg_flags = (uint32_t) flags;
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_send(struct io_uring_sqe *sqe, int fd, const void *buf, uint32_t n, int flags) {
|
||||
io_uring_prep_rw(sqe, IORING_OP_SEND, fd, buf, n, 0);
|
||||
io_uring_prep_rw(sqe, IORING_OP_SEND, fd, buf, n, /* offset= */ 0);
|
||||
sqe->msg_flags = (uint32_t) flags;
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_recvmsg(struct io_uring_sqe *sqe, int fd, struct msghdr *msg, int flags) {
|
||||
io_uring_prep_rw(sqe, IORING_OP_RECVMSG, fd, msg, 1, 0);
|
||||
io_uring_prep_rw(sqe, IORING_OP_RECVMSG, fd, msg, 1, /* offset= */ 0);
|
||||
sqe->msg_flags = (uint32_t) flags;
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_sendmsg(struct io_uring_sqe *sqe, int fd, const struct msghdr *msg, int flags) {
|
||||
io_uring_prep_rw(sqe, IORING_OP_SENDMSG, fd, msg, 1, 0);
|
||||
io_uring_prep_rw(sqe, IORING_OP_SENDMSG, fd, msg, 1, /* offset= */ 0);
|
||||
sqe->msg_flags = (uint32_t) flags;
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_accept(struct io_uring_sqe *sqe, int fd, struct sockaddr *addr, socklen_t *addrlen, int flags) {
|
||||
io_uring_prep_rw(sqe, IORING_OP_ACCEPT, fd, addr, 0, (uint64_t) (uintptr_t) addrlen);
|
||||
io_uring_prep_rw(sqe, IORING_OP_ACCEPT, fd, addr, /* len= */ 0, (uint64_t) (uintptr_t) addrlen);
|
||||
sqe->accept_flags = (uint32_t) flags;
|
||||
}
|
||||
@@ -660,7 +660,7 @@ bool mount_new_api_supported(void) {
|
||||
return cache;
|
||||
|
||||
/* This is the newest API among the ones we use, so use it as boundary */
|
||||
r = RET_NERRNO(mount_setattr(-EBADF, NULL, 0, NULL, 0));
|
||||
r = RET_NERRNO(mount_setattr(-EBADF, /* path= */ NULL, /* flags= */ 0, /* attr= */ NULL, /* size= */ 0));
|
||||
if (r == 0 || ERRNO_IS_NOT_SUPPORTED(r)) /* This should return an error if it is working properly */
|
||||
return (cache = false);
|
||||
|
||||
@@ -689,7 +689,7 @@ int mount_option_supported(const char *fstype, const char *key, const char *valu
|
||||
* fsconfig() with FSCONFIG_SET_STRING/FSCONFIG_SET_FLAG never fail. Which sucks, because we want to
|
||||
* use it for testing support, after all. Let's hence do a check if the file system got converted yet
|
||||
* first. */
|
||||
if (fsconfig(fd, FSCONFIG_SET_FD, "adefinitelynotexistingmountoption", NULL, fd) < 0) {
|
||||
if (fsconfig(fd, FSCONFIG_SET_FD, "adefinitelynotexistingmountoption", /* value= */ NULL, fd) < 0) {
|
||||
/* If FSCONFIG_SET_FD is not supported for the fs, then the file system was not converted to
|
||||
* the new mount API yet. If it returns EINVAL the mount option doesn't exist, but the fstype
|
||||
* is converted. */
|
||||
@@ -704,9 +704,9 @@ int mount_option_supported(const char *fstype, const char *key, const char *valu
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EAGAIN), "FSCONFIG_SET_FD worked unexpectedly for '%s', whoa!", fstype);
|
||||
|
||||
if (value)
|
||||
r = fsconfig(fd, FSCONFIG_SET_STRING, key, value, 0);
|
||||
r = fsconfig(fd, FSCONFIG_SET_STRING, key, value, /* aux= */ 0);
|
||||
else
|
||||
r = fsconfig(fd, FSCONFIG_SET_FLAG, key, NULL, 0);
|
||||
r = fsconfig(fd, FSCONFIG_SET_FLAG, key, /* value= */ NULL, /* aux= */ 0);
|
||||
if (r < 0) {
|
||||
if (errno == EINVAL)
|
||||
return false; /* EINVAL means option not supported. */
|
||||
|
||||
@@ -344,7 +344,7 @@ int pidfd_get_inode_id_self_cached(uint64_t *ret) {
|
||||
if (cached_pidfd_id_initialized < 0)
|
||||
return cached_pidfd_id_initialized;
|
||||
|
||||
_cleanup_close_ int fd = pidfd_open(getpid_cached(), 0);
|
||||
_cleanup_close_ int fd = pidfd_open(getpid_cached(), /* flags= */ 0);
|
||||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
|
||||
+2
-2
@@ -354,7 +354,7 @@ int pidref_kill(const PidRef *pidref, int sig) {
|
||||
return -EREMOTE;
|
||||
|
||||
if (pidref->fd >= 0)
|
||||
return RET_NERRNO(pidfd_send_signal(pidref->fd, sig, NULL, 0));
|
||||
return RET_NERRNO(pidfd_send_signal(pidref->fd, sig, /* info= */ NULL, /* flags= */ 0));
|
||||
|
||||
if (pidref->pid > 0)
|
||||
return RET_NERRNO(kill(pidref->pid, sig));
|
||||
@@ -396,7 +396,7 @@ int pidref_sigqueue(const PidRef *pidref, int sig, int value) {
|
||||
si.si_uid = getuid();
|
||||
si.si_value.sival_int = value;
|
||||
|
||||
return RET_NERRNO(pidfd_send_signal(pidref->fd, sig, &si, 0));
|
||||
return RET_NERRNO(pidfd_send_signal(pidref->fd, sig, &si, /* flags= */ 0));
|
||||
}
|
||||
|
||||
if (pidref->pid > 0)
|
||||
|
||||
@@ -2199,7 +2199,7 @@ int posix_spawn_wrapper(
|
||||
|
||||
_cleanup_close_ int pidfd = -EBADF;
|
||||
|
||||
r = pidfd_spawn(&pidfd, path, NULL, &attr, argv, envp);
|
||||
r = pidfd_spawn(&pidfd, path, /* file_actions= */ NULL, &attr, argv, envp);
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r) && FLAGS_SET(flags, POSIX_SPAWN_SETCGROUP) && cg_is_threaded(cgroup) > 0)
|
||||
return -EUCLEAN; /* clone3() could also return EOPNOTSUPP if the target cgroup is in threaded mode,
|
||||
turn that into something recognizable */
|
||||
@@ -2218,7 +2218,7 @@ int posix_spawn_wrapper(
|
||||
if (r != 0)
|
||||
return -r;
|
||||
|
||||
r = pidfd_spawn(&pidfd, path, NULL, &attr, argv, envp);
|
||||
r = pidfd_spawn(&pidfd, path, /* file_actions= */ NULL, &attr, argv, envp);
|
||||
}
|
||||
if (r == 0) {
|
||||
r = pidref_set_pidfd_consume(ret_pidref, TAKE_FD(pidfd));
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@ static inline Pages xmalloc_initrd_pages(size_t n_pages) {
|
||||
AllocateAnyPages,
|
||||
EfiLoaderData,
|
||||
EFI_SIZE_TO_PAGES(n_pages),
|
||||
0 /* Ignored. */);
|
||||
/* addr= */ 0 /* Ignored. */);
|
||||
}
|
||||
|
||||
void convert_efi_path(char16_t *path);
|
||||
|
||||
@@ -1076,12 +1076,12 @@ static int setup_credentials_internal(
|
||||
// Work around a kernel bug that results in tmpfs reconfiguration failure.
|
||||
// FIXME: drop this once https://lore.kernel.org/linux-fsdevel/20251108190930.440685-1-me@yhndnzj.com/
|
||||
// is merged and hits the distro kernels.
|
||||
(void) fsconfig(fs_fd, FSCONFIG_SET_FLAG, "noswap", NULL, 0);
|
||||
(void) fsconfig(fs_fd, FSCONFIG_SET_FLAG, "noswap", /* value= */ NULL, /* aux= */ 0);
|
||||
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_FLAG, "ro", NULL, 0) < 0)
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_FLAG, "ro", /* value= */ NULL, /* aux= */ 0) < 0)
|
||||
return -errno;
|
||||
|
||||
if (fsconfig(fs_fd, FSCONFIG_CMD_RECONFIGURE, NULL, NULL, 0) < 0)
|
||||
if (fsconfig(fs_fd, FSCONFIG_CMD_RECONFIGURE, /* key= */ NULL, /* value= */ NULL, /* aux= */ 0) < 0)
|
||||
return -errno;
|
||||
|
||||
log_debug("Successfully reconfigured credentials fs to be read only.");
|
||||
|
||||
@@ -6154,7 +6154,7 @@ int exec_invoke(
|
||||
}
|
||||
|
||||
if (context->ioprio_is_set)
|
||||
if (ioprio_set(IOPRIO_WHO_PROCESS, 0, context->ioprio) < 0) {
|
||||
if (ioprio_set(IOPRIO_WHO_PROCESS, /* who= */ 0, context->ioprio) < 0) {
|
||||
*exit_status = EXIT_IOPRIO;
|
||||
return log_error_errno(errno, "Failed to set up IO scheduling priority: %m");
|
||||
}
|
||||
|
||||
+1
-1
@@ -1752,7 +1752,7 @@ int exec_context_get_effective_ioprio(const ExecContext *c) {
|
||||
if (c->ioprio_is_set)
|
||||
return c->ioprio;
|
||||
|
||||
p = ioprio_get(IOPRIO_WHO_PROCESS, 0);
|
||||
p = ioprio_get(IOPRIO_WHO_PROCESS, /* who= */ 0);
|
||||
if (p < 0)
|
||||
return IOPRIO_DEFAULT_CLASS_AND_PRIO;
|
||||
|
||||
|
||||
@@ -1809,7 +1809,7 @@ static int mount_bpffs(const MountEntry *m, PidRef *pidref, int socket_fd, int e
|
||||
|
||||
pidref_done(pidref);
|
||||
|
||||
_cleanup_close_ int mnt_fd = fsmount(fs_fd, FSMOUNT_CLOEXEC, /* mount_attrs= */ 0);
|
||||
_cleanup_close_ int mnt_fd = fsmount(fs_fd, FSMOUNT_CLOEXEC, /* attr_flags= */ 0);
|
||||
if (mnt_fd < 0)
|
||||
return log_debug_errno(errno, "Failed to fsmount bpffs: %m");
|
||||
|
||||
@@ -3771,7 +3771,7 @@ static int unpeel_mount_and_setup_overlay(int pair_fd, const char *mount_path) {
|
||||
return log_debug_errno(r, "Failed to receive configured overlay: %m");
|
||||
|
||||
/* Create the mount */
|
||||
mount_fd = fsmount(overlay_fs_fd, FSMOUNT_CLOEXEC, /* flags= */ 0);
|
||||
mount_fd = fsmount(overlay_fs_fd, FSMOUNT_CLOEXEC, /* attr_flags= */ 0);
|
||||
if (mount_fd < 0)
|
||||
return log_debug_errno(errno, "Failed to create overlay mount: %m");
|
||||
|
||||
@@ -3925,14 +3925,14 @@ static int handle_mount_from_grandchild(
|
||||
if (!options)
|
||||
return log_oom_debug();
|
||||
|
||||
if (fsconfig(overlay_fs_fd, FSCONFIG_SET_STRING, "lowerdir", options, 0) < 0)
|
||||
if (fsconfig(overlay_fs_fd, FSCONFIG_SET_STRING, "lowerdir", options, /* aux= */ 0) < 0)
|
||||
return log_debug_errno(errno, "Failed to set lowerdir=%s: %m", options);
|
||||
|
||||
if (fsconfig(overlay_fs_fd, FSCONFIG_SET_STRING, "source", "systemd-extensions", 0) < 0)
|
||||
if (fsconfig(overlay_fs_fd, FSCONFIG_SET_STRING, "source", "systemd-extensions", /* aux= */ 0) < 0)
|
||||
return log_debug_errno(errno, "Failed to set source=systemd-extensions: %m");
|
||||
|
||||
/* Create the superblock */
|
||||
if (fsconfig(overlay_fs_fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0) < 0)
|
||||
if (fsconfig(overlay_fs_fd, FSCONFIG_CMD_CREATE, /* key= */ NULL, /* value= */ NULL, /* aux= */ 0) < 0)
|
||||
return log_debug_errno(errno, "Failed to create overlay superblock: %m");
|
||||
|
||||
/* Signal completion to grandchild */
|
||||
|
||||
@@ -2558,7 +2558,7 @@ int home_create_luks(
|
||||
setup->loop = loop_device_unref(setup->loop);
|
||||
|
||||
if (!user_record_luks_offline_discard(h)) {
|
||||
r = run_fallocate(setup->image_fd, NULL /* refresh stat() data */);
|
||||
r = run_fallocate(setup->image_fd, /* st= */ NULL /* refresh stat() data */);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ void password_cache_load_keyring(UserRecord *h, PasswordCache *cache) {
|
||||
if (!name)
|
||||
return (void) log_oom();
|
||||
|
||||
serial = request_key("user", name, NULL, 0);
|
||||
serial = request_key("user", name, /* callout_info= */ NULL, /* destringid= */ 0);
|
||||
if (serial == -1) {
|
||||
if (errno == ENOKEY) {
|
||||
log_info("Home volume key is not available in kernel keyring.");
|
||||
|
||||
@@ -2619,7 +2619,7 @@ static int vl_method_apply_tags(sd_varlink *link, sd_json_variant *parameters, s
|
||||
return r;
|
||||
|
||||
if (strv_equal(tags, current))
|
||||
return sd_varlink_reply(link, NULL);
|
||||
return sd_varlink_reply(link, /* parameters= */ NULL);
|
||||
|
||||
r = varlink_verify_polkit_async(
|
||||
link,
|
||||
@@ -2634,7 +2634,7 @@ static int vl_method_apply_tags(sd_varlink *link, sd_json_variant *parameters, s
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return sd_varlink_reply(link, NULL);
|
||||
return sd_varlink_reply(link, /* parameters= */ NULL);
|
||||
}
|
||||
|
||||
static int connect_varlink(Context *c) {
|
||||
|
||||
@@ -46,7 +46,7 @@ int fsopen_shim(const char *fsname, unsigned flags);
|
||||
FLAGS with ATTR_FLAGS describing how the mount is to be performed. */
|
||||
/* Defined since glibc-2.36.
|
||||
* Supported since kernel v5.2 (93766fbd2696c2c4453dd8e1070977e9cd4e6b6d). */
|
||||
int fsmount_shim(int fd, unsigned flags, unsigned ms_flags);
|
||||
int fsmount_shim(int fsfd, unsigned flags, unsigned attr_flags);
|
||||
#define fsmount fsmount_shim
|
||||
|
||||
/* Add the mounted FROM_DFD referenced by FROM_PATHNAME filesystem returned
|
||||
|
||||
+2
-2
@@ -9,9 +9,9 @@ DEFINE_SYSCALL_SHIM(fsopen, int,
|
||||
unsigned, flags)
|
||||
|
||||
DEFINE_SYSCALL_SHIM(fsmount, int,
|
||||
int, fd,
|
||||
int, fsfd,
|
||||
unsigned, flags,
|
||||
unsigned, ms_flags)
|
||||
unsigned, attr_flags)
|
||||
|
||||
DEFINE_SYSCALL_SHIM(move_mount, int,
|
||||
int, from_dfd,
|
||||
|
||||
@@ -493,7 +493,7 @@ TEST(dhcp_server_static_lease_special_addresses) {
|
||||
_cleanup_(sd_dhcp_server_unrefp) sd_dhcp_server *server = NULL;
|
||||
ASSERT_OK(sd_dhcp_server_new(&server, 4242));
|
||||
ASSERT_OK(sd_dhcp_server_configure_pool(server, &(struct in_addr) { htobe32(INADDR_LOOPBACK) },
|
||||
8, 0, 0));
|
||||
8, /* offset= */ 0, /* size= */ 0));
|
||||
|
||||
sd_dhcp_client_id client_id_subnet = {
|
||||
.size = 7,
|
||||
|
||||
@@ -411,7 +411,7 @@ TEST(lease_timezone) {
|
||||
|
||||
/* "UTC" in the main test messages bypasses the tzfile check in
|
||||
* verify_timezone(); exercise the validation with invalid inputs. */
|
||||
ASSERT_ERROR(dhcp6_lease_set_timezone(lease, (const uint8_t *) "", 0), EINVAL);
|
||||
ASSERT_ERROR(dhcp6_lease_set_timezone(lease, (const uint8_t *) "", /* optlen= */ 0), EINVAL);
|
||||
ASSERT_ERROR(dhcp6_lease_set_timezone(lease, (const uint8_t *) "UTC\0", 4), EINVAL);
|
||||
ASSERT_ERROR(dhcp6_lease_set_timezone(lease, (const uint8_t *) "/etc/passwd", 11), EINVAL);
|
||||
ASSERT_ERROR(dhcp6_lease_set_timezone(lease, (const uint8_t *) "../passwd", 9), EINVAL);
|
||||
|
||||
@@ -679,7 +679,7 @@ _public_ int sd_pid_notify_barrier(pid_t pid, int unset_environment, uint64_t ti
|
||||
|
||||
pipe_fd[1] = safe_close(pipe_fd[1]);
|
||||
|
||||
r = fd_wait_for_event(pipe_fd[0], 0 /* POLLHUP is implicit */, timeout);
|
||||
r = fd_wait_for_event(pipe_fd[0], /* event= */ 0 /* POLLHUP is implicit */, timeout);
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
if (r == 0) {
|
||||
|
||||
@@ -2973,7 +2973,7 @@ _public_ int sd_device_open(sd_device *device, int flags) {
|
||||
|
||||
/* We've historically returned non-cloexec fds. */
|
||||
if (!FLAGS_SET(flags, O_CLOEXEC)) {
|
||||
r = fd_cloexec(fd, false);
|
||||
r = fd_cloexec(fd, /* cloexec= */ false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -1232,7 +1232,7 @@ static void source_disown(sd_event_source *s) {
|
||||
assert(s->child.pidfd >= 0);
|
||||
|
||||
if (!s->child.exited) {
|
||||
r = RET_NERRNO(pidfd_send_signal(s->child.pidfd, SIGKILL, NULL, 0));
|
||||
r = RET_NERRNO(pidfd_send_signal(s->child.pidfd, SIGKILL, /* info= */ NULL, /* flags= */ 0));
|
||||
if (r < 0 && r != -ESRCH)
|
||||
log_debug_errno(r, "Failed to kill process " PID_FMT ", ignoring: %m",
|
||||
s->child.pid);
|
||||
@@ -1798,7 +1798,7 @@ _public_ int sd_event_add_child(
|
||||
/* We always take a pidfd here, even if we wait for anything else than WEXITED, so that we pin the
|
||||
* PID, and make regular waitid() handling race-free. */
|
||||
|
||||
s->child.pidfd = pidfd_open(pid, 0);
|
||||
s->child.pidfd = pidfd_open(pid, /* flags= */ 0);
|
||||
if (s->child.pidfd < 0)
|
||||
return -errno;
|
||||
|
||||
|
||||
@@ -905,7 +905,7 @@ static int io_uring_recv_fiber(void *userdata) {
|
||||
return r;
|
||||
|
||||
st->got = sd_future_result(f);
|
||||
return sd_event_exit(e, 0);
|
||||
return sd_event_exit(e, /* code= */ 0);
|
||||
}
|
||||
|
||||
TEST(io_uring_future_recv) {
|
||||
|
||||
@@ -580,7 +580,7 @@ TEST(pidfd) {
|
||||
/* child */
|
||||
_exit(66);
|
||||
|
||||
ASSERT_OK(pidfd = pidfd_open(pid, 0));
|
||||
ASSERT_OK(pidfd = pidfd_open(pid, /* flags= */ 0));
|
||||
|
||||
ASSERT_OK_ERRNO(pid2 = fork());
|
||||
if (pid2 == 0)
|
||||
@@ -1131,7 +1131,7 @@ TEST(child_pidfd_wnowait) {
|
||||
_exit(42);
|
||||
|
||||
_cleanup_close_ int pidfd = -EBADF;
|
||||
ASSERT_OK_ERRNO(pidfd = pidfd_open(pid, 0));
|
||||
ASSERT_OK_ERRNO(pidfd = pidfd_open(pid, /* flags= */ 0));
|
||||
|
||||
/* Add a child source with WNOWAIT flag */
|
||||
_cleanup_(sd_event_source_unrefp) sd_event_source *s = NULL;
|
||||
@@ -1364,7 +1364,7 @@ TEST(io_uring_future_many) {
|
||||
ASSERT_OK(sd_event_new(&e));
|
||||
|
||||
/* The ring can be created after the loop ran. */
|
||||
ASSERT_OK(sd_event_run(e, 0));
|
||||
ASSERT_OK(sd_event_run(e, /* timeout= */ 0));
|
||||
|
||||
if (!io_uring_available_or_skip(e))
|
||||
return;
|
||||
@@ -1466,10 +1466,10 @@ TEST(io_uring_future_cancel_after_fork) {
|
||||
ASSERT_OK(add_recv(e, sv[0], buf, sizeof(buf), &f));
|
||||
|
||||
/* sd_event_run() submits the SQE. Nobody writes to the socket, so the recv() stays armed. */
|
||||
ASSERT_OK(sd_event_run(e, 0));
|
||||
ASSERT_OK(sd_event_run(e, /* timeout= */ 0));
|
||||
ASSERT_EQ(sd_future_state(f), SD_FUTURE_PENDING);
|
||||
|
||||
r = ASSERT_OK(pidref_safe_fork("(future-cancel)", FORK_WAIT|FORK_LOG, NULL));
|
||||
r = ASSERT_OK(pidref_safe_fork("(future-cancel)", FORK_WAIT|FORK_LOG, /* ret= */ NULL));
|
||||
if (r == 0) {
|
||||
ASSERT_ERROR(ASSERT_RETURN_EXPECTED(sd_future_cancel(f)), ECHILD);
|
||||
_exit(EXIT_SUCCESS);
|
||||
@@ -1501,7 +1501,7 @@ TEST(io_uring_external_poll_loop) {
|
||||
.events = POLLIN,
|
||||
}, 1, 5000), 1);
|
||||
|
||||
r = ASSERT_OK(sd_event_wait(e, 0));
|
||||
r = ASSERT_OK(sd_event_wait(e, /* timeout= */ 0));
|
||||
if (r > 0)
|
||||
ASSERT_OK(sd_event_dispatch(e));
|
||||
|
||||
@@ -1552,7 +1552,7 @@ TEST(io_uring_wait_fd_during_exit) {
|
||||
_cleanup_(sd_future_unrefp) sd_future *f = NULL;
|
||||
ASSERT_OK(add_recv(e, sv[0], buf, sizeof(buf), &f));
|
||||
|
||||
ASSERT_OK(sd_event_exit(e, 0));
|
||||
ASSERT_OK(sd_event_exit(e, /* code= */ 0));
|
||||
ASSERT_OK(event_get_wait_fd(e));
|
||||
ASSERT_NE(event_get_wait_fd(e), sd_event_get_fd(e));
|
||||
|
||||
@@ -1590,12 +1590,12 @@ TEST(io_uring_exit_between_wait_and_dispatch) {
|
||||
ASSERT_OK(add_recv(e, sv[0], buf, sizeof(buf), &f));
|
||||
|
||||
_cleanup_(sd_event_source_unrefp) sd_event_source *d = NULL, *x = NULL;
|
||||
ASSERT_OK(sd_event_add_defer(e, &d, defer_noop, NULL));
|
||||
ASSERT_OK(sd_event_add_defer(e, &d, defer_noop, /* userdata= */ NULL));
|
||||
ASSERT_OK(sd_event_add_exit(e, &x, exit_check_resolved, f));
|
||||
|
||||
/* The defer source is pending, so sd_event_prepare() reports a pending event. */
|
||||
ASSERT_OK_POSITIVE(sd_event_prepare(e));
|
||||
ASSERT_OK(sd_event_exit(e, 0));
|
||||
ASSERT_OK(sd_event_exit(e, /* code= */ 0));
|
||||
ASSERT_OK_POSITIVE(sd_event_dispatch(e));
|
||||
|
||||
ASSERT_OK(sd_event_loop(e));
|
||||
@@ -1681,13 +1681,13 @@ TEST(io_uring_drain_on_exit_skips_ratelimit_expiry) {
|
||||
ASSERT_OK(add_recv(e, sv[0], buf, sizeof(buf), &f));
|
||||
|
||||
while (sd_event_source_is_ratelimited(s) == 0)
|
||||
ASSERT_OK(sd_event_run(e, 0));
|
||||
ASSERT_OK(sd_event_run(e, /* timeout= */ 0));
|
||||
|
||||
/* The ratelimit window ends during the sleep. Timer processing after the exit would then run the
|
||||
* ratelimit expiry callback. */
|
||||
ASSERT_OK(usleep_safe(20 * USEC_PER_MSEC));
|
||||
|
||||
ASSERT_OK(sd_event_exit(e, 0));
|
||||
ASSERT_OK(sd_event_exit(e, /* code= */ 0));
|
||||
ASSERT_OK(sd_event_loop(e));
|
||||
|
||||
ASSERT_ERROR(sd_future_result(f), ECANCELED);
|
||||
|
||||
@@ -266,7 +266,7 @@ TEST(fiber_io_cancel_after_data) {
|
||||
CancelledRead c = { .fd = sockfd[0] };
|
||||
_cleanup_(sd_future_unrefp) sd_future *f = NULL;
|
||||
ASSERT_OK(sd_fiber_new(e, "cancelled-recv", cancelled_recv_fiber, &c, &f));
|
||||
ASSERT_OK_POSITIVE(sd_event_run(e, 0));
|
||||
ASSERT_OK_POSITIVE(sd_event_run(e, /* timeout= */ 0));
|
||||
|
||||
/* The data arrives before the fiber runs again to see the cancellation. */
|
||||
ASSERT_OK_EQ_ERRNO(write(sockfd[1], "x", 1), 1);
|
||||
@@ -306,9 +306,9 @@ TEST(fiber_io_after_exit) {
|
||||
|
||||
_cleanup_(sd_future_unrefp) sd_future *f = NULL;
|
||||
ASSERT_OK(sd_fiber_new(e, "send-after-exit", send_after_exit_fiber, INT_TO_PTR(sockfd[1]), &f));
|
||||
ASSERT_OK_POSITIVE(sd_event_run(e, 0));
|
||||
ASSERT_OK_POSITIVE(sd_event_run(e, /* timeout= */ 0));
|
||||
|
||||
ASSERT_OK(sd_event_exit(e, 0));
|
||||
ASSERT_OK(sd_event_exit(e, /* code= */ 0));
|
||||
ASSERT_OK(sd_event_loop(e));
|
||||
ASSERT_OK_ZERO(sd_future_result(f));
|
||||
|
||||
@@ -359,9 +359,9 @@ TEST(fiber_io_exit_order) {
|
||||
ASSERT_OK(sd_event_add_exit(e, &s, exit_order_handler, &o));
|
||||
|
||||
/* The fiber suspends in sd_fiber_recv(). */
|
||||
ASSERT_OK_POSITIVE(sd_event_run(e, 0));
|
||||
ASSERT_OK_POSITIVE(sd_event_run(e, /* timeout= */ 0));
|
||||
|
||||
ASSERT_OK(sd_event_exit(e, 0));
|
||||
ASSERT_OK(sd_event_exit(e, /* code= */ 0));
|
||||
ASSERT_OK(sd_event_loop(e));
|
||||
|
||||
ASSERT_OK_ZERO(sd_future_result(f));
|
||||
@@ -444,7 +444,7 @@ TEST(fiber_io_pty) {
|
||||
/* The read fiber has the higher priority, so it waits on the pty before the write fiber runs. */
|
||||
_cleanup_(sd_future_unrefp) sd_future *fr = NULL, *fw = NULL;
|
||||
ASSERT_OK(sd_fiber_new(e, "pty-read", pty_read_fiber, INT_TO_PTR(slave), &fr));
|
||||
ASSERT_OK(sd_future_set_priority(fr, 0));
|
||||
ASSERT_OK(sd_future_set_priority(fr, /* priority= */ 0));
|
||||
ASSERT_OK(sd_fiber_new(e, "pty-write", pty_write_fiber, INT_TO_PTR(master), &fw));
|
||||
ASSERT_OK(sd_future_set_priority(fw, 1));
|
||||
|
||||
@@ -748,7 +748,7 @@ TEST(fiber_io_recv_dontwait) {
|
||||
* runs. */
|
||||
_cleanup_(sd_future_unrefp) sd_future *fr = NULL, *fs = NULL;
|
||||
ASSERT_OK(sd_fiber_new(e, "socket-recv-dontwait", socket_recv_dontwait_fiber, INT_TO_PTR(sockfd[1]), &fr));
|
||||
ASSERT_OK(sd_future_set_priority(fr, 0));
|
||||
ASSERT_OK(sd_future_set_priority(fr, /* priority= */ 0));
|
||||
ASSERT_OK(sd_fiber_new(e, "socket-send-dontwait", socket_send_dontwait_fiber, INT_TO_PTR(sockfd[0]), &fs));
|
||||
ASSERT_OK(sd_future_set_priority(fs, 1));
|
||||
|
||||
@@ -1828,7 +1828,7 @@ static int shutdown_reader_fiber(void *userdata) {
|
||||
}
|
||||
|
||||
static int on_shutdown_timer(sd_event_source *s, uint64_t usec, void *userdata) {
|
||||
return sd_event_exit(sd_event_source_get_event(s), 0);
|
||||
return sd_event_exit(sd_event_source_get_event(s), /* code= */ 0);
|
||||
}
|
||||
|
||||
/* Fibers doing I/O into stack-allocated buffers while a timer fires sd_event_exit(). Every fiber
|
||||
@@ -1853,8 +1853,8 @@ TEST(fiber_io_shutdown_during_work) {
|
||||
|
||||
/* Short delay so the fibers actually transfer something before the teardown. */
|
||||
_cleanup_(sd_event_source_unrefp) sd_event_source *timer = NULL;
|
||||
ASSERT_OK(sd_event_add_time_relative(e, &timer, CLOCK_MONOTONIC, 50 * USEC_PER_MSEC, 0,
|
||||
on_shutdown_timer, NULL));
|
||||
ASSERT_OK(sd_event_add_time_relative(e, &timer, CLOCK_MONOTONIC, 50 * USEC_PER_MSEC, /* accuracy= */ 0,
|
||||
on_shutdown_timer, /* userdata= */ NULL));
|
||||
|
||||
ASSERT_OK(sd_event_loop(e));
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ static int get_invocation_from_keyring(sd_id128_t *ret) {
|
||||
|
||||
assert(ret);
|
||||
|
||||
key = request_key("user", "invocation_id", NULL, 0);
|
||||
key = request_key("user", "invocation_id", /* callout_info= */ NULL, /* destringid= */ 0);
|
||||
if (key == -1) {
|
||||
/* Keyring support not available? Keyring access locked down? No invocation key stored? */
|
||||
if (ERRNO_IS_NOT_SUPPORTED(errno) ||
|
||||
|
||||
@@ -77,7 +77,7 @@ TEST(login) {
|
||||
log_info("sd_pid_get_cgroup(0, …) → %s / \"%s\"", e(r), strnull(cgroup));
|
||||
ASSERT_TRUE(IN_SET(r, 0, -ENOMEDIUM));
|
||||
|
||||
pidfd = pidfd_open(getpid_cached(), 0);
|
||||
pidfd = pidfd_open(getpid_cached(), /* flags= */ 0);
|
||||
if (pidfd >= 0) {
|
||||
_cleanup_free_ char *cgroup2 = NULL, *session2 = NULL,
|
||||
*unit2 = NULL, *user_unit2 = NULL, *slice2 = NULL;
|
||||
|
||||
@@ -694,13 +694,13 @@ TEST(split_qualified_symbol_name) {
|
||||
&name));
|
||||
ASSERT_STREQ(name, "GetInfo");
|
||||
|
||||
ASSERT_ERROR(varlink_idl_split_qualified_symbol_name(/* symbol= */ NULL, NULL, NULL), EINVAL);
|
||||
ASSERT_ERROR(varlink_idl_split_qualified_symbol_name("", NULL, NULL), EINVAL);
|
||||
ASSERT_ERROR(varlink_idl_split_qualified_symbol_name("Foo", NULL, NULL), EINVAL);
|
||||
ASSERT_ERROR(varlink_idl_split_qualified_symbol_name("xxx.xxx", NULL, NULL), EINVAL);
|
||||
ASSERT_ERROR(varlink_idl_split_qualified_symbol_name(".Foo", NULL, NULL), EINVAL);
|
||||
ASSERT_ERROR(varlink_idl_split_qualified_symbol_name("xxx.xxx.0foo", NULL, NULL), EINVAL);
|
||||
ASSERT_ERROR(varlink_idl_split_qualified_symbol_name("xxx..Foo", NULL, NULL), EINVAL);
|
||||
ASSERT_ERROR(varlink_idl_split_qualified_symbol_name(/* symbol= */ NULL, /* ret_interface= */ NULL, /* ret_name= */ NULL), EINVAL);
|
||||
ASSERT_ERROR(varlink_idl_split_qualified_symbol_name("", /* ret_interface= */ NULL, /* ret_name= */ NULL), EINVAL);
|
||||
ASSERT_ERROR(varlink_idl_split_qualified_symbol_name("Foo", /* ret_interface= */ NULL, /* ret_name= */ NULL), EINVAL);
|
||||
ASSERT_ERROR(varlink_idl_split_qualified_symbol_name("xxx.xxx", /* ret_interface= */ NULL, /* ret_name= */ NULL), EINVAL);
|
||||
ASSERT_ERROR(varlink_idl_split_qualified_symbol_name(".Foo", /* ret_interface= */ NULL, /* ret_name= */ NULL), EINVAL);
|
||||
ASSERT_ERROR(varlink_idl_split_qualified_symbol_name("xxx.xxx.0foo", /* ret_interface= */ NULL, /* ret_name= */ NULL), EINVAL);
|
||||
ASSERT_ERROR(varlink_idl_split_qualified_symbol_name("xxx..Foo", /* ret_interface= */ NULL, /* ret_name= */ NULL), EINVAL);
|
||||
}
|
||||
|
||||
TEST(validate_json) {
|
||||
|
||||
@@ -865,7 +865,7 @@ static int create_session_message(
|
||||
assert(ret);
|
||||
|
||||
if (!avoid_pidfd) {
|
||||
pidfd = pidfd_open(getpid_cached(), 0);
|
||||
pidfd = pidfd_open(getpid_cached(), /* flags= */ 0);
|
||||
if (pidfd < 0)
|
||||
return -errno;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ _public_ PAM_EXTERN int pam_sm_authenticate(
|
||||
/* Retrieve the key. */
|
||||
|
||||
key_serial_t serial;
|
||||
serial = request_key("user", keyname, NULL, 0);
|
||||
serial = request_key("user", keyname, /* callout_info= */ NULL, /* destringid= */ 0);
|
||||
if (serial < 0) {
|
||||
if (errno == ENOKEY) {
|
||||
pam_debug_syslog(pamh, debug, "Key not found: %s", keyname);
|
||||
|
||||
@@ -255,10 +255,10 @@ static int dispatch_resolve_link(sd_varlink *vlink, sd_json_variant *parameters,
|
||||
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("ifindex"));
|
||||
|
||||
if (FLAGS_SET(link->flags, IFF_LOOPBACK))
|
||||
return sd_varlink_error(vlink, "io.systemd.Resolve.Link.IsLoopback", NULL);
|
||||
return sd_varlink_error(vlink, "io.systemd.Resolve.Link.IsLoopback", /* parameters= */ NULL);
|
||||
|
||||
if (link->state == LINK_STATE_UNMANAGED)
|
||||
return sd_varlink_error(vlink, "io.systemd.Network.Link.InterfaceUnmanaged", NULL);
|
||||
return sd_varlink_error(vlink, "io.systemd.Network.Link.InterfaceUnmanaged", /* parameters= */ NULL);
|
||||
|
||||
*ret = link;
|
||||
return 0;
|
||||
@@ -327,5 +327,5 @@ int vl_method_link_set_dns(sd_varlink *vlink, sd_json_variant *parameters, sd_va
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return sd_varlink_reply(vlink, NULL);
|
||||
return sd_varlink_reply(vlink, /* parameters= */ NULL);
|
||||
}
|
||||
@@ -681,7 +681,7 @@ int config_parse_mm_allowed_auth(
|
||||
for (const char *p = rvalue;;) {
|
||||
_cleanup_free_ char *auth = NULL;
|
||||
|
||||
r = extract_first_word(&p, &auth, /* separators */ NULL, /* flags */ 0);
|
||||
r = extract_first_word(&p, &auth, /* separators= */ NULL, /* flags= */ 0);
|
||||
if (r < 0)
|
||||
return log_syntax_parse_error(unit, filename, line, r, lvalue, rvalue);
|
||||
if (r == 0)
|
||||
|
||||
@@ -43,9 +43,9 @@ static int make_tmpfs_fsmount(void) {
|
||||
_cleanup_close_ int fsfd = -EBADF, mntfd = -EBADF;
|
||||
|
||||
fsfd = ASSERT_OK_ERRNO(fsopen("tmpfs", FSOPEN_CLOEXEC));
|
||||
ASSERT_OK_ERRNO(fsconfig(fsfd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
|
||||
ASSERT_OK_ERRNO(fsconfig(fsfd, FSCONFIG_CMD_CREATE, /* key= */ NULL, /* value= */ NULL, /* aux= */ 0));
|
||||
|
||||
mntfd = ASSERT_OK_ERRNO(fsmount(fsfd, FSMOUNT_CLOEXEC, 0));
|
||||
mntfd = ASSERT_OK_ERRNO(fsmount(fsfd, FSMOUNT_CLOEXEC, /* attr_flags= */ 0));
|
||||
|
||||
return TAKE_FD(mntfd);
|
||||
}
|
||||
@@ -984,7 +984,7 @@ TEST_RET(userns_mqueue_lifetime) {
|
||||
|
||||
rb = sym_ring_buffer__new(sym_bpf_map__fd(bpf_obj->maps.userns_ringbuf), ringbuf_userns_freed, &inode, /* opts= */ NULL);
|
||||
ASSERT_NOT_NULL(rb);
|
||||
ASSERT_OK(sym_ring_buffer__poll(rb, 0));
|
||||
ASSERT_OK(sym_ring_buffer__poll(rb, /* timeout_ms= */ 0));
|
||||
inode = (unsigned) userns_st.st_ino;
|
||||
ASSERT_NE(inode, 0U);
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ TEST(oomd_cgroup_kill) {
|
||||
* by the test so that pid1 doesn't delete it before we can read the xattrs. */
|
||||
ASSERT_NOT_NULL(subcgroup = path_join(cgroup, "oomdkilltest"));
|
||||
/* Always start clean, in case of repeated runs and failures */
|
||||
ASSERT_OK(cg_trim(subcgroup, /* delete_root */ true));
|
||||
ASSERT_OK(cg_trim(subcgroup, /* delete_root= */ true));
|
||||
ASSERT_OK(cg_create(subcgroup));
|
||||
|
||||
/* If we don't have permissions to set xattrs we're likely in a userns or missing capabilities */
|
||||
@@ -216,7 +216,7 @@ TEST(oomd_cgroup_kill) {
|
||||
ASSERT_STREQ(v, i == 0 ? "2" : "4");
|
||||
}
|
||||
|
||||
ASSERT_OK(cg_trim(subcgroup, /* delete_root */ true));
|
||||
ASSERT_OK(cg_trim(subcgroup, /* delete_root= */ true));
|
||||
}
|
||||
|
||||
TEST(oomd_cgroup_kill_signal_reason) {
|
||||
|
||||
+1
-1
@@ -9050,7 +9050,7 @@ static int context_manifest_gpt(Context *context) {
|
||||
|
||||
/* Then an object for the whole image, i.e. the complete disk including the partition table */
|
||||
uint8_t image_hash[SHA256_DIGEST_SIZE];
|
||||
r = hash_range(fd, 0, context->total, image_hash);
|
||||
r = hash_range(fd, /* offset= */ 0, context->total, image_hash);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -1360,7 +1360,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
|
||||
dns_server_feature_level_to_string(t->clamp_feature_level_servfail));
|
||||
}
|
||||
|
||||
dns_transaction_retry(t, false /* use the same server */);
|
||||
dns_transaction_retry(t, /* next_server= */ false /* use the same server */);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1489,10 +1489,10 @@ static int vl_get_link(sd_varlink *vlink, int ifindex, Link **ret_link) {
|
||||
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("ifindex"));
|
||||
|
||||
if (FLAGS_SET(link->flags, IFF_LOOPBACK))
|
||||
return sd_varlink_error(vlink, "io.systemd.Resolve.Link.IsLoopback", NULL);
|
||||
return sd_varlink_error(vlink, "io.systemd.Resolve.Link.IsLoopback", /* parameters= */ NULL);
|
||||
|
||||
if (link->is_managed)
|
||||
return sd_varlink_error(vlink, "io.systemd.Resolve.Link.ManagedByNetworkd", NULL);
|
||||
return sd_varlink_error(vlink, "io.systemd.Resolve.Link.ManagedByNetworkd", /* parameters= */ NULL);
|
||||
|
||||
*ret_link = link;
|
||||
return 0;
|
||||
@@ -1555,7 +1555,7 @@ static int vl_method_link_set_dns(sd_varlink *link, sd_json_variant *parameters,
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return sd_varlink_reply(link, NULL);
|
||||
return sd_varlink_reply(link, /* parameters= */ NULL);
|
||||
}
|
||||
|
||||
static int varlink_monitor_server_init(Manager *m) {
|
||||
|
||||
@@ -316,9 +316,9 @@ TEST(dns_synthesize_answer_onion) {
|
||||
|
||||
key = dns_resource_key_new(DNS_CLASS_IN, type, "mysecret.onion");
|
||||
ASSERT_NOT_NULL(key);
|
||||
ASSERT_OK(dns_question_add(question, key, 0));
|
||||
ASSERT_OK(dns_question_add(question, key, /* flags= */ 0));
|
||||
|
||||
ASSERT_ERROR(dns_synthesize_answer(&manager, question, 0, &answer), ENXIO);
|
||||
ASSERT_ERROR(dns_synthesize_answer(&manager, question, /* ifindex= */ 0, &answer), ENXIO);
|
||||
ASSERT_NULL(answer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ int polkit_check_authorization(sd_bus *bus, PolkitFlags flags, char **ret_tmpaut
|
||||
pid = getpid_cached();
|
||||
|
||||
/* Polkit requires pidfd to honor temporary authorizations */
|
||||
pidfd = pidfd_open(pid, 0);
|
||||
pidfd = pidfd_open(pid, /* flags= */ 0);
|
||||
if (pidfd < 0)
|
||||
return log_debug_errno(errno, "pidfd_open failed: %m");
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ static inline int compat_bpf_map_create(
|
||||
value_size, max_entries, opts);
|
||||
|
||||
return sym_bpf_create_map(map_type, key_size, value_size, max_entries,
|
||||
0 /* opts->map_flags, but opts is always NULL for us so skip build dependency on the type */);
|
||||
/* map_flags= */ 0 /* opts->map_flags, but opts is always NULL for us so skip build dependency on the type */);
|
||||
}
|
||||
|
||||
/* libbpf sometimes returns error codes that make sense only in the kernel, like 524 for EOPNOTSUPP. Use
|
||||
|
||||
@@ -246,7 +246,7 @@ static void bus_wait_for_units_check_ready(BusWaitForUnits *d) {
|
||||
d->state = d->has_failed ? BUS_WAIT_FAILURE : BUS_WAIT_SUCCESS;
|
||||
|
||||
if (d->event)
|
||||
(void) sd_event_exit(d->event, 0);
|
||||
(void) sd_event_exit(d->event, /* code= */ 0);
|
||||
}
|
||||
|
||||
static void wait_for_item_fail(WaitForItem *item) {
|
||||
|
||||
@@ -85,7 +85,7 @@ int copy_data_fd_full(int fd, uint64_t max_size) {
|
||||
|
||||
/* If we have reason to believe this will fit fine in /tmp, then use that as first fallback. */
|
||||
if ((!S_ISREG(st.st_mode) || (uint64_t) st.st_size < DATA_FD_TMP_LIMIT)) {
|
||||
tmp_fd = open_tmpfile_unlinkable(NULL /* NULL as directory means /tmp */, O_RDWR);
|
||||
tmp_fd = open_tmpfile_unlinkable(/* directory= */ NULL /* NULL as directory means /tmp */, O_RDWR);
|
||||
if (tmp_fd < 0)
|
||||
return tmp_fd;
|
||||
|
||||
|
||||
@@ -2399,7 +2399,7 @@ int dns_packet_read_rr(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = dns_packet_read_name(p, &rr->svcb.target_name, false /* uncompressed */, /* start= */ NULL);
|
||||
r = dns_packet_read_name(p, &rr->svcb.target_name, /* allow_compression= */ false, /* start= */ NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -799,7 +799,7 @@ int config_parse_image_policy(
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = image_policy_from_string(rvalue, /* graceful */ true, &np);
|
||||
r = image_policy_from_string(rvalue, /* graceful= */ true, &np);
|
||||
if (r == -ENOTUNIQ)
|
||||
return log_syntax(unit, LOG_ERR, filename, line, r, "Duplicate rule in image policy, refusing: %s", rvalue);
|
||||
if (r == -EBADSLT)
|
||||
|
||||
+11
-11
@@ -2021,14 +2021,14 @@ int fsmount_credentials_fs(int *ret_fsfd) {
|
||||
if (fs_fd < 0)
|
||||
return -errno;
|
||||
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "nr_inodes", "1024", 0) < 0)
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "nr_inodes", "1024", /* aux= */ 0) < 0)
|
||||
return -errno;
|
||||
|
||||
xsprintf(size_str, "%" PRIu64, CREDENTIALS_TOTAL_SIZE_MAX);
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "size", size_str, 0) < 0)
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "size", size_str, /* aux= */ 0) < 0)
|
||||
return -errno;
|
||||
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_FLAG, "noswap", NULL, 0) < 0) {
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_FLAG, "noswap", /* value= */ NULL, /* aux= */ 0) < 0) {
|
||||
if (errno != EINVAL)
|
||||
return -errno;
|
||||
|
||||
@@ -2037,10 +2037,10 @@ int fsmount_credentials_fs(int *ret_fsfd) {
|
||||
close_and_replace(fs_fd, ramfs_fd);
|
||||
}
|
||||
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "mode", "0700", 0) < 0)
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "mode", "0700", /* aux= */ 0) < 0)
|
||||
return -errno;
|
||||
|
||||
if (fsconfig(fs_fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0) < 0)
|
||||
if (fsconfig(fs_fd, FSCONFIG_CMD_CREATE, /* key= */ NULL, /* value= */ NULL, /* aux= */ 0) < 0)
|
||||
return -errno;
|
||||
|
||||
unsigned mount_attrs = ms_flags_to_mount_attr(credentials_fs_mount_flags(/* ro = */ false));
|
||||
@@ -2109,11 +2109,11 @@ int make_fsmount(
|
||||
if (fs_fd < 0)
|
||||
return log_full_errno(error_log_level, errno, "Failed to open superblock for \"%s\": %m", type);
|
||||
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "source", what, 0) < 0)
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "source", what, /* aux= */ 0) < 0)
|
||||
return log_full_errno(error_log_level, errno, "Failed to set mount source for \"%s\" to \"%s\": %m", type, what);
|
||||
|
||||
if (FLAGS_SET(f, MS_RDONLY))
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_FLAG, "ro", NULL, 0) < 0)
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_FLAG, "ro", /* value= */ NULL, /* aux= */ 0) < 0)
|
||||
return log_full_errno(error_log_level, errno, "Failed to set read only mount flag for \"%s\": %m", type);
|
||||
|
||||
for (const char *p = o;;) {
|
||||
@@ -2131,18 +2131,18 @@ int make_fsmount(
|
||||
*eq = 0;
|
||||
eq++;
|
||||
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, word, eq, 0) < 0)
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, word, eq, /* aux= */ 0) < 0)
|
||||
return log_full_errno(error_log_level, errno, "Failed to set mount option \"%s=%s\" for \"%s\": %m", word, eq, type);
|
||||
} else {
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_FLAG, word, NULL, 0) < 0)
|
||||
if (fsconfig(fs_fd, FSCONFIG_SET_FLAG, word, /* value= */ NULL, /* aux= */ 0) < 0)
|
||||
return log_full_errno(error_log_level, errno, "Failed to set mount flag \"%s\" for \"%s\": %m", word, type);
|
||||
}
|
||||
}
|
||||
|
||||
if (fsconfig(fs_fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0) < 0)
|
||||
if (fsconfig(fs_fd, FSCONFIG_CMD_CREATE, /* key= */ NULL, /* value= */ NULL, /* aux= */ 0) < 0)
|
||||
return log_full_errno(error_log_level, errno, "Failed to realize fs fd for \"%s\" (\"%s\"): %m", what, type);
|
||||
|
||||
mnt_fd = fsmount(fs_fd, FSMOUNT_CLOEXEC, 0);
|
||||
mnt_fd = fsmount(fs_fd, FSMOUNT_CLOEXEC, /* attr_flags= */ 0);
|
||||
if (mnt_fd < 0)
|
||||
return log_full_errno(error_log_level, errno, "Failed to create mount fd for \"%s\" (\"%s\"): %m", what, type);
|
||||
|
||||
|
||||
+5
-5
@@ -904,7 +904,7 @@ static int mstack_make_overlayfs(
|
||||
report_errno_and_exit(errno_pipe_fds[1], /* error= */ 0);
|
||||
}
|
||||
|
||||
_cleanup_close_ int overlayfs_mnt_fd = fsmount(sb_fd, FSMOUNT_CLOEXEC, 0);
|
||||
_cleanup_close_ int overlayfs_mnt_fd = fsmount(sb_fd, FSMOUNT_CLOEXEC, /* attr_flags= */ 0);
|
||||
if (overlayfs_mnt_fd < 0)
|
||||
return log_debug_errno(errno, "Failed to create mount fd: %m");
|
||||
|
||||
@@ -951,16 +951,16 @@ int mstack_make_mounts(
|
||||
if (sb_fd < 0)
|
||||
return log_debug_errno(errno, "Failed to create tmpfs: %m");
|
||||
|
||||
if (fsconfig(sb_fd, FSCONFIG_SET_STRING, "source", mstack->path, 0) < 0)
|
||||
if (fsconfig(sb_fd, FSCONFIG_SET_STRING, "source", mstack->path, /* aux= */ 0) < 0)
|
||||
return log_debug_errno(errno, "Failed to set mount source: %m");
|
||||
|
||||
if (fsconfig(sb_fd, FSCONFIG_SET_STRING, "mode", "0755", 0) < 0)
|
||||
if (fsconfig(sb_fd, FSCONFIG_SET_STRING, "mode", "0755", /* aux= */ 0) < 0)
|
||||
return log_debug_errno(errno, "Failed to set mount source: %m");
|
||||
|
||||
if (fsconfig(sb_fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0) < 0)
|
||||
if (fsconfig(sb_fd, FSCONFIG_CMD_CREATE, /* key= */ NULL, /* value= */ NULL, /* aux= */ 0) < 0)
|
||||
return log_debug_errno(errno, "Failed to realize tmpfs: %m");
|
||||
|
||||
mstack->root_mount_fd = fsmount(sb_fd, FSMOUNT_CLOEXEC, 0);
|
||||
mstack->root_mount_fd = fsmount(sb_fd, FSMOUNT_CLOEXEC, /* attr_flags= */ 0);
|
||||
if (mstack->root_mount_fd < 0)
|
||||
return log_debug_errno(errno, "Failed to create mount fd: %m");
|
||||
|
||||
|
||||
@@ -72,7 +72,8 @@ int apply_numa_policy(const NUMAPolicy *policy) {
|
||||
|
||||
assert(policy);
|
||||
|
||||
if (get_mempolicy(NULL, NULL, 0, NULL, 0) < 0 && errno == ENOSYS)
|
||||
if (get_mempolicy(/* mode= */ NULL, /* nodemask= */ NULL, /* maxnode= */ 0,
|
||||
/* addr= */ NULL, /* flags= */ 0) < 0 && errno == ENOSYS)
|
||||
/* NUMA syscall interface not available (kernel compiled without NUMA support).
|
||||
* Return -ENOSYS so callers can distinguish this from -EOPNOTSUPP, which we
|
||||
* return below when the syscall interface exists but the requested policy is
|
||||
|
||||
@@ -2228,7 +2228,7 @@ static int add_personality_rules(scmp_filter_ctx seccomp, uint32_t arch, uint32_
|
||||
assert((value & ~mask) == 0);
|
||||
|
||||
BIT_FOREACH(bit, value) {
|
||||
r = add_personality_rule(seccomp, arch, INDEX_TO_MASK(uint32_t, bit), 0);
|
||||
r = add_personality_rule(seccomp, arch, INDEX_TO_MASK(uint32_t, bit), /* value= */ 0);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@@ -2281,7 +2281,7 @@ int seccomp_restrict_read_implies_exec(void) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = add_personality_rules(seccomp, arch, READ_IMPLIES_EXEC, 0);
|
||||
r = add_personality_rules(seccomp, arch, READ_IMPLIES_EXEC, /* value= */ 0);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ bool uapi16_name_is_valid(const char *s) {
|
||||
if (!path_is_normalized(s))
|
||||
return false;
|
||||
|
||||
if (string_has_cc(s, NULL))
|
||||
if (string_has_cc(s, /* ok= */ NULL))
|
||||
return false;
|
||||
|
||||
if (uapi16_manifest_filename_is_reserved(s))
|
||||
@@ -130,7 +130,7 @@ bool uapi16_xattr_name_is_valid(const char *s) {
|
||||
|
||||
return !isempty(s) &&
|
||||
utf8_is_valid(s) &&
|
||||
!string_has_cc(s, NULL);
|
||||
!string_has_cc(s, /* ok= */ NULL);
|
||||
}
|
||||
|
||||
static int json_dispatch_uapi16_name(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) {
|
||||
@@ -426,7 +426,7 @@ int uapi16_xattrs_build_json(const Uapi16Xattr *x, size_t n, sd_json_variant **r
|
||||
assert(ret);
|
||||
|
||||
_cleanup_(sd_json_variant_unrefp) sd_json_variant *ns = NULL;
|
||||
r = sd_json_variant_new_object(&ns, NULL, 0);
|
||||
r = sd_json_variant_new_object(&ns, /* array= */ NULL, 0);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
+2
-2
@@ -995,7 +995,7 @@ static int resolve_mutable_directory(
|
||||
/* This also creates, e.g., /var/lib/extensions.mutable/usr if needed and all parent
|
||||
* directories plus it also works when the last part is a symlink to the real /usr but we
|
||||
* can't use chase_and_open here because it does not behave the same. */
|
||||
r = chase(path, root, CHASE_MKDIR_0755|CHASE_MUST_BE_DIRECTORY|CHASE_PREFIX_ROOT, /* ret_path */ NULL, &path_fd);
|
||||
r = chase(path, root, CHASE_MKDIR_0755|CHASE_MUST_BE_DIRECTORY|CHASE_PREFIX_ROOT, /* ret_path= */ NULL, &path_fd);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to chase/create base directory '%s/%s': %m", strempty(root), skip_leading_slash(path));
|
||||
|
||||
@@ -2351,7 +2351,7 @@ static int merge_subprocess(
|
||||
if (old_origin_content)
|
||||
continue;
|
||||
|
||||
r = read_full_file(f, &buf, /* ret_size */ NULL);
|
||||
r = read_full_file(f, &buf, /* ret_size= */ NULL);
|
||||
if (r < 0) {
|
||||
log_debug_errno(r, "Failed to open '%s', continuing search: %m", f);
|
||||
continue;
|
||||
|
||||
@@ -102,7 +102,7 @@ TEST(subvol) {
|
||||
ASSERT_OK_POSITIVE(btrfs_subvol_get_read_only_fd(test1_fd));
|
||||
ASSERT_OK(btrfs_subvol_set_read_only_fd(test1_fd, false));
|
||||
ASSERT_OK_ZERO(btrfs_subvol_get_read_only_fd(test1_fd));
|
||||
ASSERT_OK(btrfs_subvol_snapshot_at(test1_fd, /* from= */ NULL, dir_fd, "test5", 0));
|
||||
ASSERT_OK(btrfs_subvol_snapshot_at(test1_fd, /* from= */ NULL, dir_fd, "test5", /* flags= */ 0));
|
||||
|
||||
dev_t devnum_fd = 0, devnum_path = 0;
|
||||
int r = btrfs_get_block_device_fd(dir_fd, &devnum_fd);
|
||||
|
||||
@@ -1298,7 +1298,7 @@ TEST(chase_and_open_cloexec) {
|
||||
_cleanup_free_ char *p = NULL;
|
||||
int fl;
|
||||
|
||||
ASSERT_OK(tfd = mkdtemp_open(NULL, 0, &t));
|
||||
ASSERT_OK(tfd = mkdtemp_open(/* template= */ NULL, /* flags= */ 0, &t));
|
||||
ASSERT_OK_ERRNO(mkdirat(tfd, "dir", 0755));
|
||||
|
||||
/* O_CLOEXEC is implied, whether requested or not, on the shortcut and on the full chase */
|
||||
|
||||
@@ -122,8 +122,8 @@ TEST(unit_concat_strv) {
|
||||
|
||||
TEST(service_restart_backoff_enabled) {
|
||||
ASSERT_TRUE(service_restart_backoff_enabled(10 * USEC_PER_SEC, 160 * USEC_PER_SEC, 4));
|
||||
ASSERT_FALSE(service_restart_backoff_enabled(10 * USEC_PER_SEC, 160 * USEC_PER_SEC, 0));
|
||||
ASSERT_FALSE(service_restart_backoff_enabled(0, 160 * USEC_PER_SEC, 4));
|
||||
ASSERT_FALSE(service_restart_backoff_enabled(10 * USEC_PER_SEC, 160 * USEC_PER_SEC, /* restart_steps= */ 0));
|
||||
ASSERT_FALSE(service_restart_backoff_enabled(/* restart_usec= */ 0, 160 * USEC_PER_SEC, 4));
|
||||
ASSERT_FALSE(service_restart_backoff_enabled(10 * USEC_PER_SEC, USEC_INFINITY, 4));
|
||||
ASSERT_FALSE(service_restart_backoff_enabled(160 * USEC_PER_SEC, 160 * USEC_PER_SEC, 4));
|
||||
}
|
||||
@@ -138,9 +138,9 @@ TEST(service_restart_usec_nth) {
|
||||
ASSERT_EQ(service_restart_usec_nth(1 * USEC_PER_SEC, 64 * USEC_PER_SEC, 6, 6), 32 * USEC_PER_SEC);
|
||||
ASSERT_EQ(service_restart_usec_nth(5 * USEC_PER_SEC, 60 * USEC_PER_SEC, 3, 2), 11447142u);
|
||||
|
||||
ASSERT_EQ(service_restart_usec_nth(10 * USEC_PER_SEC, 160 * USEC_PER_SEC, 0, 3), 10 * USEC_PER_SEC);
|
||||
ASSERT_EQ(service_restart_usec_nth(10 * USEC_PER_SEC, 160 * USEC_PER_SEC, /* restart_steps= */ 0, 3), 10 * USEC_PER_SEC);
|
||||
ASSERT_EQ(service_restart_usec_nth(10 * USEC_PER_SEC, USEC_INFINITY, 4, 3), 10 * USEC_PER_SEC);
|
||||
ASSERT_EQ(service_restart_usec_nth(0, 160 * USEC_PER_SEC, 4, 3), 0u);
|
||||
ASSERT_EQ(service_restart_usec_nth(/* restart_usec= */ 0, 160 * USEC_PER_SEC, 4, 3), 0u);
|
||||
ASSERT_EQ(service_restart_usec_nth(160 * USEC_PER_SEC, 160 * USEC_PER_SEC, 4, 3), 160 * USEC_PER_SEC);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ int main(int argc, char *argv[]) {
|
||||
ASSERT_TRUE(IN_SET(r, -EOPNOTSUPP, -EBADF));
|
||||
if (r == -EBADF) {
|
||||
safe_close(fd);
|
||||
ASSERT_OK_ERRNO(fd = pidfd_open(getpid_cached(), 0));
|
||||
ASSERT_OK_ERRNO(fd = pidfd_open(getpid_cached(), /* flags= */ 0));
|
||||
ASSERT_OK(sd_pidfd_get_inode_id(fd, /* ret= */ NULL));
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ TEST(encode_devnode_name_truncated) {
|
||||
|
||||
/* A zero-sized buffer is rejected without being touched, a one-byte buffer only holds the NUL */
|
||||
memset(buf, 'X', sizeof(buf));
|
||||
ASSERT_ERROR(encode_devnode_name("abc", buf, 0), EINVAL);
|
||||
ASSERT_ERROR(encode_devnode_name("abc", buf, /* len= */ 0), EINVAL);
|
||||
ASSERT_EQ(buf[0], 'X');
|
||||
|
||||
memset(buf, 'X', sizeof(buf));
|
||||
|
||||
@@ -40,7 +40,7 @@ TEST(extension_match_host) {
|
||||
|
||||
host_init(&h);
|
||||
|
||||
ASSERT_OK(tfd = mkdtemp_open(NULL, O_DIRECTORY, &t));
|
||||
ASSERT_OK(tfd = mkdtemp_open(/* template= */ NULL, O_DIRECTORY, &t));
|
||||
ASSERT_OK(write_string_file_at(tfd, "ext.raw", "x", WRITE_STRING_FILE_CREATE));
|
||||
_cleanup_free_ char *p = ASSERT_NOT_NULL(path_join(t, "ext.raw"));
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ TEST(fd_move_above_stdio) {
|
||||
ASSERT_OK(close_nointr(/* fd= */ 0));
|
||||
|
||||
new_fd = ASSERT_OK_ZERO(xopenat(AT_FDCWD, "/dev/null", O_RDONLY));
|
||||
ASSERT_OK(fd_cloexec(new_fd, false));
|
||||
ASSERT_OK(fd_cloexec(new_fd, /* cloexec= */ false));
|
||||
|
||||
new_fd = fd_move_above_stdio(new_fd);
|
||||
ASSERT_GE(new_fd, 3);
|
||||
@@ -257,7 +257,7 @@ TEST(rearrange_stdio) {
|
||||
ASSERT_OK_EQ_ERRNO(read(0, buffer, sizeof(buffer)), 6);
|
||||
ASSERT_EQ(memcmp(buffer, "foobar", 6), 0);
|
||||
|
||||
ASSERT_OK(fd_cloexec(1, true)); /* stays in place, but the flag must still be cleared */
|
||||
ASSERT_OK(fd_cloexec(1, /* cloexec= */ true)); /* stays in place, but the flag must still be cleared */
|
||||
ASSERT_OK(rearrange_stdio(-EBADF, 1, 2));
|
||||
assert_stdio_not_cloexec();
|
||||
ASSERT_ERROR_ERRNO(write(1, "a", 1), ENOSPC);
|
||||
|
||||
@@ -35,7 +35,7 @@ TEST(fdset_new_fill) {
|
||||
ASSERT_ERROR(fd_validate(fd), EBADF);
|
||||
|
||||
fd = ASSERT_OK(xopenat(AT_FDCWD, "/dev/null", O_RDONLY));
|
||||
ASSERT_OK(fd_cloexec(fd, false));
|
||||
ASSERT_OK(fd_cloexec(fd, /* cloexec= */ false));
|
||||
|
||||
ASSERT_OK(fdset_new_fill(/* filter_cloexec= */ 1, &fdset));
|
||||
ASSERT_FALSE(fdset_contains(fdset, fd));
|
||||
|
||||
@@ -622,25 +622,25 @@ TEST(xfopenat_empty_path) {
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
_cleanup_free_ char *line = NULL;
|
||||
|
||||
ASSERT_OK(tfd = mkdtemp_open(NULL, 0, &t));
|
||||
ASSERT_OK(tfd = mkdtemp_open(/* template= */ NULL, /* flags= */ 0, &t));
|
||||
ASSERT_OK(write_string_file_at(tfd, "file", "hello", WRITE_STRING_FILE_CREATE));
|
||||
ASSERT_OK(fd = xopenat(tfd, "file", O_RDONLY));
|
||||
|
||||
/* A NULL or empty path reopens the fd for reading... */
|
||||
ASSERT_OK(xfopenat(fd, /* path= */ NULL, "re", 0, &f));
|
||||
ASSERT_OK(xfopenat(fd, /* path= */ NULL, "re", /* open_flags= */ 0, &f));
|
||||
ASSERT_OK(read_line(f, SIZE_MAX, &line));
|
||||
ASSERT_STREQ(line, "hello");
|
||||
f = safe_fclose(f);
|
||||
ASSERT_OK(xfopenat(fd, "", "re", 0, &f));
|
||||
ASSERT_OK(xfopenat(fd, "", "re", /* open_flags= */ 0, &f));
|
||||
f = safe_fclose(f);
|
||||
|
||||
/* ...but creating something needs a name */
|
||||
ASSERT_ERROR(xfopenat(tfd, "", "we", 0, &f), ENOENT);
|
||||
ASSERT_ERROR(xfopenat(tfd, /* path= */ NULL, "ae", 0, &f), ENOENT);
|
||||
ASSERT_ERROR(xfopenat(tfd, "", "we", /* open_flags= */ 0, &f), ENOENT);
|
||||
ASSERT_ERROR(xfopenat(tfd, /* path= */ NULL, "ae", /* open_flags= */ 0, &f), ENOENT);
|
||||
|
||||
/* AT_FDCWD has no fd to reopen, "" fails like with fopen() */
|
||||
ASSERT_ERROR(xfopenat(AT_FDCWD, "", "re", 0, &f), ENOENT);
|
||||
ASSERT_ERROR(xfopenat(AT_FDCWD, /* path= */ NULL, "re", 0, &f), EBADF);
|
||||
ASSERT_ERROR(xfopenat(AT_FDCWD, "", "re", /* open_flags= */ 0, &f), ENOENT);
|
||||
ASSERT_ERROR(xfopenat(AT_FDCWD, /* path= */ NULL, "re", /* open_flags= */ 0, &f), EBADF);
|
||||
ASSERT_ERROR(fopen_unlocked("", "re", &f), ENOENT);
|
||||
ASSERT_ERROR(read_one_line_file("", &line), ENOENT);
|
||||
}
|
||||
@@ -932,7 +932,7 @@ TEST(xfopenat_dangling_symlink) {
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
_cleanup_close_ int tfd = -EBADF;
|
||||
|
||||
ASSERT_OK(tfd = mkdtemp_open(NULL, 0, &t));
|
||||
ASSERT_OK(tfd = mkdtemp_open(/* template= */ NULL, /* flags= */ 0, &t));
|
||||
ASSERT_OK_ERRNO(symlinkat("target", tfd, "link"));
|
||||
|
||||
/* The creating modes go through openat_report_new() now, which refuses to create through a dangling symlink */
|
||||
|
||||
@@ -748,7 +748,7 @@ TEST(xopenat_tmpfile) {
|
||||
_cleanup_close_ int tfd = -EBADF, fd = -EBADF;
|
||||
struct stat st;
|
||||
|
||||
ASSERT_OK(tfd = mkdtemp_open(NULL, 0, &t));
|
||||
ASSERT_OK(tfd = mkdtemp_open(/* template= */ NULL, /* flags= */ 0, &t));
|
||||
|
||||
BLOCK_WITH_UMASK(0022);
|
||||
|
||||
@@ -803,7 +803,7 @@ TEST(xopenat_empty_path) {
|
||||
_cleanup_(rm_rf_physical_and_freep) char *t = NULL;
|
||||
_cleanup_close_ int tfd = -EBADF, fd = -EBADF;
|
||||
|
||||
ASSERT_OK(tfd = mkdtemp_open(NULL, 0, &t));
|
||||
ASSERT_OK(tfd = mkdtemp_open(/* template= */ NULL, /* flags= */ 0, &t));
|
||||
|
||||
/* Without XO_EMPTY_PATH an empty path is a missing name, as for open("") */
|
||||
ASSERT_ERROR(xopenat(tfd, "", O_RDONLY|O_DIRECTORY), ENOENT);
|
||||
@@ -818,20 +818,20 @@ TEST(xopenat_empty_path) {
|
||||
|
||||
/* With the flag it reopens the directory itself, like AT_EMPTY_PATH... */
|
||||
ASSERT_OK(fd = xopenat_full(tfd, "", O_RDONLY|O_DIRECTORY, XO_EMPTY_PATH, MODE_INVALID));
|
||||
ASSERT_OK_POSITIVE(inode_same_at(tfd, NULL, fd, NULL, AT_EMPTY_PATH));
|
||||
ASSERT_OK_POSITIVE(inode_same_at(tfd, /* filea= */ NULL, fd, /* fileb= */ NULL, AT_EMPTY_PATH));
|
||||
fd = safe_close(fd);
|
||||
|
||||
ASSERT_OK(fd = xopenat_full(tfd, /* path= */ NULL, O_RDONLY|O_DIRECTORY, XO_EMPTY_PATH, MODE_INVALID));
|
||||
ASSERT_OK_POSITIVE(inode_same_at(tfd, NULL, fd, NULL, AT_EMPTY_PATH));
|
||||
ASSERT_OK_POSITIVE(inode_same_at(tfd, /* filea= */ NULL, fd, /* fileb= */ NULL, AT_EMPTY_PATH));
|
||||
fd = safe_close(fd);
|
||||
|
||||
ASSERT_OK(fd = xopenat_full(XAT_FDROOT, "", O_RDONLY|O_DIRECTORY, XO_EMPTY_PATH, MODE_INVALID));
|
||||
ASSERT_OK_POSITIVE(inode_same_at(AT_FDCWD, "/", fd, NULL, AT_EMPTY_PATH));
|
||||
ASSERT_OK_POSITIVE(inode_same_at(AT_FDCWD, "/", fd, /* fileb= */ NULL, AT_EMPTY_PATH));
|
||||
fd = safe_close(fd);
|
||||
|
||||
/* ...and a non-empty path is opened as usual */
|
||||
ASSERT_OK(fd = xopenat_full(tfd, "file", O_RDWR|O_CREAT|O_EXCL, XO_EMPTY_PATH, 0644));
|
||||
ASSERT_OK_POSITIVE(inode_same_at(tfd, "file", fd, NULL, AT_EMPTY_PATH));
|
||||
ASSERT_OK_POSITIVE(inode_same_at(tfd, "file", fd, /* fileb= */ NULL, AT_EMPTY_PATH));
|
||||
}
|
||||
|
||||
TEST(xopenat_nocow) {
|
||||
@@ -1157,7 +1157,7 @@ TEST(xopenat_cloexec) {
|
||||
_cleanup_close_ int tfd = -EBADF, fd = -EBADF;
|
||||
int fl;
|
||||
|
||||
ASSERT_OK(tfd = mkdtemp_open(NULL, 0, &t));
|
||||
ASSERT_OK(tfd = mkdtemp_open(/* template= */ NULL, /* flags= */ 0, &t));
|
||||
|
||||
/* O_CLOEXEC is implied, whether requested or not */
|
||||
ASSERT_OK(fd = xopenat(tfd, "regular", O_RDWR|O_CREAT|O_EXCL));
|
||||
@@ -1170,7 +1170,7 @@ TEST(xopenat_cloexec) {
|
||||
ASSERT_TRUE(FLAGS_SET(fl, FD_CLOEXEC));
|
||||
fd = safe_close(fd);
|
||||
|
||||
ASSERT_OK(fd = openat_report_new(tfd, "regular", O_RDWR|O_CREAT, 0644, NULL));
|
||||
ASSERT_OK(fd = openat_report_new(tfd, "regular", O_RDWR|O_CREAT, 0644, /* ret_newly_created= */ NULL));
|
||||
ASSERT_OK_ERRNO(fl = fcntl(fd, F_GETFD));
|
||||
ASSERT_TRUE(FLAGS_SET(fl, FD_CLOEXEC));
|
||||
fd = safe_close(fd);
|
||||
|
||||
@@ -1624,7 +1624,7 @@ TEST(dependency_mask) {
|
||||
|
||||
write_vendor_file("system/masked-dep.service", WANTED_BY_MULTI_USER);
|
||||
|
||||
do_enable(0, STRV_MAKE("masked-dep.service"));
|
||||
do_enable(/* flags= */ 0, STRV_MAKE("masked-dep.service"));
|
||||
assert_state("masked-dep.service", UNIT_FILE_ENABLED);
|
||||
|
||||
entry = strjoina(vendor_root, ETC_WANTS"masked-dep.service");
|
||||
@@ -1634,7 +1634,7 @@ TEST(dependency_mask) {
|
||||
ASSERT_OK_ERRNO(symlink("/dev/null", entry));
|
||||
assert_state("masked-dep.service", UNIT_FILE_DISABLED);
|
||||
|
||||
do_disable(0, STRV_MAKE("masked-dep.service"));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE("masked-dep.service"));
|
||||
ASSERT_TRUE(is_dependency_mask(entry));
|
||||
assert_state("masked-dep.service", UNIT_FILE_DISABLED);
|
||||
}
|
||||
@@ -1650,14 +1650,14 @@ TEST(dependency_mask_empty_file) {
|
||||
empty = strjoina(vendor_root, "/etc/empty-mask");
|
||||
ASSERT_OK(touch(empty));
|
||||
|
||||
do_enable(0, STRV_MAKE("empty-mask-dep.service"));
|
||||
do_enable(/* flags= */ 0, STRV_MAKE("empty-mask-dep.service"));
|
||||
|
||||
entry = strjoina(vendor_root, ETC_WANTS"empty-mask-dep.service");
|
||||
ASSERT_OK_ERRNO(unlink(entry));
|
||||
ASSERT_OK_ERRNO(symlink("/etc/empty-mask", entry));
|
||||
assert_state("empty-mask-dep.service", UNIT_FILE_DISABLED);
|
||||
|
||||
do_disable(0, STRV_MAKE("empty-mask-dep.service"));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE("empty-mask-dep.service"));
|
||||
ASSERT_OK(readlink_malloc(entry, &dest));
|
||||
ASSERT_STREQ(dest, "/etc/empty-mask");
|
||||
assert_state("empty-mask-dep.service", UNIT_FILE_DISABLED);
|
||||
@@ -1675,7 +1675,7 @@ TEST(disable_template_keeps_instance_mask) {
|
||||
ASSERT_OK_ERRNO(symlink("/dev/null", mask));
|
||||
assert_state("masked-tmpl@inst.service", UNIT_FILE_MASKED);
|
||||
|
||||
do_disable(0, STRV_MAKE("masked-tmpl@.service"));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE("masked-tmpl@.service"));
|
||||
ASSERT_TRUE(symlink_exists(mask));
|
||||
assert_state("masked-tmpl@inst.service", UNIT_FILE_MASKED);
|
||||
}
|
||||
@@ -1689,7 +1689,7 @@ TEST(dependency_shadow) {
|
||||
|
||||
write_vendor_file("system/shadowed-dep.service", WANTED_BY_MULTI_USER);
|
||||
|
||||
do_enable(0, STRV_MAKE("shadowed-dep.service"));
|
||||
do_enable(/* flags= */ 0, STRV_MAKE("shadowed-dep.service"));
|
||||
assert_state("shadowed-dep.service", UNIT_FILE_ENABLED);
|
||||
|
||||
shadow = strjoina(vendor_root, SYSTEM_CONFIG_UNIT_DIR".control/multi-user.target.wants/",
|
||||
@@ -1707,7 +1707,7 @@ TEST(dependency_shadow_symlink) {
|
||||
|
||||
write_vendor_file("system/shadow-linked-dep.service", WANTED_BY_MULTI_USER);
|
||||
|
||||
do_enable(0, STRV_MAKE("shadow-linked-dep.service"));
|
||||
do_enable(/* flags= */ 0, STRV_MAKE("shadow-linked-dep.service"));
|
||||
|
||||
link = strjoina(vendor_root, "/run/systemd/system.control/multi-user.target.wants/",
|
||||
"shadow-linked-dep.service");
|
||||
@@ -1726,7 +1726,7 @@ TEST(dependency_dir_not_directory) {
|
||||
"[Install]\n"
|
||||
"WantedBy=file-wants.target\n");
|
||||
|
||||
do_enable(0, STRV_MAKE("file-wants-dep.service"));
|
||||
do_enable(/* flags= */ 0, STRV_MAKE("file-wants-dep.service"));
|
||||
|
||||
file = strjoina(vendor_root, "/run/systemd/system.control/file-wants.target.wants");
|
||||
ASSERT_OK(mkdir_parents(file, 0755));
|
||||
@@ -1756,7 +1756,7 @@ TEST(dependency_unit_dir_symlink) {
|
||||
unit = strjoina(linked_root, "/usr/lib/systemd/system/linked-dir-dep.service");
|
||||
ASSERT_OK(write_string_file(unit, WANTED_BY_MULTI_USER, WRITE_STRING_FILE_CREATE));
|
||||
|
||||
ASSERT_OK(unit_file_enable(RUNTIME_SCOPE_SYSTEM, 0, linked_root, STRV_MAKE("linked-dir-dep.service"),
|
||||
ASSERT_OK(unit_file_enable(RUNTIME_SCOPE_SYSTEM, /* flags= */ 0, linked_root, STRV_MAKE("linked-dir-dep.service"),
|
||||
&changes, &n_changes));
|
||||
ASSERT_OK(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, linked_root, "linked-dir-dep.service", &state));
|
||||
ASSERT_EQ(state, UNIT_FILE_ENABLED);
|
||||
@@ -1770,7 +1770,7 @@ TEST(dependency_mask_shadowed_by_symlink) {
|
||||
|
||||
write_vendor_file("system/mask-shadowed-dep.service", WANTED_BY_MULTI_USER);
|
||||
|
||||
do_enable(0, STRV_MAKE("mask-shadowed-dep.service"));
|
||||
do_enable(/* flags= */ 0, STRV_MAKE("mask-shadowed-dep.service"));
|
||||
|
||||
entry = strjoina(vendor_root, ETC_WANTS"mask-shadowed-dep.service");
|
||||
ASSERT_OK_ERRNO(unlink(entry));
|
||||
@@ -1788,7 +1788,7 @@ TEST(dependency_shadow_mask) {
|
||||
|
||||
write_vendor_file("system/shadow-masked-dep.service", WANTED_BY_MULTI_USER);
|
||||
|
||||
do_enable(0, STRV_MAKE("shadow-masked-dep.service"));
|
||||
do_enable(/* flags= */ 0, STRV_MAKE("shadow-masked-dep.service"));
|
||||
assert_state("shadow-masked-dep.service", UNIT_FILE_ENABLED);
|
||||
|
||||
/* If the mask in /run/ counted as an enablement symlink, the unit would be enabled-runtime. */
|
||||
@@ -1818,7 +1818,7 @@ TEST(vendor_enable) {
|
||||
|
||||
/* Disabling it cannot remove the vendor symlink, so it has to shadow it with a symlink to /dev/null
|
||||
* in the configuration directory. */
|
||||
ASSERT_OK(unit_file_disable(RUNTIME_SCOPE_SYSTEM, 0, vendor_root,
|
||||
ASSERT_OK(unit_file_disable(RUNTIME_SCOPE_SYSTEM, /* flags= */ 0, vendor_root,
|
||||
STRV_MAKE("vendor-enabled.service"), &changes, &n_changes));
|
||||
ASSERT_EQ(n_changes, 1u);
|
||||
ASSERT_EQ(changes[0].type, INSTALL_CHANGE_MASK_DEPENDENCY);
|
||||
@@ -1833,12 +1833,12 @@ TEST(vendor_enable) {
|
||||
assert_state("vendor-enabled.service", UNIT_FILE_DISABLED);
|
||||
|
||||
/* Disabling twice must not undo the mask. */
|
||||
do_disable(0, STRV_MAKE("vendor-enabled.service"));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE("vendor-enabled.service"));
|
||||
ASSERT_TRUE(is_dependency_mask(mask));
|
||||
assert_state("vendor-enabled.service", UNIT_FILE_DISABLED);
|
||||
|
||||
/* Enabling drops the mask again. */
|
||||
do_enable(0, STRV_MAKE("vendor-enabled.service"));
|
||||
do_enable(/* flags= */ 0, STRV_MAKE("vendor-enabled.service"));
|
||||
ASSERT_TRUE(symlink_exists(mask));
|
||||
ASSERT_FALSE(is_dependency_mask(mask));
|
||||
assert_state("vendor-enabled.service", UNIT_FILE_ENABLED);
|
||||
@@ -1861,10 +1861,10 @@ TEST(vendor_mask_in_unrelated_target) {
|
||||
|
||||
assert_state("vendor-two-targets.service", UNIT_FILE_ENABLED);
|
||||
|
||||
do_disable(0, STRV_MAKE("vendor-two-targets.service"));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE("vendor-two-targets.service"));
|
||||
assert_state("vendor-two-targets.service", UNIT_FILE_DISABLED);
|
||||
|
||||
do_enable(0, STRV_MAKE("vendor-two-targets.service"));
|
||||
do_enable(/* flags= */ 0, STRV_MAKE("vendor-two-targets.service"));
|
||||
ASSERT_TRUE(is_dependency_mask(mask));
|
||||
assert_state("vendor-two-targets.service", UNIT_FILE_ENABLED);
|
||||
}
|
||||
@@ -1880,7 +1880,7 @@ TEST(vendor_preset_leaves_vendor_enablement_alone) {
|
||||
write_vendor_symlink("multi-user.target.wants/vendor-preset-off.service", "../vendor-preset-off.service");
|
||||
write_vendor_file("system-preset/13-vendor-off.preset", "disable vendor-preset-off.service\n");
|
||||
|
||||
do_preset(0, STRV_MAKE("vendor-preset-off.service"));
|
||||
do_preset(/* flags= */ 0, STRV_MAKE("vendor-preset-off.service"));
|
||||
|
||||
vendor_link = strjoina(vendor_root, VENDOR_WANTS"vendor-preset-off.service");
|
||||
mask = strjoina(vendor_root, ETC_WANTS"vendor-preset-off.service");
|
||||
@@ -1889,13 +1889,13 @@ TEST(vendor_preset_leaves_vendor_enablement_alone) {
|
||||
assert_state("vendor-preset-off.service", UNIT_FILE_ENABLED);
|
||||
|
||||
/* An explicit disable is a different matter. */
|
||||
do_disable(0, STRV_MAKE("vendor-preset-off.service"));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE("vendor-preset-off.service"));
|
||||
ASSERT_TRUE(is_dependency_mask(mask));
|
||||
assert_state("vendor-preset-off.service", UNIT_FILE_DISABLED);
|
||||
|
||||
/* And presetting it back to "enable" clears that mask again. */
|
||||
write_vendor_file("system-preset/13-vendor-off.preset", "enable vendor-preset-off.service\n");
|
||||
do_preset(0, STRV_MAKE("vendor-preset-off.service"));
|
||||
do_preset(/* flags= */ 0, STRV_MAKE("vendor-preset-off.service"));
|
||||
|
||||
ASSERT_FALSE(is_dependency_mask(mask));
|
||||
assert_state("vendor-preset-off.service", UNIT_FILE_ENABLED);
|
||||
@@ -1915,7 +1915,7 @@ TEST(vendor_symlinked_dependency_dir_is_not_followed) {
|
||||
|
||||
assert_state("vendor-escape.service", UNIT_FILE_DISABLED);
|
||||
|
||||
do_disable(0, STRV_MAKE("vendor-escape.service"));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE("vendor-escape.service"));
|
||||
ASSERT_FALSE(symlink_exists(strjoina(vendor_root, SYSTEM_CONFIG_UNIT_DIR"/escape.target.wants/vendor-escape.service")));
|
||||
}
|
||||
|
||||
@@ -1937,11 +1937,11 @@ TEST(vendor_requires_and_upholds) {
|
||||
write_vendor_symlink(rel, strjoina("../", name));
|
||||
assert_state(name, UNIT_FILE_ENABLED);
|
||||
|
||||
do_disable(0, STRV_MAKE(name));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE(name));
|
||||
ASSERT_TRUE(is_dependency_mask(mask));
|
||||
assert_state(name, UNIT_FILE_DISABLED);
|
||||
|
||||
do_enable(0, STRV_MAKE(name));
|
||||
do_enable(/* flags= */ 0, STRV_MAKE(name));
|
||||
ASSERT_FALSE(is_dependency_mask(mask));
|
||||
assert_state(name, UNIT_FILE_ENABLED);
|
||||
}
|
||||
@@ -1963,14 +1963,14 @@ TEST(vendor_template_instance) {
|
||||
assert_state("vendor-tmpl@inst.service", UNIT_FILE_ENABLED);
|
||||
|
||||
/* Disabling the template must reach the instance the vendor wired up. */
|
||||
do_disable(0, STRV_MAKE("vendor-tmpl@.service"));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE("vendor-tmpl@.service"));
|
||||
|
||||
mask = strjoina(vendor_root, ETC_WANTS"vendor-tmpl@inst.service");
|
||||
ASSERT_TRUE(is_dependency_mask(mask));
|
||||
ASSERT_TRUE(symlink_exists(strjoina(vendor_root, VENDOR_WANTS"vendor-tmpl@inst.service")));
|
||||
assert_state("vendor-tmpl@inst.service", UNIT_FILE_DISABLED);
|
||||
|
||||
do_enable(0, STRV_MAKE("vendor-tmpl@.service"));
|
||||
do_enable(/* flags= */ 0, STRV_MAKE("vendor-tmpl@.service"));
|
||||
ASSERT_TRUE(symlink_exists(strjoina(vendor_root, ETC_WANTS"vendor-tmpl@dflt.service")));
|
||||
ASSERT_FALSE(symlink_exists(mask));
|
||||
assert_state("vendor-tmpl@inst.service", UNIT_FILE_ENABLED);
|
||||
@@ -1991,13 +1991,13 @@ TEST(vendor_also) {
|
||||
"WantedBy=sockets.target\n");
|
||||
write_vendor_symlink("sockets.target.wants/vendor-also.socket", "../vendor-also.socket");
|
||||
|
||||
do_disable(0, STRV_MAKE("vendor-also.service"));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE("vendor-also.service"));
|
||||
|
||||
mask = strjoina(vendor_root, SYSTEM_CONFIG_UNIT_DIR"/sockets.target.wants/vendor-also.socket");
|
||||
ASSERT_TRUE(is_dependency_mask(mask));
|
||||
assert_state("vendor-also.socket", UNIT_FILE_DISABLED);
|
||||
|
||||
do_enable(0, STRV_MAKE("vendor-also.service"));
|
||||
do_enable(/* flags= */ 0, STRV_MAKE("vendor-also.service"));
|
||||
ASSERT_FALSE(is_dependency_mask(mask));
|
||||
assert_state("vendor-also.socket", UNIT_FILE_ENABLED);
|
||||
}
|
||||
@@ -2017,7 +2017,7 @@ TEST(vendor_mask_shadows_lower_priority_dir) {
|
||||
|
||||
assert_state("vendor-shadow.service", UNIT_FILE_DISABLED);
|
||||
|
||||
do_disable(0, STRV_MAKE("vendor-shadow.service"));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE("vendor-shadow.service"));
|
||||
|
||||
mask = strjoina(vendor_root, ETC_WANTS"vendor-shadow.service");
|
||||
ASSERT_FALSE(symlink_exists(mask));
|
||||
@@ -2036,14 +2036,14 @@ TEST(vendor_multiple_units) {
|
||||
write_vendor_symlink(strjoina(target, ".wants/", name), strjoina("../", name));
|
||||
}
|
||||
|
||||
do_disable(0, STRV_MAKE("vendor-multi-a.service", "vendor-multi-b.service", "vendor-multi-c.service"));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE("vendor-multi-a.service", "vendor-multi-b.service", "vendor-multi-c.service"));
|
||||
|
||||
FOREACH_STRING(name, "vendor-multi-a.service", "vendor-multi-b.service", "vendor-multi-c.service")
|
||||
FOREACH_STRING(target, "multi-user.target", "graphical.target")
|
||||
ASSERT_TRUE(is_dependency_mask(strjoina(vendor_root, SYSTEM_CONFIG_UNIT_DIR"/", target,
|
||||
".wants/", name)));
|
||||
|
||||
do_enable(0, STRV_MAKE("vendor-multi-a.service", "vendor-multi-b.service", "vendor-multi-c.service"));
|
||||
do_enable(/* flags= */ 0, STRV_MAKE("vendor-multi-a.service", "vendor-multi-b.service", "vendor-multi-c.service"));
|
||||
|
||||
FOREACH_STRING(name, "vendor-multi-a.service", "vendor-multi-b.service", "vendor-multi-c.service")
|
||||
FOREACH_STRING(target, "multi-user.target", "graphical.target")
|
||||
@@ -2086,7 +2086,7 @@ TEST(vendor_entry_kinds) {
|
||||
|
||||
/* Whatever is sitting there already shadows the vendor symlink, so disabling has nothing
|
||||
* left to do and must not replace it: that would destroy it. */
|
||||
do_disable(0, STRV_MAKE("vendor-kinds.service"));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE("vendor-kinds.service"));
|
||||
ASSERT_OK(read_full_file(entry, &back, /* ret_size= */ NULL));
|
||||
ASSERT_STREQ(back, contents);
|
||||
|
||||
@@ -2097,7 +2097,7 @@ TEST(vendor_entry_kinds) {
|
||||
assert_state("vendor-kinds.service", UNIT_FILE_DISABLED);
|
||||
|
||||
/* Replacing this one would fail outright rather than quietly. */
|
||||
do_disable(0, STRV_MAKE("vendor-kinds.service"));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE("vendor-kinds.service"));
|
||||
ASSERT_OK_ERRNO(rmdir(entry));
|
||||
}
|
||||
|
||||
@@ -2116,7 +2116,7 @@ TEST(vendor_static_dependency) {
|
||||
assert_state("vendor-static-dep.service", UNIT_FILE_ENABLED);
|
||||
|
||||
/* Disabling masks the symlink that enables the unit and leaves the static dependency symlinks alone. */
|
||||
do_disable(0, STRV_MAKE("vendor-static-dep.service"));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE("vendor-static-dep.service"));
|
||||
ASSERT_TRUE(is_dependency_mask(strjoina(vendor_root, ETC_WANTS"vendor-static-dep.service")));
|
||||
ASSERT_FALSE(symlink_exists(strjoina(vendor_root, SYSTEM_CONFIG_UNIT_DIR"/initrd-root-device.target.wants/vendor-static-dep.service")));
|
||||
ASSERT_FALSE(symlink_exists(strjoina(vendor_root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.requires/vendor-static-dep.service")));
|
||||
@@ -2131,7 +2131,7 @@ TEST(vendor_static_dependency) {
|
||||
write_vendor_symlink("multi-user.target.wants/vendor-static-dep@b.service", "../vendor-static-dep@.service");
|
||||
assert_state("vendor-static-dep@b.service", UNIT_FILE_ENABLED);
|
||||
|
||||
do_disable(0, STRV_MAKE("vendor-static-dep@.service"));
|
||||
do_disable(/* flags= */ 0, STRV_MAKE("vendor-static-dep@.service"));
|
||||
ASSERT_TRUE(is_dependency_mask(strjoina(vendor_root, ETC_WANTS"vendor-static-dep@b.service")));
|
||||
ASSERT_FALSE(symlink_exists(strjoina(vendor_root, SYSTEM_CONFIG_UNIT_DIR"/initrd-root-device.target.wants/vendor-static-dep@a.service")));
|
||||
assert_state("vendor-static-dep@a.service", UNIT_FILE_STATIC);
|
||||
@@ -2175,14 +2175,14 @@ TEST(vendor_also_keeps_sibling_preset_policy) {
|
||||
"disable vendor-main.service\n"
|
||||
"enable vendor-aux.socket\n");
|
||||
|
||||
do_enable(0, STRV_MAKE("vendor-aux.socket"));
|
||||
do_enable(/* flags= */ 0, STRV_MAKE("vendor-aux.socket"));
|
||||
assert_state("vendor-aux.socket", UNIT_FILE_ENABLED);
|
||||
|
||||
do_preset(0, STRV_MAKE("vendor-main.service"));
|
||||
do_preset(/* flags= */ 0, STRV_MAKE("vendor-main.service"));
|
||||
assert_state("vendor-main.service", UNIT_FILE_DISABLED);
|
||||
assert_state("vendor-aux.socket", UNIT_FILE_ENABLED);
|
||||
|
||||
do_preset_all(0);
|
||||
do_preset_all(/* flags= */ 0);
|
||||
assert_state("vendor-main.service", UNIT_FILE_DISABLED);
|
||||
assert_state("vendor-aux.socket", UNIT_FILE_ENABLED);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ TEST(sq_full) {
|
||||
if (!io_uring_init_or_skip(&ring, 4))
|
||||
return;
|
||||
|
||||
queue_nops(&ring, 4, 0);
|
||||
queue_nops(&ring, 4, /* first_id= */ 0);
|
||||
ASSERT_NULL(io_uring_get_sqe(&ring));
|
||||
|
||||
ASSERT_OK_EQ(io_uring_submit(&ring), 4);
|
||||
@@ -110,7 +110,7 @@ TEST(submit_and_wait) {
|
||||
|
||||
ASSERT_ERROR(io_uring_submit_and_wait(&ring, 10 * USEC_PER_MSEC), ETIME);
|
||||
|
||||
queue_nops(&ring, 1, 0);
|
||||
queue_nops(&ring, 1, /* first_id= */ 0);
|
||||
ASSERT_OK_EQ(io_uring_submit_and_wait(&ring, USEC_INFINITY), 1);
|
||||
ASSERT_EQ(reap(&ring, seen, ELEMENTSOF(seen)), 1u);
|
||||
ASSERT_TRUE(seen[0]);
|
||||
|
||||
@@ -130,7 +130,7 @@ TEST(keyring_find_by_name) {
|
||||
|
||||
/* Keyrings the process possesses show up in /proc/keys. A leftover of a crashed run may linger. */
|
||||
xsprintf(name, "test-keyring-util-find-" PID_FMT, getpid());
|
||||
ring = add_key("keyring", name, NULL, 0, KEY_SPEC_THREAD_KEYRING);
|
||||
ring = add_key("keyring", name, /* payload= */ NULL, /* plen= */ 0, KEY_SPEC_THREAD_KEYRING);
|
||||
if (ring < 0) {
|
||||
log_tests_skipped_errno(errno, "Cannot create keyring");
|
||||
return;
|
||||
@@ -159,7 +159,7 @@ TEST(keyring_find_by_name) {
|
||||
ASSERT_EQ(serial, ring);
|
||||
|
||||
/* Two keyrings of the same name are ambiguous */
|
||||
other = add_key("keyring", name, NULL, 0, KEY_SPEC_PROCESS_KEYRING);
|
||||
other = add_key("keyring", name, /* payload= */ NULL, /* plen= */ 0, KEY_SPEC_PROCESS_KEYRING);
|
||||
ASSERT_OK_ERRNO(other);
|
||||
ASSERT_ERROR(keyring_find_by_name(name, getuid(), &serial), ENOTUNIQ);
|
||||
|
||||
@@ -192,7 +192,7 @@ TEST(keyring_find_by_name_at) {
|
||||
ASSERT_ERROR(r, ENOKEY);
|
||||
|
||||
xsprintf(name, "test-keyring-util-find-at-" PID_FMT, getpid());
|
||||
ring = add_key("keyring", name, NULL, 0, KEY_SPEC_THREAD_KEYRING);
|
||||
ring = add_key("keyring", name, /* payload= */ NULL, /* plen= */ 0, KEY_SPEC_THREAD_KEYRING);
|
||||
if (ring < 0) {
|
||||
log_tests_skipped_errno(errno, "Cannot create keyring");
|
||||
return;
|
||||
@@ -242,7 +242,7 @@ TEST(keyring_ops) {
|
||||
int r;
|
||||
|
||||
/* A private keyring in the thread keyring suffices, no privileges needed */
|
||||
ring = add_key("keyring", "test-keyring-util", NULL, 0, KEY_SPEC_THREAD_KEYRING);
|
||||
ring = add_key("keyring", "test-keyring-util", /* payload= */ NULL, /* plen= */ 0, KEY_SPEC_THREAD_KEYRING);
|
||||
if (ring < 0) {
|
||||
log_tests_skipped_errno(errno, "Cannot create keyring");
|
||||
return;
|
||||
@@ -407,7 +407,7 @@ TEST(keyring_chain) {
|
||||
key_serial_t ring, serial, serial2;
|
||||
int r;
|
||||
|
||||
ring = add_key("keyring", "test-keyring-util-chain", NULL, 0, KEY_SPEC_THREAD_KEYRING);
|
||||
ring = add_key("keyring", "test-keyring-util-chain", /* payload= */ NULL, /* plen= */ 0, KEY_SPEC_THREAD_KEYRING);
|
||||
if (ring < 0)
|
||||
return (void) log_tests_skipped_errno(errno, "Cannot create keyring");
|
||||
|
||||
|
||||
@@ -59,40 +59,40 @@ TEST(machine_tag_is_valid) {
|
||||
|
||||
TEST(machine_tag_list_is_valid) {
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(NULL, /* to_add= */ true)); /* empty list is valid */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("a"), true));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo", "bar", "c-d.e"), true));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=uuu", "bar=qqqq", "c-d.e"), true));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo", "foo=aa"), true)); /* bare key and assignment coexist */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=1", "foobar=2"), true)); /* one key is a prefix of the other */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("ab=1", "a=2"), true)); /* ... and the other way around */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("a"), /* to_add= */ true));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo", "bar", "c-d.e"), /* to_add= */ true));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=uuu", "bar=qqqq", "c-d.e"), /* to_add= */ true));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo", "foo=aa"), /* to_add= */ true)); /* bare key and assignment coexist */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=1", "foobar=2"), /* to_add= */ true)); /* one key is a prefix of the other */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("ab=1", "a=2"), /* to_add= */ true)); /* ... and the other way around */
|
||||
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=aa", "foo=aa"), true)); /* same key + same value is OK */
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("foo", "b:c"), true));
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("foo", ""), true));
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("foo=aa", "foo=b"), true)); /* same key, different value */
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("a=1", "b=2", "a=3"), true)); /* ... also when not adjacent */
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("foo=aa", "bar", "foo=aa", "foo=b"), true));
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("=aa"), true));
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("ab=1*"), true)); /* globs */
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("ab=2[345]"), true));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=aa", "foo=aa"), /* to_add= */ true)); /* same key + same value is OK */
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("foo", "b:c"), /* to_add= */ true));
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("foo", ""), /* to_add= */ true));
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("foo=aa", "foo=b"), /* to_add= */ true)); /* same key, different value */
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("a=1", "b=2", "a=3"), /* to_add= */ true)); /* ... also when not adjacent */
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("foo=aa", "bar", "foo=aa", "foo=b"), /* to_add= */ true));
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("=aa"), /* to_add= */ true));
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("ab=1*"), /* to_add= */ true)); /* globs */
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("ab=2[345]"), /* to_add= */ true));
|
||||
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(NULL, /* to_add= */ false)); /* empty list is valid */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("a"), false));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo", "bar", "c-d.e"), false));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=uuu", "bar=qqqq", "c-d.e"), false));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo", "foo=aa"), false)); /* bare key and assignment coexist */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=1", "foobar=2"), false)); /* one key is a prefix of the other */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("ab=1", "a=2"), false)); /* ... and the other way around */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("a"), /* to_add= */ false));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo", "bar", "c-d.e"), /* to_add= */ false));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=uuu", "bar=qqqq", "c-d.e"), /* to_add= */ false));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo", "foo=aa"), /* to_add= */ false)); /* bare key and assignment coexist */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=1", "foobar=2"), /* to_add= */ false)); /* one key is a prefix of the other */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("ab=1", "a=2"), /* to_add= */ false)); /* ... and the other way around */
|
||||
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=aa", "foo=aa"), false)); /* same key + same value is OK */
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("foo", "b:c"), false));
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("foo", ""), false));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=aa", "foo=b"), false)); /* same key, different value */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("a=1", "b=2", "a=3"), false)); /* ... also when not adjacent */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=aa", "bar", "foo=aa", "foo=b"), false));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("=aa"), false)); /* this is not a valid pattern, but we don't check */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("ab=1*"), false)); /* globs */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("ab=2[345]"), false));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=aa", "foo=aa"), /* to_add= */ false)); /* same key + same value is OK */
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("foo", "b:c"), /* to_add= */ false));
|
||||
ASSERT_OK_ZERO(machine_tag_list_is_valid(STRV_MAKE("foo", ""), /* to_add= */ false));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=aa", "foo=b"), /* to_add= */ false)); /* same key, different value */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("a=1", "b=2", "a=3"), /* to_add= */ false)); /* ... also when not adjacent */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("foo=aa", "bar", "foo=aa", "foo=b"), /* to_add= */ false));
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("=aa"), /* to_add= */ false)); /* this is not a valid pattern, but we don't check */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("ab=1*"), /* to_add= */ false)); /* globs */
|
||||
ASSERT_OK_POSITIVE(machine_tag_list_is_valid(STRV_MAKE("ab=2[345]"), /* to_add= */ false));
|
||||
}
|
||||
|
||||
TEST(machine_tags_from_string) {
|
||||
@@ -217,10 +217,10 @@ TEST(machine_tags_apply_config) {
|
||||
ASSERT_OK(mkdtemp_malloc("/tmp/test-machine-tags-XXXXXX", &root));
|
||||
|
||||
/* No configuration at all: the base list is returned, sorted. An empty result is NULL. */
|
||||
ASSERT_OK_ZERO(machine_tags_config_files(root, NULL, NULL));
|
||||
ASSERT_OK_ZERO(machine_tags_config_files(root, /* ret_files= */ NULL, /* ret_n_files= */ NULL));
|
||||
|
||||
check(root, STRV_MAKE("foo", "bar"), STRV_MAKE("bar", "foo"));
|
||||
check(root, NULL, NULL);
|
||||
check(root, /* base= */ NULL, /* expected= */ NULL);
|
||||
|
||||
/* Comments, empty lines, several entries per line, CRLF line endings, an explicit '+' prefix, and
|
||||
* files from all directories applied in order of their names. The base tag 'vendor.env=old' is
|
||||
@@ -238,7 +238,7 @@ TEST(machine_tags_apply_config) {
|
||||
"-vendor.env=* -vendor.region=*\n"
|
||||
"local.rack=7\n");
|
||||
|
||||
ASSERT_OK_POSITIVE(machine_tags_config_files(root, NULL, NULL));
|
||||
ASSERT_OK_POSITIVE(machine_tags_config_files(root, /* ret_files= */ NULL, /* ret_n_files= */ NULL));
|
||||
|
||||
check(root, STRV_MAKE("manual", "vendor.env=old"),
|
||||
STRV_MAKE("local.rack=7", "manual", "plus", "runtime", "vendor.after-comment", "vendor.extra",
|
||||
@@ -283,14 +283,14 @@ TEST(machine_tags_apply_config) {
|
||||
/* "-*" resets the list */
|
||||
write_tags_file(root, "etc/machine-tags.d/90-reset.tags", "-* fresh\n");
|
||||
check(root, STRV_MAKE("manual", "vendor.env=old"), STRV_MAKE("fresh"));
|
||||
check(root, NULL, STRV_MAKE("fresh"));
|
||||
check(root, /* base= */ NULL, STRV_MAKE("fresh"));
|
||||
|
||||
/* Too many tags */
|
||||
_cleanup_free_ char *many = NULL;
|
||||
for (unsigned i = 0; i <= MACHINE_TAGS_MAX; i++)
|
||||
ASSERT_OK(strextendf_with_separator(&many, " ", "t%u", i));
|
||||
write_tags_file(root, "etc/machine-tags.d/95-many.tags", many);
|
||||
ASSERT_ERROR(machine_tags_apply_config(root, NULL, &l), E2BIG);
|
||||
ASSERT_ERROR(machine_tags_apply_config(root, /* base= */ NULL, &l), E2BIG);
|
||||
ASSERT_NULL(l);
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ static int make_tree(char **ret_path) {
|
||||
/* Populates a temporary directory with one inode of each type we can create unprivileged, including
|
||||
* a pair of hardlinks. */
|
||||
|
||||
ASSERT_OK(tfd = mkdtemp_open(NULL, O_DIRECTORY, &t));
|
||||
ASSERT_OK(tfd = mkdtemp_open(/* template= */ NULL, O_DIRECTORY, &t));
|
||||
|
||||
ASSERT_OK(write_string_file_at(tfd, "regular.txt", "hello world", WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_AVOID_NEWLINE));
|
||||
ASSERT_OK(write_string_file_at(tfd, "empty.txt", "", WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_AVOID_NEWLINE));
|
||||
@@ -461,8 +461,8 @@ TEST(manifest_mtree_names) {
|
||||
_cleanup_free_ char *user_name = NULL, *group_name = NULL;
|
||||
ASSERT_NOT_NULL(user_name = uid_to_name(getuid()));
|
||||
ASSERT_NOT_NULL(group_name = gid_to_name(getgid()));
|
||||
const char *expected_user_name = parse_uid(user_name, NULL) < 0 ? user_name : NULL,
|
||||
*expected_group_name = parse_gid(group_name, NULL) < 0 ? group_name : NULL;
|
||||
const char *expected_user_name = parse_uid(user_name, /* ret_uid= */ NULL) < 0 ? user_name : NULL,
|
||||
*expected_group_name = parse_gid(group_name, /* ret_gid= */ NULL) < 0 ? group_name : NULL;
|
||||
|
||||
/* Names are not included by default */
|
||||
_cleanup_free_ char *buf = NULL;
|
||||
@@ -470,8 +470,8 @@ TEST(manifest_mtree_names) {
|
||||
_cleanup_(manifest_context_done) ManifestContext c;
|
||||
context_init(&c, MANIFEST_FORMAT_MTREE);
|
||||
ASSERT_OK(generate(&c, tfd, &buf, &size));
|
||||
assert_mtree_keyword(buf, "./regular.txt ", "uname", NULL);
|
||||
assert_mtree_keyword(buf, "./regular.txt ", "gname", NULL);
|
||||
assert_mtree_keyword(buf, "./regular.txt ", "uname", /* value= */ NULL);
|
||||
assert_mtree_keyword(buf, "./regular.txt ", "gname", /* value= */ NULL);
|
||||
|
||||
/* Ask for the names only: they must be resolved even though the numeric IDs are not requested, and
|
||||
* the latter must not be included. */
|
||||
@@ -489,8 +489,8 @@ TEST(manifest_mtree_names) {
|
||||
FOREACH_STRING(prefix, "./ ", "./regular.txt ", "./subdir/ ", "./subdir/nested.txt ", "./symlink ", "./fifo ", "./hardlink_b ") {
|
||||
assert_mtree_keyword(buf2, prefix, "uname", expected_user_name);
|
||||
assert_mtree_keyword(buf2, prefix, "gname", expected_group_name);
|
||||
assert_mtree_keyword(buf2, prefix, "uid", NULL);
|
||||
assert_mtree_keyword(buf2, prefix, "gid", NULL);
|
||||
assert_mtree_keyword(buf2, prefix, "uid", /* value= */ NULL);
|
||||
assert_mtree_keyword(buf2, prefix, "gid", /* value= */ NULL);
|
||||
}
|
||||
|
||||
/* Each name may be requested individually, and is combined with the numeric ID if that is requested
|
||||
@@ -506,7 +506,7 @@ TEST(manifest_mtree_names) {
|
||||
assert_mtree_keyword(buf3, "./regular.txt ", "uid", uid_str);
|
||||
assert_mtree_keyword(buf3, "./regular.txt ", "gid", gid_str);
|
||||
assert_mtree_keyword(buf3, "./regular.txt ", "uname", expected_user_name);
|
||||
assert_mtree_keyword(buf3, "./regular.txt ", "gname", NULL);
|
||||
assert_mtree_keyword(buf3, "./regular.txt ", "gname", /* value= */ NULL);
|
||||
|
||||
_cleanup_free_ char *buf4 = NULL;
|
||||
size_t size4;
|
||||
@@ -514,9 +514,9 @@ TEST(manifest_mtree_names) {
|
||||
context_init(&c, MANIFEST_FORMAT_MTREE);
|
||||
c.fields = MANIFEST_FIELD_GROUP_NAME;
|
||||
ASSERT_OK(generate(&c, tfd, &buf4, &size4));
|
||||
assert_mtree_keyword(buf4, "./regular.txt ", "uid", NULL);
|
||||
assert_mtree_keyword(buf4, "./regular.txt ", "gid", NULL);
|
||||
assert_mtree_keyword(buf4, "./regular.txt ", "uname", NULL);
|
||||
assert_mtree_keyword(buf4, "./regular.txt ", "uid", /* value= */ NULL);
|
||||
assert_mtree_keyword(buf4, "./regular.txt ", "gid", /* value= */ NULL);
|
||||
assert_mtree_keyword(buf4, "./regular.txt ", "uname", /* value= */ NULL);
|
||||
assert_mtree_keyword(buf4, "./regular.txt ", "gname", expected_group_name);
|
||||
|
||||
/* Verification of mtree manifests is not supported, regardless of the fields */
|
||||
@@ -564,7 +564,7 @@ TEST(manifest_uapi16) {
|
||||
/* Each record starts with an RS byte */
|
||||
ASSERT_EQ(buf[0], 0x1e);
|
||||
|
||||
_cleanup_(sd_json_variant_unrefp) sd_json_variant *root = find_object(buf, NULL);
|
||||
_cleanup_(sd_json_variant_unrefp) sd_json_variant *root = find_object(buf, /* name= */ NULL);
|
||||
ASSERT_NOT_NULL(root);
|
||||
ASSERT_STREQ(sd_json_variant_string(sd_json_variant_by_key(root, "mediaType")), UAPI16_MANIFEST_MEDIA_TYPE);
|
||||
|
||||
@@ -635,11 +635,11 @@ TEST(manifest_uapi16) {
|
||||
_cleanup_(sd_json_variant_unrefp) sd_json_variant *reg3 = find_object(buf3, "regular.txt");
|
||||
ASSERT_NOT_NULL(reg3);
|
||||
ASSERT_NULL(sd_json_variant_by_key(reg3, "uid"));
|
||||
if (parse_uid(user_name, NULL) < 0) /* uid_to_name() falls back to the numeric UID if unresolvable */
|
||||
if (parse_uid(user_name, /* ret_uid= */ NULL) < 0) /* uid_to_name() falls back to the numeric UID if unresolvable */
|
||||
ASSERT_STREQ(sd_json_variant_string(sd_json_variant_by_key(reg3, "userName")), user_name);
|
||||
else
|
||||
ASSERT_NULL(sd_json_variant_by_key(reg3, "userName"));
|
||||
if (parse_gid(group_name, NULL) < 0)
|
||||
if (parse_gid(group_name, /* ret_gid= */ NULL) < 0)
|
||||
ASSERT_STREQ(sd_json_variant_string(sd_json_variant_by_key(reg3, "groupName")), group_name);
|
||||
else
|
||||
ASSERT_NULL(sd_json_variant_by_key(reg3, "groupName"));
|
||||
@@ -1147,10 +1147,10 @@ static void load_key_pair(
|
||||
ASSERT_OK(write_string_file(key_path, private_key_pem, WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_MODE_0600));
|
||||
ASSERT_OK(write_string_file(cert_path, certificate_pem, WRITE_STRING_FILE_CREATE));
|
||||
|
||||
ASSERT_OK(openssl_load_x509_certificate(OPENSSL_CERTIFICATE_SOURCE_FILE, NULL, cert_path, ret_certificate));
|
||||
ASSERT_OK(openssl_load_x509_certificate(OPENSSL_CERTIFICATE_SOURCE_FILE, /* certificate_source= */ NULL, cert_path, ret_certificate));
|
||||
ASSERT_OK(openssl_load_private_key(
|
||||
OPENSSL_KEY_SOURCE_FILE,
|
||||
NULL,
|
||||
/* private_key_source= */ NULL,
|
||||
key_path,
|
||||
&(AskPasswordRequest) {
|
||||
.tty_fd = -EBADF,
|
||||
|
||||
+14
-14
@@ -388,11 +388,11 @@ TEST(umount_recursive_stale_path) {
|
||||
|
||||
CHECK_PRIV;
|
||||
|
||||
ASSERT_OK(mkdtemp_malloc(NULL, &t));
|
||||
ASSERT_OK(mkdtemp_malloc(/* template= */ NULL, &t));
|
||||
|
||||
r = ASSERT_OK(pidref_safe_fork("(umount-rec-stale)", FORK_COMMON_FLAGS, NULL));
|
||||
r = ASSERT_OK(pidref_safe_fork("(umount-rec-stale)", FORK_COMMON_FLAGS, /* ret= */ NULL));
|
||||
if (r == 0) { /* child */
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, "tmpfs", t, "tmpfs", 0, NULL));
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, "tmpfs", t, "tmpfs", /* flags= */ 0, /* options= */ NULL));
|
||||
|
||||
_cleanup_free_ char
|
||||
*src = ASSERT_NOT_NULL(path_join(t, "src")),
|
||||
@@ -411,11 +411,11 @@ TEST(umount_recursive_stale_path) {
|
||||
/* The mount that later ends up below the parent has to be older than the parent, so that the
|
||||
* parent is reached first when the table is iterated backwards. Once the parent is detached
|
||||
* the path of the child resolves via the symlink it covered, to a mount outside of the prefix. */
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, "tmpfs", src, "tmpfs", 0, NULL));
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, "tmpfs", victim, "tmpfs", 0, NULL));
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, "tmpfs", parent, "tmpfs", 0, NULL));
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, "tmpfs", src, "tmpfs", /* flags= */ 0, /* options= */ NULL));
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, "tmpfs", victim, "tmpfs", /* flags= */ 0, /* options= */ NULL));
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, "tmpfs", parent, "tmpfs", /* flags= */ 0, /* options= */ NULL));
|
||||
ASSERT_OK(mkdir_p(child, 0755));
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, src, child, NULL, MS_MOVE, NULL));
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, src, child, /* fstype= */ NULL, MS_MOVE, /* options= */ NULL));
|
||||
|
||||
ASSERT_OK_POSITIVE(umount_recursive(prefix, MNT_DETACH));
|
||||
|
||||
@@ -432,11 +432,11 @@ TEST(umount_recursive_busy) {
|
||||
|
||||
CHECK_PRIV;
|
||||
|
||||
ASSERT_OK(mkdtemp_malloc(NULL, &t));
|
||||
ASSERT_OK(mkdtemp_malloc(/* template= */ NULL, &t));
|
||||
|
||||
r = ASSERT_OK(pidref_safe_fork("(umount-rec-busy)", FORK_COMMON_FLAGS, NULL));
|
||||
r = ASSERT_OK(pidref_safe_fork("(umount-rec-busy)", FORK_COMMON_FLAGS, /* ret= */ NULL));
|
||||
if (r == 0) { /* child */
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, "tmpfs", t, "tmpfs", 0, NULL));
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, "tmpfs", t, "tmpfs", /* flags= */ 0, /* options= */ NULL));
|
||||
|
||||
_cleanup_free_ char
|
||||
*prefix = ASSERT_NOT_NULL(path_join(t, "prefix")),
|
||||
@@ -447,12 +447,12 @@ TEST(umount_recursive_busy) {
|
||||
ASSERT_OK(mkdir_p(busy, 0755));
|
||||
|
||||
/* The busy mount is newer, hence reached first. It must not stop the walk. */
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, "tmpfs", older, "tmpfs", 0, NULL));
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, "tmpfs", busy, "tmpfs", 0, NULL));
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, "tmpfs", older, "tmpfs", /* flags= */ 0, /* options= */ NULL));
|
||||
ASSERT_OK(mount_nofollow_verbose(LOG_INFO, "tmpfs", busy, "tmpfs", /* flags= */ 0, /* options= */ NULL));
|
||||
|
||||
_unused_ _cleanup_close_ int fd = ASSERT_OK(xopenat(AT_FDCWD, busy, O_DIRECTORY));
|
||||
|
||||
ASSERT_OK_EQ(umount_recursive(prefix, 0), 1);
|
||||
ASSERT_OK_EQ(umount_recursive(prefix, /* flags= */ 0), 1);
|
||||
|
||||
ASSERT_OK_ZERO(path_is_mount_point(older));
|
||||
ASSERT_OK_POSITIVE(path_is_mount_point(busy));
|
||||
@@ -663,7 +663,7 @@ TEST(umountat) {
|
||||
CHECK_PRIV;
|
||||
|
||||
_cleanup_(rm_rf_physical_and_freep) char *p = NULL;
|
||||
_cleanup_close_ int dfd = mkdtemp_open(/* template= */ NULL, 0, &p);
|
||||
_cleanup_close_ int dfd = mkdtemp_open(/* template= */ NULL, /* flags= */ 0, &p);
|
||||
ASSERT_OK(dfd);
|
||||
|
||||
ASSERT_OK(mkdirat(dfd, "foo", 0777));
|
||||
|
||||
@@ -1164,7 +1164,7 @@ TEST(execvp_safe) {
|
||||
/* An empty executable file must make execvp_safe() fail with ENOEXEC, and must not be run as an
|
||||
* empty shell script, which would exit successfully. */
|
||||
|
||||
ASSERT_OK(mkdtemp_malloc(NULL, &d));
|
||||
ASSERT_OK(mkdtemp_malloc(/* template= */ NULL, &d));
|
||||
ASSERT_NOT_NULL(p = path_join(d, "test-process-util-empty"));
|
||||
ASSERT_OK(touch_file(p, /* parents= */ false, USEC_INFINITY, UID_INVALID, GID_INVALID, 0755));
|
||||
if (access(p, X_OK) < 0) /* e.g. /tmp/ mounted noexec */
|
||||
@@ -1173,7 +1173,7 @@ TEST(execvp_safe) {
|
||||
test_execvp_safe_one(p, /* search_path= */ NULL, -ENOEXEC);
|
||||
test_execvp_safe_one("test-process-util-empty", d, -ENOEXEC);
|
||||
test_execvp_safe_one("test-process-util-missing", d, -ENOENT);
|
||||
test_execvp_safe_one("true", /* search_path= */ NULL, 0);
|
||||
test_execvp_safe_one("true", /* search_path= */ NULL, /* expected_error= */ 0);
|
||||
}
|
||||
|
||||
static int intro(void) {
|
||||
|
||||
@@ -558,7 +558,7 @@ TEST(restrict_realtime) {
|
||||
.sched_policy = SCHED_FIFO,
|
||||
.sched_priority = 1,
|
||||
};
|
||||
ASSERT_ERROR_ERRNO(sched_setattr(0, &attr, 0), ENOANO);
|
||||
ASSERT_ERROR_ERRNO(sched_setattr(/* pid= */ 0, &attr, /* flags= */ 0), ENOANO);
|
||||
|
||||
attr = (struct sched_attr) {
|
||||
.size = sizeof(attr),
|
||||
@@ -567,13 +567,13 @@ TEST(restrict_realtime) {
|
||||
.sched_deadline = 10000000,
|
||||
.sched_period = 10000000,
|
||||
};
|
||||
ASSERT_ERROR_ERRNO(sched_setattr(0, &attr, 0), ENOANO);
|
||||
ASSERT_ERROR_ERRNO(sched_setattr(/* pid= */ 0, &attr, /* flags= */ 0), ENOANO);
|
||||
|
||||
attr = (struct sched_attr) {
|
||||
.size = sizeof(attr),
|
||||
.sched_policy = SCHED_OTHER,
|
||||
};
|
||||
ASSERT_ERROR_ERRNO(sched_setattr(0, &attr, 0), ENOANO);
|
||||
ASSERT_ERROR_ERRNO(sched_setattr(/* pid= */ 0, &attr, /* flags= */ 0), ENOANO);
|
||||
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -1024,7 +1024,7 @@ TEST(lock_personality) {
|
||||
}
|
||||
|
||||
/* Each bit set in the locked personality takes a rule of its own. */
|
||||
r = ASSERT_OK(pidref_safe_fork("(lock-personality-flags)", FORK_LOG|FORK_WAIT, NULL));
|
||||
r = ASSERT_OK(pidref_safe_fork("(lock-personality-flags)", FORK_LOG|FORK_WAIT, /* ret= */ NULL));
|
||||
if (r == 0) {
|
||||
unsigned long personality = current_opinionated | ADDR_NO_RANDOMIZE | ADDR_COMPAT_LAYOUT;
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ TEST(socket_address_is) {
|
||||
SocketAddress a;
|
||||
|
||||
ASSERT_OK(socket_address_parse(&a, "192.168.1.1:8888"));
|
||||
ASSERT_TRUE(socket_address_is(&a, "192.168.1.1:8888", 0 /* unspecified yet */));
|
||||
ASSERT_TRUE(socket_address_is(&a, "192.168.1.1:8888", /* type= */ 0 /* unspecified yet */));
|
||||
ASSERT_FALSE(socket_address_is(&a, "route", /* type= */ 0));
|
||||
ASSERT_FALSE(socket_address_is(&a, "route", SOCK_STREAM));
|
||||
ASSERT_FALSE(socket_address_is(&a, "192.168.1.1:8888", SOCK_RAW));
|
||||
|
||||
@@ -1338,7 +1338,7 @@ TEST(calculate_policy_or) {
|
||||
|
||||
/* The empty input must be rejected before the flat/tree split. */
|
||||
actual = (TPM2B_DIGEST) { .size = SHA256_DIGEST_SIZE };
|
||||
ASSERT_ERROR(tpm2_calculate_policy_or(leaves, 0, &actual), EINVAL);
|
||||
ASSERT_ERROR(tpm2_calculate_policy_or(leaves, /* n_branches= */ 0, &actual), EINVAL);
|
||||
|
||||
/* For n<=8 the flat form must be used unchanged; for n>8 the result must match the balanced tree
|
||||
* reference implementation. */
|
||||
|
||||
@@ -125,7 +125,7 @@ TEST(xattr_match_filter_test_uapi16_object) {
|
||||
_cleanup_close_ int tfd = -EBADF;
|
||||
|
||||
/* A root to load the host properties from */
|
||||
ASSERT_OK(tfd = mkdtemp_open(NULL, O_PATH, &t));
|
||||
ASSERT_OK(tfd = mkdtemp_open(/* template= */ NULL, O_PATH, &t));
|
||||
ASSERT_OK_ERRNO(mkdirat(tfd, "etc", 0755));
|
||||
ASSERT_OK(write_string_file_at(tfd, "etc/hostname", "foo.example.com", WRITE_STRING_FILE_CREATE));
|
||||
ASSERT_OK(write_string_file_at(tfd, "etc/machine-id", "4b1f7c950d4f4e1a9e8f3d22576180a3", WRITE_STRING_FILE_CREATE));
|
||||
@@ -200,7 +200,7 @@ TEST(host_properties_load_symlinks) {
|
||||
_cleanup_close_ int tfd = -EBADF;
|
||||
|
||||
/* Absolute and relative symlinks are resolved below the root, not on the host */
|
||||
ASSERT_OK(tfd = mkdtemp_open(NULL, O_PATH, &t));
|
||||
ASSERT_OK(tfd = mkdtemp_open(/* template= */ NULL, O_PATH, &t));
|
||||
ASSERT_OK_ERRNO(mkdirat(tfd, "etc", 0755));
|
||||
ASSERT_OK(write_string_file_at(tfd, "etc/hostname.real", "inroot.example.com", WRITE_STRING_FILE_CREATE));
|
||||
ASSERT_OK_ERRNO(symlinkat("/etc/hostname.real", tfd, "etc/hostname"));
|
||||
@@ -220,7 +220,7 @@ TEST(xattr_match_filter_test_inode) {
|
||||
_cleanup_close_ int tfd = -EBADF;
|
||||
int r;
|
||||
|
||||
ASSERT_OK(tfd = mkdtemp_open(NULL, O_DIRECTORY, &t));
|
||||
ASSERT_OK(tfd = mkdtemp_open(/* template= */ NULL, O_DIRECTORY, &t));
|
||||
ASSERT_OK(write_string_file_at(tfd, "plain", "x", WRITE_STRING_FILE_CREATE));
|
||||
ASSERT_OK(write_string_file_at(tfd, "mine", "x", WRITE_STRING_FILE_CREATE));
|
||||
ASSERT_OK(write_string_file_at(tfd, "other", "x", WRITE_STRING_FILE_CREATE));
|
||||
|
||||
Executable
+1001
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,7 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
check_api_docs_sh = files('check-api-docs.sh')
|
||||
check_argument_comments_py = files('check-argument-comments.py')
|
||||
check_coccinelle_sh = files('check-coccinelle.sh')
|
||||
check_efi_alignment_py = files('check-efi-alignment.py')
|
||||
check_help_sh = files('check-help.sh')
|
||||
|
||||
Reference in new issue
Block a user