main: drop hardcoded /usr/bin/logger path

The hardcoded full paths were introduced to handle the
case of an empty PATH environment variable. However,
since commit 10212d791a we set PATH to a default
value if empty. The hardcoded paths are no longer neccessary,
and cause problems on some distros:

User voobscout on
https://github.com/rfjakob/gocryptfs/issues/225#issuecomment-438682034 :

  just to chime in - please don't hardcode paths, for example I'm on
  NixOS and logger lives in /run/current-system/sw/bin/logger

Drop the hardcoded paths.
This commit is contained in:
Jakob Unterwurzacher 2018-11-17 17:03:11 +01:00
parent 1ed08c7384
commit d882ed45da

View File

@ -72,15 +72,9 @@ func redirectStdFds() {
return
}
tag := fmt.Sprintf("gocryptfs-%d-logger", os.Getpid())
// SUSE has /bin/logger, everybody else has /usr/bin/logger.
for _, path := range []string{"/usr/bin/logger", "/bin/logger"} {
cmd := exec.Command(path, "-t", tag)
cmd.Stdin = pr
err = cmd.Start()
if err == nil {
break
}
}
cmd := exec.Command("logger", "-t", tag)
cmd.Stdin = pr
err = cmd.Start()
if err != nil {
tlog.Warn.Printf("redirectStdFds: could not start logger: %v\n", err)
return