1
0
Fork 0
mirror of https://github.com/Mic92/sops-nix.git synced 2024-12-14 11:57:52 +00:00

fix(darwin): use chown only on non user mode

On the latest version of macOS (Ventura 13.4 as of this date), this
change ownership will always fail with the error:

> Failed to mount filesystem for secrets: Cannot change owner/group of '.../secrets.d' to 0/0: chown .../secrets.d: operation not permitted
This commit is contained in:
Roman Gonzalez 2023-06-21 11:37:50 -07:00 committed by mergify[bot]
parent d299d05382
commit 4ce3cc3428

View file

@ -102,8 +102,10 @@ func MountSecretFs(mountpoint string, keysGid int, userMode bool) error {
// }
//}
if err := os.Chown(mountpoint, 0, int(keysGid)); err != nil {
return fmt.Errorf("Cannot change owner/group of '%s' to 0/%d: %w", mountpoint, keysGid, err)
if !userMode {
if err := os.Chown(mountpoint, 0, int(keysGid)); err != nil {
return fmt.Errorf("Cannot change owner/group of '%s' to 0/%d: %w", mountpoint, keysGid, err)
}
}
return nil