From caa6eefabb1159eb1344a50812ba11ed88c9ca40 Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Fri, 31 Jan 2003 12:42:28 +0000 Subject: [PATCH] working up to 2.9.5 git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@141 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- ChangeLog | 5 + modules/mysqlbackend/OBJECTLIBS | 2 +- pdns/backends/bind/bindlexer.c | 88 +-- pdns/backends/bind/bindlexer.l | 16 +- pdns/backends/bind/bindparser.cc | 22 +- pdns/backends/bind/bindparser.h | 2 +- pdns/backends/bind/bindparser.yy | 32 +- pdns/dnsproxy.cc | 13 +- pdns/docs/pdns.sgml | 115 +++- pdns/lwres.hh | 2 +- pdns/mtasker.hh | 10 +- pdns/pdns_recursor.cc | 39 +- pdns/powerdns.dsw | 37 +- pdns/syncres.cc | 10 +- pdns/utility.hh | 5 +- pdns/win32_logger.cc | 360 ++++++----- pdns/win32_receiver.cc | 1028 +++++++++++++++--------------- pdns/ws.cc | 7 +- 18 files changed, 989 insertions(+), 804 deletions(-) diff --git a/ChangeLog b/ChangeLog index f662b7989..523c1c7da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,11 @@ Changes since 2.9.4: - compression (Mark Bergsma) - SRV records (Ueli Heuer) - updated J root-server IP address in the recursor + - added USR1 forced log output + - changed meaning of 'cache hits -> packets which could be answered + without sending packets out + - added -lz (James H. Cloos Jr) to MySQL + - added name to webserver (Daniel Meyer) Changes since 2.9.3a: feat - make *all* sql in gsqlbackends available for configuration (Martin Klebermass/bert hubert) diff --git a/modules/mysqlbackend/OBJECTLIBS b/modules/mysqlbackend/OBJECTLIBS index 73c143795..175432ca4 100644 --- a/modules/mysqlbackend/OBJECTLIBS +++ b/modules/mysqlbackend/OBJECTLIBS @@ -1 +1 @@ --lmysqlclient +-lmysqlclient -lz diff --git a/pdns/backends/bind/bindlexer.c b/pdns/backends/bind/bindlexer.c index 290c64cfa..f0ce3cd7d 100644 --- a/pdns/backends/bind/bindlexer.c +++ b/pdns/backends/bind/bindlexer.c @@ -1,7 +1,7 @@ /* A lexical scanner generated by flex */ /* Scanner skeleton version: - * $Header: /home/ahu/tmp/cvs2svn/pdns/pdns/backends/bind/bindlexer.c,v 1.3 2002/12/06 09:58:03 ahu Exp $ + * $Header: /home/ahu/tmp/cvs2svn/pdns/pdns/backends/bind/bindlexer.c,v 1.4 2003/01/31 12:42:28 ahu Exp $ */ #define FLEX_SCANNER @@ -456,12 +456,18 @@ char *yytext; #define YYSTYPE char * #ifdef WIN32 -#include "bindparser.tab.cc.h" -#define isatty _isatty -int isatty( int fd ) +#include "bindparser.tab.hh" + +extern "C" { - return _isatty( fd ); + int isatty( int ); + int yywrap() + { + return 1; + } } + + #else #include "bindparser.h" #endif // WIN32 @@ -483,7 +489,7 @@ extern const char *bind_directory; #define quoted 3 #define YY_STACK_USED 1 -#line 487 "lex.yy.c" +#line 493 "lex.yy.c" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -645,11 +651,11 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 36 "bindlexer.l" +#line 42 "bindlexer.l" -#line 653 "lex.yy.c" +#line 659 "lex.yy.c" if ( yy_init ) { @@ -734,42 +740,42 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 39 "bindlexer.l" +#line 45 "bindlexer.l" BEGIN(comment); YY_BREAK case 2: YY_RULE_SETUP -#line 40 "bindlexer.l" +#line 46 "bindlexer.l" /* eat anything that's not a '*' */ YY_BREAK case 3: YY_RULE_SETUP -#line 41 "bindlexer.l" +#line 47 "bindlexer.l" /* eat up '*'s not followed by '/'s */ YY_BREAK case 4: YY_RULE_SETUP -#line 42 "bindlexer.l" +#line 48 "bindlexer.l" ++linenumber; YY_BREAK case 5: YY_RULE_SETUP -#line 43 "bindlexer.l" +#line 49 "bindlexer.l" BEGIN(INITIAL); YY_BREAK case 6: YY_RULE_SETUP -#line 45 "bindlexer.l" +#line 51 "bindlexer.l" BEGIN(incl); YY_BREAK case 7: YY_RULE_SETUP -#line 46 "bindlexer.l" +#line 52 "bindlexer.l" /* eat the whitespace */ YY_BREAK case 8: YY_RULE_SETUP -#line 47 "bindlexer.l" +#line 53 "bindlexer.l" { /* got the include file name */ char filename[1024]; if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) @@ -806,7 +812,7 @@ case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(comment): case YY_STATE_EOF(incl): case YY_STATE_EOF(quoted): -#line 80 "bindlexer.l" +#line 86 "bindlexer.l" { if ( --include_stack_ptr < 0 ) { @@ -828,87 +834,87 @@ case YY_STATE_EOF(quoted): YY_BREAK case 9: YY_RULE_SETUP -#line 102 "bindlexer.l" +#line 108 "bindlexer.l" return ZONETOK; YY_BREAK case 10: YY_RULE_SETUP -#line 104 "bindlexer.l" +#line 110 "bindlexer.l" return FILETOK; YY_BREAK case 11: YY_RULE_SETUP -#line 105 "bindlexer.l" +#line 111 "bindlexer.l" return OPTIONSTOK; YY_BREAK case 12: YY_RULE_SETUP -#line 106 "bindlexer.l" +#line 112 "bindlexer.l" return ACLTOK; YY_BREAK case 13: YY_RULE_SETUP -#line 107 "bindlexer.l" +#line 113 "bindlexer.l" return LOGGINGTOK; YY_BREAK case 14: YY_RULE_SETUP -#line 108 "bindlexer.l" +#line 114 "bindlexer.l" return DIRECTORYTOK; YY_BREAK case 15: YY_RULE_SETUP -#line 109 "bindlexer.l" +#line 115 "bindlexer.l" return MASTERTOK; YY_BREAK case 16: YY_RULE_SETUP -#line 110 "bindlexer.l" +#line 116 "bindlexer.l" return TYPETOK; YY_BREAK case 17: YY_RULE_SETUP -#line 111 "bindlexer.l" +#line 117 "bindlexer.l" yy_push_state(quoted); YY_BREAK case 18: YY_RULE_SETUP -#line 112 "bindlexer.l" +#line 118 "bindlexer.l" yylval=strdup(yytext); return QUOTEDWORD; YY_BREAK case 19: YY_RULE_SETUP -#line 113 "bindlexer.l" +#line 119 "bindlexer.l" yy_pop_state(); YY_BREAK case 20: YY_RULE_SETUP -#line 114 "bindlexer.l" -yylval=strdup(yytext);return WORD; +#line 120 "bindlexer.l" +yylval=strdup(yytext);return AWORD; YY_BREAK case 21: YY_RULE_SETUP -#line 115 "bindlexer.l" +#line 121 "bindlexer.l" return OBRACE; YY_BREAK case 22: YY_RULE_SETUP -#line 116 "bindlexer.l" +#line 122 "bindlexer.l" return EBRACE; YY_BREAK case 23: YY_RULE_SETUP -#line 117 "bindlexer.l" +#line 123 "bindlexer.l" return SEMICOLON; YY_BREAK case 24: YY_RULE_SETUP -#line 118 "bindlexer.l" +#line 124 "bindlexer.l" linenumber++; YY_BREAK case 25: YY_RULE_SETUP -#line 119 "bindlexer.l" +#line 125 "bindlexer.l" ; YY_BREAK case 26: @@ -916,7 +922,7 @@ case 26: yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 120 "bindlexer.l" +#line 126 "bindlexer.l" ; YY_BREAK case 27: @@ -924,22 +930,22 @@ case 27: yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 121 "bindlexer.l" +#line 127 "bindlexer.l" ; YY_BREAK case 28: YY_RULE_SETUP -#line 122 "bindlexer.l" +#line 128 "bindlexer.l" { fprintf(stderr,"Parsing '%s': unable to parse line %d at character '%s'\n",current_filename, linenumber, yytext); exit(1); } YY_BREAK case 29: YY_RULE_SETUP -#line 125 "bindlexer.l" +#line 131 "bindlexer.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 943 "lex.yy.c" +#line 949 "lex.yy.c" case YY_END_OF_BUFFER: { @@ -1827,5 +1833,5 @@ int main() return 0; } #endif -#line 125 "bindlexer.l" +#line 131 "bindlexer.l" diff --git a/pdns/backends/bind/bindlexer.l b/pdns/backends/bind/bindlexer.l index d38f76c31..fe6952aab 100644 --- a/pdns/backends/bind/bindlexer.l +++ b/pdns/backends/bind/bindlexer.l @@ -7,12 +7,18 @@ #define YYSTYPE char * #ifdef WIN32 -#include "bindparser.tab.cc.h" -#define isatty _isatty -int isatty( int fd ) +#include "bindparser.tab.hh" + +extern "C" { - return _isatty( fd ); + int isatty( int ); + int yywrap() + { + return 1; + } } + + #else #include "bindparser.h" #endif // WIN32 @@ -111,7 +117,7 @@ type return TYPETOK; \" yy_push_state(quoted); [^\"]* yylval=strdup(yytext); return QUOTEDWORD; \" yy_pop_state(); -[^\" \t\n{};]* yylval=strdup(yytext);return WORD; +[^\" \t\n{};]* yylval=strdup(yytext);return AWORD; \{ return OBRACE; \} return EBRACE; ; return SEMICOLON; diff --git a/pdns/backends/bind/bindparser.cc b/pdns/backends/bind/bindparser.cc index 5764a854f..f3b276024 100644 --- a/pdns/backends/bind/bindparser.cc +++ b/pdns/backends/bind/bindparser.cc @@ -3,7 +3,7 @@ #define YYBISON 1 /* Identify Bison output. */ -# define WORD 257 +# define AWORD 257 # define QUOTEDWORD 258 # define OBRACE 259 # define EBRACE 260 @@ -19,11 +19,8 @@ # define MASTERTOK 270 #line 1 "bindparser.yy" - - -#define DIRTY_HACK WORD -#undef WORD - + + #include #include #include @@ -37,22 +34,25 @@ using namespace std; #define YYDEBUG 1 extern int yydebug; #include "bindparser.hh" - -#define WORD DIRTY_HACK #define YYSTYPE char * + +#ifndef WIN32 extern "C" { +#endif // WIN32 int yyparse(void); int yylex(void); + void yyrestart(FILE *); int yywrap() { return 1; } - void yyrestart(FILE *); - +#ifndef WIN32 } +#endif // WIN32 + extern int yydebug; const char *bind_directory; @@ -215,7 +215,7 @@ static const short yyrline[] = /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ static const char *const yytname[] = { - "$", "error", "$undefined.", "WORD", "QUOTEDWORD", "OBRACE", "EBRACE", + "$", "error", "$undefined.", "AWORD", "QUOTEDWORD", "OBRACE", "EBRACE", "SEMICOLON", "ZONETOK", "FILETOK", "OPTIONSTOK", "DIRECTORYTOK", "ACLTOK", "LOGGINGTOK", "CLASSTOK", "TYPETOK", "MASTERTOK", "root_commands", "root_command", "commands", "command", "zone_command", diff --git a/pdns/backends/bind/bindparser.h b/pdns/backends/bind/bindparser.h index b0336baf0..50ad9d810 100644 --- a/pdns/backends/bind/bindparser.h +++ b/pdns/backends/bind/bindparser.h @@ -5,7 +5,7 @@ # define YYSTYPE int # define YYSTYPE_IS_TRIVIAL 1 # endif -# define WORD 257 +# define AWORD 257 # define QUOTEDWORD 258 # define OBRACE 259 # define EBRACE 260 diff --git a/pdns/backends/bind/bindparser.yy b/pdns/backends/bind/bindparser.yy index d17a35838..9ea04b8fc 100644 --- a/pdns/backends/bind/bindparser.yy +++ b/pdns/backends/bind/bindparser.yy @@ -1,8 +1,5 @@ -%{ - -#define DIRTY_HACK WORD -#undef WORD - +%{ + #include #include #include @@ -16,22 +13,25 @@ using namespace std; #define YYDEBUG 1 extern int yydebug; #include "bindparser.hh" - -#define WORD DIRTY_HACK #define YYSTYPE char * + +#ifndef WIN32 extern "C" { +#endif // WIN32 int yyparse(void); int yylex(void); + void yyrestart(FILE *); int yywrap() { return 1; } - void yyrestart(FILE *); - +#ifndef WIN32 } +#endif // WIN32 + extern int yydebug; const char *bind_directory; @@ -100,7 +100,7 @@ void BindParser::commit(BindDomainInfo DI) %} -%token WORD QUOTEDWORD OBRACE EBRACE SEMICOLON ZONETOK FILETOK OPTIONSTOK +%token AWORD QUOTEDWORD OBRACE EBRACE SEMICOLON ZONETOK FILETOK OPTIONSTOK %token DIRECTORYTOK ACLTOK LOGGINGTOK CLASSTOK TYPETOK MASTERTOK %% @@ -130,7 +130,7 @@ zone_command: s_di.clear(); } | - ZONETOK quotedname WORD zone_block + ZONETOK quotedname AWORD zone_block { s_di.name=$2; parent->commit(s_di); @@ -158,7 +158,7 @@ acls: ; acl: - WORD + AWORD ; options_commands: @@ -181,7 +181,7 @@ terms: /* empty */ terms term ; -term: WORD | block | quotedname +term: AWORD | block | quotedname ; block: OBRACE commands EBRACE @@ -207,7 +207,7 @@ masters: /* empty */ masters master SEMICOLON ; -master: WORD +master: AWORD { s_di.master=$1; } @@ -222,7 +222,7 @@ zone_file_command: ; zone_type_command: -TYPETOK WORD +TYPETOK AWORD { s_di.type=$2; } @@ -236,5 +236,5 @@ quotedname: } ; -filename: WORD +filename: AWORD ; \ No newline at end of file diff --git a/pdns/dnsproxy.cc b/pdns/dnsproxy.cc index 74a6f03b0..3366374da 100644 --- a/pdns/dnsproxy.cc +++ b/pdns/dnsproxy.cc @@ -168,20 +168,23 @@ void DNSProxy::mainloop(void) } (*d_resanswers)++; (*d_udpanswers)++; - DNSPacket::dnsheader *d=reinterpret_cast(buffer); + DNSPacket::dnsheader d; + memcpy(&d,buffer,sizeof(d)); { Lock l(&d_lock); - map_t::iterator i=d_conntrack.find(d->id^d_xor); + map_t::iterator i=d_conntrack.find(d.id^d_xor); if(i==d_conntrack.end()) { - L<id^d_xor)<< + L<id^d_xor)<<" which is a duplicate"<id=i->second.id; + d.id=i->second.id; + memcpy(buffer,&d,sizeof(d)); // commit spoofed id + sendto(i->second.outsock,buffer,len,0,(struct sockaddr*)&i->second.remote,i->second.addrlen); DNSPacket p,q; diff --git a/pdns/docs/pdns.sgml b/pdns/docs/pdns.sgml index 827be45d7..09e75ad31 100644 --- a/pdns/docs/pdns.sgml +++ b/pdns/docs/pdns.sgml @@ -11,7 +11,7 @@ - v2.1 $Date: 2003/01/23 15:34:53 $ + v2.1 $Date: 2003/01/31 12:42:28 $ @@ -5739,7 +5739,110 @@ while(<>) - This is the driver that corresponds to the set of XML-RPC tools available from PowerDNS. For database schemas, see there. + This is the driver that corresponds to the set of XML-RPC tools available from PowerDNS. + + + The schema: + +CREATE TABLE MailForwards ( + Id int(10) unsigned NOT NULL auto_increment, + ZoneId int(10) unsigned NOT NULL default '0', + Name varchar(255) NOT NULL default '', + Destination varchar(255) NOT NULL default '', + Flags int(11) NOT NULL default '0', + ChangeDate timestamp(14) NOT NULL, + CreateDate timestamp(14) NOT NULL, + Active tinyint(4) NOT NULL default '0', + PRIMARY KEY (Id), + KEY NameIndex (Name), + KEY ZoneIdIndex (ZoneId) +); + +-- +-- Table structure for table 'Mailboxes' +-- + +CREATE TABLE Mailboxes ( + Id int(10) unsigned NOT NULL auto_increment, + ZoneId int(10) unsigned NOT NULL default '0', + Name varchar(255) NOT NULL default '', + Password varchar(255) NOT NULL default '', + Quota int(10) unsigned NOT NULL default '0', + Flags int(11) NOT NULL default '0', + ChangeDate timestamp(14) NOT NULL, + CreateDate timestamp(14) NOT NULL, + Active tinyint(4) NOT NULL default '0', + PRIMARY KEY (Id), + UNIQUE KEY Name (Name), + KEY ZoneIdIndex (ZoneId), + KEY NameIndex (Name) +); + +-- +-- Table structure for table 'Records' +-- + +CREATE TABLE Records ( + Id int(10) unsigned NOT NULL auto_increment, + ZoneId int(10) unsigned NOT NULL default '0', + Name varchar(255) NOT NULL default '', + Type varchar(8) NOT NULL default '', + Content varchar(255) NOT NULL default '', + TimeToLive int(11) NOT NULL default '60', + Priority int(11) NOT NULL default '0', + Flags int(11) NOT NULL default '0', + ChangeDate timestamp(14) NOT NULL, + CreateDate timestamp(14) NOT NULL, + Active tinyint(4) NOT NULL default '0', + PRIMARY KEY (Id), + KEY NameIndex (Name) +); + +-- +-- Table structure for table 'WebForwards' +-- + +CREATE TABLE WebForwards ( + Id int(10) unsigned NOT NULL auto_increment, + ZoneId int(10) unsigned NOT NULL default '0', + Name varchar(255) NOT NULL default '', + Destination varchar(255) NOT NULL default '', + Type varchar(7) NOT NULL default 'NORMAL', + Title varchar(255) NOT NULL default '', + Description varchar(255) NOT NULL default '', + Keywords varchar(255) NOT NULL default '', + FavIcon varchar(255) NOT NULL default '', + Flags int(11) NOT NULL default '0', + ChangeDate timestamp(14) NOT NULL, + CreateDate timestamp(14) NOT NULL, + Active tinyint(4) NOT NULL default '0', + PRIMARY KEY (Id), + KEY NameIndex (Name), + KEY ZoneIdIndex (ZoneId) +); + +-- +-- Table structure for table 'Zones' +-- + +CREATE TABLE Zones ( + Id int(10) unsigned NOT NULL auto_increment, + Name varchar(255) NOT NULL default '', + Hostmaster varchar(255) NOT NULL default '', + Serial int(10) unsigned NOT NULL default '0', + AutoSerial tinyint(4) NOT NULL default '0', + Flags int(11) NOT NULL default '0', + ChangeDate timestamp(14) NOT NULL, + CreateDate timestamp(14) NOT NULL, + Active tinyint(4) NOT NULL default '0', + TimeToLive int(11) NOT NULL default '0', + OwnerId varchar(255) NOT NULL default '', + PRIMARY KEY (Id), + UNIQUE KEY Name (Name), + KEY NameIndex (Name) +); + + It takes a number of parameters: @@ -5892,7 +5995,7 @@ GRANT ALL ON records TO pdns; PostgresSQL specifics - The default setup conforms to the following schema: + The default setup conforms to the following schema, which you should add to a PostgreSQL database. create table domains ( id SERIAL PRIMARY KEY, @@ -5942,7 +6045,11 @@ GRANT ALL ON records_id_seq TO pdns; Zone2sql with the --gpgsql flag also assumes this layout is in place. - + + + With PostgreSQL, you may have to run 'createdb powerdns' first and then connect to that database with 'psql powerdns', and + feed it the schema above. + Basic functionality diff --git a/pdns/lwres.hh b/pdns/lwres.hh index 7e036b88a..bd0f1736c 100644 --- a/pdns/lwres.hh +++ b/pdns/lwres.hh @@ -43,7 +43,7 @@ using namespace std; int asendto(const char *data, int len, int flags, struct sockaddr *toaddr, int addrlen, int id); -int arecvfrom(char *data, int len, int flags, struct sockaddr *toaddr, socklen_t *addrlen, int *d_len, int id); +int arecvfrom(char *data, int len, int flags, struct sockaddr *toaddr, Utility::socklen_t *addrlen, int *d_len, int id); class LWResException : public AhuException { diff --git a/pdns/mtasker.hh b/pdns/mtasker.hh index 33212b040..6e29b07f1 100644 --- a/pdns/mtasker.hh +++ b/pdns/mtasker.hh @@ -18,6 +18,11 @@ */ #ifndef MTASKER_HH #define MTASKER_HH + +#ifdef WIN32 +# include "win32_mtasker.hh" +#else + #include #include #include @@ -79,4 +84,7 @@ private: static void threadWrapper(MTasker *self, tfunc_t *tf, int tid, void* val); }; #include "mtasker.cc" -#endif + +#endif // WIN32 +#endif // MTASKER_HH + diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 5402a6001..5b63154d2 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -16,12 +16,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - + +#include "utility.hh" #include #include #include #include +#ifndef WIN32 #include +#endif // WIN32 #include #include #include @@ -33,6 +36,7 @@ #include "arguments.hh" #include "syncres.hh" +#ifndef WIN32 extern "C" { int sem_init(sem_t*, int, unsigned int){return 0;} int sem_wait(sem_t*){return 0;} @@ -40,6 +44,7 @@ extern "C" { int sem_post(sem_t*){return 0;} int sem_getvalue(sem_t*, int*){return 0;} } +#endif // WIN32 StatBag S; ArgvMap &arg() @@ -80,7 +85,7 @@ int asendto(const char *data, int len, int flags, struct sockaddr *toaddr, int a return sendto(d_clientsock, data, len, flags, toaddr, addrlen); } -int arecvfrom(char *data, int len, int flags, struct sockaddr *toaddr, socklen_t *addrlen, int *d_len, int id) +int arecvfrom(char *data, int len, int flags, struct sockaddr *toaddr, Utility::socklen_t *addrlen, int *d_len, int id) { PacketID pident; pident.id=id; @@ -120,10 +125,6 @@ void replaceCache(const string &qname, const QType& qt, const set= 0) @@ -253,6 +254,8 @@ void makeServerSocket() throw AhuException("Resolver binding to server socket: "+stringerror()); L< +Project: "installer"=".\installer.dsp" - Package Owner=<4> Package=<5> {{{ @@ -15,16 +15,19 @@ Package=<4> Project_Dep_Name pdns End Project Dependency Begin Project Dependency - Project_Dep_Name pdnsmsg + Project_Dep_Name zone2sql End Project Dependency Begin Project Dependency - Project_Dep_Name zone2sql + Project_Dep_Name pdns_recursor + End Project Dependency + Begin Project Dependency + Project_Dep_Name pdns_control End Project Dependency }}} ############################################################################### -Project: "odbcbackend"=.\odbcbackend.dsp - Package Owner=<4> +Project: "odbcbackend"=".\odbcbackend.dsp" - Package Owner=<4> Package=<5> {{{ @@ -36,7 +39,7 @@ Package=<4> ############################################################################### -Project: "pdns"=.\pdns.dsp - Package Owner=<4> +Project: "pdns"=".\pdns.dsp" - Package Owner=<4> Package=<5> {{{ @@ -54,7 +57,19 @@ Package=<4> ############################################################################### -Project: "pdnscontrol"=.\pdnscontrol.dsp - Package Owner=<4> +Project: "pdns_control"=".\pdns_control.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "pdns_recursor"=".\pdns_recursor.dsp" - Package Owner=<4> Package=<5> {{{ @@ -62,11 +77,14 @@ Package=<5> Package=<4> {{{ + Begin Project Dependency + Project_Dep_Name pdnsmsg + End Project Dependency }}} ############################################################################### -Project: "pdnsmsg"=.\pdnsmsg.dsp - Package Owner=<4> +Project: "pdnsmsg"=".\pdnsmsg.dsp" - Package Owner=<4> Package=<5> {{{ @@ -78,7 +96,7 @@ Package=<4> ############################################################################### -Project: "zone2sql"=.\zone2sql.dsp - Package Owner=<4> +Project: "zone2sql"=".\zone2sql.dsp" - Package Owner=<4> Package=<5> {{{ @@ -86,6 +104,9 @@ Package=<5> Package=<4> {{{ + Begin Project Dependency + Project_Dep_Name pdnsmsg + End Project Dependency }}} ############################################################################### diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 14ca50779..d6b8a569d 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -16,6 +16,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "utility.hh" #include "syncres.hh" #include #include @@ -380,15 +382,15 @@ int SyncRes::doResolveAt(set nameservers, string auth, const string &qna LOG<beenthere2; return doResolve(newtarget, qtype, ret,0,beenthere2); } + if(nsset.empty() && !d_lwr.d_rcode) { + LOG< # include @@ -60,9 +61,7 @@ typedef unsigned int u_int32_t; # define ETIMEDOUT WSAETIMEDOUT # define EINPROGRESS WSAEWOULDBLOCK -# define AF_INET6 -1 - -# define VERSION "2.9.2-WIN32" +# define VERSION "2.9.5-WIN32" # define snprintf _snprintf diff --git a/pdns/win32_logger.cc b/pdns/win32_logger.cc index 47218c8c7..f100fe45d 100644 --- a/pdns/win32_logger.cc +++ b/pdns/win32_logger.cc @@ -16,184 +16,190 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include "utility.hh" -#include "pdnsservice.hh" -#include "logger.hh" -#include "statbag.hh" -#include "pdnsmsg.hh" - -using namespace std; - -Logger &theL(const string &pname) -{ - static Logger l(""); - if(!pname.empty()) - l.setName(pname); - return l; -} - -void Logger::log(const string &msg, Urgency u) -{ + +#include "utility.hh" +#include "pdnsservice.hh" +#include "logger.hh" +#include "statbag.hh" +#include "pdnsmsg.hh" + +using namespace std; + +Logger &theL(const string &pname) +{ + static Logger l(""); + if(!pname.empty()) + l.setName(pname); + return l; +} + +void Logger::log(const string &msg, Urgency u) +{ const char *tmp[ 2 ]; - + tmp[ 0 ] = msg.c_str(); tmp[ 1 ] = NULL; - - extern StatBag S; - S.ringAccount("logmessages",msg); - - if ( m_pLogFile != NULL ) - { - char timestr[ 128 ]; - time_t curtime; - ostringstream message; - - curtime = time( NULL ); - strftime( timestr, sizeof( timestr ), "%a %d %b %X", localtime( &curtime )); - - message << timestr << " (" << u << "): " << msg << endl; - fwrite( message.str().c_str(), sizeof( char ), message.str().length(), m_pLogFile ); - fflush( m_pLogFile ); - } - - if ( PDNSService::instance()) - { - if ( !PDNSService::instance()->isRunningAsService() && u <= consoleUrgency ) - { - clog << msg << endl; - return; - } - } - - if ( !opened ) - return; - - if ( m_eventLogHandle == NULL ) - return; - - // Only log relevant messages. - //if ( m_toNTLog.find( pthread_self()) == m_toNTLog.end()) - // return; - - if ( m_toNTLog[ pthread_self() ] == false ) - return; - - //if ( u == EVENTLOG_INFORMATION_TYPE ) - // return; // Don't spam the NT log. - - DWORD eventId; - switch ( u ) - { - case EVENTLOG_ERROR_TYPE: - eventId = MSG_ERROR; - break; - - case EVENTLOG_WARNING_TYPE: - eventId = MSG_WARNING; - break; - - default: - eventId = MSG_INFO; - } - + + extern StatBag S; + S.ringAccount("logmessages",msg); + + if ( m_pLogFile != NULL ) + { + char timestr[ 128 ]; + time_t curtime; + ostringstream message; + + curtime = time( NULL ); + strftime( timestr, sizeof( timestr ), "%a %d %b %X", localtime( &curtime )); + + message << timestr << " (" << u << "): " << msg << endl; + fwrite( message.str().c_str(), sizeof( char ), message.str().length(), m_pLogFile ); + fflush( m_pLogFile ); + } + + if ( PDNSService::instance()) + { + if ( !PDNSService::instance()->isRunningAsService() && u <= consoleUrgency ) + { + clog << msg << endl; + return; + } + } + + if ( !PDNSService::instance()) + { + clog << msg << endl; + return; + } + + if ( !opened ) + return; + + if ( m_eventLogHandle == NULL ) + return; + + // Only log relevant messages. + //if ( m_toNTLog.find( pthread_self()) == m_toNTLog.end()) + // return; + + if ( m_toNTLog[ pthread_self() ] == false ) + return; + + //if ( u == EVENTLOG_INFORMATION_TYPE ) + // return; // Don't spam the NT log. + + DWORD eventId; + switch ( u ) + { + case EVENTLOG_ERROR_TYPE: + eventId = MSG_ERROR; + break; + + case EVENTLOG_WARNING_TYPE: + eventId = MSG_WARNING; + break; + + default: + eventId = MSG_INFO; + } + ReportEvent( m_eventLogHandle, u, 0, eventId, NULL, 1, 0, tmp, NULL ); -} - -void Logger::toConsole(Urgency u) -{ - - consoleUrgency=u; -} - - -void Logger::toFile( const string & filename ) -{ - m_pLogFile = fopen( filename.c_str(), "at" ); -} - - -void Logger::toNTLog( void ) -{ - m_eventLogHandle = RegisterEventSource( NULL, NTService::instance()->getServiceName().c_str()); -} - -void Logger::open() -{ - opened=true; -} - -void Logger::setName(const string &_name) -{ - name=_name; - open(); -} - -Logger::Logger(const string &n, int facility) -{ - opened=false; - flags=0; - d_facility=facility; - consoleUrgency=Error; - name=n; - m_pLogFile = NULL; - m_eventLogHandle = NULL; - pthread_mutex_init(&lock,0); - open(); -} - -Logger& Logger::operator<<(Urgency u) -{ - pthread_mutex_lock(&lock); - - if ( u == NTLog ) - m_toNTLog[ pthread_self() ] = true; - else - d_outputurgencies[pthread_self()]=u; - - pthread_mutex_unlock(&lock); - return *this; -} - -Logger& Logger::operator<<(const string &s) -{ - pthread_mutex_lock(&lock); - - if(!d_outputurgencies.count(pthread_self())) // default urgency - d_outputurgencies[pthread_self()]=Info; - - if ( !m_toNTLog.count( pthread_self())) - m_toNTLog[ pthread_self() ] = false; - - // if(d_outputurgencies[pthread_self()]<=(unsigned int)consoleUrgency) // prevent building strings we won't ever print - d_strings[pthread_self()].append(s); - - pthread_mutex_unlock(&lock); - return *this; -} - -Logger& Logger::operator<<(int i) -{ - ostringstream tmp; - tmp<getServiceName().c_str()); +} + +void Logger::open() +{ + opened=true; +} + +void Logger::setName(const string &_name) +{ + name=_name; + open(); +} + +Logger::Logger(const string &n, int facility) +{ + opened=false; + flags=0; + d_facility=facility; + consoleUrgency=Error; + name=n; + m_pLogFile = NULL; + m_eventLogHandle = NULL; + pthread_mutex_init(&lock,0); + open(); +} + +Logger& Logger::operator<<(Urgency u) +{ + pthread_mutex_lock(&lock); + + if ( u == NTLog ) + m_toNTLog[ pthread_self() ] = true; + else + d_outputurgencies[pthread_self()]=u; + + pthread_mutex_unlock(&lock); + return *this; +} + +Logger& Logger::operator<<(const string &s) +{ + pthread_mutex_lock(&lock); + + if(!d_outputurgencies.count(pthread_self())) // default urgency + d_outputurgencies[pthread_self()]=Info; + + if ( !m_toNTLog.count( pthread_self())) + m_toNTLog[ pthread_self() ] = false; + + // if(d_outputurgencies[pthread_self()]<=(unsigned int)consoleUrgency) // prevent building strings we won't ever print + d_strings[pthread_self()].append(s); + + pthread_mutex_unlock(&lock); + return *this; +} + +Logger& Logger::operator<<(int i) +{ + ostringstream tmp; + tmp< -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "dns.hh" -#include "dnsbackend.hh" -#include "ueberbackend.hh" -#include "dnspacket.hh" -#include "nameserver.hh" -#include "distributor.hh" -#include "logger.hh" -#include "arguments.hh" -#include "packethandler.hh" -#include "statbag.hh" -#include "tcpreceiver.hh" -#include "packetcache.hh" -#include "ws.hh" -#include "misc.hh" -#include "dynlistener.hh" -#include "dynhandler.hh" -#include "communicator.hh" -#include "dnsproxy.hh" -#include "pdnsservice.hh" -#include "common_startup.hh" - -time_t s_starttime; - -string s_programname="pdns"; // used in packethandler.cc - -char *funnytext= -"*****************************************************************************\n"\ -"Ok, you just ran pdns_server through 'strings' hoping to find funny messages.\n"\ -"Well, you found one. \n"\ -"Two ions are flying through their particle accelerator, says the one to the\n" -"other 'I think I've lost an electron!' \n"\ -"So the other one says, 'Are you sure?'. 'YEAH! I'M POSITIVE!'\n"\ -" the pdns crew - pdns@powerdns.com\n" -"*****************************************************************************\n"; - - -// start (sys)logging - -/** \var Logger L -\brief All logging is done via L, a Logger instance -*/ - - -/** -\file receiver.cc -\brief The main loop of powerdns - -This file is where it all happens - main is here, as are the two pivotal threads qthread() and athread() -*/ - - -void daemonize(void) -{ -} - - -static int cpid; - -static void takedown(int i) -{ - if(cpid) { - L<&parts, Utility::pid_t ppid) -{ - // TODO: Implement this. -#ifndef WIN32 - string line; - - for(vector::const_iterator i=parts.begin();i!=parts.end();++i) { - if(i!=parts.begin()) - line.append(1,' '); - line.append(*i); - } - line.append(1,'\n'); - - write(d_fd1[1],line.c_str(),line.size()+1); - char mesg[512]; - fgets(mesg,511,d_fp); - line=mesg; - chomp(line,"\n"); - return line; - -#else - return ""; - -#endif // WIN32 -} - -static string DLCycleHandler(const vector&parts, pid_t ppid) -{ -#ifndef WIN32 - Utility::Signal::kill(cpid,SIGKILL); -#endif // WIN32 - return "ok"; -} - -static int guardian(int argc, char **argv) -{ - // TODO: Implement this? -#ifdef WIN32 - return 0; - -#else - - if(isGuarded(argv)) - return 0; - - int infd=0, outfd=1; - - DynListener dlg(s_programname); - dlg.registerFunc("QUIT",&DLQuitHandler); - dlg.registerFunc("CYCLE",&DLCycleHandler); - dlg.registerFunc("PING",&DLPingHandler); - dlg.registerFunc("STATUS",&DLStatusHandler); - dlg.registerRestFunc(&DLRestHandler); - dlg.go(); - string progname=argv[0]; - - bool first=true; - cpid=0; - - for(;;) { - int pid; - setStatus("Launching child"); - - if(pipe(d_fd1)<0 || pipe(d_fd2)<0) { - L<((progname+"-instance").c_str())); - for(n=1;n0) { // parent - close(d_fd1[0]); - close(d_fd2[1]); - if(!(d_fp=fdopen(d_fd2[0],"r"))) { - L<modules; - - stringtok(modules,arg()["load-modules"],","); - - for(vector::const_iterator i=modules.begin();i!=modules.end();++i) { - bool res; - const string &module=*i; - - if(module.find(".")==string::npos) - res=UeberBackend::loadmodule(arg()["module-dir"]+"/lib"+module+"backend.so"); - else if(module[0]=='/' || (module[0]=='.' && module[1]=='/') || (module[0]=='.' && module[1]=='.')) // absolute or current path - res=UeberBackend::loadmodule(module); - else - res=UeberBackend::loadmodule(arg()["module-dir"]+"/"+module); - - if(res==false) { - L< +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dns.hh" +#include "dnsbackend.hh" +#include "ueberbackend.hh" +#include "dnspacket.hh" +#include "nameserver.hh" +#include "distributor.hh" +#include "logger.hh" +#include "arguments.hh" +#include "packethandler.hh" +#include "statbag.hh" +#include "tcpreceiver.hh" +#include "packetcache.hh" +#include "ws.hh" +#include "misc.hh" +#include "dynlistener.hh" +#include "dynhandler.hh" +#include "communicator.hh" +#include "dnsproxy.hh" +#include "pdnsservice.hh" +#include "common_startup.hh" + +time_t s_starttime; + +string s_programname="pdns"; // used in packethandler.cc + +char *funnytext= +"*****************************************************************************\n"\ +"Ok, you just ran pdns_server through 'strings' hoping to find funny messages.\n"\ +"Well, you found one. \n"\ +"Two ions are flying through their particle accelerator, says the one to the\n" +"other 'I think I've lost an electron!' \n"\ +"So the other one says, 'Are you sure?'. 'YEAH! I'M POSITIVE!'\n"\ +" the pdns crew - pdns@powerdns.com\n" +"*****************************************************************************\n"; + + +// start (sys)logging + +/** \var Logger L +\brief All logging is done via L, a Logger instance +*/ + + +/** +\file receiver.cc +\brief The main loop of powerdns + +This file is where it all happens - main is here, as are the two pivotal threads qthread() and athread() +*/ + + +void daemonize(void) +{ +} + + +static int cpid; + +static void takedown(int i) +{ + if(cpid) { + L<&parts, Utility::pid_t ppid) +{ + // TODO: Implement this. +#ifndef WIN32 + string line; + + for(vector::const_iterator i=parts.begin();i!=parts.end();++i) { + if(i!=parts.begin()) + line.append(1,' '); + line.append(*i); + } + line.append(1,'\n'); + + write(d_fd1[1],line.c_str(),line.size()+1); + char mesg[512]; + fgets(mesg,511,d_fp); + line=mesg; + chomp(line,"\n"); + return line; + +#else + return ""; + +#endif // WIN32 +} + +static string DLCycleHandler(const vector&parts, pid_t ppid) +{ +#ifndef WIN32 + Utility::Signal::kill(cpid,SIGKILL); +#endif // WIN32 + return "ok"; +} + +static int guardian(int argc, char **argv) +{ + // TODO: Implement this? +#ifdef WIN32 + return 0; + +#else + + if(isGuarded(argv)) + return 0; + + int infd=0, outfd=1; + + DynListener dlg(s_programname); + dlg.registerFunc("QUIT",&DLQuitHandler); + dlg.registerFunc("CYCLE",&DLCycleHandler); + dlg.registerFunc("PING",&DLPingHandler); + dlg.registerFunc("STATUS",&DLStatusHandler); + dlg.registerRestFunc(&DLRestHandler); + dlg.go(); + string progname=argv[0]; + + bool first=true; + cpid=0; + + for(;;) { + int pid; + setStatus("Launching child"); + + if(pipe(d_fd1)<0 || pipe(d_fd2)<0) { + L<((progname+"-instance").c_str())); + for(n=1;n0) { // parent + close(d_fd1[0]); + close(d_fd2[1]); + if(!(d_fp=fdopen(d_fd2[0],"r"))) { + L<modules; + + stringtok(modules,arg()["load-modules"],","); + + for(vector::const_iterator i=modules.begin();i!=modules.end();++i) { + bool res; + const string &module=*i; + + if(module.find(".")==string::npos) + res=UeberBackend::loadmodule(arg()["module-dir"]+"/lib"+module+"backend.so"); + else if(module[0]=='/' || (module[0]=='.' && module[1]=='/') || (module[0]=='.' && module[1]=='.')) // absolute or current path + res=UeberBackend::loadmodule(module); + else + res=UeberBackend::loadmodule(arg()["module-dir"]+"/"+module); + + if(res==false) { + L<modules=BackendMakers().getModules(); - cerr<<"Modules available:"<::const_iterator i=modules.begin();i!=modules.end();++i) - cout<<*i<registerFunc("SHOW",&DLShowHandler); - dl->registerFunc("RPING",&DLPingHandler); - dl->registerFunc("QUIT",&DLRQuitHandler); - dl->registerFunc("UPTIME",&DLUptimeHandler); - dl->registerFunc("NOTIFY-HOST",&DLNotifyHostHandler); - dl->registerFunc("NOTIFY",&DLNotifyHandler); - dl->registerFunc("RELOAD",&DLReloadHandler); - dl->registerFunc("REDISCOVER",&DLRediscoverHandler); - dl->registerFunc("VERSION",&DLVersionHandler); - - - // reparse, with error checking - if(!arg().mustDo("no-config")) - arg().file(configname.c_str()); - arg().parse(argc,argv); - UeberBackend::go(); - N=new UDPNameserver; // this fails when we are not root, throws exception - - if(!arg().mustDo("disable-tcp")) - TN=new TCPNameserver; - } - catch(const ArgException &A) { - L<modules=BackendMakers().getModules(); + cerr<<"Modules available:"<::const_iterator i=modules.begin();i!=modules.end();++i) + cout<<*i<registerFunc("SHOW",&DLShowHandler); + dl->registerFunc("RPING",&DLPingHandler); + dl->registerFunc("QUIT",&DLRQuitHandler); + dl->registerFunc("UPTIME",&DLUptimeHandler); + dl->registerFunc("NOTIFY-HOST",&DLNotifyHostHandler); + dl->registerFunc("NOTIFY",&DLNotifyHandler); + dl->registerFunc("RELOAD",&DLReloadHandler); + dl->registerFunc("REDISCOVER",&DLRediscoverHandler); + dl->registerFunc("VERSION",&DLVersionHandler); + dl->registerFunc("PURGE",&DLPurgeHandler); + dl->registerFunc("CCOUNTS",&DLCCHandler); + dl->registerFunc("SET",&DLSettingsHandler); + dl->registerFunc("RETRIEVE",&DLNotifyRetrieveHandler); + + + // reparse, with error checking + if(!arg().mustDo("no-config")) + arg().file(configname.c_str()); + arg().parse(argc,argv); + UeberBackend::go(); + N=new UDPNameserver; // this fails when we are not root, throws exception + + if(!arg().mustDo("disable-tcp")) + TN=new TCPNameserver; + } + catch(const ArgException &A) { + L<start( argc, argv, arg().mustDo( "ntservice" )); - - exit(1); - - return 1; -} - - - + + // Register console control hander. + if ( !arg().mustDo( "ntservice" )) + SetConsoleCtrlHandler( consoleHandler, true ); + + PDNSService::instance()->start( argc, argv, arg().mustDo( "ntservice" )); + + exit(1); + + return 1; +} + + + diff --git a/pdns/ws.cc b/pdns/ws.cc index 4fef8ee93..458a318eb 100644 --- a/pdns/ws.cc +++ b/pdns/ws.cc @@ -159,10 +159,13 @@ string StatWebServer::indexfunction(const map &varmap, void *ptr, ret<<"PowerDNS Operational Monitor"<"; + if(!arg()["config-name"].empty()) + ret<<"["<PDNS "VERSION" Main Page"<"<Details pageBack to main page

"<Back to main page

"<