Changeset 156
- Timestamp:
- 03/04/03 19:33:39 (10 years ago)
- Location:
- trunk/pdns
- Files:
-
- 13 modified
-
ChangeLog (modified) (1 diff)
-
modules/ldapbackend/ldapbackend.cc (modified) (7 diffs)
-
modules/ldapbackend/ldapbackend.hh (modified) (3 diffs)
-
pdns/Makefile.am (modified) (1 diff)
-
pdns/backends/bind/Makefile.am (modified) (1 diff)
-
pdns/backends/bind/zoneparser.hh (modified) (1 diff)
-
pdns/backends/bind/zoneparser2.cc (modified) (10 diffs)
-
pdns/common_startup.cc (modified) (2 diffs)
-
pdns/docs/pdns.sgml (modified) (8 diffs)
-
pdns/dynmessenger.cc (modified) (2 diffs)
-
pdns/pdns_recursor.cc (modified) (1 diff)
-
pdns/receiver.cc (modified) (3 diffs)
-
pdns/tcpreceiver.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/ChangeLog
r155 r156 6 6 - improved error reporting if unable to figure out IP addresses for 7 7 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 8 12 9 13 Changes since 2.9.5: -
trunk/pdns/modules/ldapbackend/ldapbackend.cc
r149 r156 1 1 #include "ldapbackend.hh" 2 2 3 #include <algorithm> 3 4 #include <utility> 4 5 #include <ctype.h> 6 7 static int Toupper(int c) 8 { 9 return toupper(c); 10 } 11 5 12 6 13 LdapBackend::LdapBackend( const string &suffix ) … … 8 15 m_msgid = 0; 9 16 m_qname = ""; 17 m_revlookup = 0; 10 18 setArgPrefix( "ldap" + suffix ); 11 19 … … 36 44 void LdapBackend::lookup( const QType &qtype, const string &qname, DNSPacket *dnspkt, int zoneid ) 37 45 { 38 string filter, attr; 46 int len = 0; 47 vector<string> parts; 48 string filter, attr, ipaddr; 39 49 char** attributes = attrany; 40 char* attronly[] = { NULL, NULL };50 char* attronly[] = { "associatedDomain", NULL, NULL }; 41 51 42 52 43 53 m_qtype = qtype; 44 m_qname = m_pldap->escape( qname );45 filter = "(associatedDomain=" + m_qname + ")";54 m_qname = qname; 55 len = qname.length(); 46 56 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 ) 48 71 { 49 72 attr = qtype.getName() + "Record"; 50 73 filter = "(&" + filter + "(" + attr + "=*))"; 51 attronly[ 0] = (char*) attr.c_str();74 attronly[1] = (char*) attr.c_str(); 52 75 attributes = attronly; 53 76 } … … 58 81 } 59 82 60 static int Toupper(int c)61 {62 return toupper(c);63 }64 83 65 84 bool LdapBackend::get( DNSResourceRecord &rr ) … … 76 95 while( !m_result.empty() ) 77 96 { 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 78 103 attribute = m_result.begin(); 79 104 attrname = attribute->first; … … 82 107 qt = QType( const_cast<char*>(qstr.c_str()) ); 83 108 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() ) ) 85 110 { 86 111 content = attribute->second.back(); … … 91 116 rr.priority = 0; 92 117 93 if( qt.getCode() == 15) // MX Record, e.g. 10 smtp.example.com118 if( qt.getCode() == QType::MX ) // MX Record, e.g. 10 smtp.example.com 94 119 { 95 stringtok( parts, content );120 stringtok( parts, content, " " ); 96 121 rr.priority = (u_int16_t) strtol( parts[0].c_str(), NULL, 10 ); 97 122 content = parts[1]; -
trunk/pdns/modules/ldapbackend/ldapbackend.hh
r149 r156 6 6 #include <unistd.h> 7 7 #include <pdns/dns.hh> 8 #include <pdns/utility.hh> 8 9 #include <pdns/dnspacket.hh> 9 10 #include <pdns/dnsbackend.hh> … … 24 25 25 26 static char* attrany[] = { 27 "associatedDomain", 26 28 "ARecord", 27 29 "NSRecord", … … 46 48 47 49 int m_msgid; 50 int m_revlookup; 51 48 52 QType m_qtype; 49 53 string m_qname; -
trunk/pdns/pdns/Makefile.am
r138 r156 32 32 dnsproxy.hh randombackend.cc unix_utility.cc common_startup.cc \ 33 33 utility.hh iputils.hh common_startup.hh \ 34 backends/bind/bindbackend .cc backends/bind/zoneparser2.cc \34 backends/bind/bindbackend2.cc backends/bind/zoneparser2.cc \ 35 35 backends/bind/bindparser.cc backends/bind/bindlexer.c \ 36 36 backends/bind/huffman.cc backends/gsql/gsqlbackend.cc \ -
trunk/pdns/pdns/backends/bind/Makefile.am
r155 r156 2 2 noinst_LTLIBRARIES = libbindbackend.la 3 3 4 libbindbackend_la_SOURCES=bindbackend .cc bindbackend.hh bindparser.yy \4 libbindbackend_la_SOURCES=bindbackend2.cc bindbackend2.hh bindparser.yy \ 5 5 bindlexer.l zoneparser2.cc ../../misc.cc huffman.cc huffman.hh zoneparser.hh \ 6 6 bindparser.hh ../../unix_utility.cc -
trunk/pdns/pdns/backends/bind/zoneparser.hh
r86 r156 46 46 callback_t *d_callback; 47 47 bool parseLine(const vector<string>&words, vector<Record> &); 48 bool eatLine( stringline, vector<Record>&);48 bool eatLine(const string& line, vector<Record>&); 49 49 void setDirectory(const string &dir); 50 50 static string canonic(const string& dom); -
trunk/pdns/pdns/backends/bind/zoneparser2.cc
r155 r156 66 66 fds.push(zonein); 67 67 68 68 69 while(!fds.empty()) { 69 while(fgets (cline,sizeof(cline)-1,fds.top())) {70 while(fgets_unlocked(cline,sizeof(cline)-1,fds.top())) { 70 71 line=cline; 71 72 chomp(line," \x1a\r\n"); … … 73 74 74 75 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 "))) { 76 80 vector<string> parts; 77 81 stringtok(parts,line," \t\n"); … … 122 126 stack<FILE *>fds; 123 127 fds.push(zonein); 128 124 129 while(!fds.empty()) { 125 while(fgets (cline,sizeof(cline)-1,fds.top())) {130 while(fgets_unlocked(cline,sizeof(cline)-1,fds.top())) { 126 131 line=cline; 127 132 chomp(line," \x1a\r\n"); … … 129 134 130 135 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 "))) { 132 140 vector<string> parts; 133 141 stringtok(parts,line," \t\r\n"); … … 155 163 fds.pop(); 156 164 } 157 158 159 165 } 160 166 … … 172 178 rec.prio=prio; 173 179 recs.push_back(rec); 174 175 180 } 176 181 … … 181 186 if(pos==string::npos) 182 187 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 191 bool ZoneParser::eatLine(const string& line, vector<Record> &rec) 192 { 189 193 rec.clear(); 190 194 static string tline; … … 193 197 194 198 if(tline.empty()) { 195 pos=line.find ("(");199 pos=line.find_first_of("("); 196 200 if(pos!=string::npos) { // this is a line that continues 197 201 tline=line.substr(0,pos); … … 240 244 void ZoneParser::setCallback(callback_t *callback) 241 245 { 242 d_callback=callback;246 d_callback=callback; 243 247 } 244 248 … … 271 275 bool ZoneParser::isClass(const string &s) 272 276 { 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")); 274 278 } 275 279 -
trunk/pdns/pdns/common_startup.cc
r155 r156 91 91 arg().set("webserver-password","Password required for accessing the webserver")=""; 92 92 93 arg().set("receiver-threads","Number of receiver threads to launch")="1";94 95 93 arg().setSwitch("out-of-zone-additional-processing","Do out of zone additional processing")="no"; 96 94 arg().setSwitch("query-logging","Hint backends that queries should be logged")="no"; … … 269 267 270 268 // 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 275 271 276 272 void *p; -
trunk/pdns/pdns/docs/pdns.sgml
r152 r156 12 12 </author> 13 13 14 <PubDate>v2.1 $Date: 2003/0 2/15 11:30:17$</PubDate>14 <PubDate>v2.1 $Date: 2003/03/04 18:33:39 $</PubDate> 15 15 16 16 <Abstract> … … 3309 3309 <title>Configure database connectivity</title> 3310 3310 <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 3313 3314 in <filename>pdns.conf</filename>. Add the following lines, adjusted for your local setup: 3314 3315 3315 3316 <screen> 3316 launch= mysql3317 mysql-host=127.0.0.13318 mysql-user=root3319 mysql-dbname=pdnstest3317 launch=gmysql 3318 gmysql-host=127.0.0.1 3319 gmysql-user=root 3320 gmysql-dbname=pdnstest 3320 3321 </screen> 3321 3322 … … 3332 3333 <warning> 3333 3334 <para> 3334 This section describes the deprecated MySQL backend, which should no longer be used! Use the Generic MySQL backend!See3335 <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. 3336 3337 </para> 3337 3338 </warning> … … 3344 3345 15:31:30 PowerDNS 1.99.0 (Mar 12 2002, 15:00:28) starting up 3345 3346 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' 3349 3350 </screen> 3350 3351 … … 3360 3361 Connect to MySQL as a user with sufficient privileges and issue the following commands: 3361 3362 <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 ); 3363 create 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 3374 CREATE UNIQUE INDEX name_index ON domains(name); 3375 3376 CREATE 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 3388 CREATE INDEX rec_name_index ON records(name); 3389 CREATE INDEX nametype_index ON records(name,type); 3390 CREATE INDEX domain_id ON records(domain_id); 3391 3392 create table supermasters ( 3393 ip VARCHAR(25) NOT NULL, 3394 nameserver VARCHAR(255) NOT NULL, 3395 account VARCHAR(40) DEFAULT NULL 3396 ); 3397 3398 GRANT SELECT ON supermasters TO pdns; 3399 GRANT ALL ON domains TO pdns; 3400 GRANT ALL ON records TO pdns; 3380 3401 </screen> 3381 3402 … … 3387 3408 15:31:30 PowerDNS 1.99.0 (Mar 12 2002, 15:00:28) starting up 3388 3409 15:31:30 About to create 3 backend threads 3389 15:39:55 [ MySQLbackend] MySQL connection succeeded3390 15:39:55 [ MySQLbackend] MySQL connection succeeded3391 15:39:55 [ MySQLbackend] MySQL connection succeeded3410 15:39:55 [gMySQLbackend] MySQL connection succeeded 3411 15:39:55 [gMySQLbackend] MySQL connection succeeded 3412 15:39:55 [gMySQLbackend] MySQL connection succeeded 3392 3413 </screen> 3393 3414 … … 3406 3427 <screen> 3407 3428 # mysql pdnstest 3408 mysql> 3429 mysql> INSERT INTO domains (name, type) values ('test.com', 'NATIVE'); 3409 3430 INSERT INTO records (domain_id, name, content, type,ttl,prio) 3410 3431 VALUES (1,'test.com','localhost ahu@ds9a.nl 1','SOA',86400,NULL); … … 3474 3495 Your MySQL installation is probably defaulting to another location for its socket. Can be resolved 3475 3496 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. 3477 3498 </para> 3478 3499 <para> 3479 3500 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>. 3481 3502 </para> 3482 3503 </listitem> -
trunk/pdns/pdns/dynmessenger.cc
r106 r156 46 46 unlink(d_local.sun_path); 47 47 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); 49 50 throw AhuException("Unable to bind to local temporary file: "+string(strerror(errno))); 51 } 50 52 51 53 if(chmod(d_local.sun_path,0666)<0) { // make sure that pdns can reply! 54 unlink(d_local.sun_path); 52 55 perror("fchmod"); 53 56 exit(1); … … 58 61 d_remote.sun_family=AF_UNIX; 59 62 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); 61 65 throw AhuException("Unable to connect to remote '"+fname+"': "+string(strerror(errno))); 66 } 62 67 63 68 } -
trunk/pdns/pdns/pdns_recursor.cc
r148 r156 392 392 FD_SET( d_clientsock, &readfds ); 393 393 FD_SET( d_serversock, &readfds ); 394 395 396 /* this should listen on a TCP port as well for new connections, */ 394 397 int selret = select( max(d_clientsock,d_serversock) + 1, &readfds, NULL, NULL, &tv ); 395 398 if(selret<=0) -
trunk/pdns/pdns/receiver.cc
r108 r156 1 1 /* 2 2 PowerDNS Versatile Database Driven Nameserver 3 Copyright (C) 200 2PowerDNS.COM BV3 Copyright (C) 2003 PowerDNS.COM BV 4 4 5 5 This program is free software; you can redistribute it and/or modify … … 17 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 18 */ 19 // $Id: receiver.cc,v 1. 6 2003/01/02 15:43:00ahu Exp $19 // $Id: receiver.cc,v 1.7 2003/03/04 18:33:39 ahu Exp $ 20 20 #include <cstdio> 21 21 #include <signal.h> … … 541 541 DLOG(L<<Logger::Warning<<"Verbose logging in effect"<<endl); 542 542 543 L<<Logger::Warning<<"PowerDNS "<<VERSION<<" (C) 200 2PowerDNS.COM BV ("<<__DATE__", "__TIME__<<") starting up"<<endl;543 L<<Logger::Warning<<"PowerDNS "<<VERSION<<" (C) 2001-2003 PowerDNS.COM BV ("<<__DATE__", "__TIME__<<") starting up"<<endl; 544 544 545 545 L<<Logger::Warning<<"PowerDNS comes with ABSOLUTELY NO WARRANTY. " -
trunk/pdns/pdns/tcpreceiver.cc
r148 r156 172 172 // now what 173 173 // 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! 174 176 S.inc("recursing-questions"); 175 177 Resolver res;