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
1 changed files with 3 additions and 9 deletions

View File

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