From 615119260d4eb680887f5f02c8b790c943230a6b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 12 Dec 2018 02:55:38 -0500 Subject: [PATCH] fix: ensure chowned properties always have a user and group set Depending on the execution path, the variables may not be set at the top-level. Closes #3328 --- plugins/common/properties.go | 7 +++++++ plugins/common/property-functions | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/common/properties.go b/plugins/common/properties.go index 46977b983..61da772f3 100644 --- a/plugins/common/properties.go +++ b/plugins/common/properties.go @@ -144,6 +144,13 @@ func setPermissions(path string, fileMode os.FileMode) (err error) { systemGroup := os.Getenv("DOKKU_SYSTEM_GROUP") systemUser := os.Getenv("DOKKU_SYSTEM_USER") + if systemGroup == "" { + systemGroup = "dokku" + } + if systemUser == "" { + systemUser = "dokku" + } + group, err := user.LookupGroup(systemGroup) if err != nil { return diff --git a/plugins/common/property-functions b/plugins/common/property-functions index ff68008f1..73828e286 100755 --- a/plugins/common/property-functions +++ b/plugins/common/property-functions @@ -67,7 +67,10 @@ fn-plugin-property-setup() { mkdir -p "${DOKKU_LIB_ROOT}/config/${PLUGIN}" chmod 0755 "${DOKKU_LIB_ROOT}/config/${PLUGIN}" - chown "${DOKKU_SYSTEM_USER}:${DOKKU_SYSTEM_GROUP}" "${DOKKU_LIB_ROOT}/config/${PLUGIN}" + + local dokku_system_group=${DOKKU_SYSTEM_GROUP:="dokku"} + local dokku_system_user=${DOKKU_SYSTEM_USER:="dokku"} + chown "${dokku_system_user}:${dokku_system_group}" "${DOKKU_LIB_ROOT}/config/${PLUGIN}" } fn-plugin-property-read() {