You are here: Re: filehandling and system() permissions. « PHP Programming Language « IT news, forums, messages
Re: filehandling and system() permissions.

Posted by Colin McKinnon on 04/01/06 18:50

mikeisgreat@gmail.com wrote:

>
> I am creating an Apache admin tool for some less "linux-able" users at
> my job.
> My tool needs to be able to 'restart' apache on 3 different servers
> being that it is a cluster.
>

....and presumably you are thinking of running this via apache.

Working out how to sort out the privilege thing is trivial compared to the
other problems you will have if you try to control apache VIA apache.

For 3 machines, I'd say install webmin and leave it at that.

> I have a shell script that I write that uses 'ssh' to accomplish this
> but only if I am root or in the sudoers file.

Yes - there's good reasons why you need to be root, or in the sudoers.

> How would I allow the user via my web tool enough privileges to restart
> apache? I know I can add the 'www' user which apache is running as to
> the sudoers file and explicitly allow running the 'apachectl' command,
> but I don't feel safe doing this...

Very not safe. I would be wary about doing this on a private lan - and NEVER
on a machine connected to the internet.

>
> what is the difference between using system(), exec(), shell_exec() etc
> ... here is how I was thining of doing it. Of course, I still have my
> perm problem.
> if(isset($_POST["restart"]))
> {
> $restart = shell_exec('/usr/sbin/apachectl restart 2>&1'); #send
> stdout/stderr to the browser

This isn't going to work if you are running via apache. You are killing of
the parent process of the apachectl, Therefore it will terminate, probably
before starting apache again. You need to either run a second webserver on
a different port or interface or dissociate apachectl from the process grop
of apache.

C.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация