Skip to content

Commit

Permalink
fix wrong init of /etc/crontab #19
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Blaschke <[email protected]>
  • Loading branch information
mblaschke committed Sep 24, 2022
1 parent d1f84e7 commit b887b00
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func includeSystemDefaults() []CrontabEntry {
if checkIfFileExistsAndOwnedByRoot("/etc/redhat-release") {
log.Infof(" --> detected RedHat family, using distribution defaults")

if checkIfFileExists("/etc/crontabs") {
if checkIfFileExistsAndOwnedByRoot("/etc/crontabs") {
ret = append(ret, includePathForCrontabs("/etc/crontabs", CRONTAB_TYPE_SYSTEM)...)
}

Expand All @@ -301,8 +301,8 @@ func includeSystemDefaults() []CrontabEntry {
if checkIfFileExistsAndOwnedByRoot("/etc/SuSE-release") {
log.Infof(" --> detected SuSE family, using distribution defaults")

if checkIfFileExists("/etc/crontab") {
ret = append(ret, includePathForCrontabs("/etc/crontab", CRONTAB_TYPE_SYSTEM)...)
if checkIfFileExistsAndOwnedByRoot("/etc/crontab") {
ret = append(ret, parseCrontab("/etc/crontab", CRONTAB_TYPE_SYSTEM)...)
}

systemDetected = true
Expand All @@ -314,8 +314,8 @@ func includeSystemDefaults() []CrontabEntry {
if checkIfFileExistsAndOwnedByRoot("/etc/debian_version") {
log.Infof(" --> detected Debian family, using distribution defaults")

if checkIfFileExists("/etc/crontab") {
ret = append(ret, includePathForCrontabs("/etc/crontab", CRONTAB_TYPE_SYSTEM)...)
if checkIfFileExistsAndOwnedByRoot("/etc/crontab") {
ret = append(ret, parseCrontab("/etc/crontab", CRONTAB_TYPE_SYSTEM)...)
}

systemDetected = true
Expand All @@ -325,11 +325,11 @@ func includeSystemDefaults() []CrontabEntry {
// General
// ----------------------
if !systemDetected {
if checkIfFileExists("/etc/crontab") {
if checkIfFileExistsAndOwnedByRoot("/etc/crontab") {
ret = append(ret, includePathForCrontabs("/etc/crontab", CRONTAB_TYPE_SYSTEM)...)
}

if checkIfFileExists("/etc/crontabs") {
if checkIfFileExistsAndOwnedByRoot("/etc/crontabs") {
ret = append(ret, includePathForCrontabs("/etc/crontabs", CRONTAB_TYPE_SYSTEM)...)
}
}
Expand Down

0 comments on commit b887b00

Please sign in to comment.