I'm currently programming a web interface in PHP (5.3) for handling timings and installing cronjobs as a simple interface for managing cronjobs. The web server is on the same server as the cron service. I've managed to save the crontab to a file to exchange it for a specific user on the system. Now I have the problem that php is running with a different user than the crontab should be installed for. In addition I need to be able to define the cron-user in my web interface via an input field.
I've tried to execute a shell command via PHP crontab -u MyCronuser MyCrontab
but the PHP user does not have privileges for using -u parameter (and I'm not allowed to change this)
So next thought was to do something like su cronUser
but there is no -p parameter so I cannot handle over the password for login. I tried to chain the commands like su cronuser && echo 'MyPassword'
but it didn't work and I did not find any solution via Google for logging into shell with different users with PHP. Is there a way for doing so?
Using sudo for performing as root user without password is also not an option since I'm not allowed to activate these permissions.
Is there any solution I might have missed? Maybe a different approach to my issue?