Skip to content

Commit

Permalink
client/allocdir: chown directories as _daemon_ user if avaliable
Browse files Browse the repository at this point in the history
running within a snap (https://snapcraft.io/) means code is unable to chown to nobody user unfortunately

chown to _daemon_ user instead if available https://snapcraft.io/docs/system-usernames

ref hashicorp#23619
  • Loading branch information
stuart-warren committed Jul 18, 2024
1 parent afbd283 commit 9bb083b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions client/allocdir/fs_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ func dropDirPermissions(path string, desired os.FileMode) error {
return fmt.Errorf("Unable to find nobody user: %w", err)
}

// Within a snap we can't chown to `nobody`, so we use `_daemon_` instead
// requires snap configured to use `system-usernames`
// https://snapcraft.io/docs/system-usernames
snapu, err := users.Lookup("_daemon_")
if err == nil {
u = snapu
}

uid, err := getUid(u)
if err != nil {
return err
Expand Down

0 comments on commit 9bb083b

Please sign in to comment.