fix: remove the need for executing crontab as root

This was done by design previously - to fix an issue with RHEL not allowing running crontab as the current user - but is no longer necessary with the removal of non-Debian platform support.
This commit is contained in:
Jose Diaz-Gonzalez committed 2024-03-06 09:36:48 -05:00
1 parent 67331cd206
commit 08cf35aa36
3 files changed
+5 -9

No files matched your search

+1 -1
View File
@@ -1 +1 @@
dokku ALL=NOPASSWD:SETENV:/usr/bin/docker,/usr/bin/docker-container-healthchecker,/usr/bin/docker-image-labeler,/usr/bin/pack,/usr/bin/crontab dokku ALL=NOPASSWD:SETENV:/usr/bin/docker,/usr/bin/docker-container-healthchecker,/usr/bin/docker-image-labeler,/usr/bin/pack
+3 -6
View File
@@ -16,18 +16,16 @@ import (
func deleteCrontab() error { func deleteCrontab() error {
result, err := common.CallExecCommand(common.ExecCommandInput{ result, err := common.CallExecCommand(common.ExecCommandInput{
Command: "/usr/bin/crontab", Command: "crontab",
Args: []string{"-l", "-u", "dokku"}, Args: []string{"-l", "-u", "dokku"},
Sudo: true,
}) })
if err != nil || result.ExitCode != 0 { if err != nil || result.ExitCode != 0 {
return nil return nil
} }
result, err = common.CallExecCommand(common.ExecCommandInput{ result, err = common.CallExecCommand(common.ExecCommandInput{
Command: "/usr/bin/crontab", Command: "crontab",
Args: []string{"-r", "-u", "dokku"}, Args: []string{"-r", "-u", "dokku"},
Sudo: true,
}) })
if err != nil { if err != nil {
return fmt.Errorf("Unable to remove schedule file: %w", err) return fmt.Errorf("Unable to remove schedule file: %w", err)
@@ -148,9 +146,8 @@ func writeCronEntries() error {
} }
result, err := common.CallExecCommand(common.ExecCommandInput{ result, err := common.CallExecCommand(common.ExecCommandInput{
Command: "/usr/bin/crontab", Command: "crontab",
Args: []string{"-u", "dokku", tmpFile.Name()}, Args: []string{"-u", "dokku", tmpFile.Name()},
Sudo: true,
}) })
if err != nil { if err != nil {
return fmt.Errorf("Unable to update schedule file: %w", err) return fmt.Errorf("Unable to update schedule file: %w", err)
+1 -2
View File
@@ -14,8 +14,7 @@ trigger-scheduler-docker-local-install() {
fn-plugin-property-setup "scheduler-docker-local" fn-plugin-property-setup "scheduler-docker-local"
echo "%dokku ALL=(ALL) NOPASSWD:/usr/bin/crontab" >"/etc/sudoers.d/dokku-cron" rm -f "/etc/sudoers.d/dokku-cron"
chmod "0440" "/etc/sudoers.d/dokku-cron"
echo "%dokku ALL=(ALL) NOPASSWD:/usr/bin/docker-container-healthchecker" >"/etc/sudoers.d/dokku-docker-container-healthchecker" echo "%dokku ALL=(ALL) NOPASSWD:/usr/bin/docker-container-healthchecker" >"/etc/sudoers.d/dokku-docker-container-healthchecker"
chmod "0440" "/etc/sudoers.d/dokku-docker-container-healthchecker" chmod "0440" "/etc/sudoers.d/dokku-docker-container-healthchecker"