Re: [PHP] reboot pc with PHP

2003-08-28 Thread David T-G
Petre, et al --

...and then Petre Agenbag said...
% 
% Hi List

Hi!


% 
% I've gone through the list for previous questions and the only one that
% seems to be a solution is to use sudo, however, I cannot seem to get it
% right.
...
% 
% Obviously these command(s) need to be run as root, so I looked at the
% /etc/sudoers and added apache , BUT, in the error log it prompts for a
% password.

1) Are you sure your web server is running as apache?  If not, run
something like

  passthru("/usr/bin/id") ;

(or wherever your id program is) in a php page (easier than redirecting
to a file :-) and see what it tells you.


% 
% I tried to add the option NOPASSWD: ALL to the file, but it says there's
% a syntax error.

Your line should look about like

  admind  ALL = (ALL) NOPASSWD: /path/to/reboot

where "admind" is the name under which your web server runs.  In fact, it
should probably look more like

  admind  hostname = (root) NOPASSWD: /path/to/reboot

to allow admind to run reboot as root on machine "hostname".

Have you read the man page for sudoers?  Yes, it's a bit thick, but it
absolutely covers everything you need to know :-)


% 
% What am I missing?

Since you haven't shown us your attempt, it's tough to answer that other
than to note that you're at least missing showing what you tried!


% 
% Any other ways of doing this?  PS, I don't even want to consider Webmin,
% it's way too complicated, I just want a handfull of predefined commands
% to be run, nothing else)

sudo is *definitely* your best approach.  It really is.  It's easy, too,
I promise.


% 
% Thanks


HTH & HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


Re: [PHP] reboot pc with PHP

2003-08-28 Thread Matthew Harrison
of course, i've only just seen that the script removes it. it's been a long
day, my apologies.

just out of curiosity, why would you want the ability to reboot your box
like that?

On Thu, Aug 28, 2003 at 04:06:25PM +0200, Javier Tacon wrote:
> 
> Exactly ..
> Well, the script removes the rreboot file before the shutdown.
> 
> For security choose a directory for rreboot file placed in a directory that only can 
> be readed/writed by apache, and the php file in the example its very simple, but you 
> can ask for a password, create a log, etc ..
> 
> chown 700 /directory/for/rrebootfile
> chown apache.nobody /directory/for/rrebootfile
> 
> 
> -Mensaje original-
> De: Matthew Harrison [mailto:[EMAIL PROTECTED]
> Enviado el: jueves, 28 de agosto de 2003 15:49
> Para: Javier Tacon
> CC: Petre Agenbag; [EMAIL PROTECTED]
> Asunto: Re: [PHP] reboot pc with PHP
> 
> 
> On Thu, Aug 28, 2003 at 03:35:59PM +0200, Javier Tacon wrote:
> > 
> > A more easy solution is that:
> > 
> > Make a cron that executes every minut /tmp/rreboot.sh for user root
> > crontab -e
> > Add the line:
> > * * * * *  /tmp/rreboot.sh
> > 
> > The script is:
> > /tmp/rreboot.sh
> > ---
> > #!/bin/sh
> > if [ -f "/tmp/rreboot" ]; then
> >  rm -f /tmp/rreboot
> >  shutdown -r now
> > fi
> > ---
> > Make executable the file with chmod +x /tmp/rreboot.sh
> >
> 
> just one little point (i'm glad i don't have to give a setuid lecture) personally
> i would make sure that the location of the check file is extremely secure.
> 
> under normal circumstances, any user could write the rreboot file and cause a reboot
> 
> also, remember to remove the file again in rc.local before cron starts etc.
> 
> but i like the idea. its much more secure (from a web perspective).
> 
> > And a simple PHP like:
> >  > exec("echo rreboot > /tmp/rreboot");
> > echo "Ok, i'll reboot in a few seconds";
> > ?>
> > 
> > 
> > So, when anyone calls to this PHP, creates a file, that if its detected by 
> > rreboot.sh, the root will reboot the machine.
> > 
> > 
> > 
> > -Mensaje original-
> > De: Javier Tacon 
> > Enviado el: jueves, 28 de agosto de 2003 15:07
> > Para: Petre Agenbag; [EMAIL PROTECTED]
> > Asunto: RE: [PHP] reboot pc with PHP
> > 
> > 
> > 
> > You can write a little script with expect (man expect) and execute it from php 
> > with exec().
> > 
> > Other solution its to write a .procmailrc in root that executes the reboot when 
> > coming a mail with some text in subject or boyd, so, from php you only need to 
> > send a mail.
> > 
> > 
> > -Mensaje original-
> > De: Petre Agenbag [mailto:[EMAIL PROTECTED]
> > Enviado el: jueves, 28 de agosto de 2003 14:48
> > Para: [EMAIL PROTECTED]
> > Asunto: [PHP] reboot pc with PHP
> > 
> > 
> > Hi List
> > 
> > I've gone through the list for previous questions and the only one that
> > seems to be a solution is to use sudo, however, I cannot seem to get it
> > right.
> > 
> > Just as background:
> > 
> > I want to make a small "admin" utill for an intranet machine, so the
> > security risks don't bother me at all.
> > 
> > Instead of myself having to ssh into the box to reboot or do other
> > "routine" commands, I'd like to make a simple password protected webpage
> > that would have simple links on them like "reboot", "redial" etc, so
> > that someone with some sort of responsibility can do it themselves.
> > 
> > Obviously these command(s) need to be run as root, so I looked at the
> > /etc/sudoers and added apache , BUT, in the error log it prompts for a
> > password.
> > 
> > I tried to add the option NOPASSWD: ALL to the file, but it says there's
> > a syntax error.
> > 
> > What am I missing?
> > 
> > Any other ways of doing this?  PS, I don't even want to consider Webmin,
> > it's way too complicated, I just want a handfull of predefined commands
> > to be run, nothing else)
> > 
> > Thanks
> >  
> > 
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> Mat Harrison
> Technical Developer
> 3d Computer Systems Ltd.
> [EMAIL PROTECTED]
> -
> ASCII ribbon campaign ( )
>  - against HTML email  X
>& Usenet posts / \

-- 
Mat Harrison
Technical Developer
3d Computer Systems Ltd.
[EMAIL PROTECTED]
-
ASCII ribbon campaign ( )
 - against HTML email  X
   & Usenet posts / \

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] reboot pc with PHP

