Cronjob not executing for non root user

Hi ,

I'm trying to run my service as jailed services as daemon user.
the file is getting created under /etc/crontabs as daemon user.
But the job is not executing only root user job is executing.
my guid and suid for the daemon file is daemon.
If i change that to root then cronjob is running.

I tried to create cron.allow and cron.deny files with username daemon. But still not executing. Any other way to run the daemon job with daemon suid and guid, not as root?

sudo + sudoers, will still be as root though.

sudo option is not enabled. what about cron.allow and cron.deny files is that applicable in openwrt? any acl available for the cron jobs to run as non root user without root permission?

I saw a check in miscutils/crond.c file to check for DAEMON_UID as 0 in line number 440. If i remove that check it's working for other user (daemon). But i just want to know any other way of doing it.

https://git.busybox.net/busybox/tree/miscutils/crond.c#n3

enabled where ?

cron and sudo have no relation ...

yes agree. Other than sudo any other options available in openwrt.

sticky bit on a/the script, will still execute as root though.

cat << EOF > /etc/crontabs/daemon
* * * * * /bin/touch /tmp/test-cron
EOF

Seems to work fine for me.

1 Like

What is the uid of the /etc/crontabs/daemon file you created?

By default is root, but it works fine if you chown to daemon.
The whole point is that the cronjobs are executed as daemon user.

I'm also doing the same but no luck. any specific setting to be done? I'm using BusyBox v1.33.1. OpenWrt 21.02-SNAPSHOT, r16756-f04e26ac5b. I'm able to run with
-rw-r--r-- 1 root root 36 Jan 12 04:14 daemon

but below one not working -
-rw-r--r-- 1 daemon daemon 36 Jan 12 04:14 daemon

Start by upgrading.

So problem solved :slight_smile: