From b15e15f03877a96f3db700e513f13d87aaf602a8 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 7b63848c61ad..bc65af7c46a0 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": + if h, err := os.UserHomeDir(); err != nil { + logrus.Error("Unable to determine user's home directory") + return "" + } else { + return h + } } return "" } diff --git a/test/system/037-runlabel.bats b/test/system/037-runlabel.bats index 3056d6aca740..b59b8c1f8855 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 <