From: Lennart Poettering Date: Thu, 27 Feb 2025 16:20:29 +0000 (+0100) Subject: test: add integration test for the functionality added in this PR X-Git-Tag: v258-rc1~1143^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b9f711b66e5ccbb2935d87281adebf7652968c2e;p=thirdparty%2Fsystemd.git test: add integration test for the functionality added in this PR --- diff --git a/test/units/TEST-46-HOMED.sh b/test/units/TEST-46-HOMED.sh index 5bab0b11b7f..78c91044b81 100755 --- a/test/units/TEST-46-HOMED.sh +++ b/test/units/TEST-46-HOMED.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: LGPL-2.1-or-later -# shellcheck disable=SC2016 +# shellcheck disable=SC2016,SC2209 set -eux set -o pipefail @@ -28,9 +28,18 @@ inspect() { homectl inspect --json=pretty "$USERNAME" } +wait_for_exist() { + # 2min max + for i in {1..60}; do + (( i > 1 )) && sleep 2 + homectl inspect "$1" && break + done +} + wait_for_state() { - for i in {1..10}; do - (( i > 1 )) && sleep 0.5 + # 2min max + for i in {1..60}; do + (( i > 1 )) && sleep 2 homectl inspect "$1" | grep -qF "State: $2" && break done } @@ -46,6 +55,9 @@ systemctl service-log-level systemd-homed debug mkdir -p /home mount -t tmpfs tmpfs /home -o size=290M +# Make sure systemd-homed takes notice of the overmounted /home/ +systemctl kill -sUSR1 systemd-homed + TMP_SKEL=$(mktemp -d) echo hogehoge >"$TMP_SKEL"/hoge @@ -727,6 +739,108 @@ systemctl stop user@"$(id -u subareatest)".service wait_for_state subareatest inactive homectl remove subareatest +# Test signing key logic +homectl list-signing-keys | grep -q local.public +(! (homectl list-signing-keys | grep -q signtest.public)) + +IDENTITY='{"userName":"signtest","storage":"directory","disposition":"regular","privileged":{"hashedPassword":["$y$j9T$I5Wxfm.fyg.RRWlgWw.rI1$gnQqGtbpPexqxZJkWMq8FxQi5Swc.CWeKtM8LwvEUB6"]},"enforcePasswordPolicy":false,"lastChangeUSec":1740677608017608,"lastPasswordChangeUSec":1740677608017608,"signature":[{"data":"Gl4wtc0sMjVnsH6FQwG/0M+x0nLI5cvvdtSSCttUu1gNtXqYn0UI4wZi/7zX35ERht6XHWDlP4d6V8HiAst4Dg==","key":"-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEA6uvVaP1vh7O6nIbiOcvyIHRl4ihYSs0R7ctxtz2Zu7E=\n-----END PUBLIC KEY-----\n"}],"secret":{"password":["test"]}}' + +# Try with stripping the foreign signature first, this should just work +echo "$IDENTITY" | homectl create -P --identity=- --seize=yes +homectl remove signtest + +# No try again, and don't strip the signature. It will be refused. +(! (echo "$IDENTITY" | homectl create -P --identity=- --seize=no)) + +print_public_key() { + cat <