Results 1 to 4 of 4

Thread: rndc reload as user?

  1. #1
    Member morissette's Avatar
    Join Date
    May 2009
    Location
    Austin, TX
    Posts
    103
    cPanel/WHM Access Level

    Root Administrator

    Default rndc reload as user?

    Is there an API call to reload rndc? I have a cpanel plugin im developing which modifies dns but it looks like named isn't being reloaded.

  2. #2
    Member This forum account has been confirmed by cPanel staff to represent a vendor. KostonConsulting's Avatar
    Join Date
    Jun 2010
    Location
    Austin, TX
    Posts
    149
    cPanel/WHM Access Level

    Root Administrator

    Default Re: rndc reload as user?

    Anything that edits DNS zones will restart named (add/remove sub/parked/addon domains, edit dns zones, etc). However, thos may not be useful unless you want to mess with the account. You could make your own api2 call that connects to dnsadmin by creating /usr/local/cpanel/Cpanel/DNSAPI.pm:

    Code:
    package Cpanel::DNSAPI;
    BEGIN{ push( @INC, '/usr/local/cpanel'); }
    
    use Cpanel::DnsUtils::AskDnsAdmin ();
    
    sub api2 {
        my $func = shift;
        my %API;
    
        $API{'reload'}{'func'} = 'api2_reload';
        $API{'reload'}{'engine'} = 'hasharray';
      
        return \%{ $API{$func} };
    }
    
    
    sub api2_reload{
      my %OPTS = @_;
    
      my $domain_to_reload = $OPTS{'domain'}; #sanitize this as you don't know what the code in dnsadmin looks like
    
      #original usage is below, my usage is not tested
      #my %RELOADLIST = shift;  
      #Cpanel::DnsUtils::AskDnsAdmin::askdnsadmin( 'RELOADZONES', 0, join( ',', keys %RELOADLIST ) );
    
      Cpanel::DnsUtils::AskDnsAdmin::askdnsadmin( 'RELOADZONES', 0, $domain_to_reload );
    }
    
    1;
    Now, I pulled the askdnsadmin function call from /usr/local/cpanel/Cpanel/DnsUtils.pm so you'll have to go through that module to see how the %RELOADLIST is built for what to send as the zones to reload but it should do the trick.

    You could then call it with:

    Code:
    https://domain.com:2083/xml-api/cpanel?cpanel_xmlapi_module=DNSAPI&cpanel_xmlapi_func=reload&cpanel_xmlapi_apiversion=2&domain=thedomain.tld




    Now, there's also a call for ZoneEdit::resetzone which will reload named but it likely will wipe out your changes: ZoneEdit Module Documentation


    You'll want to make sure you're using the ZoneEdit functions to edit the DNS zone or it will likely be rebuilt without your changes at some future point.
    Dave Koston
    Koston Consulting
    http://www.kostonconsulting.com

  3. #3
    Member morissette's Avatar
    Join Date
    May 2009
    Location
    Austin, TX
    Posts
    103
    cPanel/WHM Access Level

    Root Administrator

    Default Re: rndc reload as user?

    Late reply but whatevs,

    So I am using cptt and the ZoneEdit functions in TT and rndc is not being reloaded. Any ideas?
    http://mattharris.org
    System Administrator

  4. #4
    Member This forum account has been confirmed by cPanel staff to represent a vendor. KostonConsulting's Avatar
    Join Date
    Jun 2010
    Location
    Austin, TX
    Posts
    149
    cPanel/WHM Access Level

    Root Administrator

    Default Re: rndc reload as user?

    Quote Originally Posted by morissette View Post
    Late reply but whatevs,

    So I am using cptt and the ZoneEdit functions in TT and rndc is not being reloaded. Any ideas?

    It's reloading fine on my test box:

    add_zone_record:

    Code:
    https://domain.com:2083/cpsessXXXXXXXXXX/xml-api/cpanel?cpanel_xmlapi_module=ZoneEdit&cpanel_xmlapi_func=add_zone_record&domain=domain.com&name=domain.com&type=TXT&txtdata=test
    output:

    Code:
    <cpanelresult>
    <apiversion>2</apiversion>
    <data>
    <name>result</name>
    <newserial>2012080201</newserial>
    <status>1</status>
    <statusmsg>
    Bind reloading on hostname using rndc zone: [domain.com]
    </statusmsg>
    </data>
    <event>
    <result>1</result>
    </event>
    <func>add_zone_record</func>
    <module>ZoneEdit</module>
    </cpanelresult>

    edit_zone_record:


    Code:
    https://domain.com:2083/cpsessXXXXXXXXXX/xml-api/cpanel?cpanel_xmlapi_module=ZoneEdit&cpanel_xmlapi_func=edit_zone_record&domain=domain.com&Line=31&type=TXT&txtdata=updated


    output:

    Code:
    <cpanelresult>
    <apiversion>2</apiversion>
    <data>
    <name>result</name>
    <newserial>2012080202</newserial>
    <status>1</status>
    <statusmsg>
    Bind reloading on hostname using rndc zone: [domain.com]
    </statusmsg>
    </data>
    <event>
    <result>1</result>
    </event>
    <func>edit_zone_record</func>
    <module>ZoneEdit</module>
    </cpanelresult>


    You should note that if you're doing this programmatically, you'll need to wait for the nameserver reload to complete which could take up to a minute. If you have another function immediately looking at the zone, it will fail as that's going to happen in milliseconds.
    Dave Koston
    Koston Consulting
    http://www.kostonconsulting.com

Similar Threads

  1. named: rndc reload problem
    By carock in forum cPanel & WHM Discussions
    Replies: 5
    Last Post: 01-18-2009, 10:05 PM
  2. How can user reload his Webapp?
    By rodstewart in forum New User Questions
    Replies: 3
    Last Post: 06-19-2007, 07:08 AM
  3. Error reloading bind on dnserver3: rndc: 'reload' failed: not found
    By KatieBuller in forum cPanel & WHM Discussions
    Replies: 12
    Last Post: 06-22-2005, 04:50 PM
  4. Trustix rndc reload problem
    By ntwaddel in forum cPanel & WHM Discussions
    Replies: 15
    Last Post: 02-05-2005, 05:18 PM
  5. Error reloading bind on ns1: rndc: 'reload' failed: not found
    By Kloe in forum cPanel & WHM Discussions
    Replies: 3
    Last Post: 11-28-2004, 04:51 AM