I have a php script that exec("crontab...
It's script work fine in Ubuntu.
In OpenWRT when I run this script manually at cli - it work fine too. But when script runs by web server via http request - it does not work: crontab does not change.
At cli the root crontab changes. Via web server not one changes.
So, my digs:
The config of php7-fpm (/etc/php7-fpm.d/www.conf) has: user = nobody
but this user cannot be changed to root, because:
[30-Jan-2023 12:51:09] ERROR: [pool www] please specify user and group other than root
[30-Jan-2023 12:51:09] ERROR: FPM initialization failed
Yes, this is your f... security.
Ok, I set user = http - this user is present in OpenWRT.
Nothing happens after reboot: exec('crontab... don't work.
Then I create non-privileged user manually by this recipe. And I update the /etc/php7-fpm.d/www.conf.
Yes, nginx runs from my user. But exec('crontab... don't work.
What's next?
UPD: Yes, busybox's cron run only for root, and OpenWRT not have way to run job from other user.
The OpenWRT is castrated linux. It has neither su, sudo, runuser.
But especially for such php7-fpm has a -R parm.
I just added it in /etc/init.d/php7-fpm's PROG variable. It works.
But the right way is to add a parameter to /etc/config/php7-fpm. But as far as I understand /etc/init.d/php7-fpm, it does not insert parameters from /etc/config/php7-fpm in the php7-fpm start line.
Am I wrong? Is it possible to add a parameter to the /etc/config/php7-fpm to run php7-fpm?
Dunno, whether my following notes are still valid for newest openwrt, but anyway:
Having had similar issues like yours, I was setting user root; in nginx.conf
I replaced usual /etc/init.d/nginx with my private, simple one, to start nginx from rc.local
Not using uci for config of nginx, but nginx.conf, only.
In other words, to get rid of the openwrt-specials, but using the linux-like style.
To make shure, nginx runs as root, to allow me all kind of php exec's.