aboutsummaryrefslogtreecommitdiff
path: root/pkg/zabbix/statefile.go
diff options
context:
space:
mode:
authorJulien Dessaux2021-05-19 10:58:22 +0200
committerJulien Dessaux2021-05-19 10:58:22 +0200
commitffa3b6f3d20db7d067272a0dc2245d724fbe1598 (patch)
tree8cc19286ec06bcdaf0f8acbbf723669b3c3fd9f3 /pkg/zabbix/statefile.go
parentUpdated for go 1.16 modules (diff)
downloadbareos-zabbix-check-ffa3b6f3d20db7d067272a0dc2245d724fbe1598.tar.gz
bareos-zabbix-check-ffa3b6f3d20db7d067272a0dc2245d724fbe1598.tar.bz2
bareos-zabbix-check-ffa3b6f3d20db7d067272a0dc2245d724fbe1598.zip
Fixes #1 segmentation violation with unprivileged user1.3
Diffstat (limited to '')
-rw-r--r--pkg/zabbix/statefile.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/pkg/zabbix/statefile.go b/pkg/zabbix/statefile.go
index 26ea650..ae8dd28 100644
--- a/pkg/zabbix/statefile.go
+++ b/pkg/zabbix/statefile.go
@@ -15,18 +15,18 @@ func checkStateFile() error {
// Finds the state file to parse
if stateFileName != "" {
stateFileName = filepath.Join(workDir, stateFileName)
- info, err := os.Stat(stateFileName)
- if os.IsNotExist(err) || info.IsDir() {
- return fmt.Errorf("The state file %s does not exist", stateFileName)
+ _, err := os.Stat(stateFileName)
+ if err != nil {
+ return fmt.Errorf("Could not open state file %s", stateFileName)
}
} else {
stateFileName = filepath.Join(workDir, bareosStateFile)
- info, err := os.Stat(stateFileName)
- if os.IsNotExist(err) || info.IsDir() {
+ _, err := os.Stat(stateFileName)
+ if err != nil {
stateFileName = filepath.Join(workDir, baculaStateFile)
- info, err = os.Stat(stateFileName)
- if os.IsNotExist(err) || info.IsDir() {
- return fmt.Errorf("Could not find a suitable state file. Has a job ever run?")
+ _, err = os.Stat(stateFileName)
+ if err != nil {
+ return fmt.Errorf("Could not autodetect a suitable state file. Has a job ever run? Does the user you are running the check as has read access to bacula or bareos' /var/lib directory? Alternatively use the -w and -f flags to specify the work directory and state file to use.")
}
}
}