QuoVadis Posted October 17, 2012 Share Posted October 17, 2012 Hi all. First post in these forums. I am an experienced C/C++/Java/C# programmer but have never done any web development. I have a pretty basic question about running executables on a server via php. I gather this is not a good idea, basically. I have some (large-ish) programs written in C that I would like to execute and get the results into a browser. Is there a 'safe' way of doing this? I would really rather not reimplement my programs in php if I can possibly avoid that. Quote Link to comment https://forums.phpfreaks.com/topic/269578-phpweb-programming-noobrunning-executables/ Share on other sites More sharing options...
trq Posted October 17, 2012 Share Posted October 17, 2012 If they are programs that can be invoked via some form of shell you can use one of the exec family of functions. Otherwise, if they are written in C, you might like to turn them into PHP extensions (though this will be a fair bit more work). Quote Link to comment https://forums.phpfreaks.com/topic/269578-phpweb-programming-noobrunning-executables/#findComment-1385749 Share on other sites More sharing options...
QuoVadis Posted October 17, 2012 Author Share Posted October 17, 2012 Thanks for your prompt reply. As I understand from my currently limited knowledge, there are potential security issues with using the exec() functions? That's the bit I am concerned about. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/269578-phpweb-programming-noobrunning-executables/#findComment-1385752 Share on other sites More sharing options...
QuoVadis Posted October 17, 2012 Author Share Posted October 17, 2012 Thinking about this some more, it could be that the problem exists when you allow users to enter the filename of the exe in a form. That wasn't what I intended doing but I can see how that would be a massive issue. Quote Link to comment https://forums.phpfreaks.com/topic/269578-phpweb-programming-noobrunning-executables/#findComment-1385767 Share on other sites More sharing options...
DavidAM Posted October 17, 2012 Share Posted October 17, 2012 If the executable name or any parameters that will be passed are supplied by the user, then you have potential security issues. You must validate all user supplied data to make sure it is expected and acceptable. Keep in mind that your hosting provider may put restrictions on you that either prevent running executables, or require them to be in a "safe directory" or limit the CPU or memory resource usage. Quote Link to comment https://forums.phpfreaks.com/topic/269578-phpweb-programming-noobrunning-executables/#findComment-1385781 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.