1
0
mirror of https://github.com/systemd/systemd synced 2025-09-29 08:44:45 +02:00

Compare commits

...

18 Commits

Author SHA1 Message Date
Yu Watanabe
b10619484d
Cleanups for test/units directory (#38807) 2025-09-04 18:11:27 +09:00
Yu Watanabe
2ddeb2adfd
install: follow-up for initrd presets (#38790)
Follow up for 4a8c395167c1631224c02d990c847955a2bf23b0.
2025-09-04 18:03:21 +09:00
Daan De Meyer
67573e8b8b
repart: add test case for btrfs specific options and MountPoint=, and update man page (#38756)
Closes #38749.
2025-09-04 09:00:09 +02:00
Daan De Meyer
af5dde2097
core/transaction: fix issue in dropping unmergeable jobs (#38776)
Fixes #38765.
2025-09-04 08:57:59 +02:00
Daan De Meyer
41ae31a9ac install: Fall back to system presets if there are no initrd presets
We might be operating with a newer systemctl on an image with older
systemd and thus without an initrd-preset directory. Before
4a8c395167c1631224c02d990c847955a2bf23b0, we would use the system
presets, let's make sure we keep doing that if we're operating on an
image without initrd presets.

Follow up for 4a8c395167c1631224c02d990c847955a2bf23b0.
2025-09-04 08:55:40 +02:00
Daan De Meyer
c8e1e5814f install: Coding style fixlet 2025-09-04 08:42:32 +02:00
Daan De Meyer
fcb90e6f55
core: fix segfault by drop-in config for masked unit (#38810) 2025-09-04 08:41:26 +02:00
Yu Watanabe
c02f570260 TEST-87-AUX-UTILS-VM: rotate journal at one more place
Follow-ups for ab56a96194d102cb4ec279fc4eb181d16c1251ea.

Fixes the following failure:
```
TEST-87-AUX-UTILS-VM.sh[1196]: + systemd-run --user --wait --pipe -M testuser@.host -- coredumpctl
TEST-87-AUX-UTILS-VM.sh[1840]: Running as unit: run-p1840-i1841.service; invocation ID: 325a026377aa4cffb046c5a63a8906ab
TEST-87-AUX-UTILS-VM.sh[1853]: Hint: You are currently not seeing messages from other users and the system.
TEST-87-AUX-UTILS-VM.sh[1853]:       Users in groups 'adm', 'systemd-journal', 'wheel' can see all messages.
TEST-87-AUX-UTILS-VM.sh[1853]:       Pass -q to turn off this notice.
TEST-87-AUX-UTILS-VM.sh[1853]: Journal file /var/log/journal/6835d335b6684b6197bf071ad66f2678/user-4711.journal is truncated, ignoring file.
TEST-87-AUX-UTILS-VM.sh[1853]: No coredumps found.
TEST-87-AUX-UTILS-VM.sh[1840]:           Finished with result: exit-code
TEST-87-AUX-UTILS-VM.sh[1840]: Main processes terminated with: code=exited, status=1/FAILURE
TEST-87-AUX-UTILS-VM.sh[1840]:                Service runtime: 154ms
TEST-87-AUX-UTILS-VM.sh[1840]:              CPU time consumed: 78ms
TEST-87-AUX-UTILS-VM.sh[1840]:                    Memory peak: 21.9M (swap: 0B)
```
2025-09-04 08:39:39 +02:00
Yu Watanabe
642744b492 test: move test units to their own directories
This also add test cases for verifying loopy.service and friends,
which was added by e66047ff62c971eefa32b42373420d61e3f2a9c1 but never
used in integration tests.
2025-09-04 14:36:46 +09:00
Yu Watanabe
b419e927ee test: add comment about custom autorelabel.service
Salvaged from ead814a0b0f64c572282b9e27a0a995893f10cf0.
2025-09-04 11:02:13 +09:00
Yu Watanabe
023de38782 TEST-07-PID1: add test cases for mask/unmask unit
For issue #38802.
2025-09-04 10:58:33 +09:00
Yu Watanabe
2ba0eacc6c core/unit: do not load drop-in configs for masked unit files
Otherwise, ExecXYZ= given by drop-ins may be added to a masked unit,
then commands may be unexpectedly executed. For example, if an ExecStop=
is set in a drop-in for a running unit, then 'systemctl mask --now' for
the unit try to invoke the command specified in ExecStop=.

Fixes #38802.
2025-09-04 10:58:33 +09:00
Yu Watanabe
975f27a2b5 repart: fix memleak
Fixes a bug in 1a0541d44c78ced78a566051ec8f63417370aeaa (v256).
2025-09-04 06:52:17 +09:00
Yu Watanabe
5b89cc2a5a test: add test case for issue #38765 2025-09-04 02:05:09 +09:00
Yu Watanabe
811af8d534 core/transaction: first drop unmergable jobs for anchor jobs
As you can see, something spurious happens in the logs below.
```
initrd-switch-root.target: Trying to enqueue job initrd-switch-root.target/start/isolate
systemd-repart.service: Looking at job systemd-repart.service/stop conflicted_by=no
systemd-repart.service: Looking at job systemd-repart.service/start conflicted_by=no
systemd-repart.service: Fixing conflicting jobs systemd-repart.service/stop,systemd-repart.service/start by deleting job systemd-repart.service/stop
initrd-switch-root.target: Fixing conflicting jobs initrd-switch-root.target/stop,initrd-switch-root.target/start by deleting job initrd-switch-root.target/stop
systemd-repart.service: Deleting job systemd-repart.service/start as dependency of job initrd-switch-root.target/stop
```

The two conflicting jobs for systemd-repart.service are initially queued
as the following:
- initrd-switch-root.target has Wants=initrd-root-fs.target, and
  initrd-root-fs.target has Wants=systemd-repart.service (through symlink),
  hence starting initrd-switch-root.target tries to start
  systemd-repart.service,
- systemd-repart.service has Conflicts=initrd-switch-root.target, hence
  starting initrd-switch-root.target tries to stop
  systemd-repart.service.

As similar, interestingly(?) starting initrd-switch-root.target tries to
stop initrd-switch-root.target.

So, now there are at least two pairs of conflicting jobs:
- systemd-repart.service: start vs stop,
- initrd-switch-root.target: start vs stop.

As these jobs are induced by starting initrd-switch-root.target, of course
the most important one is the start job for initrd-switch-root.target.

Previously, as you can see in the logs at the beginning, even if
the start job for initrd-switch-root.target is important, we may first
try to resolve the conflict in systemd-repart.service, and may drop the
stop job for systemd-repart.service even if it is relevant to the start
job of initrd-switch-root.target.

This makes first we solve the pair of conflicting jobs for anchor task.
So the stop job for initrd-switch-root.target is dropped first, and the
induced start job for systemd-repart.service is automatically removed,
thus it is not necessary to solve the conflict in systemd-repart.service
anymore.

This is especially important for services that are enabled both in initrd
and after switching root. If a stop job for one of the service is
unexpectedly dropped during switching root, then the service is not stopped
before switching root, and will never start after that.

Fixes #38765.
2025-09-04 02:04:56 +09:00
Yu Watanabe
a1eb53e934 man/repart.d: mention each field of MountPoint= needs to be quoted when contains colon
Closes #38749.
2025-09-04 01:46:11 +09:00
Yu Watanabe
e34f8128b1 TEST-58-REPART: add test case for btrfs specific options and MountPoint= 2025-09-04 01:45:38 +09:00
Yu Watanabe
e4f15fc140 TEST-58-REPART: make sector size test as a normal test case 2025-09-04 01:34:04 +09:00
86 changed files with 261 additions and 77 deletions

View File

@ -837,8 +837,10 @@
partition should be mounted. The second field specifies extra mount options to append to the default
mount options. These fields correspond to the second and fourth column of the
<citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>
format. This setting may be specified multiple times to mount the partition multiple times. This can
be used to add mounts for different
format. As a colon is used for separating fields, each field needs to be quoted when it contains
colons. E.g. <programlisting>MountPoint="/path/with:colon":"zstd:1,noatime,lazytime"</programlisting>
This setting may be specified multiple times to mount the partition multiple times. This can be used
to add mounts for different
<citerefentry project="url"><refentrytitle url="https://btrfs.readthedocs.io/en/latest/btrfs.html">btrfs</refentrytitle><manvolnum>8</manvolnum></citerefentry>
subvolumes located on the same btrfs partition.</para>

View File

@ -15,6 +15,7 @@
#include "strv.h"
#include "transaction.h"
static bool job_matters_to_anchor(Job *job);
static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies);
static void transaction_delete_job(Transaction *tr, Job *j, bool delete_dependencies) {
@ -171,6 +172,7 @@ static int delete_one_unmergeable_job(Transaction *tr, Job *job) {
* another unit in which case we
* rather remove the start. */
/* Update test/units/TEST-87-AUX-UTILS-VM.sh when logs below are changed. */
log_unit_debug(j->unit,
"Looking at job %s/%s conflicted_by=%s",
j->unit->id, job_type_to_string(j->type),
@ -216,17 +218,18 @@ static int delete_one_unmergeable_job(Transaction *tr, Job *job) {
return -EINVAL;
}
static int transaction_merge_jobs(Transaction *tr, sd_bus_error *e) {
static int transaction_ensure_mergeable(Transaction *tr, bool matters_to_anchor, sd_bus_error *e) {
Job *j;
int r;
assert(tr);
/* First step, check whether any of the jobs for one specific
* task conflict. If so, try to drop one of them. */
HASHMAP_FOREACH(j, tr->jobs) {
JobType t;
if (job_matters_to_anchor(j) != matters_to_anchor)
continue;
t = j->type;
LIST_FOREACH(transaction, k, j->transaction_next) {
if (job_type_merge_and_collapse(&t, k->type, j->unit) >= 0)
@ -253,7 +256,26 @@ static int transaction_merge_jobs(Transaction *tr, sd_bus_error *e) {
}
}
/* Second step, merge the jobs. */
return 0;
}
static int transaction_merge_jobs(Transaction *tr, sd_bus_error *e) {
Job *j;
int r;
assert(tr);
/* First step, try to drop unmergeable jobs for jobs that matter to anchor. */
r = transaction_ensure_mergeable(tr, /* matters_to_anchor = */ true, e);
if (r < 0)
return r;
/* Second step, do the same for jobs that not matter to anchor. */
r = transaction_ensure_mergeable(tr, /* matters_to_anchor = */ false, e);
if (r < 0)
return r;
/* Third step, merge the jobs. */
HASHMAP_FOREACH(j, tr->jobs) {
JobType t = j->type;

View File

@ -1422,6 +1422,9 @@ int unit_load_fragment_and_dropin(Unit *u, bool fragment_required) {
if (r < 0)
return r;
if (u->load_state == UNIT_MASKED)
return 0;
if (u->load_state == UNIT_STUB) {
if (fragment_required)
return -ENOENT;

View File

@ -7859,7 +7859,7 @@ static int context_fstab(Context *context) {
fputs(AUTOMATIC_FSTAB_HEADER_START "\n", f);
LIST_FOREACH(partitions, p, context->partitions) {
_cleanup_free_ char *what = NULL, *options = NULL;
_cleanup_free_ char *what = NULL;
if (!need_fstab_one(p))
continue;
@ -7869,6 +7869,8 @@ static int context_fstab(Context *context) {
return r;
FOREACH_ARRAY(mountpoint, p->mountpoints, p->n_mountpoints) {
_cleanup_free_ char *options = NULL;
r = partition_pick_mount_options(
p->type.designator,
p->format,

View File

@ -3283,7 +3283,7 @@ static int split_pattern_into_name_and_instances(const char *pattern, char **out
return 0;
}
static int presets_find_config(RuntimeScope scope, const char *root_dir, char ***files) {
static int presets_find_config(RuntimeScope scope, const char *root_dir, char ***ret) {
static const char* const initrd_dirs[] = { CONF_PATHS("systemd/initrd-preset"), NULL };
static const char* const system_dirs[] = { CONF_PATHS("systemd/system-preset"), NULL };
static const char* const user_dirs[] = { CONF_PATHS("systemd/user-preset"), NULL };
@ -3298,13 +3298,26 @@ static int presets_find_config(RuntimeScope scope, const char *root_dir, char **
if (r < 0 && r != -ENOENT)
return r;
dirs = r >= 0 ? initrd_dirs : system_dirs;
/* Make sure that we fall back to the system preset directories if we're operating on a root
* directory without initrd preset directories. This makes sure that we don't regress when
* using a newer systemctl to operate on a root directory with an older version of systemd
* installed that doesn't yet known about initrd preset directories. */
if (r >= 0)
STRV_FOREACH(d, initrd_dirs) {
r = chase_and_access(*d, root_dir, CHASE_PREFIX_ROOT, F_OK, /* ret_path= */ NULL);
if (r >= 0)
return conf_files_list_strv(ret, ".preset", root_dir, 0, initrd_dirs);
if (r != -ENOENT)
return r;
}
dirs = system_dirs;
} else if (IN_SET(scope, RUNTIME_SCOPE_GLOBAL, RUNTIME_SCOPE_USER))
dirs = user_dirs;
else
assert_not_reached();
return conf_files_list_strv(files, ".preset", root_dir, 0, dirs);
return conf_files_list_strv(ret, ".preset", root_dir, 0, dirs);
}
static int read_presets(RuntimeScope scope, const char *root_dir, UnitFilePresets *presets) {

View File

@ -32,7 +32,7 @@ TEST_RET(cgroup_mask, .sd_booted = true) {
/* Prepare the manager. */
_cleanup_free_ char *unit_dir = NULL;
ASSERT_OK(get_testdata_dir("units", &unit_dir));
ASSERT_OK(get_testdata_dir("test-cgroup-mask", &unit_dir));
ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
r = manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m);

View File

@ -21,7 +21,7 @@ TEST_RET(default_memory_low, .sd_booted = true) {
return log_tests_skipped("cgroupfs not available");
_cleanup_free_ char *unit_dir = NULL;
ASSERT_OK(get_testdata_dir("units", &unit_dir));
ASSERT_OK(get_testdata_dir("test-cgroup-unit-default", &unit_dir));
ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
r = manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m);

View File

@ -89,7 +89,7 @@ int main(int argc, char *argv[]) {
/* prepare the test */
_cleanup_free_ char *unit_dir = NULL;
ASSERT_OK(get_testdata_dir("units", &unit_dir));
ASSERT_OK(get_testdata_dir("test-engine", &unit_dir));
ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());

View File

@ -25,7 +25,7 @@ int main(int argc, char *argv[]) {
/* prepare the test */
_cleanup_free_ char *unit_dir = NULL;
ASSERT_OK(get_testdata_dir("units", &unit_dir));
ASSERT_OK(get_testdata_dir("test-sched-prio", &unit_dir));
ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());

View File

@ -4,7 +4,7 @@ set -eux
set -o pipefail
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
. "$(dirname "$0")"/../units/util.sh
assert_eq "$LISTEN_FDS" "$1"
assert_eq "$LISTEN_FDNAMES" "$2"

View File

@ -4,7 +4,7 @@ set -eux
set -o pipefail
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
. "$(dirname "$0")"/../units/util.sh
assert_eq "$LISTEN_FDS" "$1"
assert_eq "$LISTEN_FDNAMES" "$2"

View File

@ -8,4 +8,4 @@ StartLimitBurst=15
StartLimitIntervalSec=1h
[Service]
ExecStart=/usr/lib/systemd/tests/testdata/units/TEST-23-UNIT-FILE-short-lived.sh
ExecStart=/usr/lib/systemd/tests/testdata/TEST-23-UNIT-FILE.units/TEST-23-UNIT-FILE-short-lived.sh

View File

@ -339,15 +339,18 @@ if install_tests
'auxv',
'journal-data',
'knot-data',
'test-journals',
'units',
'test-cgroup-mask',
'test-cgroup-unit-default',
'test-engine',
'test-execute',
'test-fstab-generator',
'test-path',
'test-path-util',
'test-umount',
'test-journals',
'test-network',
'test-network-generator-conversion',
'test-path',
'test-path-util',
'test-sched-prio',
'test-umount',
'integration-tests/TEST-07-PID1/TEST-07-PID1.units',
'integration-tests/TEST-03-JOBS/TEST-03-JOBS.units',
'integration-tests/TEST-04-JOURNAL/TEST-04-JOURNAL.units',
@ -355,9 +358,15 @@ if install_tests
'integration-tests/TEST-16-EXTEND-TIMEOUT/TEST-16-EXTEND-TIMEOUT.units',
'integration-tests/TEST-23-UNIT-FILE/TEST-23-UNIT-FILE.units',
'integration-tests/TEST-30-ONCLOCKCHANGE/TEST-30-ONCLOCKCHANGE.units',
'integration-tests/TEST-38-FREEZER/TEST-38-FREEZER.units',
'integration-tests/TEST-52-HONORFIRSTSHUTDOWN/TEST-52-HONORFIRSTSHUTDOWN.units',
'integration-tests/TEST-55-OOMD/TEST-55-OOMD.units',
'integration-tests/TEST-62-RESTRICT-IFACES/TEST-62-RESTRICT-IFACES.units',
'integration-tests/TEST-63-PATH/TEST-63-PATH.units',
'integration-tests/TEST-65-ANALYZE/TEST-65-ANALYZE.units',
'integration-tests/TEST-66-DEVICE-ISOLATION/TEST-66-DEVICE-ISOLATION.units',
'integration-tests/TEST-80-NOTIFYACCESS/TEST-80-NOTIFYACCESS.units',
'units',
]
foreach subdir : testdata_subdirs

View File

@ -10,6 +10,8 @@
[Unit]
Description=System Initialization
Documentation=man:systemd.special(7)
Conflicts=emergency.service emergency.target
Wants=local-fs.target swap.target
After=local-fs.target swap.target emergency.service emergency.target
After=local-fs.target swap.target
Conflicts=emergency.service emergency.target
Before=emergency.service emergency.target

90
test/units/TEST-07-PID1.mask.sh Executable file
View File

@ -0,0 +1,90 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux
set -o pipefail
at_exit() {
set +e
systemctl stop mask-test.service
rm -rf /run/systemd/system/mask-test.service*
systemctl daemon-reload
rm -f /tmp/should-not-exist-by-*
}
trap at_exit EXIT
rm -f /tmp/should-not-exist-by-*
mkdir -p /run/systemd/system/mask-test.service.d
cat >/run/systemd/system/mask-test.service <<EOF
[Service]
Type=exec
ExecStart=sleep infinity
ExecStop=touch /tmp/should-not-exist-by-main
EOF
# Check if ExecStop= and friends in a masked unit are not executed even defined
# in drop-in. See issue #38802.
cat >/run/systemd/system/mask-test.service.d/10-stop.conf <<EOF
[Service]
ExecStop=touch /tmp/should-not-exist-by-dropin
EOF
systemctl daemon-reload
[[ "$(systemctl is-enabled mask-test.service || :)" == static ]]
systemctl start mask-test.service
[[ "$(systemctl is-active mask-test.service || :)" == active ]]
# When not masked, of course ExecStop= are executed.
systemctl stop mask-test.service
[[ "$(systemctl is-active mask-test.service || :)" == inactive ]]
[[ -f /tmp/should-not-exist-by-main ]]
[[ -f /tmp/should-not-exist-by-dropin ]]
rm -f /tmp/should-not-exist-by-*
systemctl start mask-test.service
[[ "$(systemctl is-active mask-test.service || :)" == active ]]
# Check if mask --now works and ExecStop= are not executed.
systemctl mask --now mask-test.service
[[ "$(systemctl is-enabled mask-test.service || :)" == masked ]]
[[ "$(systemctl is-active mask-test.service || :)" == inactive ]]
[[ ! -f /tmp/should-not-exist-by-main ]]
[[ ! -f /tmp/should-not-exist-by-dropin ]]
systemctl unmask mask-test.service
[[ "$(systemctl is-enabled mask-test.service || :)" == static ]]
systemctl start mask-test.service
[[ "$(systemctl is-active mask-test.service || :)" == active ]]
systemctl mask mask-test.service
[[ "$(systemctl is-enabled mask-test.service || :)" == masked ]]
[[ "$(systemctl is-active mask-test.service || :)" == active ]]
# Check if mask --now for already masked unit stops the service.
systemctl mask --now mask-test.service
[[ "$(systemctl is-enabled mask-test.service || :)" == masked ]]
[[ "$(systemctl is-active mask-test.service || :)" == inactive ]]
[[ ! -f /tmp/should-not-exist-by-main ]]
[[ ! -f /tmp/should-not-exist-by-dropin ]]
systemctl unmask mask-test.service
[[ "$(systemctl is-enabled mask-test.service || :)" == static ]]
systemctl start mask-test.service
[[ "$(systemctl is-active mask-test.service || :)" == active ]]
systemctl mask mask-test.service
[[ "$(systemctl is-enabled mask-test.service || :)" == masked ]]
[[ "$(systemctl is-active mask-test.service || :)" == active ]]
# Check if already masked unit can be stopped.
systemctl stop mask-test.service
[[ "$(systemctl is-active mask-test.service || :)" == inactive ]]
[[ ! -f /tmp/should-not-exist-by-main ]]
[[ ! -f /tmp/should-not-exist-by-dropin ]]

View File

@ -31,8 +31,8 @@ busctl call \
org.freedesktop.systemd1.Manager StartTransientUnit \
"ssa(sv)a(sa(sv))" "$TEST_UNIT" replace 4 \
ExecStart "a(sasb)" 1 \
/usr/lib/systemd/tests/testdata/units/TEST-23-UNIT-FILE-ExtraFileDescriptors-child.sh \
5 /usr/lib/systemd/tests/testdata/units/TEST-23-UNIT-FILE-ExtraFileDescriptors-child.sh 2 "test:other" "Hello" "Extra" \
/usr/lib/systemd/tests/testdata/TEST-23-UNIT-FILE.units/TEST-23-UNIT-FILE-ExtraFileDescriptors-child.sh \
5 /usr/lib/systemd/tests/testdata/TEST-23-UNIT-FILE.units/TEST-23-UNIT-FILE-ExtraFileDescriptors-child.sh 2 "test:other" "Hello" "Extra" \
true \
RemainAfterExit "b" true \
Type "s" oneshot \

View File

@ -28,7 +28,7 @@ systemd-run -p DynamicUser=yes -p EnvironmentFile=-/usr/lib/systemd/systemd-asan
-p RemainAfterExit=yes \
--unit=test-23-openfile-existing.service \
--service-type=oneshot \
/usr/lib/systemd/tests/testdata/units/TEST-23-UNIT-FILE-openfile-child.sh 2 "open.txt:colon" "Open" "File"
/usr/lib/systemd/tests/testdata/TEST-23-UNIT-FILE.units/TEST-23-UNIT-FILE-openfile-child.sh 2 "open.txt:colon" "Open" "File"
cmp <(systemctl show -p OpenFile test-23-openfile-existing.service) <<EOF
OpenFile=/tmp/test-open-file/open.txt::read-only
@ -43,7 +43,7 @@ systemctl start TEST-23-UNIT-FILE-openfile-server.socket
systemd-run -p OpenFile=/tmp/test.sock:socket:read-only \
--wait \
/usr/lib/systemd/tests/testdata/units/TEST-23-UNIT-FILE-openfile-child.sh 1 "socket" "Socket"
/usr/lib/systemd/tests/testdata/TEST-23-UNIT-FILE.units/TEST-23-UNIT-FILE-openfile-child.sh 1 "socket" "Socket"
systemctl stop TEST-23-UNIT-FILE-openfile-server.socket

View File

@ -1375,6 +1375,16 @@ EOF
assert_in "${loop}p3 : start= *${start}, size= *${size}, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=DB081670-07AE-48CA-9F5E-813D5E40B976, name=\"linux-generic-2\"" "$output"
}
testcase_sector() {
# Valid block sizes on the Linux block layer are >= 512 and <= PAGE_SIZE, and
# must be powers of 2. Which leaves exactly four different ones to test on
# typical hardware
test_sector 512
test_sector 1024
test_sector 2048
test_sector 4096
}
testcase_dropped_partitions() {
local workdir image defs
@ -1618,6 +1628,57 @@ EOF
assert_in "${image}2 : start= 286680, size= 532480, type=${esp_guid}" "$output"
}
testcase_btrfs() {
local defs imgs output root
if ! systemd-analyze compare-versions "$(btrfs --version | head -n 1 | awk '{ print $2 }')" ge v6.12; then
echo "btrfs-progs is not installed or older than v6.12, skipping test."
return 0
fi
if [[ "$OFFLINE" != "yes" ]]; then
return 0
fi
defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")"
imgs="$(mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")"
root="$(mktemp --directory "/var/test-repart.root.XXXXXXXXXX")"
# shellcheck disable=SC2064
trap "rm -rf '$defs' '$imgs' '$root'" RETURN
chmod 0755 "$defs"
echo "*** testcase for btrfs ***"
tee "$defs/root.conf" <<EOF
[Partition]
Type=root
Format=btrfs
MakeDirectories=/@ /@home
Subvolumes=/@ /@home
DefaultSubvolume=/@
MountPoint=/:"subvol=@,zstd:1,noatime,lazytime"
MountPoint=/home:"subvol=@home,zstd:1,noatime,lazytime"
EOF
mkdir -p "$root"/etc
systemd-repart --pretty=yes \
--definitions "$defs" \
--empty=create \
--size=1G \
--seed="$seed" \
--dry-run=no \
--offline=yes \
--generate-fstab "$root"/etc/fstab \
"$imgs/btrfs.img"
sfdisk --dump "$imgs/btrfs.img"
cat "$root"/etc/fstab
grep -q 'UUID=[0-9a-f-]* / btrfs discard,rw,nodev,suid,exec,subvol=@,zstd:1,noatime,lazytime 0 1' "$root"/etc/fstab
grep -q 'UUID=[0-9a-f-]* /home btrfs discard,rw,nodev,suid,exec,subvol=@home,zstd:1,noatime,lazytime 0 1' "$root"/etc/fstab
}
OFFLINE="yes"
run_testcases
@ -1627,12 +1688,4 @@ if ! systemd-detect-virt --container; then
run_testcases
fi
# Valid block sizes on the Linux block layer are >= 512 and <= PAGE_SIZE, and
# must be powers of 2. Which leaves exactly four different ones to test on
# typical hardware
test_sector 512
test_sector 1024
test_sector 2048
test_sector 4096
touch /testok

View File

@ -510,6 +510,12 @@ systemd-analyze verify /tmp/testwarnings.service
rm /tmp/testwarnings.service
TESTDATA=/usr/lib/systemd/tests/testdata/TEST-65-ANALYZE.units
systemd-analyze verify "${TESTDATA}/loopy.service"
systemd-analyze verify "${TESTDATA}/loopy2.service"
systemd-analyze verify "${TESTDATA}/loopy3.service"
systemd-analyze verify "${TESTDATA}/loopy4.service"
# Added an additional "INVALID_ID" id to the .json to verify that nothing breaks when input is malformed
# The PrivateNetwork id description and weight was changed to verify that 'security' is actually reading in
# values from the .json file when required. The default weight for "PrivateNetwork" is 2500, and the new weight

View File

@ -177,6 +177,10 @@ rm -fv /run/systemd/coredump.conf.d/99-external.conf
# Wait a bit for the coredumps to get processed
timeout 30 bash -c "while [[ \$(coredumpctl list -q --no-legend $CORE_TEST_UNPRIV_BIN | wc -l) -lt 4 ]]; do sleep 1; done"
# Sync and rotate journal again to make the coredump stored in an archived journal.
journalctl --sync
journalctl --rotate
# root should see coredumps from both binaries
coredumpctl info "$CORE_TEST_UNPRIV_BIN"
coredumpctl info "${CORE_TEST_UNPRIV_BIN##*/}"

View File

@ -3,6 +3,14 @@
set -eux
set -o pipefail
# For issue #38765
journalctl --sync
if journalctl -q -o short-monotonic --grep "Looking at job .*/.* conflicted_by=(yes|no)" >/failed; then
echo "Found unexpected unmergeable jobs"
cat /failed
exit 1
fi
# shellcheck source=test/units/test-control.sh
. "$(dirname "$0")"/test-control.sh

View File

@ -1,4 +1,15 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# We use a custom autorelabel service instead of the SELinux provided set of
# units & a generator, since the generator overrides the default target to the
# SELinux one when it detects /.autorelabel. However, we use systemd.unit= on
# the kernel command cmdline which always takes precedence, rendering all
# SELinux efforts useless. Also, pulling in selinux-autorelabel.service
# explicitly doesn't work either, as it doesn't check for the presence of
# /.autorelabel and does the relabeling unconditionally which always ends with
# a reboot, so we end up in a reboot loop (and it also spews quite a lot of
# errors as it wants /etc/fstab and dracut-initramfs-restore).
[Unit]
Description=Relabel all filesystems
DefaultDependencies=no

View File

@ -1,14 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Shutdown
Documentation=man:systemd.special(7)
DefaultDependencies=no
RefuseManualStart=yes

View File

@ -1,12 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Sockets
Documentation=man:systemd.special(7)

View File

@ -1,15 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Timers
Documentation=man:systemd.special(7)
DefaultDependencies=no
Conflicts=shutdown.target