Skip to content

Commit

Permalink
fix(darwin): RuntimeDir trailing slash
Browse files Browse the repository at this point in the history
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/<random>/<hash>//secrets.d
```

This commit ensures that the runtime dir will get the trailing '/'
character removed.
  • Loading branch information
Roman Gonzalez authored and mergify[bot] committed Jun 22, 2023
1 parent 4ce3cc3 commit 2ff6973
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkgs/sops-install-secrets/darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2ff6973

Please sign in to comment.