From: Yu Watanabe Date: Sat, 3 Aug 2024 05:19:35 +0000 (+0900) Subject: core: make ImportCredentialEx= DBus property support without renaming X-Git-Tag: v257-rc1~751^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40dd2a1c24b886d9e635fef8f7b5336700df03c3;p=thirdparty%2Fsystemd.git core: make ImportCredentialEx= DBus property support without renaming Note that the conf parser for ImportCredential= checks in the same way. Follow-up for 831f208783aeac443e6f2fc2efc3119535a032ef. --- diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index feafa15e430..c7c43ce7d38 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -2225,7 +2225,7 @@ int bus_exec_context_set_transient_property( if (!credential_glob_valid(glob)) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Credential name or glob is invalid: %s", glob); - if (rename && !credential_name_valid(rename)) + if (!isempty(rename) && !credential_name_valid(rename)) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Credential name is invalid: %s", rename); empty = false; diff --git a/test/units/TEST-54-CREDS.sh b/test/units/TEST-54-CREDS.sh index 9f7f4b11606..aa0a1329e0e 100755 --- a/test/units/TEST-54-CREDS.sh +++ b/test/units/TEST-54-CREDS.sh @@ -279,6 +279,8 @@ echo -n ignored >/run/credstore/test.creds.second mkdir -p /etc/credstore echo -n b >/etc/credstore/test.creds.second echo -n c >/etc/credstore/test.creds.third + +# Check that all valid credentials are imported. systemd-run -p "ImportCredential=test.creds.*" \ --unit=test-54-ImportCredential.service \ -p DynamicUser=1 \ @@ -289,6 +291,17 @@ systemd-run -p "ImportCredential=test.creds.*" \ '${CREDENTIALS_DIRECTORY}/test.creds.third' >/tmp/ts54-concat cmp /tmp/ts54-concat <(echo -n abc) +# Check that ImportCredentialEx= works without renaming. +systemd-run -p "ImportCredentialEx=test.creds.*" \ + --unit=test-54-ImportCredential.service \ + -p DynamicUser=1 \ + --wait \ + --pipe \ + cat '${CREDENTIALS_DIRECTORY}/test.creds.first' \ + '${CREDENTIALS_DIRECTORY}/test.creds.second' \ + '${CREDENTIALS_DIRECTORY}/test.creds.third' >/tmp/ts54-concat +cmp /tmp/ts54-concat <(echo -n abc) + # Check that renaming with globs works as expected. systemd-run -p "ImportCredentialEx=test.creds.*:renamed.creds." \ --unit=test-54-ImportCredential.service \