daemonize: try /bin/logger if /usr/bin/logger fails

SUSE has /bin/logger, everybody else has /usr/bin/logger,
so try both.

Fixes https://github.com/rfjakob/gocryptfs/issues/225
This commit is contained in:
Jakob Unterwurzacher 2018-04-11 20:31:02 +02:00
parent bcc8378a2c
commit 12832851c6
1 changed files with 9 additions and 3 deletions

View File

@ -65,9 +65,15 @@ func redirectStdFds() {
return
}
tag := fmt.Sprintf("gocryptfs-%d-logger", os.Getpid())
cmd := exec.Command("/usr/bin/logger", "-t", tag)
cmd.Stdin = pr
err = cmd.Start()
// 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
}
}
if err != nil {
tlog.Warn.Printf("redirectStdFds: could not start logger: %v\n", err)
return