2003-08-28 Thread Javier Tacon

Exactly ..
Well, the script removes the rreboot file before the shutdown.

For security choose a directory for rreboot file placed in a directory that only can 
be readed/writed by apache, and the php file in the example its very simple, but you 
can ask for a password, create a log, etc ..

chown 700 /directory/for/rrebootfile
chown apache.nobody /directory/for/rrebootfile


-Mensaje original-
De: Matthew Harrison [mailto:[EMAIL PROTECTED]
Enviado el: jueves, 28 de agosto de 2003 15:49
Para: Javier Tacon
CC: Petre Agenbag; [EMAIL PROTECTED]
Asunto: Re: [PHP] reboot pc with PHP


On Thu, Aug 28, 2003 at 03:35:59PM +0200, Javier Tacon wrote:
> 
> A more easy solution is that:
> 
> Make a cron that executes every minut /tmp/rreboot.sh for user root
> crontab -e
> Add the line:
> * * * * *  /tmp/rreboot.sh
> 
> The script is:
> /tmp/rreboot.sh
> ---
> #!/bin/sh
> if [ -f "/tmp/rreboot" ]; then
>  rm -f /tmp/rreboot
>  shutdown -r now
> fi
> ---
> Make executable the file with chmod +x /tmp/rreboot.sh
>

just one little point (i'm glad i don't have to give a setuid lecture) personally
i would make sure that the location of the check file is extremely secure.

under normal circumstances, any user could write the rreboot file and cause a reboot

also, remember to remove the file again in rc.local before cron starts etc.

but i like the idea. its much more secure (from a web perspective).

> And a simple PHP like:
>  exec("echo rreboot > /tmp/rreboot");
> echo "Ok, i'll reboot in a few seconds";
> ?>
> 
> 
> So, when anyone calls to this PHP, creates a file, that if its detected by 
> rreboot.sh, the root will reboot the machine.
> 
> 
> 
> -Mensaje original-----
> De: Javier Tacon 
> Enviado el: jueves, 28 de agosto de 2003 15:07
> Para: Petre Agenbag; [EMAIL PROTECTED]
> Asunto: RE: [PHP] reboot pc with PHP
> 
> 
> 
> You can write a little script with expect (man expect) and execute it from php with 
> exec().
> 
> Other solution its to write a .procmailrc in root that executes the reboot when 
> coming a mail with some text in subject or boyd, so, from php you only need to send 
> a mail.
> 
> 
> -Mensaje original-
> De: Petre Agenbag [mailto:[EMAIL PROTECTED]
> Enviado el: jueves, 28 de agosto de 2003 14:48
> Para: [EMAIL PROTECTED]
> Asunto: [PHP] reboot pc with PHP
> 
> 
> Hi List
> 
> I've gone through the list for previous questions and the only one that
> seems to be a solution is to use sudo, however, I cannot seem to get it
> right.
> 
> Just as background:
> 
> I want to make a small "admin" utill for an intranet machine, so the
> security risks don't bother me at all.
> 
> Instead of myself having to ssh into the box to reboot or do other
> "routine" commands, I'd like to make a simple password protected webpage
> that would have simple links on them like "reboot", "redial" etc, so
> that someone with some sort of responsibility can do it themselves.
> 
> Obviously these command(s) need to be run as root, so I looked at the
> /etc/sudoers and added apache , BUT, in the error log it prompts for a
> password.
> 
> I tried to add the option NOPASSWD: ALL to the file, but it says there's
> a syntax error.
> 
> What am I missing?
> 
> Any other ways of doing this?  PS, I don't even want to consider Webmin,
> it's way too complicated, I just want a handfull of predefined commands
> to be run, nothing else)
> 
> Thanks
>  
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
Mat Harrison
Technical Developer
3d Computer Systems Ltd.
[EMAIL PROTECTED]
-
ASCII ribbon campaign ( )
 - against HTML email  X
   & Usenet posts / \

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] reboot pc with PHP

