1
0
mirror of https://github.com/systemd/systemd synced 2025-12-26 02:44:46 +01:00

Compare commits

..

11 Commits

Author SHA1 Message Date
Lennart Poettering
3b493d94ae mount-util: show mount source in mount_verbose_full() debug output 2020-09-25 17:55:39 +02:00
Lennart Poettering
e25a0a69be
Merge pull request #17166 from poettering/loop-mini-fixes
two minor fixes to the loop block device handling
2020-09-25 17:55:18 +02:00
Lennart Poettering
77ad674b51 loop-util: apparently opening a loop device sometimes results in ENXIO, handle this 2020-09-25 16:03:05 +02:00
Lennart Poettering
0950526afd loop-util: use right flags field 2020-09-25 16:02:56 +02:00
Lennart Poettering
ea223d3d3e
Merge pull request #17148 from jlebon/pr/crypt-source
cryptsetup-generator: use "/proc/cmdline" as source when appropriate
2020-09-25 15:50:15 +02:00
Zbigniew Jędrzejewski-Szmek
581b2c7359
Merge pull request #17132 from keszybz/test-suite-update
Test suite updates
2020-09-25 13:39:24 +02:00
Jonathan Lebon
263a79642b cryptsetup-generator: avoid magic value in ternary
`startswith` already returns the string with the prefix skipped, so we
can simplify this further and avoid using a magic value.

Noticed in passing.

Co-authored-by: Lennart Poettering <lennart@poettering.net>
2020-09-24 11:19:40 -04:00
Zbigniew Jędrzejewski-Szmek
0af05e485a test-seccomp: accept ENOSYS from sysctl(2) too
It seems that kernel 5.9 started returning that.
2020-09-24 17:02:20 +02:00
Zbigniew Jędrzejewski-Szmek
9309a23b95 test: switch TEST-02-CRYPTSETUP and TEST-24-UNITTESTS
When tests are executed serially (the default), it seems better to launch
the fairly generic test that runs the unittests early in the sequence.
Right now the tests are ordered based on when they were written, but
this doesn't make much sense.
2020-09-24 17:02:20 +02:00
Jonathan Lebon
62ca7d3b38 cryptsetup-generator: use "/proc/cmdline" as source when appropriate
Right now, we always say `/etc/crypttab` even if the source was fully
derived from the kargs.

Let's match what `systemd-fstab-generator` does and use `/proc/cmdline`
when that's the case.
2020-09-23 15:31:31 -04:00
Zbigniew Jędrzejewski-Szmek
abf6346c5e test/run-integration-tests: do not run the tests if only "clean" is passed 2020-09-22 18:05:19 +02:00
13 changed files with 22 additions and 18 deletions

View File

