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

Discussion in 'Perl Misc' started by google@warcode.com, Sep 14, 2005.

  1. Guest

    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
     
    , Sep 14, 2005
    #1
    1. Advertising

  2. Thomas Kratz Guest

    Re: Permissions to Run StartService/StopService from Web Interface?

    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^.-
     
    Thomas Kratz, Sep 15, 2005
    #2
    1. Advertising

  3. Guest

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

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

    Any other ideas?

    Thanks!

    -peter
     
    , Sep 15, 2005
    #3
  4. Thomas Kratz Guest

    Re: Permissions to Run StartService/StopService from Web Interface?

    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^.-
     
    Thomas Kratz, Sep 16, 2005
    #4
  5. Guest

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

    > 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
     
    , Sep 16, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott Allen
    Replies:
    0
    Views:
    462
    Scott Allen
    Jul 13, 2004
  2. Curt K
    Replies:
    0
    Views:
    585
    Curt K
    Nov 3, 2006
  3. Mr. X.

    StartService in jini 2.1

    Mr. X., Jul 3, 2007, in forum: Java
    Replies:
    1
    Views:
    290
    Mr. X.
    Jul 3, 2007
  4. Leo Violette
    Replies:
    0
    Views:
    1,090
    Leo Violette
    Apr 17, 2009
  5. Kai Geng
    Replies:
    0
    Views:
    223
    Kai Geng
    Dec 12, 2007
Loading...

Share This Page