diff options
author | Aditya Rajan <arajan@redhat.com> | 2021-11-15 14:39:26 +0530 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2021-12-06 14:37:46 -0500 |
commit | db6b9131ef1a14cd19cdd52425fb60d90862f05e (patch) | |
tree | 71158613e1f1905fea963b8bb6dec3d544658d4d /libpod | |
parent | 08bcd60c8f4147e4817d3e4e488e3394dbb29c64 (diff) | |
download | podman-db6b9131ef1a14cd19cdd52425fb60d90862f05e.tar.gz podman-db6b9131ef1a14cd19cdd52425fb60d90862f05e.tar.bz2 podman-db6b9131ef1a14cd19cdd52425fb60d90862f05e.zip |
secret: honor custom target for secrets with run
Honor custom `target` if specified while running or creating containers
with secret `type=mount`.
Example:
`podman run -it --secret token,type=mount,target=TOKEN ubi8/ubi:latest
bash`
Signed-off-by: Aditya Rajan <arajan@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container.go | 2 | ||||
-rw-r--r-- | libpod/container_internal_linux.go | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/libpod/container.go b/libpod/container.go index a4bbb5dd0..8bbe02b58 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -253,6 +253,8 @@ type ContainerSecret struct { GID uint32 // Mode is the mode of the secret file Mode uint32 + // Secret target inside container + Target string } // ContainerNetworkDescriptions describes the relationship between the CNI diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 89869e2f5..1c85339c7 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -1777,8 +1777,17 @@ rootless=%d return errors.Wrapf(err, "error creating secrets mount") } for _, secret := range c.Secrets() { + secretFileName := secret.Name + base := "/run/secrets" + if secret.Target != "" { + secretFileName = secret.Target + //If absolute path for target given remove base. + if filepath.IsAbs(secretFileName) { + base = "" + } + } src := filepath.Join(c.config.SecretsPath, secret.Name) - dest := filepath.Join("/run/secrets", secret.Name) + dest := filepath.Join(base, secretFileName) c.state.BindMounts[dest] = src } } |