Skip to content

Commit

Permalink
Set a default PATH if PATH is empty or unset
Browse files Browse the repository at this point in the history
mount(1) unsets PATH before calling mount.fuse. Therefore it's not set
in gocrpytfs either and daemonization fails if gocryptfs was not
executed via an absolute path.

mount.fuse handles this by leaving the execution of the helper to
/bin/sh. /bin/sh handles an empty PATH by searching a few default
locations.

This patch sets the PATH to a sane default if it's empty or unset.
  • Loading branch information
mahkoh authored and rfjakob committed Jun 7, 2018
1 parent 53d6a99 commit 10212d7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ func main() {
// On a 2-core machine, setting maxprocs to 4 gives 10% better performance
runtime.GOMAXPROCS(4)
}
// mount(1) unsets PATH. Since exec.Command does not handle this case, we set
// PATH to a default value if it's empty or unset.
if os.Getenv("PATH") == "" {
os.Setenv("PATH", "/usr/sbin:/usr/bin:/sbin:/bin")
}
var err error
// Parse all command-line options (i.e. arguments starting with "-")
// into "args". Path arguments are parsed below.
Expand Down

0 comments on commit 10212d7

Please sign in to comment.