osx - php exec fails even though _www has root privileges -


i want open text file stored on mac os x 10.8 server via php exec command. so, first created dummy text file called dummy.txt text inside. created script file called script.sh including following:

open -a /applications/textedit.app /library/webserver/documents/secured/upload/dummy.txt 

and created test php file including following:

exec('/library/webserver/documents/secured/upload/script.sh'); 

the apache user "_www" on mac, given ownership of files _www , group wheel permission of dummy.txt , test.php 644 while permission of script.sh file 755.

logged in standard user, running script.sh terminal shows textedit program opens dummy.txt file.

logged in root, tried again standard user follows:

su - myuser -c "/library/webserver/documents/secured/upload/script.sh" 

will display editor normally. however;

su - _www -c "/library/webserver/documents/secured/upload/script.sh" 

cannot run text editor.

when access test.php via client machine browser, not show text editor.

accessing through client machine, however, shows following error in apache error log:

lsopenurlswithrole() failed error -10810 file /library/webserver/documents/secured/upload/dummy.txt 

adding _www sudoers file (as below) permissions did not solve problems.

_www    all=(all) nopasswd: 

i tried adding following line sudoers:

defaults:_www !requiretty 

and setting shell _www user false sh in passwd file.

none of them worked. should add that, security not concern @ point. want run it. take care of security pitfalls.

any suggestions ? in advance

the open command (as other way of opening textedit) work in context of gui session; web server not part of session, has no way open within session.

there ways solve this, they're really ugly. involve switching _www user root (probably sudo), attaching context of process running in gui session (launchctl bsexec somepid somecommand), maybe having switch session owner (sudo -u loggedinuser), then running open command.

this ugly because you're trying unnatural. having in web server trigger gui edit session doesn't make sense. please rethink you're trying , why.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -