471,071 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

Can i restart httpd from a php script?

anr
Hi everyone,

I have made a solution where a user is added to the system and a folder
is set up for him. In order to make the folder webDAV accessible for
him I have to add some lines to the current httpd.conf file and restart
the webserver. Is this possible to do from my php script - or even
advisable?

I could envision an alternative where i would make a cron job restart
httpd every 15 minutes or so, but i would prefer the first method.
Is this possible?

anr

Jul 17 '05 #1
5 3077
*** an*@mac.com wrote/escribió (13 Aug 2004 02:22:45 -0700):
I have made a solution where a user is added to the system and a folder
is set up for him. In order to make the folder webDAV accessible for
him I have to add some lines to the current httpd.conf file and restart
the webserver. Is this possible to do from my php script - or even
advisable?


An idea I can think of is using sudo. Edit /etc/sudoers width 'visudo'
command and give 'apache' user the right to execute only what you need:

apache localhost=/etc/rc.d/init.d/httpd reload

I've never used it myself so you're advised to read manual first.
--
-- Álvaro G. Vicario - Burgos, Spain
-- Questions sent to my mailbox will be billed ;-)
--
Jul 17 '05 #2
an*@mac.com wrote:
Hi everyone,

I have made a solution where a user is added to the system and a
folder is set up for him. In order to make the folder webDAV
accessible for him I have to add some lines to the current httpd.conf
file and restart the webserver. Is this possible to do from my php
script - or even advisable?

I could envision an alternative where i would make a cron job restart
httpd every 15 minutes or so, but i would prefer the first method.
Is this possible?

anr


If you ask me, that is asking for trouble. What happens with the connection
that user has to your server during a restart ? Besides, you would have to
give Nobody executable access to httpd.
Why not have PHP create a flag file somewhere and have a cron shell script
check for the flag file, then act upon its existence and remove it? (If
there is no other ay of course of telling apache to accept new WEBdav
settings.

HTH
Pjotr
Jul 17 '05 #3
an*@mac.com wrote:
Hi everyone,

I have made a solution where a user is added to the system and a folder
is set up for him. In order to make the folder webDAV accessible for
him I have to add some lines to the current httpd.conf file and restart
the webserver. Is this possible to do from my php script - or even
advisable?

I could envision an alternative where i would make a cron job restart
httpd every 15 minutes or so, but i would prefer the first method.
Is this possible?

anr


Hi,

direct:
- Giving nobody (or whoever runs as apache) rights to restart Apache.
This means that nobody can do a sudo.
I think that is bad.

indirect:
You could write a 'signal-file' as user nobody in some special directory and
let some cronjob check for that file every hour or so.
If it is found --> restart Apache and delete the file.

Of course this is not instant, but safer than giving nobody rights.

Maybe there is a better solution (sticky bit????), but I am too nOOb on *nix
to think of it. :-)

Regards,
Erwin Moller
Jul 17 '05 #4
"anr" wrote:
Hi everyone,

I have made a solution where a user is added to the system and a
folder
is set up for him. In order to make the folder webDAV accessible for him I have to add some lines to the current httpd.conf file and
restart
the webserver. Is this possible to do from my php script - or even
advisable?

I could envision an alternative where i would make a cron job restart httpd every 15 minutes or so, but i would prefer the first method.
Is this possible?

anr


DONT DO THAT. I think I have a flash of brilliance (happens once
every 10 years or so).

Set up lots of folders, and then assign them to new users as they come
in. This way, you don’t have to reboot anything.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-restart-...ict139383.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=467188
Jul 17 '05 #5
On Fri, 13 Aug 2004 02:22:45 -0700, anr wrote:
I have made a solution where a user is added to the system and a folder
is set up for him. In order to make the folder webDAV accessible for
him I have to add some lines to the current httpd.conf file and restart
the webserver. Is this possible to do from my php script - or even
advisable?

I could envision an alternative where i would make a cron job restart
httpd every 15 minutes or so, but i would prefer the first method.
Is this possible?


Of course it is possible! Make a little C program which will contain the
following sequence of commands:

/*
The definition of INIT depends on your OS. It may be /etc/init or
even /bin/init.
*/
#define INIT "/sbin/init 6"
#define ROOT 0
setuid((uid_t) ROOT);
system(INIT);

Then make that program setuid root (chown root prog; chmod 4755 prog)
and put in the path visible by PHP scripts. All you need is to execute
the program using "system" from a PHP script. As per that being advisable,
any manual or article about the computer security will tell you exactly
how advisable is that.
--
A city is a large community where people are lonesome together.

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Solange Ezveff | last post: by
6 posts views Thread by black francis | last post: by
1 post views Thread by Piotr Trawiñski | last post: by
1 post views Thread by drhopscotch | last post: by
reply views Thread by =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post: by
12 posts views Thread by Kevin Blount | last post: by
1 post views Thread by symbioid | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.