shell_exec and sudo
i'd like to be able to create directories from a php script. i added the following to sudoers:
and have confirmed in a terminal that apache can create directories without being prompted for a password. but if i do something like
nothing happens when i run the script. i added a few generic commands (ls, pwd) to the MAKEDIR alias, and confirmed that they also work in a terminal, but not from a php script.
safe mode is not on and i can do things like
if i do
so basically, i'm pretty sure apache has permission, but if i try to use sudo in shell_exec() it just doesn't do anything. anyone know what i might have done wrong?
Cmnd_Alias MAKEDIR = /bin/mkdir %apache ALL = NOPASSWD: MAKEDIR
and have confirmed in a terminal that apache can create directories without being prompted for a password. but if i do something like
shell_exec("sudo mkdir test");nothing happens when i run the script. i added a few generic commands (ls, pwd) to the MAKEDIR alias, and confirmed that they also work in a terminal, but not from a php script.
safe mode is not on and i can do things like
shell_exec("ls"); successfully. i'm also able to do shell_exec("mkdir test"); to create directories inside a test directory which apache has write access to. however, i need to create directories in the root of the site, and don't think it's good to set permissions to 777 on that.if i do
idfrom a script i get
uid=48(apache) gid=48(apache) groups=48(apache),2522(psaserv)confirming (i think) that apache is the correct user and group (i've tried both in sudoers).
so basically, i'm pretty sure apache has permission, but if i try to use sudo in shell_exec() it just doesn't do anything. anyone know what i might have done wrong?
