Running sudo command as _www user

Joined
Mar 12, 2010
Messages
3
Reaction score
0
Points
1
I have a web site on a Mac server that uses php's "exec" function to run a bash script on the server. It's password protected, and can only run certain code, so I'm not worried about security.

My problem is that I want to add a feature that requires the sudo command. However, the script is run by the user _www, which apparently can't do the sudo command.

What are my options for making this work?
Thanks!
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Try following the instructions here to add the user to the sudoers file. Now, you're going to need root access to this machine to edit the sudoers file. Do you have access?
 
OP
J
Joined
Mar 12, 2010
Messages
3
Reaction score
0
Points
1
I added _www to sudoers, and it still doesn't work. Also, I just realized I've been using the admin password, and have no idea what the _www password would be. It should still be the default.

Any idea what this would be?
 
OP
J
Joined
Mar 12, 2010
Messages
3
Reaction score
0
Points
1
Ok, it's trickier than I thought.

The script must be run as root. Is there any way I can run a script as root from _www?

Another option is to disect the script, and add the actual commands directly into my script. They seem to just be a set of 3 launchctl commands. How can I run launchctl commands as _www?
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top