Merge pull request #24011 from poettering/condition-cred

pid1: add new condition type "ConditionCredential=" for checking for credentials passed into the system
This commit is contained in:
Lennart Poettering
2022-07-15 15:03:49 +02:00
committed by GitHub
19 changed files with 186 additions and 35 deletions

View File

@@ -1,18 +1,19 @@
[Match]
MACAddress=
PermanentMACAddress=
OriginalName=
Path=
Architecture=
Credential=
Driver=
Type=
Kind=
Property=
Firmware=
Host=
Virtualization=
KernelCommandLine=
KernelVersion=
Architecture=
Firmware=
Kind=
MACAddress=
OriginalName=
Path=
PermanentMACAddress=
Property=
Type=
Virtualization=
[Link]
Description=
MACAddressPolicy=

View File

@@ -24,11 +24,12 @@ Mode=
SourceMACAddress=
[Match]
Architecture=
Credential=
Firmware=
Host=
KernelCommandLine=
KernelVersion=
Virtualization=
KernelCommandLine=
[GENEVE]
DestinationPort=
TTL=

View File

@@ -15,23 +15,24 @@ ProxyARP=
ProxyARPWiFi=
MulticastRouter=
[Match]
KernelVersion=
Type=
Kind=
Driver=
Architecture=
Firmware=
Path=
WLANInterfaceType=
SSID=
BSSID=
Name=
Property=
Virtualization=
KernelCommandLine=
Credential=
Driver=
Firmware=
Host=
KernelCommandLine=
KernelVersion=
Kind=
MACAddress=
Name=
Path=
PermanentMACAddress=
Property=
SSID=
Type=
Virtualization=
WLANInterfaceType=
[Link]
ActivationPolicy=
RequiredForOnline=

View File

@@ -10,9 +10,10 @@ Also=
AmbientCapabilities=
AssertACPower=
AssertArchitecture=
AssertCPUPressure=
AssertCapability=
AssertControlGroupController=
AssertCPUPressure=
AssertCredential=
AssertDirectoryNotEmpty=
AssertFileIsExecutable=
AssertFileNotEmpty=
@@ -59,6 +60,7 @@ ConditionACPower=
ConditionArchitecture=
ConditionCapability=
ConditionControlGroupController=
ConditionCredential=
ConditionCPUPressure=
ConditionDirectoryNotEmpty=
ConditionFileIsExecutable=
@@ -481,6 +483,7 @@ InitialCongestionWindow=
InputKey=
InvertRule=
KernelCommandLine=
Credential=
KernelVersion=
Key=
Kind=

View File

@@ -9,6 +9,7 @@ AssertCPUPressure=
AssertCPUs=
AssertCapability=
AssertControlGroupController=
AssertCredential=
AssertDirectoryNotEmpty=
AssertEnvironment=
AssertFileIsExecutable=
@@ -47,6 +48,7 @@ ConditionCPUs=
ConditionFirmware=
ConditionCapability=
ConditionControlGroupController=
ConditionCredential=
ConditionDirectoryNotEmpty=
ConditionEnvironment=
ConditionFileIsExecutable=

View File

@@ -58,6 +58,12 @@ if [ "$expected_credential" != "" ] ; then
# Combine it with a fallback (which should have no effect, given the cred should be passed down)
[ "$(systemd-run -p LoadCredential="$expected_credential" -p SetCredential="$expected_credential":zzz --pipe --wait systemd-creds cat "$expected_credential")" = "$expected_value" ]
# This should succeed
systemd-run -p AssertCredential="$expected_credential" -p Type=oneshot true
# And this should fail
systemd-run -p AssertCredential="undefinedcredential" -p Type=oneshot true && { echo 'unexpected success'; exit 1; }
fi
# Verify that the creds are immutable