Skip to content

Commit 10212d7

Browse files
mahkohrfjakob
authored andcommitted
Set a default PATH if PATH is empty or unset
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.
1 parent 53d6a99 commit 10212d7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ func main() {
126126
// On a 2-core machine, setting maxprocs to 4 gives 10% better performance
127127
runtime.GOMAXPROCS(4)
128128
}
129+
// mount(1) unsets PATH. Since exec.Command does not handle this case, we set
130+
// PATH to a default value if it's empty or unset.
131+
if os.Getenv("PATH") == "" {
132+
os.Setenv("PATH", "/usr/sbin:/usr/bin:/sbin:/bin")
133+
}
129134
var err error
130135
// Parse all command-line options (i.e. arguments starting with "-")
131136
// into "args". Path arguments are parsed below.

0 commit comments

Comments
 (0)