-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Issue Description
I'm been experimenting the shell driver of podman secrets. It's not really working well.
Steps to reproduce the issue
Setup
I created a simple shell script test.sh
podman secret create \
--driver=shell \
--driver-opts=list=/bin/true \
--driver-opts=lookup="cat $2" \
--driver-opts=store=/bin/true \
--driver-opts=delete=/bin/true \
--replace=true \
"$1" - <<<SECRET
The idea is, test.sh name filename will allow me to register the content of filename as secret name. This is similar to LoadCredential= in systemd.
Test Cases
Test Case 1
- Make sure
podman secret lsis empty, make sure/var/lib/containers/storage/secretsis empty (or does not exist). - Run as root (same below)
echo SECRET | podman secret create test1 - podman secret lsshould showtest1test.sh test2 /test2podman secret lsshows onlytest2.test1disappeared/var/lib/containers/storage/secrets/filedriver/secretsdata.jsonstill containstest1.
Test Case 2
- Make sure
podman secret lsis empty, make sure/var/lib/containers/storage/secretsis empty (or does not exist). - Run as root (same below)
echo SECRET | podman secret create test1 - echo SECRET | podman secret create test2 -podman secret lsshould showtest1andtest2test.sh test3 /test3got errorError: deleting secret : more than one result secret with prefix : secret is ambiguous
Issue 1: Bug with --replace for new secret
When --replace is specified, podman tries to delete the old secret, however, the ID field is not set for new secrets.
This means we are deleting a secret with an empty string. The file driver will throw an "no such secret" error, which is muted, that's why the file driver works.
However, if the driver does not throw an error, podman will go ahead and try to delete the metadata. Because an empty ID does not exist, it is now interpreted as a prefix (which is even worse in my opinion).
This explains both test cases: if there is only one entry in the store, it is matched with the empty prefix and deleted. If there are multiple entries, podman will complain the prefix is ambigiuous.
Proposal
A workaround is to check SECRET_ID is not empty in the shell script. But I think this is hacky, because the shell driver treats any error as "no such secret" error.
The correct solution should be avoid deleting anything, when adding a new secret.
Issue 2: Incorrect logic with multiple drivers
Let's say I run the following:
podman secret create --driver=DRIVER1 --replace secret ...podman secret create --driver=DRIVER2 --replace secret ...
Currently podman asks DRIVER2 to delete the secret, which doesn't make sense to me. We should use DRIVER1.
Issue 3: Quoting/Escaping issues with shell scripts
It seems that if a script (e.g. lookup/delete/store/list) ends with ", it will be removed. Examples:
--driver-opts=list="echo \"SECRET\""will produce"list": "echo \"SECRET"inpodman secret inspect--driver-opts=list="echo \"SECRET\" "works as expected, note the trialing whitespace.
Issue 4: list command for shell driver
Throughout the codebase I cannot find where it is used, nor can I trigger it.
Is it expected?
Describe the results you received
See above
Describe the results you expected
See above
podman info output
podman version 5.4.2 on Debian.Podman in a container
No
Privileged Or Rootless
Privileged
Upstream Latest Release
No
Additional environment details
No response
Additional information
No response