Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Permissions to Run StartService/StopService from Web Interface? (Win32::Service)

Reply
Thread Tools

Permissions to Run StartService/StopService from Web Interface? (Win32::Service)

 
 
google@warcode.com
Guest
Posts: n/a
 
      09-14-2005
I have a simple perl script which permits me to query the Services ona
Win2k server and check status for each to see if it is running.

I have two other simple script which will stop and start any service
for me.

The problem is making these work from a web interface. I'm able to do
the first (i.e. get list of running services and check status for each:

http://mrtg.fusionserver.com/Services/status.pl

Youll notice I'm filtering so I just see the two WebTrends services.

But my links to stop/start the services don't work. The same code
works fine from the command line -- just not from the web browser.

If you test it out and try to stop one of the services, the error you
see is generated by this line of code:

Win32::Service::StopService('',$DefProcess) or $abort = 1;

$abort is a flag I use on the next line to stop the script and display
the erro you see. $DefProcess is properly defined -- so that's not the
problem.

I assume it is a permissions problem of some type, but I can't figure
it out. Does anyone have any ideas of what I can do to make this work?

Thanks!

-peter

 
Reply With Quote
 
 
 
 
Thomas Kratz
Guest
Posts: n/a
 
      09-15-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I have a simple perl script which permits me to query the Services ona
> Win2k server and check status for each to see if it is running.
>
> I have two other simple script which will stop and start any service
> for me.
>
> The problem is making these work from a web interface. I'm able to do
> the first (i.e. get list of running services and check status for each:
>
> http://mrtg.fusionserver.com/Services/status.pl
>
> Youll notice I'm filtering so I just see the two WebTrends services.
>
> But my links to stop/start the services don't work. The same code
> works fine from the command line -- just not from the web browser.


You need to grant start/stop rights for the services to the user your web
server is running as.

Look here for a tool that can do this:
http://setacl.sourceforge.net

This has nothing to do with Perl.
Thomas


--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e. r^.>l^..>k^.-
 
Reply With Quote
 
 
 
 
google@warcode.com
Guest
Posts: n/a
 
      09-15-2005
Thanks, Thomas! My web server is running as System, which has
permission to Start and Stop services.

Any other ideas?

Thanks!

-peter

 
Reply With Quote
 
Thomas Kratz
Guest
Posts: n/a
 
      09-16-2005
(E-Mail Removed) wrote:
>


First: please quote some context in replies! And read the posting
guidelines posted here regularly.

borrowed from Anno:

If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.

> Thanks, Thomas! My web server is running as System, which has
> permission to Start and Stop services.


That is most likely a very bad idea. Please read about web servers and
security issues almost anywhere.

> Any other ideas?


First, you will have to get to the error message the call to
Win32::Service::StopService returns.

print Win32::FormatMessage(Win32::GetLastError());

perldoc Win32
perldoc Win32::Service

If this doesn't help, use system() or backticks with your net stop/start
command as parameter and look at the result.

Thomas

--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e. r^.>l^..>k^.-
 
Reply With Quote
 
google@warcode.com
Guest
Posts: n/a
 
      09-16-2005
> First: please quote some context in replies! And read the posting
> guidelines posted here regularly.


Thanks for the tip! Will do that from now on.


> > Thanks, Thomas! My web server is running as System, which has
> > permission to Start and Stop services.

>
> That is most likely a very bad idea. Please read about web servers and
> security issues almost anywhere.


OK, thanks. Will do.


> > Any other ideas?

>
> First, you will have to get to the error message the call to
> Win32::Service::StopService returns.
>
> print Win32::FormatMessage(Win32::GetLastError());


Yields "Access is denied."

This weekend I'll mess around with chaning the account the web server
is running as and see if I can get it to work.

Thanks again!

-peter

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
In-depth documenation on User Permissions, Group Permissions, ACLs, DCLs etc. Curt K ASP .Net 0 11-03-2006 04:54 PM
Change NTFS Permissions or run shell script Shawn H. Mesiatowsky ASP .Net 0 02-03-2005 10:23 PM
ASPX file returning obscur runtime error - after changing permissions to a subweb (.net app) to different permissions than on its parent ? Isabelle ASP .Net 0 08-11-2004 02:04 PM
Re: Permissions - giving "everyone" full permissions is bad ? Scott Allen ASP .Net 0 07-13-2004 08:54 PM
Permissions needed to run aspnet_regiis.exe -c Eric Caron ASP .Net 3 04-05-2004 04:57 PM



Advertisments