Changeset 156

Show
Ignore:
Timestamp:
03/04/03 19:33:39 (10 years ago)
Author:
ahu
Message:

working up to 2.9.7

Location:
trunk/pdns
Files:
13 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/ChangeLog

    r155 r156  
    66        - improved error reporting if unable to figure out IP addresses for 
    77          slaves 
     8        - removed vestigal receiver-threads setting 
     9        - ldapbackend needs to include utility.hh (Remco Post) 
     10        - pdns_control could sometimes leave files behind in /tmp (dG) 
     11        - ldapbackend updates    
    812 
    913Changes since 2.9.5: 
  • trunk/pdns/modules/ldapbackend/ldapbackend.cc

    r149 r156  
    11#include "ldapbackend.hh" 
     2 
    23#include <algorithm> 
    34#include <utility> 
    45#include <ctype.h>  
     6 
     7static int Toupper(int c) 
     8{ 
     9  return toupper(c); 
     10} 
     11 
    512 
    613LdapBackend::LdapBackend( const string &suffix ) 
     
    815        m_msgid = 0; 
    916        m_qname = ""; 
     17        m_revlookup = 0; 
    1018        setArgPrefix( "ldap" + suffix ); 
    1119 
     
    3644void LdapBackend::lookup( const QType &qtype, const string &qname, DNSPacket *dnspkt, int zoneid ) 
    3745{ 
    38         string filter, attr; 
     46        int len = 0; 
     47        vector<string> parts; 
     48        string filter, attr, ipaddr; 
    3949        char** attributes = attrany; 
    40         char* attronly[] = { NULL, NULL }; 
     50        char* attronly[] = { "associatedDomain", NULL, NULL }; 
    4151 
    4252 
    4353        m_qtype = qtype; 
    44         m_qname = m_pldap->escape( qname ); 
    45         filter = "(associatedDomain=" + m_qname + ")"; 
     54        m_qname = qname; 
     55        len = qname.length(); 
    4656 
    47         if( qtype.getCode() != 255 )   // qtype != ANY 
     57        if( len > 20 && qname.substr( len - 13, 13 ) == ".in-addr.arpa" ) 
     58        { 
     59                m_revlookup = 1; 
     60                stringtok( parts, qname.substr( 0, len - 13 ), "." ); 
     61                filter = "(aRecord=" + parts[3] + "." + parts[2] + "." + parts[1] + "." + parts[0] + ")"; 
     62                attributes = attronly; 
     63        } 
     64        else 
     65        { 
     66                m_revlookup = 0; 
     67                filter = "(associatedDomain=" + m_pldap->escape( m_qname ) + ")"; 
     68        } 
     69 
     70        if( qtype.getCode() != QType::ANY ) 
    4871        { 
    4972                attr = qtype.getName() + "Record"; 
    5073                filter = "(&" + filter + "(" + attr + "=*))"; 
    51                 attronly[0] = (char*) attr.c_str(); 
     74                attronly[1] = (char*) attr.c_str(); 
    5275                attributes = attronly; 
    5376        } 
     
    5881} 
    5982 
    60 static int Toupper(int c) 
    61 { 
    62   return toupper(c); 
    63 } 
    6483 
    6584bool LdapBackend::get( DNSResourceRecord &rr ) 
     
    7695                while( !m_result.empty() ) 
    7796                { 
     97                        if( m_revlookup == 1 && m_result.find( "associatedDomain" ) != m_result.end() ) 
     98                        { 
     99                                m_result["PTRRecord"] = m_result["associatedDomain"]; 
     100                        } 
     101                        m_result.erase( "associatedDomain" ); 
     102 
    78103                        attribute = m_result.begin(); 
    79104                        attrname = attribute->first; 
     
    82107                        qt = QType( const_cast<char*>(qstr.c_str()) ); 
    83108 
    84                         while( !attribute->second.empty() && ( m_qtype == "ANY" || qt.getCode() == m_qtype.getCode() ) ) 
     109                        while( !attribute->second.empty() && ( m_qtype.getCode() == QType::ANY ||  m_qtype.getCode() == qt.getCode() ) ) 
    85110                        { 
    86111                                content = attribute->second.back(); 
     
    91116                                rr.priority = 0; 
    92117 
    93                                 if( qt.getCode() == 15 )   // MX Record, e.g. 10 smtp.example.com 
     118                                if( qt.getCode() == QType::MX )   // MX Record, e.g. 10 smtp.example.com 
    94119                                { 
    95                                         stringtok( parts, content ); 
     120                                        stringtok( parts, content, " " ); 
    96121                                        rr.priority = (u_int16_t) strtol( parts[0].c_str(), NULL, 10 ); 
    97122                                        content = parts[1]; 
  • trunk/pdns/modules/ldapbackend/ldapbackend.hh

    r149 r156  
    66#include <unistd.h> 
    77#include <pdns/dns.hh> 
     8#include <pdns/utility.hh> 
    89#include <pdns/dnspacket.hh> 
    910#include <pdns/dnsbackend.hh> 
     
    2425 
    2526static char* attrany[] = { 
     27        "associatedDomain", 
    2628        "ARecord", 
    2729        "NSRecord", 
     
    4648 
    4749        int m_msgid; 
     50        int m_revlookup; 
     51   
    4852        QType m_qtype; 
    4953        string m_qname; 
  • trunk/pdns/pdns/Makefile.am

    r138 r156  
    3232dnsproxy.hh randombackend.cc unix_utility.cc common_startup.cc \ 
    3333utility.hh iputils.hh common_startup.hh \ 
    34 backends/bind/bindbackend.cc backends/bind/zoneparser2.cc \ 
     34backends/bind/bindbackend2.cc backends/bind/zoneparser2.cc \ 
    3535backends/bind/bindparser.cc backends/bind/bindlexer.c \ 
    3636backends/bind/huffman.cc backends/gsql/gsqlbackend.cc \ 
  • trunk/pdns/pdns/backends/bind/Makefile.am

    r155 r156  
    22noinst_LTLIBRARIES = libbindbackend.la 
    33 
    4 libbindbackend_la_SOURCES=bindbackend.cc bindbackend.hh bindparser.yy \ 
     4libbindbackend_la_SOURCES=bindbackend2.cc bindbackend2.hh bindparser.yy \ 
    55bindlexer.l zoneparser2.cc ../../misc.cc huffman.cc huffman.hh zoneparser.hh \ 
    66bindparser.hh ../../unix_utility.cc 
  • trunk/pdns/pdns/backends/bind/zoneparser.hh

    r86 r156  
    4646  callback_t *d_callback; 
    4747  bool parseLine(const vector<string>&words, vector<Record> &); 
    48   bool eatLine(string line, vector<Record>&); 
     48  bool eatLine(const string& line, vector<Record>&); 
    4949  void setDirectory(const string &dir); 
    5050  static string canonic(const string& dom); 
  • trunk/pdns/pdns/backends/bind/zoneparser2.cc

    r155 r156  
    6666  fds.push(zonein); 
    6767 
     68 
    6869  while(!fds.empty()) { 
    69     while(fgets(cline,sizeof(cline)-1,fds.top())) { 
     70    while(fgets_unlocked(cline,sizeof(cline)-1,fds.top())) { 
    7071      line=cline; 
    7172      chomp(line," \x1a\r\n"); 
     
    7374 
    7475      d_lineno++; 
    75       if(!line.find("$INCLUDE ") || !line.find("$include ")) { 
     76      if(line.empty()) 
     77        continue; 
     78 
     79      if(line[0]=='$' && (!line.find("$INCLUDE ") || !line.find("$include "))) { 
    7680        vector<string> parts; 
    7781        stringtok(parts,line," \t\n");  
     
    122126  stack<FILE *>fds; 
    123127  fds.push(zonein); 
     128 
    124129  while(!fds.empty()) { 
    125     while(fgets(cline,sizeof(cline)-1,fds.top())) { 
     130    while(fgets_unlocked(cline,sizeof(cline)-1,fds.top())) { 
    126131      line=cline; 
    127132      chomp(line," \x1a\r\n"); 
     
    129134 
    130135      d_lineno++; 
    131       if(!line.find("$INCLUDE ") || !line.find("$include ")) { 
     136      if(line.empty()) 
     137        continue; 
     138 
     139      if(line[0]=='$' && (!line.find("$INCLUDE ") || !line.find("$include "))) { 
    132140        vector<string> parts; 
    133141        stringtok(parts,line," \t\r\n"); 
     
    155163    fds.pop(); 
    156164  } 
    157    
    158  
    159165} 
    160166 
     
    172178  rec.prio=prio; 
    173179  recs.push_back(rec); 
    174  
    175180} 
    176181 
     
    181186  if(pos==string::npos) 
    182187    return; 
    183   line=line.substr(0,pos); 
    184 } 
    185  
    186 bool ZoneParser::eatLine(string line, vector<Record> &rec) 
    187 { 
    188  
     188  line.resize(pos); 
     189} 
     190 
     191bool ZoneParser::eatLine(const string& line, vector<Record> &rec) 
     192{ 
    189193  rec.clear(); 
    190194  static string tline; 
     
    193197 
    194198  if(tline.empty()) { 
    195     pos=line.find("("); 
     199    pos=line.find_first_of("("); 
    196200    if(pos!=string::npos) { // this is a line that continues 
    197201      tline=line.substr(0,pos); 
     
    240244void ZoneParser::setCallback(callback_t *callback) 
    241245{ 
    242         d_callback=callback; 
     246  d_callback=callback; 
    243247} 
    244248 
     
    271275bool ZoneParser::isClass(const string &s) 
    272276{ 
    273   return (s=="IN" || s=="CH" || s=="HS" || s=="in" || s=="ch" || s=="hs"); 
     277  return (s.size()==2 && (s=="IN" || s=="CH" || s=="HS" || s=="in" || s=="ch" || s=="hs")); 
    274278} 
    275279 
  • trunk/pdns/pdns/common_startup.cc

    r155 r156  
    9191  arg().set("webserver-password","Password required for accessing the webserver")=""; 
    9292 
    93   arg().set("receiver-threads","Number of receiver threads to launch")="1"; 
    94    
    9593  arg().setSwitch("out-of-zone-additional-processing","Do out of zone additional processing")="no"; 
    9694  arg().setSwitch("query-logging","Hint backends that queries should be logged")="no"; 
     
    269267     
    270268  //  fork(); (this worked :-)) 
    271   for(int n=0;n<arg().asNum("receiver-threads");++n) { 
    272     DNSDistributor *D= new DNSDistributor(arg().asNum("distributor-threads")); // the big dispatcher! 
    273     pthread_create(&qtid,0,qthread,static_cast<void *>(D)); // receives packets 
    274   } 
     269  DNSDistributor *D= new DNSDistributor(arg().asNum("distributor-threads")); // the big dispatcher! 
     270  pthread_create(&qtid,0,qthread,static_cast<void *>(D)); // receives packets 
    275271 
    276272  void *p; 
  • trunk/pdns/pdns/docs/pdns.sgml

    r152 r156  
    1212    </author> 
    1313     
    14     <PubDate>v2.1 $Date: 2003/02/15 11:30:17 $</PubDate> 
     14    <PubDate>v2.1 $Date: 2003/03/04 18:33:39 $</PubDate> 
    1515     
    1616    <Abstract> 
     
    33093309    <title>Configure database connectivity</title> 
    33103310    <para> 
    3311       The default PDNS distribution comes with a simple MySQL backend built in, which we will now use for  
    3312       demonstrating database connectivity. This backend is called 'mysql', and needs to be configured 
     3311      This chapter shows you how to configure the Generic MySQL backend, which we like a lot. But feel free to use any of the myriad 
     3312      other backends. 
     3313      This backend is called 'gmysql', and needs to be configured 
    33133314      in <filename>pdns.conf</filename>. Add the following lines, adjusted for your local setup: 
    33143315       
    33153316      <screen> 
    3316         launch=mysql 
    3317         mysql-host=127.0.0.1 
    3318         mysql-user=root 
    3319         mysql-dbname=pdnstest 
     3317        launch=gmysql 
     3318        gmysql-host=127.0.0.1 
     3319        gmysql-user=root 
     3320        gmysql-dbname=pdnstest 
    33203321      </screen> 
    33213322       
     
    33323333      <warning> 
    33333334        <para> 
    3334           This section describes the deprecated MySQL backend, which should no longer be used! Use the Generic MySQL backend! See 
    3335           <xref linkend="generic-mypgsql-backends">. 
     3335          Be very very sure that you configure the *g*mysql backend and not the mysql backend. See 
     3336          <xref linkend="generic-mypgsql-backends">. If you use the 'mysql' backend things will only appear to work. 
    33363337        </para> 
    33373338      </warning> 
     
    33443345        15:31:30 PowerDNS 1.99.0 (Mar 12 2002, 15:00:28) starting up 
    33453346        15:31:30 About to create 3 backend threads 
    3346         15:31:30 [MySQLbackend] Failed to connect to database: Error: Unknown database 'pdnstest' 
    3347         15:31:30 [MySQLbackend] Failed to connect to database: Error: Unknown database 'pdnstest' 
    3348         15:31:30 [MySQLbackend] Failed to connect to database: Error: Unknown database 'pdnstest' 
     3347        15:31:30 [gMySQLbackend] Failed to connect to database: Error: Unknown database 'pdnstest' 
     3348        15:31:30 [gMySQLbackend] Failed to connect to database: Error: Unknown database 'pdnstest' 
     3349        15:31:30 [gMySQLbackend] Failed to connect to database: Error: Unknown database 'pdnstest' 
    33493350      </screen> 
    33503351       
     
    33603361        Connect to MySQL as a user with sufficient privileges and issue the following commands: 
    33613362        <screen> 
    3362           # mysql  
    3363           mysql> CREATE DATABASE pdnstest; 
    3364           mysql> use pdnstest; 
    3365  
    3366           mysql> CREATE TABLE records ( 
    3367           id int(11) NOT NULL auto_increment, 
    3368           domain_id int(11) NOT NULL, 
    3369           name varchar(255) NOT NULL, 
    3370           type varchar(6) NOT NULL, 
    3371           content varchar(255) default NULL, 
    3372           ttl int(11) NOT NULL, 
    3373           prio int(11) default NULL, 
    3374           change_date int(11) default NULL, 
    3375           PRIMARY KEY (id), 
    3376           KEY name_index(name), 
    3377           KEY nametype_index(name,type), 
    3378           KEY domainid_index(domain_id) 
    3379           ); 
     3363create table domains ( 
     3364 id              INT auto_increment, 
     3365 name            VARCHAR(255) NOT NULL, 
     3366 master          VARCHAR(20) DEFAULT NULL, 
     3367 last_check      INT DEFAULT NULL, 
     3368 type            VARCHAR(6) NOT NULL, 
     3369 notified_serial INT DEFAULT NULL,  
     3370 account         VARCHAR(40) DEFAULT NULL, 
     3371 primary key (id) 
     3372)type=InnoDB; 
     3373 
     3374CREATE UNIQUE INDEX name_index ON domains(name); 
     3375 
     3376CREATE TABLE records ( 
     3377  id              INT auto_increment, 
     3378  domain_id       INT DEFAULT NULL, 
     3379  name            VARCHAR(255) DEFAULT NULL, 
     3380  type            VARCHAR(6) DEFAULT NULL, 
     3381  content         VARCHAR(255) DEFAULT NULL, 
     3382  ttl             INT DEFAULT NULL, 
     3383  prio            INT DEFAULT NULL, 
     3384  change_date     INT DEFAULT NULL, 
     3385  primary key(id) 
     3386)type=InnoDB; 
     3387 
     3388CREATE INDEX rec_name_index ON records(name); 
     3389CREATE INDEX nametype_index ON records(name,type); 
     3390CREATE INDEX domain_id ON records(domain_id); 
     3391 
     3392create table supermasters ( 
     3393  ip VARCHAR(25) NOT NULL,  
     3394  nameserver VARCHAR(255) NOT NULL,  
     3395  account VARCHAR(40) DEFAULT NULL 
     3396); 
     3397 
     3398GRANT SELECT ON supermasters TO pdns; 
     3399GRANT ALL ON domains TO pdns; 
     3400GRANT ALL ON records TO pdns; 
    33803401        </screen> 
    33813402         
     
    33873408          15:31:30 PowerDNS 1.99.0 (Mar 12 2002, 15:00:28) starting up 
    33883409          15:31:30 About to create 3 backend threads 
    3389           15:39:55 [MySQLbackend] MySQL connection succeeded 
    3390           15:39:55 [MySQLbackend] MySQL connection succeeded 
    3391           15:39:55 [MySQLbackend] MySQL connection succeeded 
     3410          15:39:55 [gMySQLbackend] MySQL connection succeeded 
     3411          15:39:55 [gMySQLbackend] MySQL connection succeeded 
     3412          15:39:55 [gMySQLbackend] MySQL connection succeeded 
    33923413        </screen> 
    33933414         
     
    34063427        <screen> 
    34073428          # mysql pdnstest 
    3408           mysql> 
     3429          mysql> INSERT INTO domains (name, type) values ('test.com', 'NATIVE'); 
    34093430          INSERT INTO records (domain_id, name, content, type,ttl,prio)  
    34103431          VALUES (1,'test.com','localhost ahu@ds9a.nl 1','SOA',86400,NULL); 
     
    34743495                  Your MySQL installation is probably defaulting to another location for its socket. Can be resolved 
    34753496                  by figuring out this location (often <filename>/var/run/mysqld.sock</filename>), and specifying it  
    3476                   in the configuration file with the <command>mysql-socket</command> parameter. 
     3497                  in the configuration file with the <command>gmysql-socket</command> parameter. 
    34773498                </para> 
    34783499                <para> 
    34793500                  Another solution is to not connect to the socket, but to 127.0.0.1, which can be achieved by specifying 
    3480                   <command>mysql-host=127.0.0.1</command>. 
     3501                  <command>gmysql-host=127.0.0.1</command>. 
    34813502                </para> 
    34823503              </listitem> 
  • trunk/pdns/pdns/dynmessenger.cc

    r106 r156  
    4646  unlink(d_local.sun_path); 
    4747   
    48   if(bind(d_s, (sockaddr*)&d_local,sizeof(d_local))<0)  
     48  if(bind(d_s, (sockaddr*)&d_local,sizeof(d_local))<0) { 
     49    unlink(d_local.sun_path); 
    4950    throw AhuException("Unable to bind to local temporary file: "+string(strerror(errno))); 
     51  } 
    5052   
    5153  if(chmod(d_local.sun_path,0666)<0) { // make sure that pdns can reply! 
     54    unlink(d_local.sun_path); 
    5255    perror("fchmod"); 
    5356    exit(1); 
     
    5861  d_remote.sun_family=AF_UNIX; 
    5962  strcpy(d_remote.sun_path,fname.c_str()); 
    60   if(connect(d_s,(sockaddr*)&d_remote,sizeof(d_remote))<0)  
     63  if(connect(d_s,(sockaddr*)&d_remote,sizeof(d_remote))<0) { 
     64    unlink(d_local.sun_path); 
    6165    throw AhuException("Unable to connect to remote '"+fname+"': "+string(strerror(errno))); 
     66  } 
    6267   
    6368} 
  • trunk/pdns/pdns/pdns_recursor.cc

    r148 r156  
    392392      FD_SET( d_clientsock, &readfds ); 
    393393      FD_SET( d_serversock, &readfds ); 
     394 
     395 
     396      /* this should listen on a TCP port as well for new connections,  */ 
    394397      int selret = select( max(d_clientsock,d_serversock) + 1, &readfds, NULL, NULL, &tv ); 
    395398      if(selret<=0)  
  • trunk/pdns/pdns/receiver.cc

    r108 r156  
    11/* 
    22    PowerDNS Versatile Database Driven Nameserver 
    3     Copyright (C) 2002  PowerDNS.COM BV 
     3    Copyright (C) 2003  PowerDNS.COM BV 
    44 
    55    This program is free software; you can redistribute it and/or modify 
     
    1717    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1818*/ 
    19 // $Id: receiver.cc,v 1.6 2003/01/02 15:43:00 ahu Exp $ 
     19// $Id: receiver.cc,v 1.7 2003/03/04 18:33:39 ahu Exp $ 
    2020#include <cstdio> 
    2121#include <signal.h> 
     
    541541  DLOG(L<<Logger::Warning<<"Verbose logging in effect"<<endl); 
    542542   
    543   L<<Logger::Warning<<"PowerDNS "<<VERSION<<" (C) 2002 PowerDNS.COM BV ("<<__DATE__", "__TIME__<<") starting up"<<endl; 
     543  L<<Logger::Warning<<"PowerDNS "<<VERSION<<" (C) 2001-2003 PowerDNS.COM BV ("<<__DATE__", "__TIME__<<") starting up"<<endl; 
    544544 
    545545  L<<Logger::Warning<<"PowerDNS comes with ABSOLUTELY NO WARRANTY. " 
  • trunk/pdns/pdns/tcpreceiver.cc

    r148 r156  
    172172        // now what 
    173173        // this is a pretty rare event all in all, so we can afford to be slow 
     174 
     175        // this code SHOULD attempt to answer from the local cache first! 
    174176        S.inc("recursing-questions"); 
    175177        Resolver res;