From 2ff6973350682f8d16371f8c071a304b8067f192 Mon Sep 17 00:00:00 2001 From: Roman Gonzalez Date: Wed, 21 Jun 2023 12:48:31 -0700 Subject: [PATCH] fix(darwin): RuntimeDir trailing slash In later versions of macOS (e.g. Ventura), the command used to get a runtime directory (e.g. `getconf DARWIN_USER_TEMP_DIR`) returns a trailing slash. When using a configuration like: ``` sops.defaultSecretsMountPoint = "%r/secrets.d"; ``` The final path is going to contain a double slash in the suffix of the path, an example: ``` /var////secrets.d ``` This commit ensures that the runtime dir will get the trailing '/' character removed. --- pkgs/sops-install-secrets/darwin.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/sops-install-secrets/darwin.go b/pkgs/sops-install-secrets/darwin.go index 95f3662..f1399b9 100644 --- a/pkgs/sops-install-secrets/darwin.go +++ b/pkgs/sops-install-secrets/darwin.go @@ -15,13 +15,13 @@ import ( ) func RuntimeDir() (string, error) { - // TODO this could be garbage collected on a 3d basis - out, err := exec.Command("getconf", "DARWIN_USER_TEMP_DIR").Output() + // TODO this could be garbage collected on a 3d basis + out, err := exec.Command("getconf", "DARWIN_USER_TEMP_DIR").Output() rundir := strings.TrimRight(string(out[:]), " \t\n") if err != nil { - return "", fmt.Errorf("Cannot get DARWIN_USER_TEMP_DIR: %v", err) + return "", fmt.Errorf("Cannot get DARWIN_USER_TEMP_DIR: %v", err) } - return rundir, nil + return strings.TrimSuffix(rundir, "/"), nil } func SecureSymlinkChown(symlinkToCheck string, expectedTarget string, owner, group int) error {