Changeset 1211

Show
Ignore:
Timestamp:
03/05/10 10:05:16 (2 years ago)
Author:
Gary
Message:

unxsBind bind.c named-checkX experimental sections debugged and fixed major open file design error.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/unxsBind/bind.c

    r1210 r1211  
    33        $Id$ 
    44AUTHOR 
    5         (C) 2001-2009 Gary Wallis and Hugo Urquiza for Unixservice. 
     5        (C) 2001-2010 Gary Wallis and Hugo Urquiza for Unixservice, LLC. 
    66PURPOSE 
    77        GUI independent code: 
     
    5050unsigned uGetZoneOwner(unsigned uZone);//local 
    5151 
    52 //#define EXPERIMENTAL 
     52#define EXPERIMENTAL 
    5353#ifdef EXPERIMENTAL 
    5454        unsigned uNamedCheckConf(char *cNSSet); 
     
    17181718                        } 
    17191719                        mysql_free_result(res2); 
     1720                        if(zfp && !uDebug) fclose(zfp); 
    17201721#ifdef EXPERIMENTAL 
    17211722                        //Here's when this EXPERIMENTAL code starts to make sense. 
     
    17301731                        //tLog.uOwner will match the tClient.uClient value of the company that owns the zone 
    17311732 
     1733                        int iRetVal; 
     1734                        char cQuery[512]; 
     1735 
    17321736                        uZoneOwner=uGetZoneOwner(uZone); 
    1733                         sprintf(gcQuery,"%s/named-checkzone %s %s > /dev/null 2>&1",gcBinDir,field[0],cZoneFile); 
    1734                         printf("Running:%s\n",gcQuery); 
    1735                         if(system(gcQuery)) 
     1737                        sprintf(cQuery,"%s/named-checkzone -q %s %s",gcBinDir,field[0],cZoneFile); 
     1738                        if((iRetVal=system(cQuery))>0) 
    17361739                        { 
    17371740                                //Command failed, create tLog entry 
    1738                                 sprintf(gcQuery,"INSERT INTO tLog SET uLogType=1,uPermLevel=12,uLoginClient=1," 
     1741                                sprintf(gcQuery,"INSERT INTO tLog SET uLogType=4,uPermLevel=12,uLoginClient=1," 
    17391742                                        "cLogin='JobQueue',cHost ='127.0.0.1',uTablePK='%u',cTableName='tZone'," 
    1740                                         "cMessage='Zone with errors',cServer='%s',uOwner=%u,uCreatedBy=1," 
    1741                                         "uCreatedDate=UNIX_TIMESTAMP(NOW()),cLabel='named-checkzone %.32s'", 
    1742                                                 uZone,cMasterNS,uZoneOwner,field[0]); 
     1743                                        "cMessage='Zone %.99s with errors',cServer='%s',uOwner=%u,uCreatedBy=1," 
     1744                                        "uCreatedDate=UNIX_TIMESTAMP(NOW()),cLabel='named-checkzone'", 
     1745                                                uZone,field[0],cMasterNS,uZoneOwner); 
    17431746                                mysql_query(&gMysql,gcQuery); 
    17441747                                if(mysql_errno(&gMysql)) 
    17451748                                        htmlPlainTextError(mysql_error(&gMysql)); 
     1749                                printf("%s returned %d\n",cQuery,iRetVal); 
    17461750                        } 
    17471751#endif 
    1748                         if(zfp && !uDebug) fclose(zfp); 
    17491752                } 
    17501753                mysql_free_result(res); 
     
    23312334//      mysql_free_result(res); 
    23322335 
     2336        if(uReload) 
     2337        { 
    23332338#ifdef EXPERIMENTAL 
    2334         if((uNamedCheckConf(cNameServer))) exit(1); //Will exit without server reload or reconfig 
     2339                if((uNamedCheckConf(cNameServer))) exit(1); //Will exit without server reload or reconfig 
    23352340#endif 
    2336         if(uReload) 
    2337         { 
    23382341                if(cuControlPort[0]) 
    23392342                        sprintf(cCmd,"%s/rndc -c /etc/unxsbind-rndc.conf -p %s reload",gcBinDir,cuControlPort); 
     
    23462349        else if(uReconfig) 
    23472350        { 
     2351#ifdef EXPERIMENTAL 
     2352                if((uNamedCheckConf(cNameServer))) exit(1); //Will exit without server reload or reconfig 
     2353#endif 
    23482354                if(cuControlPort[0]) 
    23492355                        sprintf(cCmd,"%s/rndc -c /etc/unxsbind-rndc.conf -p %s reconfig",gcBinDir,cuControlPort); 
     
    36893695unsigned uNamedCheckConf(char *cNameServer) 
    36903696{ 
    3691         //This function runs a named-checkzone for the iDNS controlled named daemon 
     3697        //This function runs a named-checkconf for the iDNS controlled named daemon 
    36923698        //Returns 0 if OK, 1 if failure. Also it will create a tLog entry in case of error for informing 
    36933699        //the admin users via the iDNS backennd dashboard. 
     
    36993705        //We will check named configuration file to see if there are any issues there 
    37003706        sprintf(gcQuery,"%s/named-checkconf /usr/local/idns/named.conf",gcBinDir); 
    3701          
    3702         if(system(gcQuery)) 
     3707        printf("%s\n",gcQuery);  
     3708        if(system(gcQuery)>0) 
    37033709        { 
    37043710                //Insert tLog record and skip server reload or reconfig 
    3705                 sprintf(gcQuery,"INSERT INTO tLog SET uLogType=1,uPermLevel=12,uLoginClient=1," 
     3711                sprintf(gcQuery,"INSERT INTO tLog SET uLogType=4,uPermLevel=12,uLoginClient=1," 
    37063712                                "cLogin='MasterJobQueue()',cHost ='127.0.0.1',uTablePK=0,cTableName='(None)'," 
    37073713                                "cMessage='Server named.conf with errors',cServer='%s',uOwner=1,uCreatedBy=1,"