m3bik Posted December 8, 2011 Share Posted December 8, 2011 I'm working on a light use/kiosk system. I have apache2 and php5 installed on Ubuntu 10.04 and I have the browser open the localhost web page by default. I would like to include a link on this page to open oowriter (open office writer) for the end user on the machine. I've tried exec('oowriter'); with no luck. I've also tried setting the DISPLAY value before the command like exec('DISPLAY=:0 oowriter'); with no success. I don't mind have the www-data user in the sudoers file if I have to sudo the command or something, but is this possible to do?? I'm not having any luck at all! Quote Link to comment https://forums.phpfreaks.com/topic/252729-exec-open-application-for-local-user/ Share on other sites More sharing options...
trq Posted December 8, 2011 Share Posted December 8, 2011 You might need to add the www-data user to the video group. What errors are you getting exactly? Quote Link to comment https://forums.phpfreaks.com/topic/252729-exec-open-application-for-local-user/#findComment-1295653 Share on other sites More sharing options...
m3bik Posted December 8, 2011 Author Share Posted December 8, 2011 Well I've verified that the error reporting is turned on, but I don't actually get any errors when loading the webpage.. I have tried adding the www-data to the video group with no luck. I've also tried adding the www-data user to the user group running on the desktop, but still nothing. I do have success running "php ./myfile.php" in the command line. It does open the application on the local user's screen.. but for some reason when I access the page on the web, I get nothing Quote Link to comment https://forums.phpfreaks.com/topic/252729-exec-open-application-for-local-user/#findComment-1295998 Share on other sites More sharing options...
kicken Posted December 9, 2011 Share Posted December 9, 2011 You could try: putenv('DISPLAY=:0'); exec('oowriter'); Also, the server may be using a PATH which does not include where oowriter is at. Try using an absolute path to the file. Quote Link to comment https://forums.phpfreaks.com/topic/252729-exec-open-application-for-local-user/#findComment-1296021 Share on other sites More sharing options...
m3bik Posted December 9, 2011 Author Share Posted December 9, 2011 Thanks kicken! That did the trick! I did have to add the www-data user to the sudoers file because it wasn't working without "sudo" but here's my end result: putenv('DISPLAY=:0'); exec('sudo oowriter'); Quote Link to comment https://forums.phpfreaks.com/topic/252729-exec-open-application-for-local-user/#findComment-1296041 Share on other sites More sharing options...
trq Posted December 9, 2011 Share Posted December 9, 2011 I wouldn't be running oowritter as root. You've just opened a massive security hole. There is nothing stoping anyone editing any file on the system as root. You need to find out exactly what group www-data needs to be in and add them to it. Quote Link to comment https://forums.phpfreaks.com/topic/252729-exec-open-application-for-local-user/#findComment-1296088 Share on other sites More sharing options...
m3bik Posted December 9, 2011 Author Share Posted December 9, 2011 Thanks for pointing that out, thorpe. I will look into it, but as a proof of concept sort of deal, I got it working.. That makes me happy. Quote Link to comment https://forums.phpfreaks.com/topic/252729-exec-open-application-for-local-user/#findComment-1296406 Share on other sites More sharing options...
m3bik Posted December 10, 2011 Author Share Posted December 10, 2011 As a reference here, I eventually changed the user that apache runs under to the user name in question.. and it works without sudo now. Quote Link to comment https://forums.phpfreaks.com/topic/252729-exec-open-application-for-local-user/#findComment-1296469 Share on other sites More sharing options...
trq Posted December 10, 2011 Share Posted December 10, 2011 Which user did you change it to? Not root I hope. Quote Link to comment https://forums.phpfreaks.com/topic/252729-exec-open-application-for-local-user/#findComment-1296648 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.