@ -274,7 +274,8 @@ static int create_disk(
const char *device,
const char *password,
const char *keydev,
const char *options) {
const char *options,
const char *source) {
_cleanup_free_ char *n = NULL, *d = NULL, *u = NULL, *e = NULL,
*keydev_mount = NULL, *keyfile_timeout_value = NULL,
@ -343,7 +344,7 @@ static int create_disk(
if (r < 0)
return r;
r = generator_write_cryptsetup_unit_section(f, arg_crypttab);
r = generator_write_cryptsetup_unit_section(f, source);
if (r < 0)
return r;
@ -540,7 +541,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
if (proc_cmdline_value_missing(key, value))
return 0;
d = get_crypto_device(startswith(value, "luks-") ? value+5 : value);
d = get_crypto_device(startswith(value, "luks-") ?: value);
if (!d)
return log_oom();
@ -680,7 +681,7 @@ static int add_crypttab_devices(void) {
if (r < 0)
return r;
r = create_disk(name, device, keyfile, keydev, (d && d->options) ? d->options : options);
r = create_disk(name, device, keyfile, keydev, (d && d->options) ? d->options : options, arg_crypttab);
if (r < 0)
return r;
@ -715,7 +716,8 @@ static int add_proc_cmdline_devices(void) {
device,
d->keyfile ?: arg_default_keyfile,
d->keydev,
d->options ?: arg_default_options);
d->options ?: arg_default_options,
"/proc/cmdline");
if (r < 0)
return r;
}

View File

@ -176,7 +176,7 @@ int loop_device_make(
.fd = fd,
.info = {
/* Use the specified flags, but configure the read-only flag from the open flags, and force autoclear */
.lo_flags = (loop_flags & ~LO_FLAGS_READ_ONLY) | ((loop_flags & O_ACCMODE) == O_RDONLY ? LO_FLAGS_READ_ONLY : 0) | LO_FLAGS_AUTOCLEAR,
.lo_flags = (loop_flags & ~LO_FLAGS_READ_ONLY) | ((open_flags & O_ACCMODE) == O_RDONLY ? LO_FLAGS_READ_ONLY : 0) | LO_FLAGS_AUTOCLEAR,
.lo_offset = offset,
.lo_sizelimit = size == UINT64_MAX ? 0 : size,
},
@ -198,7 +198,7 @@ int loop_device_make(
if (loop < 0) {
/* Somebody might've gotten the same number from the kernel, used the device,
* and called LOOP_CTL_REMOVE on it. Let's retry with a new number. */
if (errno != ENOENT)
if (!IN_SET(errno, ENOENT, ENXIO))
return -errno;
} else {
r = loop_configure(loop, &config);

View File

@ -644,8 +644,8 @@ int mount_verbose_full(
log_debug("Moving mount %s → %s (%s \"%s\")...",
what, where, strnull(fl), strempty(o));
else
log_debug("Mounting %s on %s (%s \"%s\")...",
strna(type), where, strnull(fl), strempty(o));
log_debug("Mounting %s (%s) on %s (%s \"%s\")...",
strna(what), strna(type), where, strnull(fl), strempty(o));
if (follow_symlink)
r = mount(what, where, type, f, o) < 0 ? -errno : 0;

View File

@ -318,7 +318,7 @@ static void test_protect_sysctl(void) {
if (pid == 0) {
#if defined __NR__sysctl && __NR__sysctl >= 0
assert_se(syscall(__NR__sysctl, NULL) < 0);
assert_se(errno == EFAULT);
assert_se(IN_SET(errno, EFAULT, ENOSYS));
#endif
assert_se(seccomp_protect_sysctl() >= 0);

View File

@ -60,4 +60,4 @@ check_result_qemu() {
return $_ret
}
do_test "$@" 24
do_test "$@" 02

View File

@ -76,4 +76,4 @@ test_setup_cleanup() {
cleanup_initdir
}
do_test "$@" 02
do_test "$@" 24

View File

@ -7,7 +7,7 @@ if [ $# -gt 0 ]; then
else
args="setup run clean-again"
fi
args_no_clean=$(sed -r 's/(^| )clean($| )/ /g' <<<$args)
args_no_clean=$(sed -r 's/\bclean\b//g' <<<$args)
do_clean=$( [ "$args" = "$args_no_clean" ]; echo $? )
ninja -C "$BUILD_DIR"
@ -26,6 +26,8 @@ if [ $do_clean = 1 ]; then
for TEST in TEST-??-* ; do
( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" clean )
done
[ -n "$args_no_clean" ] || exit 0
fi
pass_blacklist() {

View File

@ -1,8 +1,7 @@
[Unit]
Description=TEST-02-CRYPTSETUP
After=multi-user.target
Description=TEST-02-UNITTESTS
[Service]
ExecStartPre=rm -f /failed /testok
ExecStart=sh -x -e -c 'mountpoint /var; systemctl --state=failed --no-legend --no-pager >/failed; echo OK >/testok'
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=oneshot

View File

@ -1,7 +1,8 @@
[Unit]
Description=TEST-24-UNIT-TESTS
Description=TEST-24-CRYPTSETUP
After=multi-user.target
[Service]
ExecStartPre=rm -f /failed /testok
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
ExecStart=sh -x -e -c 'mountpoint /var; systemctl --state=failed --no-legend --no-pager >/failed; echo OK >/testok'
Type=oneshot