diff options
author | Jakob Unterwurzacher | 2017-05-23 18:01:21 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2017-05-23 18:01:21 +0200 |
commit | 508fd9e1d64131958c86175cb8d848f730e629cf (patch) | |
tree | 6d6d9370bf9760af229e93bbea29cb0f9cf4f494 /mount.go | |
parent | 245b84c887955d12cd1113e9a6701ee7338c8255 (diff) |
main: downgrade panic log create failure from fatal error to warning
Exiting with a fatal error just pushes users to use "-nosyslog",
which is even worse than not having a paniclog.
Diffstat (limited to 'mount.go')
-rw-r--r-- | mount.go | 25 |
1 files changed, 18 insertions, 7 deletions
@@ -117,8 +117,8 @@ func doMount(args *argContainer) int { if !args.nosyslog { paniclog, err = ioutil.TempFile("", "gocryptfs_paniclog.") if err != nil { - tlog.Fatal.Printf("Failed to create gocryptfs_paniclog: %v", err) - os.Exit(exitcodes.PanicLogCreate) + tlog.Warn.Printf("Failed to create paniclog: %v."+ + " Carrying on, but fatal errors will not be logged.", err) } // Switch all of our logs and the generic logger to syslog tlog.Info.SwitchToSyslog(syslog.LOG_USER | syslog.LOG_INFO) @@ -132,10 +132,21 @@ func doMount(args *argContainer) int { // instead of closing them so users have a chance to get the // backtrace on a panic. // https://github.com/golang/go/issues/325#issuecomment-66049178 - syscall.Dup2(int(paniclog.Fd()), 1) - syscall.Dup2(int(paniclog.Fd()), 2) - // No need for the extra FD anymore, we have it saved in Stderr - paniclog.Close() + if paniclog != nil { + err = syscall.Dup2(int(paniclog.Fd()), 1) + if err != nil { + tlog.Warn.Printf("paniclog stdout dup error: %v\n", err) + } + syscall.Dup2(int(paniclog.Fd()), 2) + if err != nil { + tlog.Warn.Printf("paniclog stderr dup error: %v\n", err) + } + // No need for the extra FD anymore, we have copies in Stdout and Stderr + err = paniclog.Close() + if err != nil { + tlog.Warn.Printf("paniclog close error: %v\n", err) + } + } } // Disconnect from the controlling terminal by creating a new session. // This prevents us from getting SIGINT when the user presses Ctrl-C @@ -158,7 +169,7 @@ func doMount(args *argContainer) int { srv.Serve() // Delete empty paniclogs if paniclog != nil { - // The paniclog FD is saved in Stderr + // The paniclog FD is saved in Stdout and Stderr fi, err := os.Stderr.Stat() if err != nil { tlog.Warn.Printf("paniclog fstat error: %v", err) |