FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Exec Security
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Exec Security [message #178991 is a reply to message #178988] Sat, 01 September 2012 06:54 Go to previous messageGo to previous message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma:
Senior Member
On 01/09/12 03:49, Ryan wrote:
> I am working on a PHP script that will create Nginx vhosts. Creating the files should be simple enough. The hard part is this command "service nginx reload" to load the new vhost config.
>
> The result is I have to use Exec() to run the command. The bad problem I host sites for clients on the server, they obviously should not have access to Exec().
>
> Is there anything I can do to allow me to use it but prevent my other users?
>

You could make a database table in which you store command to execute
(use a id, not the command it self, like id 1 = reload nginx rules),
time stamp when inserted and time stamp when executed.

Your php script will just add a line to the table.

You have another job which reads the table say every minute and takes
all unexecuted and execute those (write some logic that makes it will
only restart once if there is more than one request for reload/restart
in the list at one time), as this one will run as a privileged user, it
will not have issues with the commands.


This method is scalable to work with multiple servers if you have a
centralized database server, in that case you need to add column for
which host is supposed to execute the command. Worked fine when I workd
at a hosting company.

--

//Aho
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Is PDO an abstraction layer?
Next Topic: Net Connect API -php
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 10:34:41 GMT 2024

Total time taken to generate the page: 0.05000 seconds