2003-08-28 Thread Matthew Harrison
On Thu, Aug 28, 2003 at 03:35:59PM +0200, Javier Tacon wrote:
> 
> A more easy solution is that:
> 
> Make a cron that executes every minut /tmp/rreboot.sh for user root
> crontab -e
> Add the line:
> * * * * *  /tmp/rreboot.sh
> 
> The script is:
> /tmp/rreboot.sh
> ---
> #!/bin/sh
> if [ -f "/tmp/rreboot" ]; then
>  rm -f /tmp/rreboot
>  shutdown -r now
> fi
> ---
> Make executable the file with chmod +x /tmp/rreboot.sh
>

just one little point (i'm glad i don't have to give a setuid lecture) personally
i would make sure that the location of the check file is extremely secure.

under normal circumstances, any user could write the rreboot file and cause a reboot

also, remember to remove the file again in rc.local before cron starts etc.

but i like the idea. its much more secure (from a web perspective).

> And a simple PHP like:
>  exec("echo rreboot > /tmp/rreboot");
> echo "Ok, i'll reboot in a few seconds";
> ?>
> 
> 
> So, when anyone calls to this PHP, creates a file, that if its detected by 
> rreboot.sh, the root will reboot the machine.
> 
> 
> 
> -Mensaje original-----
> De: Javier Tacon 
> Enviado el: jueves, 28 de agosto de 2003 15:07
> Para: Petre Agenbag; [EMAIL PROTECTED]
> Asunto: RE: [PHP] reboot pc with PHP
> 
> 
> 
> You can write a little script with expect (man expect) and execute it from php with 
> exec().
> 
> Other solution its to write a .procmailrc in root that executes the reboot when 
> coming a mail with some text in subject or boyd, so, from php you only need to send 
> a mail.
> 
> 
> -Mensaje original-
> De: Petre Agenbag [mailto:[EMAIL PROTECTED]
> Enviado el: jueves, 28 de agosto de 2003 14:48
> Para: [EMAIL PROTECTED]
> Asunto: [PHP] reboot pc with PHP
> 
> 
> Hi List
> 
> I've gone through the list for previous questions and the only one that
> seems to be a solution is to use sudo, however, I cannot seem to get it
> right.
> 
> Just as background:
> 
> I want to make a small "admin" utill for an intranet machine, so the
> security risks don't bother me at all.
> 
> Instead of myself having to ssh into the box to reboot or do other
> "routine" commands, I'd like to make a simple password protected webpage
> that would have simple links on them like "reboot", "redial" etc, so
> that someone with some sort of responsibility can do it themselves.
> 
> Obviously these command(s) need to be run as root, so I looked at the
> /etc/sudoers and added apache , BUT, in the error log it prompts for a
> password.
> 
> I tried to add the option NOPASSWD: ALL to the file, but it says there's
> a syntax error.
> 
> What am I missing?
> 
> Any other ways of doing this?  PS, I don't even want to consider Webmin,
> it's way too complicated, I just want a handfull of predefined commands
> to be run, nothing else)
> 
> Thanks
>  
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
Mat Harrison
Technical Developer
3d Computer Systems Ltd.
[EMAIL PROTECTED]
-
ASCII ribbon campaign ( )
 - against HTML email  X
   & Usenet posts / \

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] reboot pc with PHP

2003-08-28 Thread Javier Tacon

