From aed01565791c9accc47bcad0de52b416a5e44ea9 Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Mon, 13 Apr 2020 14:36:57 +0100 Subject: [PATCH] chasquid: Check result of initial os.Chdir The daemon attempts to change to the config directory on startup, for security and convenience. We currently don't check if this works, which is not a big deal since it will just fail later on when it can't find the files. However, it makes things more awkward to debug, so this patch adds an explicit check. --- chasquid.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/chasquid.go b/chasquid.go index 1f35af8..ce3ae0a 100644 --- a/chasquid.go +++ b/chasquid.go @@ -81,7 +81,10 @@ func main() { // It also can be useful in unusual environments and for testing purposes, // where paths inside the configuration itself could be relative, and this // fixes the point of reference. - os.Chdir(*configDir) + err = os.Chdir(*configDir) + if err != nil { + log.Fatalf("Error changing to config dir %q: %v", *configDir, err) + } initMailLog(conf.MailLogPath)