Can i make PHP login as a different user while running shell_exec or exec?
I don't want it to use the www-data user, since i want to execute commands as the git user in order to create repos in the current machine.
Can i make PHP login as a different user while running shell_exec or exec?
This is a risky option and it can create a serious security hole in your server. It should be avoided.
i want to execute commands as the git user
I would suggest that your web app writes to a database table the information about the new repo that needs to be created. Then have a constant running process (or one invoked via cron) on the server that runs as the git user. That process can check that resource periodically and create the repo. That way, your web server doesn't user-switch and you can still create the new repo safely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With