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.
This commit is contained in:
parent
245b84c887
commit
508fd9e1d6
|
@ -49,8 +49,9 @@ const (
|
||||||
FuseNewServer = 19
|
FuseNewServer = 19
|
||||||
// CtlSock - the control socket file could not be created.
|
// CtlSock - the control socket file could not be created.
|
||||||
CtlSock = 20
|
CtlSock = 20
|
||||||
// PanicLogCreate - there was a problem creating the /tmp/gocryptfs_paniclog.XYZ file.
|
// Downgraded to a warning in gocryptfs v1.4
|
||||||
PanicLogCreate = 21
|
//PanicLogCreate = 21
|
||||||
|
|
||||||
// PasswordEmpty - we received an empty password
|
// PasswordEmpty - we received an empty password
|
||||||
PasswordEmpty = 22
|
PasswordEmpty = 22
|
||||||
// OpenConf - the was an error opening the gocryptfs.conf file for reading
|
// OpenConf - the was an error opening the gocryptfs.conf file for reading
|
||||||
|
|
25
mount.go
25
mount.go
|
@ -117,8 +117,8 @@ func doMount(args *argContainer) int {
|
||||||
if !args.nosyslog {
|
if !args.nosyslog {
|
||||||
paniclog, err = ioutil.TempFile("", "gocryptfs_paniclog.")
|
paniclog, err = ioutil.TempFile("", "gocryptfs_paniclog.")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tlog.Fatal.Printf("Failed to create gocryptfs_paniclog: %v", err)
|
tlog.Warn.Printf("Failed to create paniclog: %v."+
|
||||||
os.Exit(exitcodes.PanicLogCreate)
|
" Carrying on, but fatal errors will not be logged.", err)
|
||||||
}
|
}
|
||||||
// Switch all of our logs and the generic logger to syslog
|
// Switch all of our logs and the generic logger to syslog
|
||||||
tlog.Info.SwitchToSyslog(syslog.LOG_USER | syslog.LOG_INFO)
|
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
|
// instead of closing them so users have a chance to get the
|
||||||
// backtrace on a panic.
|
// backtrace on a panic.
|
||||||
// https://github.com/golang/go/issues/325#issuecomment-66049178
|
// https://github.com/golang/go/issues/325#issuecomment-66049178
|
||||||
syscall.Dup2(int(paniclog.Fd()), 1)
|
if paniclog != nil {
|
||||||
syscall.Dup2(int(paniclog.Fd()), 2)
|
err = syscall.Dup2(int(paniclog.Fd()), 1)
|
||||||
// No need for the extra FD anymore, we have it saved in Stderr
|
if err != nil {
|
||||||
paniclog.Close()
|
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.
|
// Disconnect from the controlling terminal by creating a new session.
|
||||||
// This prevents us from getting SIGINT when the user presses Ctrl-C
|
// This prevents us from getting SIGINT when the user presses Ctrl-C
|
||||||
|
@ -158,7 +169,7 @@ func doMount(args *argContainer) int {
|
||||||
srv.Serve()
|
srv.Serve()
|
||||||
// Delete empty paniclogs
|
// Delete empty paniclogs
|
||||||
if paniclog != nil {
|
if paniclog != nil {
|
||||||
// The paniclog FD is saved in Stderr
|
// The paniclog FD is saved in Stdout and Stderr
|
||||||
fi, err := os.Stderr.Stat()
|
fi, err := os.Stderr.Stat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tlog.Warn.Printf("paniclog fstat error: %v", err)
|
tlog.Warn.Printf("paniclog fstat error: %v", err)
|
||||||
|
|
Loading…
Reference in New Issue