The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Making accounts through another perl script

Discussion in 'General Discussion' started by infinity, Aug 16, 2001.

  1. infinity

    infinity Member

    Joined:
    Aug 15, 2001
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Im trying to get my billing script to create new accounts but so far I\'ve had no luck.....

    myf irst guess was to use system(\"/scripts/www/acct ...\"); but this doesnt work because the script thinks its a telnet based request and promts for a confirm.

    I then tried taking code from /scripts/wwstat and placing it into my new script but while the script says it does everything, it lacks the permisions to really do anything.

    Does anyone know how I can get a general perl script to make users or is there another program to do this?
     
  2. infinity

    infinity Member

    Joined:
    Aug 15, 2001
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    To elaborate... I made a test script which executes system("/scripts/wwwacct"); only and recieved a 'permision denied' error when executing via telnet. Chowning the script to root fixed this for telnet but the permisions error persists via httpd apache calls.

    I have also tried using an lwp connection similar to the following but always recieve a 500 Timeout error despite the timeout setting I set.

    [quote:0ab22ac6af][b:0ab22ac6af]
    use LWP::UserAgent;
    use HTTP::Request;
    use HTTP::Request::Common;
    use HTTP::Response;


    my $url = qq(http://xxx.yyy.com:2086/scripts/wwwacct);
    my $ua = LWP::UserAgent->new();
    $ua->timeout(300000000);
    my $req = POST $url,;
    #my $req = HTTP::Request->new(GET => $url);


    # This is important. Need to give our UserAgent the
    # login name and password for realm authentication.
    #$req->authorization_basic($User,$Pass);

    print qq($namet) . $req->url() . qq(n);

    my $response = $ua->request($req);
    if ($response->is_error()) {
    print $response->status_line . qq(n);
    } else { print "it worked $response"; [/b:0ab22ac6af][/quote:0ab22ac6af]

    (Yes this is a bit insecure but it's the best I could think up for a quick solution)

    [Edited on 8/17/01 by infinity]

    [Edited on 8/17/01 by infinity]
     
  3. infinity

    infinity Member

    Joined:
    Aug 15, 2001
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    [b:f69a5b56a3]Sucess![/b:f69a5b56a3]

    Well, after a lot of thought I realized thazt the only think I could semi-safeuly run as root is a cronjob so I nw have perl writting to a cleaverly named file which inturn is read by a cron file, checked against an sql database (query only access) then it runs wwwacct.

    Its not great but it works.... if anyone has a better suggestion PLEASE let me know.
     
  4. Site5-Matt

    Site5-Matt Well-Known Member
    PartnerNOC

    Joined:
    Aug 10, 2001
    Messages:
    81
    Likes Received:
    0
    Trophy Points:
    6
    [quote:dce68b2d5a]Im trying to get my billing script to create new accounts but so far I've had no luck.....

    myf irst guess was to use system("/scripts/www/acct ..."); but this doesnt work because the script thinks its a telnet based request and promts for a confirm.
    [/quote:dce68b2d5a]
    It shouldn't if the output is not going to a terminal...
    [quote:dce68b2d5a]
    I then tried taking code from /scripts/wwstat and placing it into my new script but while the script says it does everything, it lacks the permisions to really do anything.
    [/quote:dce68b2d5a]
    This is because the webserver runs as 'nobody' and you need to be root to add an account.
    [quote:dce68b2d5a]
    Does anyone know how I can get a general perl script to make users or is there another program to do this?
    [/quote:dce68b2d5a]
    You could use a setuid wrapper to run the script as root. Of course, it would be pretty insecure unless you knew what you were doing. That is unadvisable.

    Matt

    [Edited on 8/18/01 by Site5-Matt]
     
  5. infinity

    infinity Member

    Joined:
    Aug 15, 2001
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Matt,
    I\'ve been considering using NETSSL or LWP with https to connect to the WHM panel and submit the form to sign a new user up. While this still have some security risks, it seems smarter than any othe mehotd espcially if I use a resller name and not root to access WHM and make accounts.

    However, NETSSL doesnt seem to accept the user:pass@site:port method or atleast I cant find any code for it and lwp seems to time out on attempts... any thoughts?
     
  6. valhalla

    valhalla Member

    Joined:
    Sep 1, 2001
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    I´m trying to do the same you say. I´m using LWP, if you can send me what you have done, I will thank you a lot.
     
  7. seasoned

    seasoned Member

    Joined:
    Jan 25, 2004
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    fort wayne
    Two questions

    1. Why don't you just use creatacct?
    2. I used creatacct. works like a charm, BUT, it selects the next available IP. Do you know how I can force it to use NAME BASED resolution with the one IP?

    Steve
     
  8. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    It probably wasn't an option 2 years ago.
     
  9. seasoned

    seasoned Member

    Joined:
    Jan 25, 2004
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    fort wayne
    Sorry,

    I didn't notice. 8-( Does anyone have an answer to the SECOND question?
     
  10. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    That's ok. I've seen some pretty unusual replies to old threads. My favorite is when someone asks how to do something and over a year later someone gives an answer. It's nice in case someone else looks it up someday, but it's pretty safe to assume the original poster isn't looking anymore.

    As far as the 2nd question, sorry, I don't have an answer for it. Someone should though. If you don't get a reply within a couple days, bump the thread. They go down the list pretty fast here.
     
  11. anand

    anand Well-Known Member

    Joined:
    Nov 11, 2002
    Messages:
    1,435
    Likes Received:
    1
    Trophy Points:
    38
    Location:
    India
    cPanel Access Level:
    DataCenter Provider
    Re: Two questions

    Did you try to use a package while creating an account. Just a thought.
     
Loading...

Share This Page