1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-08 08:58:27 +03:00

core: make ImportCredentialEx= DBus property support without renaming

Note that the conf parser for ImportCredential= checks in the same way.

Follow-up for 831f208783aeac443e6f2fc2efc3119535a032ef.
This commit is contained in:
Yu Watanabe 2024-08-03 14:19:35 +09:00
parent e0fc14a456
commit 40dd2a1c24
2 changed files with 14 additions and 1 deletions

View File

@ -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;

View File

@ -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 \