From b8a8000aba4620a1d93ac1d04dbb86050d9c5fe8 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 5 Sep 2024 15:49:09 +0900 Subject: [PATCH 1/3] repart: initialize seed earlier As the seed is used by context_load_partition_table() -> derive_uuid(). Fixes #34257. --- src/partition/repart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/partition/repart.c b/src/partition/repart.c index 6e76cb011a..8d8d133c05 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -8483,6 +8483,10 @@ static int run(int argc, char *argv[]) { if (!context) return log_oom(); + r = context_read_seed(context, arg_root); + if (r < 0) + return r; + r = context_copy_from(context); if (r < 0) return r; @@ -8560,10 +8564,6 @@ static int run(int argc, char *argv[]) { return r; } - r = context_read_seed(context, arg_root); - if (r < 0) - return r; - /* Make sure each partition has a unique UUID and unique label */ r = context_acquire_partition_uuids_and_labels(context); if (r < 0) From 56d6ebd40468e2a743b39ad7d87b0675bdf9a042 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 5 Sep 2024 17:58:29 +0900 Subject: [PATCH 2/3] test: add test case for systemd-repart --seed=random For issue #34257. --- test/units/TEST-58-REPART.sh | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/units/TEST-58-REPART.sh b/test/units/TEST-58-REPART.sh index b2a3be686c..6110dc4e52 100755 --- a/test/units/TEST-58-REPART.sh +++ b/test/units/TEST-58-REPART.sh @@ -1347,6 +1347,49 @@ EOF done } +testcase_random_seed() { + local defs imgs output + + # For issue #34257 + + defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")" + imgs="$(mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")" + # shellcheck disable=SC2064 + trap "rm -rf '$defs' '$imgs'" RETURN + chmod 0755 "$defs" + + tee "$defs/root.conf" < Date: Thu, 5 Sep 2024 17:57:24 +0900 Subject: [PATCH 3/3] test: fix indentation --- test/units/TEST-58-REPART.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/units/TEST-58-REPART.sh b/test/units/TEST-58-REPART.sh index 6110dc4e52..bbef52ea51 100755 --- a/test/units/TEST-58-REPART.sh +++ b/test/units/TEST-58-REPART.sh @@ -161,7 +161,7 @@ $imgs/zzz1 : start= 2048, size= 1775576, type=933AC7E1-2EB4-4F13-B844 $imgs/zzz2 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=78C92DB8-3D2B-4823-B0DC-792B78F66F1E, name=\"swap\"" systemd-repart --offline="$OFFLINE" \ - --definitions="$defs" \ + --definitions="$defs" \ --empty=create \ --size=50M \ --seed="$seed" \