A more easy solution is that:

Make a cron that executes every minut /tmp/rreboot.sh for user root
crontab -e
Add the line:
* * * * *  /tmp/rreboot.sh

The script is:
/tmp/rreboot.sh
---
#!/bin/sh
if [ -f "/tmp/rreboot" ]; then
 rm -f /tmp/rreboot
 shutdown -r now
fi
---
Make executable the file with chmod +x /tmp/rreboot.sh

And a simple PHP like:
 /tmp/rreboot");
echo "Ok, i'll reboot in a few seconds";
?>


So, when anyone calls to this PHP, creates a file, that if its detected by rreboot.sh, 
the root will reboot the machine.



-Mensaje original-
De: Javier Tacon 
Enviado el: jueves, 28 de agosto de 2003 15:07
Para: Petre Agenbag; [EMAIL PROTECTED]
Asunto: RE: [PHP] reboot pc with PHP



You can write a little script with expect (man expect) and execute it from php with 
exec().

Other solution its to write a .procmailrc in root that executes the reboot when coming 
a mail with some text in subject or boyd, so, from php you only need to send a mail.


-Mensaje original-
De: Petre Agenbag [mailto:[EMAIL PROTECTED]
Enviado el: jueves, 28 de agosto de 2003 14:48
Para: [EMAIL PROTECTED]
Asunto: [PHP] reboot pc with PHP


Hi List

I've gone through the list for previous questions and the only one that
seems to be a solution is to use sudo, however, I cannot seem to get it
right.

Just as background:

I want to make a small "admin" utill for an intranet machine, so the
security risks don't bother me at all.

Instead of myself having to ssh into the box to reboot or do other
"routine" commands, I'd like to make a simple password protected webpage
that would have simple links on them like "reboot", "redial" etc, so
that someone with some sort of responsibility can do it themselves.

Obviously these command(s) need to be run as root, so I looked at the
/etc/sudoers and added apache , BUT, in the error log it prompts for a
password.

I tried to add the option NOPASSWD: ALL to the file, but it says there's
a syntax error.

What am I missing?

Any other ways of doing this?  PS, I don't even want to consider Webmin,
it's way too complicated, I just want a handfull of predefined commands
to be run, nothing else)

Thanks
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] reboot pc with PHP

2003-08-28 Thread Javier Tacon

You can write a little script with expect (man expect) and execute it from php with 
exec().

Other solution its to write a .procmailrc in root that executes the reboot when coming 
a mail with some text in subject or boyd, so, from php you only need to send a mail.


-Mensaje original-
De: Petre Agenbag [mailto:[EMAIL PROTECTED]
Enviado el: jueves, 28 de agosto de 2003 14:48
Para: [EMAIL PROTECTED]
Asunto: [PHP] reboot pc with PHP


Hi List

I've gone through the list for previous questions and the only one that
seems to be a solution is to use sudo, however, I cannot seem to get it
right.

Just as background:

I want to make a small "admin" utill for an intranet machine, so the
security risks don't bother me at all.

Instead of myself having to ssh into the box to reboot or do other
"routine" commands, I'd like to make a simple password protected webpage
that would have simple links on them like "reboot", "redial" etc, so
that someone with some sort of responsibility can do it themselves.

Obviously these command(s) need to be run as root, so I looked at the
/etc/sudoers and added apache , BUT, in the error log it prompts for a
password.

I tried to add the option NOPASSWD: ALL to the file, but it says there's
a syntax error.

What am I missing?

Any other ways of doing this?  PS, I don't even want to consider Webmin,
it's way too complicated, I just want a handfull of predefined commands
to be run, nothing else)

Thanks
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] reboot pc with PHP

2003-08-28 Thread Petre Agenbag
Hi List

I've gone through the list for previous questions and the only one that
seems to be a solution is to use sudo, however, I cannot seem to get it
right.

Just as background:

I want to make a small "admin" utill for an intranet machine, so the
security risks don't bother me at all.

Instead of myself having to ssh into the box to reboot or do other
"routine" commands, I'd like to make a simple password protected webpage
that would have simple links on them like "reboot", "redial" etc, so
that someone with some sort of responsibility can do it themselves.

Obviously these command(s) need to be run as root, so I looked at the
/etc/sudoers and added apache , BUT, in the error log it prompts for a
password.

I tried to add the option NOPASSWD: ALL to the file, but it says there's
a syntax error.

What am I missing?

Any other ways of doing this?  PS, I don't even want to consider Webmin,
it's way too complicated, I just want a handfull of predefined commands
to be run, nothing else)

Thanks
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php