webdevops / go-crond

:alarm_clock: Cron daemon written in golang (for eg. usage in docker images)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Single files (/etc/crontab) are ignored

manzsolutions-lpr opened this issue · comments

A check unfortunately only works with directories leading to a rather irritating error message:

$ strace -f -e file /opt/go-crond-64-linux --allow-unprivileged --auto
INFO[0000] starting go-crond version 20.7.0 (09eeb85; go1.14.4)  
[pid   377] openat(AT_FDCWD, "/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
WARN[0000] go-crond is NOT running as root, disabling user switching 
[pid   377] newfstatat(AT_FDCWD, ".", {st_mode=S_IFDIR|0777, st_size=42, ...}, 0) = 0
[pid   377] newfstatat(AT_FDCWD, "/var/www/nextcloud", {st_mode=S_IFDIR|0777, st_size=42, ...}, 0) = 0
INFO[0000] starting http server on                      
[pid   377] chdir("/var/www/nextcloud") = 0
[pid   377] newfstatat(AT_FDCWD, "/etc/alpine-release", 0xc0001a1a38, 0) = -1 ENOENT (No such file or directory)
[pid   377] newfstatat(AT_FDCWD, "/etc/redhat-release", 0xc0001a1b08, 0) = -1 ENOENT (No such file or directory)
[pid   377] newfstatat(AT_FDCWD, "/etc/SuSE-release", 0xc0001a1bd8, 0) = -1 ENOENT (No such file or directory)
[pid   377] newfstatat(AT_FDCWD, "/etc/debian_version", {st_mode=S_IFREG|0644, st_size=5, ...}, 0) = 0
INFO[0000]  --> detected Debian family, using distribution defaults 
[pid   377] newfstatat(AT_FDCWD, "/etc/crontab", {st_mode=S_IFREG|0644, st_size=589, ...}, 0) = 0
[pid   377] newfstatat(AT_FDCWD, "/etc/crontab", {st_mode=S_IFREG|0644, st_size=589, ...}, 0) = 0
INFO[0000] path /etc/crontab does not exists            
[pid   377] newfstatat(AT_FDCWD, "/etc/cron.d", 0xc0001a1f18, 0) = -1 ENOENT (No such file or directory)
[pid   376] chdir("/")                  = 0
INFO[0000] start runner with 0 jobs                     
^Cstrace: Process 373 detached
strace: Process 374 detached
strace: Process 375 detached
strace: Process 376 detached
strace: Process 377 detached
strace: Process 378 detached
strace: Process 379 detached
INFO[0003] got signal: interrupt                        
INFO[0003] stop runner                                  
INFO[0003] terminated                            

As you can see from strace /etc/crontab does exist but is logged as “does not exist”. Putting /etc/crontab into a dedicated folder and running with --include <folder> works. The linked line in the code seems to fit as it only allows folders to pass.

//edit:

Running a file directly like /opt/go-crond-64-linux /etc/crontab works.