From 46f247d88072ef42cc69af553b112525b19a51e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Mon, 29 Apr 2024 10:11:16 +0200 Subject: [PATCH] Also substitute $HOME in runlabel with user's homedir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some programs have their configuration files relative to the user's home. It would be convenient being able to mount these into the container, but that requires expansion of `~` or `$HOME` in a label. This commit adds support for that for the `runlabel` command. Signed-off-by: Dan Čermák --- pkg/domain/infra/abi/containers_runlabel.go | 7 +++++++ test/system/037-runlabel.bats | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/domain/infra/abi/containers_runlabel.go b/pkg/domain/infra/abi/containers_runlabel.go index 7b63848c61..2a4119996f 100644 --- a/pkg/domain/infra/abi/containers_runlabel.go +++ b/pkg/domain/infra/abi/containers_runlabel.go @@ -173,6 +173,13 @@ func generateRunlabelCommand(runlabel string, img *libimage.Image, inputName str return "" } return d + case "HOME": + h, err := os.UserHomeDir() + if err != nil { + logrus.Warnf("Unable to determine user's home directory: %s", err) + return "" + } + return h } return "" } diff --git a/test/system/037-runlabel.bats b/test/system/037-runlabel.bats index 3056d6aca7..b59b8c1f88 100644 --- a/test/system/037-runlabel.bats +++ b/test/system/037-runlabel.bats @@ -12,16 +12,16 @@ load helpers rand3=$(random_string 30) cat >$containerfile <