From 8729fa0e4b1ba89e4c18c7dfe367e744ae892a81 Mon Sep 17 00:00:00 2001 From: dongshengyuan <545258830@qq.com> Date: Thu, 16 Jul 2026 14:18:01 +0800 Subject: [PATCH] id128: reject app-specific IDs for new Reject --app-specific= for the new verb. The option only makes sense for verbs that derive IDs from an existing base ID. Reproducer: systemd-id128 new --app-specific=4f68bce3e8cd4db196e7fbcaf984b709 Before: the command printed a random ID and exited successfully. Follow-up: 0d1d512f7f42071595f0c950f911f3557fda09ea --- src/id128/id128.c | 4 ++++ test/units/TEST-74-AUX-UTILS.id128.sh | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/id128/id128.c b/src/id128/id128.c index a4452f1cc5..5326ef1f51 100644 --- a/src/id128/id128.c +++ b/src/id128/id128.c @@ -52,6 +52,10 @@ static int verb_new(int argc, char *argv[], uintptr_t _data, void *userdata) { sd_id128_t id; int r; + if (!sd_id128_is_null(arg_app)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Verb \"new\" cannot be combined with --app-specific=."); + r = sd_id128_randomize(&id); if (r < 0) return log_error_errno(r, "Failed to generate ID: %m"); diff --git a/test/units/TEST-74-AUX-UTILS.id128.sh b/test/units/TEST-74-AUX-UTILS.id128.sh index 5da2323461..518642442d 100755 --- a/test/units/TEST-74-AUX-UTILS.id128.sh +++ b/test/units/TEST-74-AUX-UTILS.id128.sh @@ -36,7 +36,6 @@ systemd-id128 show root --value --json=short | jq -e '.id | type == "string"' systemd-id128 --json=short new | jq -e '.id | type == "string"' systemd-id128 new -p systemd-id128 new -u -systemd-id128 new -a 4f68bce3e8cd4db196e7fbcaf984b709 systemd-id128 machine-id assert_eq "$(systemd-id128 --json=short machine-id | jq --raw-output .id)" "$(