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

G

google

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
 
T

Thomas Kratz

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^.-
 
G

google

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

Any other ideas?

Thanks!

-peter
 
T

Thomas Kratz

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^.-
 
G

google

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.

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

OK, thanks. Will do.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top