Blame
Date:
Mon Jan 11 09:00:47 2021 UTC
Message:
a usleep makes it unnecessary slow, I guess it forces a context switch...
0001
2014-11-14
pjp
/*
0002
2021-01-07
pjp
* Copyright (c) 2014-2021 Peter J. Philipp. All rights reserved.
0003
2014-11-14
pjp
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
0004
2014-11-14
pjp
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
0005
2014-11-14
pjp
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
0006
2014-11-14
pjp
* Copyright (c) 2001 Markus Friedl. All rights reserved.
0007
2014-11-14
pjp
* Copyright (c) 2001 Daniel Hartmeier. All rights reserved.
0008
2014-11-14
pjp
* Copyright (c) 2001 Theo de Raadt. All rights reserved.
0009
2014-11-14
pjp
*
0010
2014-11-14
pjp
* Permission to use, copy, modify, and distribute this software for any
0011
2014-11-14
pjp
* purpose with or without fee is hereby granted, provided that the above
0012
2014-11-14
pjp
* copyright notice and this permission notice appear in all copies.
0013
2014-11-14
pjp
*
0014
2014-11-14
pjp
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0015
2014-11-14
pjp
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0016
2014-11-14
pjp
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0017
2014-11-14
pjp
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0018
2014-11-14
pjp
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0019
2014-11-14
pjp
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0020
2014-11-14
pjp
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0021
2014-11-14
pjp
*/
0022
2014-11-14
pjp
0023
2014-11-14
pjp
%{
0024
2019-06-06
pjp
#include <sys/types.h>
0025
2019-06-06
pjp
#include <sys/socket.h>
0026
2019-06-06
pjp
#include <sys/time.h>
0027
2019-06-06
pjp
#include <sys/stat.h>
0028
2019-11-06
pjp
#include <sys/wait.h>
0029
2019-06-06
pjp
0030
2019-06-06
pjp
#include <netinet/in.h>
0031
2019-06-06
pjp
#include <arpa/inet.h>
0032
2019-06-06
pjp
#include <netdb.h>
0033
2019-06-06
pjp
0034
2019-06-06
pjp
#include <stdio.h>
0035
2019-06-06
pjp
#include <stdlib.h>
0036
2019-06-06
pjp
#include <stdint.h>
0037
2019-06-06
pjp
#include <stdarg.h>
0038
2019-06-06
pjp
#include <string.h>
0039
2019-06-06
pjp
#include <unistd.h>
0040
2019-06-06
pjp
#include <fcntl.h>
0041
2019-06-06
pjp
#include <errno.h>
0042
2019-06-06
pjp
#include <syslog.h>
0043
2019-06-06
pjp
#include <ctype.h>
0044
2019-06-06
pjp
#include <signal.h>
0045
2019-06-06
pjp
#include <time.h>
0046
2019-11-03
pjp
#include <pwd.h>
0047
2019-06-06
pjp
0048
2019-06-06
pjp
#ifdef __linux__
0049
2019-06-06
pjp
#include <grp.h>
0050
2019-06-06
pjp
#define __USE_BSD 1
0051
2019-06-06
pjp
#include <endian.h>
0052
2019-06-06
pjp
#include <bsd/stdlib.h>
0053
2019-06-06
pjp
#include <bsd/string.h>
0054
2019-06-06
pjp
#include <bsd/unistd.h>
0055
2019-06-06
pjp
#include <bsd/sys/queue.h>
0056
2019-06-06
pjp
#define __unused
0057
2019-06-06
pjp
#include <bsd/sys/tree.h>
0058
2019-06-06
pjp
#include <bsd/sys/endian.h>
0059
2019-06-06
pjp
#else /* not linux */
0060
2019-06-06
pjp
#include <sys/queue.h>
0061
2019-06-06
pjp
#include <sys/tree.h>
0062
2019-06-06
pjp
#endif /* __linux__ */
0063
2019-06-06
pjp
0064
2019-06-06
pjp
0065
2016-07-06
pjp
#include "ddd-dns.h"
0066
2016-07-06
pjp
#include "ddd-db.h"
0067
2016-07-06
pjp
0068
2019-02-15
pjp
void yyerror(const char *);
0069
2019-02-15
pjp
int yylex(void);
0070
2016-07-06
pjp
0071
2019-12-03
pjp
extern void pack(char *, char *, int);
0072
2019-12-03
pjp
extern void pack32(char *, u_int32_t);
0073
2019-12-03
pjp
extern void pack16(char *, u_int16_t);
0074
2019-12-03
pjp
extern void pack8(char *, u_int8_t);
0075
2019-12-03
pjp
extern uint32_t unpack32(char *);
0076
2019-12-03
pjp
extern uint16_t unpack16(char *);
0077
2019-12-03
pjp
extern void unpack(char *, char *, int);
0078
2019-12-03
pjp
0079
2019-10-25
pjp
extern int memcasecmp(u_char *, u_char *, int);
0080
2019-02-07
pjp
extern struct rrtab *rrlookup(char *);
0081
2015-11-17
pjp
extern int base32hex_decode(u_char *, u_char *);
0082
2014-11-14
pjp
extern void dolog(int, char *, ...);
0083
2014-11-14
pjp
extern char *dns_label(char *, int *);
0084
2014-11-14
pjp
extern u_int8_t find_region(struct sockaddr_storage *, int);
0085
2015-09-14
pjp
extern int insert_apex(char *, char *, int);
0086
2015-09-14
pjp
extern int insert_nsec3(char *, char *, char *, int);
0087
2014-11-14
pjp
extern int insert_region(char *, char *, u_int8_t);
0088
2014-11-14
pjp
extern int insert_axfr(char *, char *);
0089
2020-06-25
pjp
extern int insert_notifyddd(char *, char *);
0090
2014-11-14
pjp
extern int insert_filter(char *, char *);
0091
2020-07-03
pjp
extern int insert_forward(int, struct sockaddr_storage *, uint16_t, char *);
0092
2020-07-16
pjp
extern int insert_passlist(char *, char *);
0093
2021-01-07
pjp
extern int insert_tsigpassname(char *);
0094
2019-02-24
pjp
extern int insert_tsig(char *, char *);
0095
2019-02-24
pjp
extern int insert_tsig_key(char *, int, char *, int);
0096
2020-08-26
pjp
extern int insert_zone(char *);
0097
2020-06-25
pjp
extern void ddd_shutdown(void);
0098
2014-11-21
pjp
extern int mybase64_encode(u_char const *, size_t, char *, size_t);
0099
2014-11-21
pjp
extern int mybase64_decode(char const *, u_char *, size_t);
0100
2020-07-15
pjp
extern struct rbtree * create_rr(ddDB *, char *, int, int, void *, uint32_t, uint16_t);
0101
2019-02-15
pjp
extern struct rbtree * find_rrset(ddDB *db, char *name, int len);
0102
2019-02-15
pjp
extern struct rrset * find_rr(struct rbtree *rbt, u_int16_t rrtype);
0103
2019-02-15
pjp
extern int display_rr(struct rrset *rrset);
0104
2021-01-08
pjp
extern void flag_rr(struct rbtree *, uint32_t);
0105
2019-11-19
pjp
extern int pull_rzone(struct rzone *, time_t);
0106
2014-11-14
pjp
0107
2021-01-07
pjp
extern int tsigpassname;
0108
2020-07-16
pjp
extern int passlist;
0109
2019-02-24
pjp
extern int tsig;
0110
2014-11-14
pjp
extern int notify;
0111
2014-11-14
pjp
extern int errno;
0112
2014-11-14
pjp
extern int debug;
0113
2020-06-30
pjp
extern int forward;
0114
2020-07-01
pjp
extern int forwardtsig;
0115
2020-07-17
pjp
extern int strictx20i;
0116
2020-07-06
pjp
extern int cache;
0117
2020-07-03
pjp
extern int zonecount;
0118
2014-11-14
pjp
extern int verbose;
0119
2014-11-14
pjp
extern int bflag;
0120
2014-11-14
pjp
extern int iflag;
0121
2014-11-14
pjp
extern int lflag;
0122
2014-11-14
pjp
extern int nflag;
0123
2014-11-14
pjp
extern int bcount;
0124
2014-11-14
pjp
extern int icount;
0125
2014-11-14
pjp
extern int ratelimit;
0126
2014-11-14
pjp
extern int ratelimit_packets_per_second;
0127
2014-11-14
pjp
extern u_int16_t port;
0128
2014-11-14
pjp
extern u_int32_t cachesize;
0129
2014-11-14
pjp
extern char *bind_list[255];
0130
2014-11-14
pjp
extern char *interface_list[255];
0131
2015-09-05
pjp
extern char *versionstring;
0132
2015-09-05
pjp
extern uint8_t vslen;
0133
2014-11-14
pjp
0134
2014-11-14
pjp
0135
2014-11-14
pjp
0136
2014-11-14
pjp
TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files);
0137
2019-02-04
pjp
TAILQ_HEAD(rzonefiles, file) rzonefiles = TAILQ_HEAD_INITIALIZER(rzonefiles);
0138
2019-02-04
pjp
0139
2014-11-14
pjp
static struct file {
0140
2019-02-04
pjp
TAILQ_ENTRY(file) file_entry;
0141
2014-11-14
pjp
FILE *stream;
0142
2014-11-14
pjp
char *name;
0143
2019-02-04
pjp
int lineno;
0144
2019-02-04
pjp
int errors;
0145
2018-07-11
pjp
int descend;
0146
2018-07-11
pjp
#define DESCEND_NO 0
0147
2018-07-11
pjp
#define DESCEND_YES 1
0148
2019-02-04
pjp
} *file, *topfile, *rzonefile;
0149
2014-11-14
pjp
0150
2019-02-04
pjp
SLIST_HEAD(rzones, rzone) rzones = SLIST_HEAD_INITIALIZER(rzones);
0151
2019-06-26
pjp
SLIST_HEAD(mzones ,mzone) mzones = SLIST_HEAD_INITIALIZER(mzones);
0152
2019-02-04
pjp
0153
2014-11-14
pjp
#define STATE_IP 1
0154
2014-11-14
pjp
#define STATE_ZONE 2
0155
2014-11-14
pjp
0156
2019-02-04
pjp
#define NO_RZONEFILE 0
0157
2019-02-04
pjp
#define RZONEFILE 1
0158
2014-11-14
pjp
0159
2020-07-15
pjp
#define DELPHINUSVERSION 1
0160
2019-02-04
pjp
0161
2014-11-14
pjp
#define CONFIG_START 0x1
0162
2014-11-14
pjp
#define CONFIG_VERSION 0x2
0163
2014-11-14
pjp
#define CONFIG_REGION 0x4
0164
2014-11-14
pjp
#define CONFIG_ZONE 0x8
0165
2014-11-14
pjp
#define CONFIG_INCLUDE 0x10
0166
2014-11-14
pjp
#define CONFIG_WILDCARDONLYFOR 0x20
0167
2014-11-14
pjp
#define CONFIG_RECURSEFOR 0x40
0168
2019-11-25
pjp
#define CONFIG_LOGGING 0x80 /* deprecated */
0169
2014-11-14
pjp
#define CONFIG_AXFRFOR 0x100
0170
2014-11-14
pjp
#define CONFIG_AXFRPORT 0x200
0171
2018-07-11
pjp
#define CONFIG_ZINCLUDE 0x400
0172
2019-02-04
pjp
#define CONFIG_RZONE 0x800
0173
2014-11-14
pjp
0174
2014-11-14
pjp
typedef struct {
0175
2014-11-14
pjp
union {
0176
2014-11-14
pjp
char *string;
0177
2015-06-20
pjp
int64_t intval;
0178
2014-11-14
pjp
} v;
0179
2014-11-14
pjp
int lineno;
0180
2014-11-14
pjp
} YYSTYPE;
0181
2014-11-14
pjp
0182
2014-11-14
pjp
#ifdef __APPLE__
0183
2014-11-14
pjp
#define YYSTYPE_IS_DECLARED 1
0184
2014-11-14
pjp
#endif
0185
2014-11-14
pjp
0186
2014-11-14
pjp
static int version = 0;
0187
2014-11-14
pjp
static int state = 0;
0188
2014-11-14
pjp
static uint8_t region = 0;
0189
2014-11-14
pjp
static uint64_t confstatus = 0;
0190
2017-06-26
pjp
static ddDB *mydb;
0191
2015-09-14
pjp
static char *current_zone = NULL;
0192
2019-11-14
pjp
static int pullzone = 1;
0193
2014-11-14
pjp
0194
2021-01-08
pjp
0195
2014-11-14
pjp
YYSTYPE yylval;
0196
2014-11-14
pjp
0197
2014-11-14
pjp
0198
2014-11-14
pjp
char *converted_name;
0199
2014-11-14
pjp
int converted_namelen;
0200
2021-01-05
pjp
uint32_t zonenumber = 0;
0201
2017-06-26
pjp
ddDBT key, data;
0202
2014-11-14
pjp
int axfrport = 0;
0203
2014-11-14
pjp
time_t time_changed;
0204
2015-06-20
pjp
int dnssec = 0;
0205
2019-11-01
pjp
int raxfrflag = 0;
0206
2020-04-23
pjp
int tcpanyonly = 0;
0207
2020-09-30
pjp
u_int max_udp_payload = 0xffff; /* 65535 */
0208
2021-01-07
pjp
uint16_t fudge_forward = DEFAULT_TSIG_FUDGE;
0209
2021-01-08
pjp
uint8_t rdomain = 0;
0210
2021-01-08
pjp
uint8_t forward_rdomain = 0;
0211
2014-11-14
pjp
0212
2014-11-14
pjp
char *check_rr(char *, char *, int, int *);
0213
2020-07-06
pjp
int fill_a(ddDB *, char *, char *, int, char *);
0214
2020-07-06
pjp
int fill_aaaa(ddDB *, char *, char *, int, char *);
0215
2020-07-06
pjp
int fill_ptr(ddDB *, char *, char *, int, char *);
0216
2020-07-06
pjp
int fill_cname(ddDB *, char *, char *, int, char *);
0217
2020-07-06
pjp
int fill_mx(ddDB *, char *, char *, int, int, char *);
0218
2020-07-06
pjp
int fill_naptr(ddDB *, char *, char *, int, int, int, char *, char *, char *, char *);
0219
2020-07-06
pjp
int fill_ns(ddDB *, char *, char *, int, char *);
0220
2020-07-06
pjp
int fill_soa(ddDB *, char *, char *, int, char *, char *, int, int, int, int, int);
0221
2020-07-06
pjp
int fill_sshfp(ddDB *, char *, char *, int, int, int, char *);
0222
2020-07-06
pjp
int fill_srv(ddDB *, char *, char *, int, int, int, int, char *);
0223
2020-07-06
pjp
int fill_tlsa(ddDB *, char *, char *,int, uint8_t, uint8_t, uint8_t, char *);
0224
2020-07-06
pjp
int fill_txt(ddDB *, char *, char *, int, char *);
0225
2020-07-06
pjp
int fill_dnskey(ddDB *, char *, char *, u_int32_t, u_int16_t, u_int8_t, u_int8_t, char *);
0226
2020-07-06
pjp
int fill_rrsig(ddDB *, char *, char *, u_int32_t, char *, u_int8_t, u_int8_t, u_int32_t, u_int64_t, u_int64_t, u_int16_t, char *, char *);
0227
2020-07-06
pjp
int fill_nsec(ddDB *, char *, char *, u_int32_t, char *, char *);
0228
2020-07-06
pjp
int fill_nsec3param(ddDB *, char *, char *, u_int32_t, u_int8_t, u_int8_t, u_int16_t, char *);
0229
2020-07-06
pjp
int fill_nsec3(ddDB *, char *, char *, u_int32_t, u_int8_t, u_int8_t, u_int16_t, char *, char *, char *);
0230
2020-07-06
pjp
int fill_ds(ddDB *, char *, char *, u_int32_t, u_int16_t, u_int8_t, u_int8_t, char *);
0231
2020-07-23
pjp
int fill_rp(ddDB *, char *, char *, int, char *, char *);
0232
2020-07-23
pjp
int fill_hinfo(ddDB *, char *, char *, int, char *, char *);
0233
2020-07-23
pjp
int fill_caa(ddDB *, char *, char *, int, uint8_t, char *, char *);
0234
2014-11-20
pjp
0235
2015-06-25
pjp
void create_nsec_bitmap(char *, char *, int *);
0236
2014-11-14
pjp
int findeol(void);
0237
2014-11-14
pjp
int get_ip(char *, int);
0238
2014-11-14
pjp
char *get_prefixlen(char *, char *, int);
0239
2014-11-14
pjp
int get_quotedstring(char *, int);
0240
2014-11-14
pjp
int get_string(char *, int);
0241
2015-06-25
pjp
int hex2bin(char *, int, char *);
0242
2014-11-14
pjp
int lgetc(int);
0243
2014-11-14
pjp
struct tab * lookup(struct tab *, char *);
0244
2014-11-14
pjp
int lungetc(int);
0245
2019-11-14
pjp
int parse_file(ddDB *, char *, uint32_t);
0246
2019-02-04
pjp
struct file *pushfile(const char *, int, int, int);
0247
2014-11-14
pjp
int popfile(void);
0248
2014-11-14
pjp
static int temp_inet_net_pton_ipv6(const char *, void *, size_t);
0249
2014-11-14
pjp
int yyparse(void);
0250
2019-02-04
pjp
static struct rzone * add_rzone(void);
0251
2019-06-26
pjp
static struct mzone * add_mzone(void);
0252
2019-02-04
pjp
static int pull_remote_zone(struct rzone *);
0253
2019-10-25
pjp
int notifysource(struct question *, struct sockaddr_storage *);
0254
2019-11-06
pjp
int drop_privs(char *, struct passwd *);
0255
2014-11-14
pjp
0256
2014-11-14
pjp
0257
2014-11-14
pjp
%}
0258
2014-11-14
pjp
0259
2014-11-14
pjp
0260
2019-02-04
pjp
%token VERSION OBRACE EBRACE REGION RZONE AXFRFOR
0261
2014-11-14
pjp
%token DOT COLON TEXT WOF INCLUDE ZONE COMMA CRLF
0262
2019-11-25
pjp
%token ERROR AXFRPORT OPTIONS FILTER MZONE
0263
2020-07-16
pjp
%token PASSLIST ZINCLUDE MASTER MASTERPORT TSIGAUTH
0264
2020-06-30
pjp
%token TSIG NOTIFYDEST NOTIFYBIND PORT FORWARD
0265
2020-07-17
pjp
%token INCOMINGTSIG DESTINATION CACHE STRICTX20
0266
2021-01-08
pjp
%token BYTELIMIT FUDGE TSIGPASSNAME RDOMAIN
0267
2014-11-14
pjp
0268
2014-11-14
pjp
%token <v.string> POUND
0269
2014-11-14
pjp
%token <v.string> SEMICOLON
0270
2014-11-14
pjp
%token <v.string> STRING
0271
2014-11-14
pjp
%token <v.string> IP
0272
2014-11-14
pjp
%token <v.string> IPV6
0273
2014-11-14
pjp
%token <v.string> SLASH
0274
2014-11-14
pjp
%token <v.string> QUOTEDSTRING
0275
2014-11-14
pjp
0276
2014-11-14
pjp
%token <v.intval> NUMBER
0277
2014-11-14
pjp
0278
2014-11-14
pjp
%type <v.string> quotednumber quotedfilename ipcidr
0279
2014-11-14
pjp
0280
2014-11-14
pjp
%start cmd_list
0281
2014-11-14
pjp
0282
2014-11-14
pjp
%%
0283
2014-11-14
pjp
cmd_list:
0284
2014-11-14
pjp
| cmd_list cmd
0285
2014-11-14
pjp
;
0286
2014-11-14
pjp
0287
2014-11-14
pjp
cmd :
0288
2014-11-14
pjp
version
0289
2019-02-04
pjp
| rzone
0290
2019-06-26
pjp
| mzone
0291
2019-02-24
pjp
| tsigauth
0292
2016-07-19
pjp
| axfrport
0293
2016-07-19
pjp
| include
0294
2018-07-11
pjp
| zinclude
0295
2016-07-19
pjp
| zone
0296
2014-11-14
pjp
| region CRLF
0297
2014-11-14
pjp
| axfr CRLF
0298
2020-07-16
pjp
| passlist CRLF
0299
2019-02-24
pjp
| tsig CRLF
0300
2021-01-07
pjp
| tsigpassname CRLF
0301
2014-11-14
pjp
| filter CRLF
0302
2020-06-30
pjp
| forward CRLF
0303
2014-11-14
pjp
| comment CRLF
0304
2014-11-14
pjp
| options
0305
2014-11-14
pjp
;
0306
2014-11-14
pjp
0307
2014-11-14
pjp
0308
2014-11-14
pjp
comment:
0309
2014-11-14
pjp
comment comments
0310
2014-11-14
pjp
| comments
0311
2014-11-14
pjp
;
0312
2014-11-14
pjp
0313
2014-11-14
pjp
comments:
0314
2014-11-14
pjp
SEMICOLON
0315
2014-11-14
pjp
| POUND
0316
2014-11-14
pjp
;
0317
2014-11-14
pjp
0318
2014-11-14
pjp
version:
0319
2014-11-14
pjp
VERSION quotednumber SEMICOLON CRLF
0320
2014-11-14
pjp
{
0321
2014-11-14
pjp
version = atoi($2);
0322
2015-12-01
pjp
if (version != DELPHINUSVERSION) {
0323
2014-11-14
pjp
dolog(LOG_ERR, "version of configfile is wrong,"
0324
2015-12-01
pjp
" must be \"%d\"!\n", DELPHINUSVERSION);
0325
2014-11-14
pjp
return (-1);
0326
2014-11-14
pjp
}
0327
2014-11-14
pjp
free ($2);
0328
2014-11-14
pjp
0329
2014-11-14
pjp
confstatus |= CONFIG_VERSION;
0330
2014-11-14
pjp
}
0331
2014-11-14
pjp
;
0332
2014-11-14
pjp
0333
2014-11-14
pjp
axfrport:
0334
2014-11-14
pjp
AXFRPORT quotednumber SEMICOLON CRLF
0335
2014-11-14
pjp
{
0336
2014-11-14
pjp
if ((confstatus & CONFIG_VERSION) != CONFIG_VERSION) {
0337
2014-11-14
pjp
dolog(LOG_INFO, "There must be a version at the top of the first configfile\n");
0338
2014-11-14
pjp
return (-1);
0339
2014-11-14
pjp
}
0340
2018-07-11
pjp
if (file->descend == DESCEND_YES) {
0341
2018-07-11
pjp
axfrport = atoi($2);
0342
2018-07-11
pjp
}
0343
2014-11-14
pjp
free ($2);
0344
2014-11-14
pjp
}
0345
2014-11-14
pjp
;
0346
2014-11-14
pjp
0347
2014-11-14
pjp
quotednumber:
0348
2014-11-14
pjp
QUOTEDSTRING
0349
2014-11-14
pjp
{
0350
2014-11-14
pjp
if (debug)
0351
2014-11-14
pjp
printf("quotednumber is %s\n", $$);
0352
2014-11-14
pjp
}
0353
2014-11-14
pjp
;
0354
2014-11-14
pjp
0355
2014-11-14
pjp
include:
0356
2014-11-14
pjp
includes CRLF
0357
2014-11-14
pjp
;
0358
2014-11-14
pjp
0359
2014-11-14
pjp
includes:
0360
2014-11-14
pjp
INCLUDE quotedfilename SEMICOLON {
0361
2014-11-14
pjp
struct file *nfile;
0362
2014-11-14
pjp
0363
2014-11-14
pjp
if ((confstatus & CONFIG_VERSION) != CONFIG_VERSION) {
0364
2014-11-14
pjp
dolog(LOG_INFO, "There must be a version at the top of the first configfile\n");
0365
2014-11-14
pjp
return (-1);
0366
2014-11-14
pjp
}
0367
2014-11-14
pjp
0368
2018-07-11
pjp
if (file->descend == DESCEND_YES) {
0369
2019-02-04
pjp
if ((nfile = pushfile($2, 0, DESCEND_YES, NO_RZONEFILE)) == NULL) {
0370
2018-07-11
pjp
fprintf(stderr, "failed to include file %s\n", $2);
0371
2018-07-11
pjp
free($2);
0372
2018-07-11
pjp
return (-1);
0373
2018-07-11
pjp
}
0374
2018-07-11
pjp
0375
2018-07-11
pjp
file = nfile;
0376
2018-07-11
pjp
lungetc('\n');
0377
2014-11-14
pjp
}
0378
2014-11-14
pjp
0379
2014-11-14
pjp
free($2);
0380
2018-07-11
pjp
}
0381
2018-07-11
pjp
;
0382
2014-11-14
pjp
0383
2018-07-11
pjp
zinclude:
0384
2018-07-11
pjp
zincludes CRLF
0385
2018-07-11
pjp
;
0386
2018-07-11
pjp
0387
2018-07-11
pjp
zincludes:
0388
2018-07-11
pjp
ZINCLUDE quotedfilename SEMICOLON {
0389
2018-07-11
pjp
struct file *nfile;
0390
2018-07-11
pjp
0391
2018-07-11
pjp
if ((confstatus & CONFIG_VERSION) != CONFIG_VERSION) {
0392
2018-07-11
pjp
dolog(LOG_INFO, "There must be a version at the top of the first configfile\n");
0393
2018-07-11
pjp
return (-1);
0394
2018-07-11
pjp
}
0395
2018-07-11
pjp
0396
2018-07-11
pjp
if (file->descend == DESCEND_YES) {
0397
2019-02-04
pjp
if ((nfile = pushfile($2, 0, DESCEND_NO, NO_RZONEFILE)) == NULL) {
0398
2018-07-11
pjp
fprintf(stderr, "failed to include file %s\n", $2);
0399
2018-07-11
pjp
free($2);
0400
2018-07-11
pjp
return (-1);
0401
2018-07-11
pjp
}
0402
2018-07-11
pjp
0403
2018-07-11
pjp
file = nfile;
0404
2018-07-11
pjp
lungetc('\n');
0405
2018-07-11
pjp
}
0406
2018-07-11
pjp
0407
2018-07-11
pjp
free($2);
0408
2014-11-14
pjp
}
0409
2014-11-14
pjp
;
0410
2014-11-14
pjp
0411
2014-11-14
pjp
quotedfilename:
0412
2014-11-14
pjp
QUOTEDSTRING
0413
2014-11-14
pjp
{
0414
2014-11-14
pjp
if (debug)
0415
2014-11-14
pjp
printf("quotedfilename is %s\n", $$);
0416
2014-11-14
pjp
}
0417
2014-11-14
pjp
;
0418
2014-11-14
pjp
0419
2019-02-04
pjp
0420
2019-02-24
pjp
tsigauth:
0421
2019-02-24
pjp
TSIGAUTH STRING QUOTEDSTRING SEMICOLON CRLF {
0422
2019-06-28
pjp
char key[512];
0423
2019-02-24
pjp
char *keyname;
0424
2019-02-24
pjp
int keylen, keynamelen;
0425
2019-02-24
pjp
0426
2019-06-28
pjp
if ((keylen = mybase64_decode($3, key, sizeof(key))) < 0) {
0427
2019-02-24
pjp
dolog(LOG_ERR, "can't decode tsig base64\n");
0428
2019-02-24
pjp
return -1;
0429
2019-02-24
pjp
}
0430
2019-02-24
pjp
0431
2019-02-24
pjp
keyname = dns_label($2, &keynamelen);
0432
2019-11-05
pjp
if (keyname == NULL) {
0433
2019-11-05
pjp
dolog(LOG_ERR, "dns_label: %s\n", strerror(errno));
0434
2019-11-05
pjp
return -1;
0435
2019-11-05
pjp
}
0436
2019-02-24
pjp
0437
2019-02-24
pjp
insert_tsig_key(key, keylen, keyname, keynamelen);
0438
2019-02-24
pjp
0439
2019-02-24
pjp
free($2);
0440
2019-02-24
pjp
free($3);
0441
2019-02-24
pjp
free(keyname);
0442
2019-02-24
pjp
}
0443
2019-02-24
pjp
;
0444
2019-06-26
pjp
mzone:
0445
2019-06-26
pjp
MZONE mzonelabel mzonecontent {
0446
2019-06-26
pjp
mz = add_mzone();
0447
2019-06-26
pjp
if (mz == NULL) {
0448
2019-06-26
pjp
dolog(LOG_INFO, "add_mzone failed\n");
0449
2019-06-26
pjp
return (-1);
0450
2019-06-26
pjp
}
0451
2019-06-26
pjp
SLIST_INIT(&mz->dest);
0452
2019-06-26
pjp
}
0453
2019-06-26
pjp
;
0454
2019-02-24
pjp
0455
2019-06-26
pjp
mzonelabel:
0456
2019-06-26
pjp
QUOTEDSTRING
0457
2019-06-26
pjp
;
0458
2019-06-26
pjp
0459
2019-06-26
pjp
mzonecontent:
0460
2019-06-26
pjp
OBRACE mzonestatements EBRACE CRLF
0461
2019-06-26
pjp
| OBRACE CRLF mzonestatements EBRACE CRLF
0462
2019-06-26
pjp
;
0463
2019-06-26
pjp
0464
2019-06-26
pjp
mzonestatements :
0465
2019-06-26
pjp
mzonestatements mzonestatement
0466
2019-06-26
pjp
| mzonestatement
0467
2019-06-26
pjp
;
0468
2019-06-26
pjp
0469
2019-06-26
pjp
mzonestatement:
0470
2019-06-26
pjp
0471
2019-06-26
pjp
STRING QUOTEDSTRING SEMICOLON CRLF
0472
2019-06-26
pjp
{
0473
2019-06-26
pjp
mz = SLIST_FIRST(&mzones);
0474
2019-06-26
pjp
if (mz == NULL) {
0475
2019-06-26
pjp
mz = add_mzone();
0476
2019-06-26
pjp
SLIST_INIT(&mz->dest);
0477
2019-06-26
pjp
}
0478
2019-06-26
pjp
0479
2019-06-26
pjp
if (strcmp($1, "zonename") == 0) {
0480
2019-06-26
pjp
mz->humanname = strdup($2);
0481
2019-06-26
pjp
if (mz->humanname == NULL) {
0482
2019-06-26
pjp
perror("strdup");
0483
2019-06-26
pjp
return -1;
0484
2019-06-26
pjp
}
0485
2019-06-26
pjp
0486
2019-06-26
pjp
mz->zonename = dns_label(mz->humanname, &mz->zonenamelen);
0487
2019-06-26
pjp
if (mz->zonename == NULL) {
0488
2019-06-26
pjp
fprintf(stderr, "could not convert zone to dns_label\n");
0489
2019-06-26
pjp
return -1;
0490
2019-06-26
pjp
}
0491
2019-06-26
pjp
}
0492
2019-06-26
pjp
0493
2019-06-26
pjp
free($1);
0494
2019-06-26
pjp
free($2);
0495
2019-06-26
pjp
}
0496
2019-06-26
pjp
|
0497
2019-07-09
pjp
NOTIFYDEST ipcidr PORT NUMBER STRING SEMICOLON CRLF
0498
2019-07-09
pjp
{
0499
2019-07-09
pjp
struct sockaddr_in *sin;
0500
2019-07-09
pjp
struct sockaddr_in6 *sin6;
0501
2019-07-09
pjp
struct mzone_dest *md;
0502
2019-07-09
pjp
0503
2019-07-09
pjp
mz = SLIST_FIRST(&mzones);
0504
2019-07-09
pjp
if (mz == NULL) {
0505
2019-07-09
pjp
mz = add_mzone();
0506
2019-07-09
pjp
SLIST_INIT(&mz->dest);
0507
2019-07-09
pjp
}
0508
2019-07-09
pjp
0509
2019-07-09
pjp
md = calloc(sizeof(struct mzone_dest), 1);
0510
2019-07-09
pjp
if (md == NULL) {
0511
2019-07-09
pjp
dolog(LOG_INFO, "calloc: %s\n", strerror(errno));
0512
2019-07-09
pjp
return (-1);
0513
2019-07-09
pjp
}
0514
2019-07-09
pjp
0515
2019-07-09
pjp
sin = (struct sockaddr_in *)&md->notifydest;
0516
2019-07-09
pjp
sin6 = (struct sockaddr_in6 *)&md->notifydest;
0517
2019-07-09
pjp
0518
2019-07-09
pjp
if (strchr($2, ':')) {
0519
2019-07-09
pjp
inet_pton(AF_INET6, $2, &sin6->sin6_addr);
0520
2019-07-09
pjp
md->port = $4 & 0xffff;
0521
2019-07-09
pjp
md->notifydest.ss_family = AF_INET6;
0522
2019-07-09
pjp
if (strcmp($5, "NOKEY") == 0) {
0523
2019-07-09
pjp
md->tsigkey = NULL;
0524
2019-07-09
pjp
} else {
0525
2019-07-09
pjp
md->tsigkey = strdup($5);
0526
2019-07-09
pjp
if (md->tsigkey == NULL) {
0527
2019-07-09
pjp
perror("stdup");
0528
2019-07-09
pjp
return -1;
0529
2019-07-09
pjp
}
0530
2019-07-09
pjp
}
0531
2019-07-09
pjp
0532
2019-07-09
pjp
0533
2019-07-09
pjp
SLIST_INSERT_HEAD(&mz->dest, md, entries);
0534
2019-07-09
pjp
0535
2019-07-09
pjp
notify++;
0536
2019-07-09
pjp
} else {
0537
2019-07-09
pjp
inet_pton(AF_INET, $2, &sin->sin_addr.s_addr);
0538
2019-07-09
pjp
md->notifydest.ss_family = AF_INET;
0539
2019-07-09
pjp
md->port = $4 & 0xffff;
0540
2019-07-09
pjp
0541
2019-07-09
pjp
if (strcmp($5, "NOKEY") == 0) {
0542
2019-07-09
pjp
md->tsigkey = NULL;
0543
2019-07-09
pjp
} else {
0544
2019-07-09
pjp
md->tsigkey = strdup($5);
0545
2019-07-09
pjp
if (md->tsigkey == NULL) {
0546
2019-07-09
pjp
perror("stdup");
0547
2019-07-09
pjp
return -1;
0548
2019-07-09
pjp
}
0549
2019-07-09
pjp
}
0550
2019-07-09
pjp
0551
2019-07-09
pjp
SLIST_INSERT_HEAD(&mz->dest, md, entries);
0552
2019-07-09
pjp
notify++;
0553
2019-07-09
pjp
}
0554
2019-07-09
pjp
0555
2019-07-09
pjp
0556
2019-07-09
pjp
free($2);
0557
2019-07-09
pjp
free($5);
0558
2019-07-09
pjp
}
0559
2019-07-09
pjp
|
0560
2019-06-26
pjp
NOTIFYDEST ipcidr STRING SEMICOLON CRLF
0561
2019-06-26
pjp
{
0562
2019-06-26
pjp
struct sockaddr_in *sin;
0563
2019-06-26
pjp
struct sockaddr_in6 *sin6;
0564
2019-06-26
pjp
struct mzone_dest *md;
0565
2019-06-26
pjp
0566
2019-06-26
pjp
mz = SLIST_FIRST(&mzones);
0567
2019-06-26
pjp
if (mz == NULL) {
0568
2019-06-26
pjp
mz = add_mzone();
0569
2019-06-26
pjp
SLIST_INIT(&mz->dest);
0570
2019-06-26
pjp
}
0571
2019-06-26
pjp
0572
2019-06-26
pjp
md = calloc(sizeof(struct mzone_dest), 1);
0573
2019-06-26
pjp
if (md == NULL) {
0574
2019-06-26
pjp
dolog(LOG_INFO, "calloc: %s\n", strerror(errno));
0575
2019-06-26
pjp
return (-1);
0576
2019-06-26
pjp
}
0577
2019-06-26
pjp
0578
2019-06-26
pjp
sin = (struct sockaddr_in *)&md->notifydest;
0579
2019-06-26
pjp
sin6 = (struct sockaddr_in6 *)&md->notifydest;
0580
2019-06-26
pjp
0581
2019-06-26
pjp
if (strchr($2, ':')) {
0582
2019-06-26
pjp
inet_pton(AF_INET6, $2, &sin6->sin6_addr);
0583
2019-06-26
pjp
md->notifydest.ss_family = AF_INET6;
0584
2019-07-09
pjp
md->port = 53;
0585
2019-06-26
pjp
if (strcmp($3, "NOKEY") == 0) {
0586
2019-06-26
pjp
md->tsigkey = NULL;
0587
2019-06-26
pjp
} else {
0588
2019-06-26
pjp
md->tsigkey = strdup($3);
0589
2019-06-26
pjp
if (md->tsigkey == NULL) {
0590
2019-06-26
pjp
perror("stdup");
0591
2019-06-26
pjp
return -1;
0592
2019-06-26
pjp
}
0593
2019-06-26
pjp
}
0594
2019-06-26
pjp
0595
2019-06-26
pjp
0596
2019-06-26
pjp
SLIST_INSERT_HEAD(&mz->dest, md, entries);
0597
2019-06-26
pjp
0598
2019-06-26
pjp
notify++;
0599
2019-06-26
pjp
} else {
0600
2019-06-26
pjp
inet_pton(AF_INET, $2, &sin->sin_addr.s_addr);
0601
2019-06-26
pjp
md->notifydest.ss_family = AF_INET;
0602
2019-07-09
pjp
md->port = 53;
0603
2019-06-26
pjp
0604
2019-06-26
pjp
if (strcmp($3, "NOKEY") == 0) {
0605
2019-06-26
pjp
md->tsigkey = NULL;
0606
2019-06-26
pjp
} else {
0607
2019-06-26
pjp
md->tsigkey = strdup($3);
0608
2019-06-26
pjp
if (md->tsigkey == NULL) {
0609
2019-06-26
pjp
perror("stdup");
0610
2019-06-26
pjp
return -1;
0611
2019-06-26
pjp
}
0612
2019-06-26
pjp
}
0613
2019-06-26
pjp
0614
2019-06-26
pjp
SLIST_INSERT_HEAD(&mz->dest, md, entries);
0615
2019-06-26
pjp
notify++;
0616
2019-06-26
pjp
}
0617
2019-06-26
pjp
0618
2019-06-26
pjp
0619
2019-06-26
pjp
free($2);
0620
2019-06-26
pjp
free($3);
0621
2019-06-26
pjp
}
0622
2019-06-26
pjp
|
0623
2019-06-26
pjp
NOTIFYBIND ipcidr SEMICOLON CRLF
0624
2019-06-26
pjp
{
0625
2019-06-26
pjp
struct sockaddr_in *sin;
0626
2019-06-26
pjp
struct sockaddr_in6 *sin6;
0627
2019-06-26
pjp
0628
2019-06-26
pjp
mz = SLIST_FIRST(&mzones);
0629
2019-06-26
pjp
if (mz == NULL) {
0630
2019-06-26
pjp
mz = add_mzone();
0631
2019-06-26
pjp
SLIST_INIT(&mz->dest);
0632
2019-06-26
pjp
}
0633
2019-06-26
pjp
0634
2019-06-26
pjp
sin = (struct sockaddr_in *)&mz->notifybind;
0635
2019-06-26
pjp
sin6 = (struct sockaddr_in6 *)&mz->notifybind;
0636
2019-06-26
pjp
0637
2019-06-26
pjp
if (strchr($2, ':')) {
0638
2019-06-26
pjp
mz->notifybind.ss_family = AF_INET6;
0639
2019-06-26
pjp
inet_pton(AF_INET6, $2, &sin6->sin6_addr);
0640
2019-06-26
pjp
} else {
0641
2019-06-26
pjp
mz->notifybind.ss_family = AF_INET;
0642
2019-06-26
pjp
inet_pton(AF_INET, $2, &sin->sin_addr.s_addr);
0643
2019-06-26
pjp
}
0644
2019-06-26
pjp
free($2);
0645
2019-06-26
pjp
}
0646
2019-11-18
pjp
| comment CRLF
0647
2019-11-18
pjp
;
0648
2019-06-26
pjp
0649
2019-02-04
pjp
rzone:
0650
2019-02-04
pjp
RZONE rzonelabel rzonecontent {
0651
2019-02-04
pjp
struct file *nfile;
0652
2019-02-04
pjp
struct rzone *lrz;
0653
2019-02-04
pjp
struct stat sb;
0654
2019-02-04
pjp
0655
2019-02-04
pjp
/* we must pull the last zone added */
0656
2019-02-04
pjp
lrz = SLIST_FIRST(&rzones);
0657
2019-02-04
pjp
if (lrz == NULL || lrz->filename == NULL) {
0658
2019-02-04
pjp
fprintf(stderr, "incomplete rzone, missing filename\n");
0659
2019-02-04
pjp
return -1;
0660
2019-02-04
pjp
}
0661
2019-02-04
pjp
if (lstat(lrz->filename, &sb) < 0 || sb.st_size == 0) {
0662
2019-11-14
pjp
if (pullzone && pull_remote_zone(lrz) < 0) {
0663
2019-02-04
pjp
dolog(LOG_ERR, "can't pull zone %s into filename %s, stop.\n", lrz->zonename, lrz->filename);
0664
2019-02-04
pjp
return -1;
0665
2019-02-04
pjp
}
0666
2019-02-04
pjp
0667
2019-02-04
pjp
}
0668
2019-02-04
pjp
0669
2019-02-04
pjp
if (file->descend == DESCEND_YES) {
0670
2019-02-04
pjp
if ((nfile = pushfile(lrz->filename, 0, DESCEND_NO, RZONEFILE)) == NULL) {
0671
2019-02-04
pjp
fprintf(stderr, "failed to include rzone file %s\n", lrz->filename);
0672
2019-02-04
pjp
return (-1);
0673
2019-02-04
pjp
}
0674
2019-02-04
pjp
0675
2019-02-04
pjp
rzonefile = nfile;
0676
2019-02-04
pjp
}
0677
2019-02-04
pjp
0678
2019-02-04
pjp
(void)add_rzone();
0679
2019-11-01
pjp
raxfrflag = 1;
0680
2019-02-04
pjp
}
0681
2019-02-04
pjp
;
0682
2019-02-04
pjp
0683
2019-02-04
pjp
rzonelabel:
0684
2019-02-04
pjp
QUOTEDSTRING
0685
2019-02-04
pjp
;
0686
2019-02-04
pjp
0687
2019-02-04
pjp
rzonecontent:
0688
2019-02-04
pjp
OBRACE rzonestatements EBRACE CRLF
0689
2019-02-04
pjp
| OBRACE CRLF rzonestatements EBRACE CRLF
0690
2019-02-04
pjp
;
0691
2019-02-04
pjp
0692
2019-02-04
pjp
rzonestatements :
0693
2019-02-04
pjp
rzonestatements rzonestatement
0694
2019-02-04
pjp
| rzonestatement
0695
2019-02-04
pjp
;
0696
2019-02-04
pjp
0697
2019-02-04
pjp
rzonestatement:
0698
2019-02-04
pjp
0699
2019-02-04
pjp
MASTERPORT NUMBER SEMICOLON CRLF
0700
2019-02-04
pjp
{
0701
2019-02-04
pjp
rz = SLIST_FIRST(&rzones);
0702
2019-02-04
pjp
if (rz == NULL) {
0703
2019-02-04
pjp
return -1;
0704
2019-02-04
pjp
}
0705
2019-02-04
pjp
0706
2019-10-25
pjp
rz->active = 1;
0707
2019-02-04
pjp
rz->masterport = $2 & 0xffff;
0708
2019-02-04
pjp
0709
2019-02-04
pjp
}
0710
2019-02-04
pjp
|
0711
2019-02-04
pjp
MASTER ipcidr SEMICOLON CRLF
0712
2019-02-04
pjp
{
0713
2019-10-25
pjp
struct sockaddr_in *sin;
0714
2019-10-25
pjp
struct sockaddr_in6 *sin6;
0715
2019-02-04
pjp
char *p;
0716
2019-02-04
pjp
0717
2019-02-04
pjp
rz = SLIST_FIRST(&rzones);
0718
2019-02-04
pjp
if (rz == NULL) {
0719
2019-02-04
pjp
return -1;
0720
2019-02-04
pjp
}
0721
2019-02-04
pjp
0722
2019-10-25
pjp
rz->active = 1;
0723
2019-02-04
pjp
p = strdup($2);
0724
2019-02-04
pjp
if (p == NULL) {
0725
2019-02-04
pjp
perror("strdup");
0726
2019-02-04
pjp
return -1;
0727
2019-02-04
pjp
}
0728
2019-02-04
pjp
0729
2019-02-04
pjp
rz->master = p;
0730
2019-02-04
pjp
0731
2019-10-25
pjp
sin = (struct sockaddr_in *)&rz->storage;
0732
2019-10-25
pjp
sin6 = (struct sockaddr_in6 *)&rz->storage;
0733
2019-10-25
pjp
0734
2019-10-25
pjp
if (strchr(rz->master, ':')) {
0735
2019-10-25
pjp
rz->storage.ss_family = AF_INET6;
0736
2019-11-19
pjp
#ifndef __linux__
0737
2019-10-25
pjp
rz->storage.ss_len = 16;
0738
2019-11-19
pjp
#endif
0739
2019-10-25
pjp
inet_pton(AF_INET6, rz->master, &sin6->sin6_addr);
0740
2019-10-25
pjp
} else {
0741
2019-10-25
pjp
rz->storage.ss_family = AF_INET;
0742
2019-11-19
pjp
#ifndef __linux__
0743
2019-10-25
pjp
rz->storage.ss_len = 4;
0744
2019-11-19
pjp
#endif
0745
2019-10-25
pjp
inet_pton(AF_INET, rz->master, &sin->sin_addr.s_addr);
0746
2019-10-25
pjp
}
0747
2019-04-25
pjp
0748
2019-10-25
pjp
0749
2019-02-04
pjp
free($2);
0750
2019-02-04
pjp
}
0751
2019-02-04
pjp
|
0752
2019-02-04
pjp
STRING QUOTEDSTRING SEMICOLON CRLF
0753
2019-02-04
pjp
{
0754
2019-02-04
pjp
char *p;
0755
2019-02-04
pjp
0756
2019-02-04
pjp
rz = SLIST_FIRST(&rzones);
0757
2019-02-04
pjp
if (rz == NULL) {
0758
2019-02-04
pjp
fprintf(stderr, "SLIST_FIRST failed\n");
0759
2019-02-04
pjp
return -1;
0760
2019-02-04
pjp
}
0761
2019-02-04
pjp
0762
2019-10-25
pjp
rz->active = 1;
0763
2019-02-04
pjp
p = strdup($2);
0764
2019-02-04
pjp
if (p == NULL) {
0765
2019-02-04
pjp
perror("strdup");
0766
2019-02-04
pjp
return -1;
0767
2019-02-04
pjp
}
0768
2019-02-04
pjp
0769
2019-02-04
pjp
if (strcmp($1, "zonename") == 0) {
0770
2019-02-04
pjp
rz->zonename = p;
0771
2019-11-04
pjp
0772
2019-11-04
pjp
rz->zone = dns_label(p, &rz->zonelen);
0773
2019-11-04
pjp
if (rz->zone == NULL) {
0774
2019-11-04
pjp
perror("dns_label");
0775
2019-11-04
pjp
return -1;
0776
2019-11-04
pjp
}
0777
2019-02-04
pjp
} else if (strcmp($1, "filename") == 0) {
0778
2019-02-04
pjp
rz->filename = p;
0779
2019-02-04
pjp
0780
2019-02-04
pjp
} else if (strcmp($1, "tsigkey") == 0) {
0781
2019-02-04
pjp
rz->tsigkey = p;
0782
2019-02-04
pjp
}
0783
2019-02-04
pjp
0784
2019-02-04
pjp
free($1);
0785
2019-02-04
pjp
free($2);
0786
2019-02-04
pjp
}
0787
2020-07-27
pjp
|
0788
2020-07-27
pjp
STRING NUMBER COMMA NUMBER COMMA NUMBER SEMICOLON CRLF
0789
2020-07-27
pjp
{
0790
2020-07-27
pjp
if (strcmp($1, "constraints") == 0) {
0791
2020-07-27
pjp
rz = SLIST_FIRST(&rzones);
0792
2020-07-27
pjp
if (rz == NULL) {
0793
2020-07-27
pjp
return -1;
0794
2020-07-27
pjp
}
0795
2020-07-27
pjp
0796
2020-07-27
pjp
rz->active = 1;
0797
2020-07-27
pjp
0798
2020-07-27
pjp
rz->constraints.refresh = $2;
0799
2020-07-27
pjp
rz->constraints.retry = $4;
0800
2020-07-27
pjp
rz->constraints.expire = $6;
0801
2020-07-27
pjp
}
0802
2020-07-27
pjp
0803
2020-07-27
pjp
free ($1);
0804
2020-07-27
pjp
}
0805
2020-09-24
pjp
|
0806
2020-09-24
pjp
BYTELIMIT NUMBER SEMICOLON CRLF
0807
2020-09-24
pjp
{
0808
2020-09-24
pjp
rz = SLIST_FIRST(&rzones);
0809
2020-09-24
pjp
if (rz == NULL) {
0810
2020-09-24
pjp
return -1;
0811
2020-09-24
pjp
}
0812
2020-09-24
pjp
0813
2020-09-24
pjp
rz->active = 1;
0814
2020-09-24
pjp
rz->bytelimit = $2;
0815
2020-09-24
pjp
}
0816
2019-11-18
pjp
| comment CRLF
0817
2019-02-04
pjp
;
0818
2019-02-04
pjp
0819
2014-11-14
pjp
/* zone */
0820
2014-11-14
pjp
0821
2014-11-14
pjp
zone:
0822
2014-11-14
pjp
ZONE zonelabel zonecontent
0823
2014-11-14
pjp
{
0824
2020-07-03
pjp
zonecount++;
0825
2014-11-14
pjp
}
0826
2014-11-14
pjp
;
0827
2014-11-14
pjp
0828
2014-11-14
pjp
zonelabel:
0829
2014-11-14
pjp
QUOTEDSTRING
0830
2020-08-26
pjp
{
0831
2020-08-26
pjp
if (insert_zone($1) < 0) {
0832
2020-08-26
pjp
return -1;
0833
2020-08-26
pjp
}
0834
2020-08-26
pjp
0835
2021-01-05
pjp
zonenumber++;
0836
2021-01-05
pjp
0837
2020-08-26
pjp
free($1);
0838
2020-08-26
pjp
}
0839
2014-11-14
pjp
;
0840
2014-11-14
pjp
0841
2014-11-14
pjp
zonecontent:
0842
2014-11-14
pjp
OBRACE zonestatements EBRACE CRLF
0843
2014-11-14
pjp
| OBRACE CRLF zonestatements EBRACE CRLF
0844
2014-11-14
pjp
;
0845
2014-11-14
pjp
0846
2014-11-14
pjp
0847
2014-11-14
pjp
zonestatements :
0848
2014-11-14
pjp
zonestatements zonestatement
0849
2014-11-14
pjp
| zonestatement
0850
2014-11-14
pjp
;
0851
2014-11-14
pjp
0852
2014-11-14
pjp
0853
2014-11-14
pjp
zonestatement:
0854
2014-11-14
pjp
0855
2020-03-06
pjp
/* centroid.eu,soa,3600,uranus.centroid.eu.,hostmaster.centroid.eu.,1258740680,3600,1800,7200,3600 */
0856
2014-11-14
pjp
0857
2014-11-14
pjp
STRING COMMA STRING COMMA NUMBER COMMA STRING COMMA STRING COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER CRLF
0858
2014-11-14
pjp
{
0859
2014-11-14
pjp
if (strcasecmp($3, "soa") == 0) {
0860
2020-07-06
pjp
if (fill_soa(mydb, $1, $3, $5, $7, $9, $11, $13, $15, $17, $19) < 0) {
0861
2014-11-14
pjp
return -1;
0862
2014-11-14
pjp
}
0863
2014-11-14
pjp
0864
2019-11-04
pjp
#if DEBUG
0865
2014-11-14
pjp
if (debug)
0866
2014-11-14
pjp
printf("%s SOA\n", $1);
0867
2019-11-04
pjp
#endif
0868
2014-11-14
pjp
} else {
0869
2014-11-14
pjp
if (debug)
0870
2014-11-14
pjp
printf("soa error\n");
0871
2014-11-14
pjp
return -1;
0872
2014-11-14
pjp
}
0873
2014-11-14
pjp
0874
2014-11-14
pjp
0875
2014-11-14
pjp
free ($1);
0876
2014-11-14
pjp
free ($3);
0877
2014-11-14
pjp
free ($7);
0878
2014-11-14
pjp
free ($9);
0879
2014-11-14
pjp
}
0880
2014-11-14
pjp
|
0881
2014-11-14
pjp
STRING COMMA STRING COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA QUOTEDSTRING CRLF
0882
2014-11-14
pjp
{
0883
2014-11-14
pjp
if (strcasecmp($3, "sshfp") == 0) {
0884
2020-07-06
pjp
if (fill_sshfp(mydb, $1, $3, $5, $7, $9, $11) < 0) {
0885
2014-11-14
pjp
return -1;
0886
2014-11-14
pjp
}
0887
2014-11-14
pjp
0888
2014-11-14
pjp
} else {
0889
2014-11-14
pjp
if (debug)
0890
2014-11-14
pjp
printf("another sshfp record I don't know about?");
0891
2014-11-14
pjp
return (-1);
0892
2014-11-14
pjp
}
0893
2014-11-14
pjp
0894
2014-11-14
pjp
free ($1);
0895
2014-11-14
pjp
free ($3);
0896
2014-11-14
pjp
free ($11);
0897
2014-11-14
pjp
}
0898
2014-11-14
pjp
|
0899
2014-11-14
pjp
STRING COMMA STRING COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA STRING CRLF
0900
2014-11-14
pjp
{
0901
2014-11-14
pjp
if (strcasecmp($3, "srv") == 0) {
0902
2020-07-06
pjp
if (fill_srv(mydb, $1, $3, $5, $7, $9, $11, $13) < 0) {
0903
2014-11-14
pjp
return -1;
0904
2014-11-14
pjp
}
0905
2019-11-04
pjp
#if DEBUG
0906
2015-06-26
pjp
if (debug)
0907
2015-06-26
pjp
printf("SRV\n");
0908
2019-11-04
pjp
#endif
0909
2014-11-14
pjp
0910
2014-11-14
pjp
} else {
0911
2014-11-14
pjp
if (debug)
0912
2014-11-14
pjp
printf("2 another record I don't know about?");
0913
2014-11-14
pjp
return (-1);
0914
2014-11-14
pjp
}
0915
2014-11-14
pjp
0916
2014-11-14
pjp
free ($1);
0917
2014-11-14
pjp
free ($3);
0918
2014-11-14
pjp
free ($13);
0919
2014-11-14
pjp
}
0920
2014-11-14
pjp
|
0921
2014-11-14
pjp
STRING COMMA STRING COMMA NUMBER COMMA STRING CRLF {
0922
2014-11-14
pjp
if (strcasecmp($3, "ns") == 0 ||
0923
2014-11-14
pjp
strcasecmp($3, "delegate") == 0 ||
0924
2014-11-14
pjp
strcasecmp($3, "hint") == 0) {
0925
2020-07-06
pjp
if (fill_ns(mydb, $1, $3, $5, $7) < 0) {
0926
2014-11-14
pjp
return -1;
0927
2014-11-14
pjp
}
0928
2014-11-14
pjp
0929
2019-11-04
pjp
#if DEBUG
0930
2014-11-14
pjp
if (debug)
0931
2014-11-14
pjp
printf("%s NS\n", $1);
0932
2019-11-04
pjp
#endif
0933
2014-11-14
pjp
0934
2014-11-14
pjp
} else if (strcasecmp($3, "ptr") == 0) {
0935
2020-07-06
pjp
if (fill_ptr(mydb, $1, $3, $5, $7) < 0) {
0936
2014-11-14
pjp
return -1;
0937
2014-11-14
pjp
}
0938
2014-11-14
pjp
0939
2019-11-04
pjp
#if DEBUG
0940
2014-11-14
pjp
if (debug)
0941
2014-11-14
pjp
printf("%s PTR\n", $1);
0942
2019-11-04
pjp
#endif
0943
2014-11-14
pjp
0944
2014-11-14
pjp
} else if (strcasecmp($3, "cname") == 0) {
0945
2020-07-06
pjp
if (fill_cname(mydb, $1, $3, $5, $7) < 0) {
0946
2014-11-14
pjp
return -1;
0947
2014-11-14
pjp
}
0948
2014-11-14
pjp
0949
2019-11-04
pjp
#if DEBUG
0950
2014-11-14
pjp
if (debug)
0951
2014-11-14
pjp
printf("%s CNAME\n", $3);
0952
2019-11-04
pjp
#endif
0953
2014-11-14
pjp
0954
2014-11-14
pjp
} else {
0955
2014-11-14
pjp
if (debug)
0956
2014-11-14
pjp
printf("%s other\n", $3);
0957
2014-11-14
pjp
return -1;
0958
2014-11-14
pjp
}
0959
2014-11-14
pjp
0960
2014-11-14
pjp
free ($1);
0961
2014-11-14
pjp
free ($3);
0962
2014-11-14
pjp
free ($7);
0963
2014-11-14
pjp
}
0964
2014-11-14
pjp
|
0965
2014-11-14
pjp
STRING COMMA STRING COMMA NUMBER COMMA IPV6 CRLF {
0966
2014-11-14
pjp
if (strcasecmp($3, "aaaa") == 0) {
0967
2020-07-06
pjp
if (fill_aaaa(mydb, $1, $3, $5, $7) < 0) {
0968
2014-11-14
pjp
return -1;
0969
2014-11-14
pjp
}
0970
2014-11-14
pjp
0971
2019-11-04
pjp
#if DEBUG
0972
2014-11-14
pjp
if (debug)
0973
2014-11-14
pjp
printf("%s AAAA\n", $1);
0974
2019-11-04
pjp
#endif
0975
2014-11-14
pjp
} else {
0976
2014-11-14
pjp
0977
2014-11-14
pjp
if (debug)
0978
2014-11-14
pjp
printf("error AAAA\n");
0979
2014-11-14
pjp
return (-1);
0980
2014-11-14
pjp
}
0981
2014-11-14
pjp
free ($1);
0982
2014-11-14
pjp
free ($3);
0983
2014-11-14
pjp
free ($7);
0984
2014-11-14
pjp
}
0985
2014-11-14
pjp
|
0986
2014-11-14
pjp
STRING COMMA STRING COMMA NUMBER COMMA IP CRLF
0987
2014-11-14
pjp
{
0988
2014-11-14
pjp
if (strcasecmp($3, "a") == 0) {
0989
2020-07-06
pjp
if (fill_a(mydb, $1, $3, $5, $7) < 0) {
0990
2014-11-14
pjp
return -1;
0991
2014-11-14
pjp
}
0992
2014-11-14
pjp
0993
2019-11-04
pjp
#if DEBUG
0994
2014-11-14
pjp
if (debug)
0995
2014-11-14
pjp
printf("%s A\n", $1);
0996
2019-11-04
pjp
#endif
0997
2014-11-14
pjp
0998
2014-11-14
pjp
} else {
0999
2014-11-14
pjp
if (debug)
1000
2014-11-14
pjp
printf("another a record?\n");
1001
2014-11-14
pjp
return -1;
1002
2014-11-14
pjp
}
1003
2014-11-14
pjp
1004
2014-11-14
pjp
free ($1);
1005
2014-11-14
pjp
free ($3);
1006
2014-11-14
pjp
free ($7);
1007
2014-11-14
pjp
}
1008
2014-11-14
pjp
|
1009
2014-11-14
pjp
STRING COMMA STRING COMMA NUMBER COMMA NUMBER COMMA STRING CRLF
1010
2014-11-14
pjp
{
1011
2014-11-14
pjp
if (strcasecmp($3, "mx") == 0) {
1012
2020-07-06
pjp
if (fill_mx(mydb, $1, $3, $5, $7, $9) < 0) {
1013
2014-11-14
pjp
return -1;
1014
2014-11-14
pjp
}
1015
2014-11-14
pjp
1016
2019-11-04
pjp
#if DEBUG
1017
2014-11-14
pjp
if (debug)
1018
2015-06-20
pjp
printf("%s MX -> %lld %s\n", $1, $7, $9);
1019
2019-11-04
pjp
#endif
1020
2014-11-14
pjp
1021
2014-11-14
pjp
} else {
1022
2014-11-14
pjp
if (debug)
1023
2014-11-14
pjp
printf("another record I don't know about?");
1024
2014-11-14
pjp
return (-1);
1025
2014-11-14
pjp
}
1026
2014-11-14
pjp
1027
2014-11-14
pjp
free ($1);
1028
2014-11-14
pjp
free ($3);
1029
2014-11-14
pjp
free ($9);
1030
2014-11-14
pjp
}
1031
2014-11-14
pjp
|
1032
2014-11-14
pjp
STRING COMMA STRING COMMA NUMBER COMMA QUOTEDSTRING CRLF
1033
2014-11-14
pjp
{
1034
2014-11-14
pjp
if (strcasecmp($3, "txt") == 0) {
1035
2020-07-06
pjp
if (fill_txt(mydb, $1, $3, $5, $7) < 0) {
1036
2014-11-14
pjp
return -1;
1037
2014-11-14
pjp
}
1038
2014-11-14
pjp
1039
2019-11-04
pjp
#if DEBUG
1040
2014-11-14
pjp
if (debug)
1041
2014-11-14
pjp
printf(" %s TXT -> %s\n", $1, $7);
1042
2019-11-04
pjp
#endif
1043
2014-11-14
pjp
} else {
1044
2014-11-14
pjp
if (debug)
1045
2017-03-14
pjp
printf("another txt like record I don't know?\n");
1046
2014-11-14
pjp
return (-1);
1047
2014-11-14
pjp
}
1048
2014-11-14
pjp
1049
2014-11-14
pjp
free ($1);
1050
2014-11-14
pjp
free ($3);
1051
2014-11-14
pjp
free ($7);
1052
2014-11-14
pjp
}
1053
2014-11-14
pjp
|
1054
2014-11-14
pjp
STRING COMMA STRING COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA QUOTEDSTRING COMMA QUOTEDSTRING COMMA QUOTEDSTRING COMMA STRING CRLF
1055
2014-11-14
pjp
{
1056
2014-11-14
pjp
if (strcasecmp($3, "naptr") == 0) {
1057
2020-07-06
pjp
if (fill_naptr(mydb, $1, $3, $5, $7, $9, $11, $13, $15, $17) < 0) {
1058
2014-11-14
pjp
return -1;
1059
2014-11-14
pjp
}
1060
2014-11-14
pjp
1061
2019-11-04
pjp
#if DEBUG
1062
2014-11-14
pjp
if (debug)
1063
2014-11-14
pjp
printf(" %s NAPTR\n", $1);
1064
2019-11-04
pjp
#endif
1065
2014-11-14
pjp
} else {
1066
2014-11-14
pjp
if (debug)
1067
2014-11-14
pjp
printf("another naptr like record I don't know?\n");
1068
2014-11-14
pjp
return (-1);
1069
2014-11-14
pjp
}
1070
2014-11-14
pjp
1071
2014-11-14
pjp
free ($1);
1072
2014-11-14
pjp
free ($3);
1073
2014-11-14
pjp
free ($11);
1074
2014-11-14
pjp
free ($13);
1075
2014-11-14
pjp
free ($15);
1076
2014-11-14
pjp
free ($17);
1077
2014-11-14
pjp
}
1078
2014-11-20
pjp
|
1079
2014-11-21
pjp
STRING COMMA STRING COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA QUOTEDSTRING CRLF
1080
2014-11-21
pjp
{
1081
2015-06-20
pjp
if (! dnssec) {
1082
2016-07-06
pjp
dolog(LOG_INFO, "WARNING DNSSEC DNSKEY/DS/NSEC3PARAM/TLSA RR but no dnssec enabled!\n");
1083
2015-06-20
pjp
}
1084
2015-06-20
pjp
1085
2014-11-21
pjp
if (strcasecmp($3, "dnskey") == 0) {
1086
2020-07-06
pjp
if (fill_dnskey(mydb, $1, $3, $5, $7, $9, $11, $13) < 0) {
1087
2014-11-21
pjp
return -1;
1088
2014-11-21
pjp
}
1089
2014-11-21
pjp
1090
2019-11-04
pjp
#if DEBUG
1091
2014-11-21
pjp
if (debug)
1092
2014-11-21
pjp
printf(" %s DNSKEY\n", $1);
1093
2019-11-04
pjp
#endif
1094
2015-06-25
pjp
} else if (strcasecmp($3, "ds") == 0) {
1095
2020-07-06
pjp
if (fill_ds(mydb, $1, $3, $5, $7, $9, $11, $13) < 0) {
1096
2015-06-25
pjp
return -1;
1097
2015-06-25
pjp
}
1098
2019-11-04
pjp
#if DEBUG
1099
2015-06-26
pjp
if (debug)
1100
2015-06-26
pjp
printf(" %s DS\n", $1);
1101
2019-11-04
pjp
#endif
1102
2015-06-26
pjp
} else if (strcasecmp($3, "nsec3param") == 0) {
1103
2020-07-06
pjp
if (fill_nsec3param(mydb, $1, $3, $5, $7, $9, $11, $13) < 0) {
1104
2015-06-26
pjp
return -1;
1105
2015-06-26
pjp
}
1106
2019-11-04
pjp
#if DEBUG
1107
2015-06-26
pjp
if (debug)
1108
2015-06-26
pjp
printf(" %s NSEC3PARAM\n", $1);
1109
2019-11-04
pjp
#endif
1110
2015-11-10
pjp
} else if (strcasecmp($3, "tlsa") == 0) {
1111
2020-07-06
pjp
if (fill_tlsa(mydb, $1, $3, $5, $7, $9, $11, $13) < 0) {
1112
2015-11-10
pjp
return -1;
1113
2015-11-10
pjp
}
1114
2019-11-04
pjp
#if DEBUG
1115
2015-11-10
pjp
if (debug)
1116
2015-11-10
pjp
printf(" %s TLSA\n", $1);
1117
2019-11-04
pjp
#endif
1118
2014-11-21
pjp
} else {
1119
2014-11-21
pjp
if (debug)
1120
2014-11-21
pjp
printf("another dnskey like record I don't know?\n");
1121
2014-11-21
pjp
return (-1);
1122
2014-11-21
pjp
}
1123
2014-11-21
pjp
1124
2014-11-21
pjp
free ($1);
1125
2014-11-21
pjp
free ($3);
1126
2014-11-21
pjp
free ($13);
1127
2014-11-21
pjp
}
1128
2014-11-21
pjp
|
1129
2014-11-20
pjp
STRING COMMA STRING COMMA NUMBER COMMA STRING COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA STRING COMMA QUOTEDSTRING CRLF
1130
2014-11-20
pjp
{
1131
2014-11-20
pjp
if (strcasecmp($3, "rrsig") == 0) {
1132
2015-06-20
pjp
if (! dnssec) {
1133
2015-06-20
pjp
dolog(LOG_INFO, "WARNING DNSSEC RRSIG RR but no dnssec enabled!\n");
1134
2015-06-20
pjp
}
1135
2015-06-20
pjp
1136
2020-07-06
pjp
if (fill_rrsig(mydb, $1, $3, $5, $7, $9, $11, $13, $15, $17, $19, $21, $23) < 0) {
1137
2015-06-26
pjp
fprintf(stderr, "fill_rrsig failed\n");
1138
2014-11-20
pjp
return -1;
1139
2014-11-20
pjp
}
1140
2014-11-20
pjp
1141
2019-11-04
pjp
#if DEBUG
1142
2014-11-20
pjp
if (debug)
1143
2014-11-20
pjp
printf(" %s RRSIG\n", $1);
1144
2019-11-04
pjp
#endif
1145
2014-11-20
pjp
} else {
1146
2014-11-20
pjp
if (debug)
1147
2014-11-20
pjp
printf("another rrsig like record I don't know?\n");
1148
2014-11-20
pjp
return (-1);
1149
2014-11-20
pjp
}
1150
2014-11-20
pjp
1151
2014-11-20
pjp
free ($1);
1152
2014-11-20
pjp
free ($3);
1153
2014-11-20
pjp
free ($7);
1154
2014-11-20
pjp
free ($21);
1155
2014-11-20
pjp
free ($23);
1156
2014-11-20
pjp
}
1157
2014-11-21
pjp
|
1158
2014-11-21
pjp
STRING COMMA STRING COMMA NUMBER COMMA STRING COMMA QUOTEDSTRING CRLF
1159
2014-11-21
pjp
{
1160
2014-11-21
pjp
if (strcasecmp($3, "nsec") == 0) {
1161
2015-06-20
pjp
if (! dnssec) {
1162
2015-06-20
pjp
dolog(LOG_INFO, "WARNING DNSSEC NSEC RR but no dnssec enabled!\n");
1163
2015-06-20
pjp
}
1164
2015-06-20
pjp
1165
2020-07-06
pjp
if (fill_nsec(mydb, $1, $3, $5, $7, $9) < 0) {
1166
2014-11-21
pjp
return -1;
1167
2014-11-21
pjp
}
1168
2014-11-21
pjp
1169
2019-11-04
pjp
#if DEBUG
1170
2014-11-21
pjp
if (debug)
1171
2014-11-21
pjp
printf(" %s NSEC\n", $1);
1172
2019-11-04
pjp
#endif
1173
2014-11-21
pjp
} else {
1174
2014-11-21
pjp
if (debug)
1175
2014-11-21
pjp
printf("another nsec like record I don't know?\n");
1176
2014-11-21
pjp
return (-1);
1177
2014-11-21
pjp
}
1178
2014-11-21
pjp
1179
2014-11-21
pjp
free ($1);
1180
2014-11-21
pjp
free ($3);
1181
2014-11-21
pjp
free ($7);
1182
2014-11-21
pjp
free ($9);
1183
2014-11-21
pjp
}
1184
2015-06-26
pjp
|
1185
2015-06-26
pjp
STRING COMMA STRING COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA QUOTEDSTRING COMMA QUOTEDSTRING COMMA QUOTEDSTRING CRLF
1186
2015-06-26
pjp
{
1187
2015-06-26
pjp
if (strcasecmp($3, "nsec3") == 0) {
1188
2015-06-26
pjp
if (! dnssec) {
1189
2015-06-26
pjp
dolog(LOG_INFO, "WARNING DNSSEC NSEC3 RR but no dnssec enabled!\n");
1190
2015-06-26
pjp
}
1191
2015-06-26
pjp
1192
2020-07-06
pjp
if (fill_nsec3(mydb, $1, $3, $5, $7, $9, $11, $13, $15, $17) < 0) {
1193
2015-06-26
pjp
return -1;
1194
2015-06-26
pjp
}
1195
2015-06-26
pjp
1196
2019-11-04
pjp
#if DEBUG
1197
2015-06-26
pjp
if (debug)
1198
2015-06-26
pjp
printf(" %s NSEC3\n", $1);
1199
2019-11-04
pjp
#endif
1200
2015-06-26
pjp
}
1201
2015-06-26
pjp
1202
2015-06-26
pjp
1203
2015-06-26
pjp
1204
2015-06-26
pjp
free ($1);
1205
2015-06-26
pjp
free ($3);
1206
2015-06-26
pjp
free ($13);
1207
2015-06-26
pjp
free ($15);
1208
2015-06-26
pjp
free ($17);
1209
2015-06-26
pjp
}
1210
2020-07-23
pjp
|
1211
2020-07-23
pjp
STRING COMMA STRING COMMA NUMBER COMMA NUMBER COMMA STRING COMMA QUOTEDSTRING CRLF
1212
2020-07-23
pjp
{
1213
2020-07-23
pjp
if (strcasecmp($3, "caa") == 0) {
1214
2020-07-23
pjp
if (fill_caa(mydb, $1, $3, $5, $7, $9, $11) < 0) {
1215
2020-07-23
pjp
return -1;
1216
2020-07-23
pjp
}
1217
2020-07-23
pjp
1218
2020-07-23
pjp
#if DEBUG
1219
2020-07-23
pjp
if (debug)
1220
2020-07-23
pjp
printf("%s CAA -> %lld %s \"%s\"\n", $1, $7, $9, $11);
1221
2020-07-23
pjp
#endif
1222
2020-07-23
pjp
1223
2020-07-23
pjp
} else {
1224
2020-07-23
pjp
if (debug)
1225
2020-07-23
pjp
printf("another record I don't know about?");
1226
2020-07-23
pjp
return (-1);
1227
2020-07-23
pjp
}
1228
2020-07-23
pjp
1229
2020-07-23
pjp
free ($1);
1230
2020-07-23
pjp
free ($3);
1231
2020-07-23
pjp
free ($9);
1232
2020-07-23
pjp
free ($11);
1233
2020-07-23
pjp
1234
2020-07-23
pjp
}
1235
2020-07-23
pjp
|
1236
2020-07-23
pjp
STRING COMMA STRING COMMA NUMBER COMMA QUOTEDSTRING COMMA QUOTEDSTRING CRLF
1237
2020-07-23
pjp
{
1238
2020-07-23
pjp
/* HINFO */
1239
2020-07-23
pjp
if (strcasecmp($3, "hinfo") == 0) {
1240
2020-07-23
pjp
if (fill_hinfo(mydb, $1, $3, $5, $7, $9) < 0) {
1241
2020-07-23
pjp
return -1;
1242
2020-07-23
pjp
}
1243
2020-07-23
pjp
1244
2020-07-23
pjp
#if DEBUG
1245
2020-07-23
pjp
if (debug)
1246
2020-07-23
pjp
printf("%s HINFO -> \"%s\" \"%s\"\n", $1, $7, $9);
1247
2020-07-23
pjp
#endif
1248
2020-07-23
pjp
1249
2020-07-23
pjp
} else {
1250
2020-07-23
pjp
if (debug)
1251
2020-07-23
pjp
printf("another record I don't know about?");
1252
2020-07-23
pjp
return (-1);
1253
2020-07-23
pjp
}
1254
2020-07-23
pjp
1255
2020-07-23
pjp
free ($1);
1256
2020-07-23
pjp
free ($3);
1257
2020-07-23
pjp
free ($7);
1258
2020-07-23
pjp
free ($9);
1259
2020-07-23
pjp
}
1260
2020-07-23
pjp
|
1261
2020-07-23
pjp
STRING COMMA STRING COMMA NUMBER COMMA STRING COMMA STRING CRLF
1262
2020-07-23
pjp
{
1263
2020-07-23
pjp
/* RP */
1264
2020-07-23
pjp
if (strcasecmp($3, "rp") == 0) {
1265
2020-07-23
pjp
if (fill_rp(mydb, $1, $3, $5, $7, $9) < 0) {
1266
2020-07-23
pjp
return -1;
1267
2020-07-23
pjp
}
1268
2020-07-23
pjp
1269
2020-07-23
pjp
#if DEBUG
1270
2020-07-23
pjp
if (debug)
1271
2020-07-23
pjp
printf("%s RP -> %s %s\n", $1, $7, $9);
1272
2020-07-23
pjp
#endif
1273
2020-07-23
pjp
1274
2020-07-23
pjp
} else {
1275
2020-07-23
pjp
if (debug)
1276
2020-07-23
pjp
printf("another record I don't know about?");
1277
2020-07-23
pjp
return (-1);
1278
2020-07-23
pjp
}
1279
2020-07-23
pjp
1280
2020-07-23
pjp
free ($1);
1281
2020-07-23
pjp
free ($3);
1282
2020-07-23
pjp
free ($7);
1283
2020-07-23
pjp
free ($9);
1284
2020-07-23
pjp
}
1285
2014-11-14
pjp
| comment CRLF
1286
2014-11-14
pjp
;
1287
2014-11-14
pjp
1288
2014-11-14
pjp
1289
2014-11-14
pjp
options:
1290
2014-11-14
pjp
OPTIONS optionslabel optionscontent
1291
2014-11-14
pjp
{
1292
2014-11-14
pjp
if ((confstatus & CONFIG_VERSION) != CONFIG_VERSION) {
1293
2014-11-14
pjp
dolog(LOG_INFO, "There must be a version at the top of the first configfile\n");
1294
2014-11-14
pjp
return (-1);
1295
2014-11-14
pjp
}
1296
2014-11-14
pjp
}
1297
2014-11-14
pjp
;
1298
2014-11-14
pjp
1299
2014-11-14
pjp
optionslabel:
1300
2014-11-14
pjp
QUOTEDSTRING
1301
2014-11-14
pjp
;
1302
2014-11-14
pjp
1303
2014-11-14
pjp
optionscontent:
1304
2014-11-14
pjp
OBRACE optionsstatements EBRACE CRLF
1305
2014-11-14
pjp
| OBRACE CRLF optionsstatements EBRACE CRLF
1306
2014-11-14
pjp
;
1307
2014-11-14
pjp
1308
2014-11-14
pjp
optionsstatements:
1309
2014-11-14
pjp
optionsstatement
1310
2014-11-14
pjp
| optionsstatements optionsstatement
1311
2014-11-14
pjp
;
1312
2014-11-14
pjp
1313
2014-11-14
pjp
optionsstatement:
1314
2014-11-14
pjp
1315
2014-11-14
pjp
STRING SEMICOLON CRLF
1316
2014-11-14
pjp
{
1317
2018-07-11
pjp
if (file->descend == DESCEND_YES) {
1318
2018-07-11
pjp
if (strcasecmp($1, "dnssec") == 0) {
1319
2018-07-11
pjp
dolog(LOG_DEBUG, "DNSSEC enabled\n");
1320
2018-07-11
pjp
dnssec = 1;
1321
2018-07-11
pjp
} else if (strcasecmp($1, "log") == 0) {
1322
2018-07-11
pjp
dolog(LOG_DEBUG, "logging on\n");
1323
2018-07-11
pjp
lflag = 1;
1324
2020-04-23
pjp
} else if (strcasecmp($1, "tcp-on-any-only") == 0) {
1325
2020-04-23
pjp
dolog(LOG_DEBUG, "TCP on ANY only\n");
1326
2020-04-23
pjp
tcpanyonly = 1;
1327
2018-07-11
pjp
}
1328
2014-11-14
pjp
}
1329
2014-11-14
pjp
}
1330
2014-11-14
pjp
|
1331
2014-11-14
pjp
STRING QUOTEDSTRING SEMICOLON CRLF
1332
2014-11-14
pjp
{
1333
2018-07-11
pjp
if (file->descend == DESCEND_YES) {
1334
2018-07-11
pjp
if (strcasecmp($1, "interface") == 0) {
1335
2018-07-11
pjp
iflag = 1;
1336
2018-07-11
pjp
if (icount > 253) {
1337
2018-07-11
pjp
dolog(LOG_ERR, "too many interface keywords in options\n");
1338
2018-07-11
pjp
return (-1);
1339
2018-07-11
pjp
}
1340
2018-07-11
pjp
1341
2018-07-11
pjp
dolog(LOG_DEBUG, "interface \"%s\" added\n", $2);
1342
2018-07-11
pjp
interface_list[icount++] = $2;
1343
2018-07-11
pjp
} else if (strcasecmp($1, "versionstring") == 0) {
1344
2018-07-11
pjp
if (strlen($2) > 255) {
1345
2018-07-11
pjp
dolog(LOG_ERR, "versionstring too long\n");
1346
2018-07-11
pjp
return (-1);
1347
2018-07-11
pjp
}
1348
2015-09-05
pjp
1349
2018-07-11
pjp
versionstring = strdup($2);
1350
2018-07-11
pjp
vslen = strlen(versionstring);
1351
2018-07-11
pjp
}
1352
2014-11-14
pjp
}
1353
2014-11-14
pjp
}
1354
2014-11-14
pjp
|
1355
2019-07-09
pjp
PORT NUMBER SEMICOLON CRLF
1356
2019-07-09
pjp
{
1357
2019-07-09
pjp
port = $2 & 0xffff;
1358
2019-07-09
pjp
dolog(LOG_DEBUG, "listening on port %d\n", port);
1359
2019-07-09
pjp
}
1360
2019-07-09
pjp
|
1361
2015-12-19
pjp
STRING NUMBER SEMICOLON CRLF
1362
2014-11-14
pjp
{
1363
2018-07-11
pjp
if (file->descend == DESCEND_YES) {
1364
2018-07-11
pjp
if (strcasecmp($1, "fork") == 0) {
1365
2018-07-11
pjp
dolog(LOG_DEBUG, "forking %d times\n", $2);
1366
2018-07-11
pjp
nflag = $2;
1367
2018-07-11
pjp
} else if (strcasecmp($1, "ratelimit-pps") == 0) {
1368
2018-07-11
pjp
if ($2 > 127 || $2 < 1) {
1369
2018-07-11
pjp
dolog(LOG_ERR, "ratelimit packets per second must be between 1 and 127, or leave it off!\n");
1370
2018-07-11
pjp
return -1;
1371
2018-07-11
pjp
}
1372
2018-07-11
pjp
ratelimit = 1;
1373
2018-07-11
pjp
ratelimit_packets_per_second = $2;
1374
2019-02-04
pjp
dolog(LOG_DEBUG, "ratelimiting to %d packets per second\n", ratelimit_packets_per_second);
1375
2020-09-30
pjp
} else if (strcasecmp($1, "max-udp-payload") == 0) {
1376
2020-09-30
pjp
max_udp_payload = $2;
1377
2020-09-30
pjp
1378
2020-09-30
pjp
dolog(LOG_DEBUG, "max-udp-payload is now %u\n", max_udp_payload);
1379
2021-01-08
pjp
}
1380
2021-01-08
pjp
1381
2018-07-11
pjp
1382
2014-11-14
pjp
}
1383
2014-11-14
pjp
}
1384
2014-11-14
pjp
|
1385
2015-12-19
pjp
STRING ipcidr SEMICOLON CRLF
1386
2014-11-14
pjp
{
1387
2018-07-11
pjp
if (file->descend == DESCEND_YES) {
1388
2018-07-11
pjp
if (strcasecmp($1, "bind") == 0) {
1389
2018-07-11
pjp
bflag = 1;
1390
2018-07-11
pjp
if (bcount > 253) {
1391
2018-07-11
pjp
dolog(LOG_ERR, "too many bind keywords in options\n");
1392
2018-07-11
pjp
return (-1);
1393
2018-07-11
pjp
}
1394
2018-07-11
pjp
dolog(LOG_DEBUG, "binding to %s\n", $2);
1395
2018-07-11
pjp
bind_list[bcount++] = $2;
1396
2014-11-14
pjp
}
1397
2014-11-14
pjp
}
1398
2018-07-11
pjp
}
1399
2021-01-08
pjp
|
1400
2021-01-08
pjp
RDOMAIN NUMBER SEMICOLON CRLF
1401
2021-01-08
pjp
{
1402
2021-01-08
pjp
if ($2 > 255 || $2 < 0) {
1403
2021-01-08
pjp
dolog(LOG_INFO, "bad rdomain number (0-255)\n");
1404
2021-01-08
pjp
return -1;
1405
2021-01-08
pjp
}
1406
2021-01-08
pjp
1407
2021-01-08
pjp
rdomain = $2;
1408
2021-01-08
pjp
forward_rdomain = rdomain;
1409
2021-01-08
pjp
1410
2021-01-08
pjp
dolog(LOG_DEBUG, "default rdomain is now %u\n", rdomain);
1411
2021-01-08
pjp
}
1412
2014-11-14
pjp
| comment CRLF
1413
2014-11-14
pjp
;
1414
2019-11-25
pjp
1415
2019-02-24
pjp
/* tsig "these hosts" { .. } */
1416
2019-02-24
pjp
1417
2019-02-24
pjp
tsig:
1418
2019-02-24
pjp
TSIG tsiglabel tsigcontent
1419
2014-11-14
pjp
{
1420
2014-11-14
pjp
if ((confstatus & CONFIG_VERSION) != CONFIG_VERSION) {
1421
2014-11-14
pjp
dolog(LOG_INFO, "There must be a version at the top of the first configfile\n");
1422
2014-11-14
pjp
return (-1);
1423
2014-11-14
pjp
}
1424
2014-11-14
pjp
}
1425
2014-11-14
pjp
;
1426
2014-11-14
pjp
1427
2019-02-24
pjp
tsiglabel:
1428
2019-02-24
pjp
QUOTEDSTRING
1429
2014-11-14
pjp
;
1430
2014-11-14
pjp
1431
2019-02-24
pjp
tsigcontent:
1432
2019-02-24
pjp
OBRACE tsigstatements EBRACE
1433
2019-02-24
pjp
| OBRACE CRLF tsigstatements EBRACE
1434
2014-11-14
pjp
;
1435
2014-11-14
pjp
1436
2019-02-24
pjp
tsigstatements :
1437
2019-02-24
pjp
tsigstatements tsigstatement
1438
2019-02-24
pjp
| tsigstatement
1439
2019-02-24
pjp
;
1440
2014-11-14
pjp
1441
2019-02-24
pjp
tsigstatement : ipcidr SEMICOLON CRLF
1442
2019-02-24
pjp
{
1443
2019-02-24
pjp
char prefixlength[INET_ADDRSTRLEN];
1444
2019-02-24
pjp
char *dst;
1445
2019-02-24
pjp
1446
2019-02-24
pjp
1447
2019-02-24
pjp
if (file->descend == DESCEND_YES) {
1448
2019-02-24
pjp
if ((dst = get_prefixlen($1, (char *)&prefixlength, sizeof(prefixlength))) == NULL) {
1449
2019-02-24
pjp
return (-1);
1450
2019-02-24
pjp
}
1451
2019-02-24
pjp
1452
2019-02-24
pjp
if (insert_tsig(dst, prefixlength) < 0) {
1453
2019-02-24
pjp
dolog(LOG_ERR, "insert_tsig, line %d\n", file->lineno);
1454
2019-02-24
pjp
return (-1);
1455
2019-02-24
pjp
}
1456
2018-07-11
pjp
1457
2019-02-24
pjp
if (debug)
1458
2019-02-24
pjp
printf("tsig inserted %s address\n", $1);
1459
2018-07-11
pjp
1460
2019-02-24
pjp
tsig = 1;
1461
2015-12-19
pjp
1462
2019-02-24
pjp
free (dst);
1463
2019-02-24
pjp
}
1464
2014-11-14
pjp
1465
2019-02-24
pjp
free ($1);
1466
2014-11-14
pjp
}
1467
2019-02-24
pjp
| comment CRLF
1468
2019-02-24
pjp
;
1469
2014-11-14
pjp
1470
2021-01-07
pjp
/* tsigpassname "these names" { .. } */
1471
2021-01-07
pjp
1472
2021-01-07
pjp
tsigpassname:
1473
2021-01-07
pjp
TSIGPASSNAME tsigpassnamelabel tsigpassnamecontent
1474
2021-01-07
pjp
{
1475
2021-01-07
pjp
if ((confstatus & CONFIG_VERSION) != CONFIG_VERSION) {
1476
2021-01-07
pjp
dolog(LOG_INFO, "There must be a version at the top of the first configfile\n");
1477
2021-01-07
pjp
return (-1);
1478
2021-01-07
pjp
}
1479
2021-01-07
pjp
}
1480
2021-01-07
pjp
;
1481
2021-01-07
pjp
1482
2021-01-07
pjp
tsigpassnamelabel:
1483
2021-01-07
pjp
QUOTEDSTRING
1484
2021-01-07
pjp
;
1485
2021-01-07
pjp
1486
2021-01-07
pjp
tsigpassnamecontent:
1487
2021-01-07
pjp
OBRACE tsigpassnamestatements EBRACE
1488
2021-01-07
pjp
| OBRACE CRLF tsigpassnamestatements EBRACE
1489
2021-01-07
pjp
;
1490
2021-01-07
pjp
1491
2021-01-07
pjp
tsigpassnamestatements :
1492
2021-01-07
pjp
tsigpassnamestatements tsigpassnamestatement
1493
2021-01-07
pjp
| tsigpassnamestatement
1494
2021-01-07
pjp
;
1495
2021-01-07
pjp
1496
2021-01-07
pjp
tsigpassnamestatement : QUOTEDSTRING SEMICOLON CRLF
1497
2021-01-07
pjp
{
1498
2021-01-07
pjp
if (insert_tsigpassname($1) != 0) {
1499
2021-01-07
pjp
dolog(LOG_INFO, "insert_tsigpassname failed\n");
1500
2021-01-07
pjp
return -1;
1501
2021-01-07
pjp
}
1502
2021-01-07
pjp
1503
2021-01-07
pjp
tsigpassname = 1;
1504
2021-01-07
pjp
free ($1);
1505
2021-01-07
pjp
}
1506
2021-01-07
pjp
| comment CRLF
1507
2021-01-07
pjp
;
1508
2021-01-07
pjp
1509
2020-07-16
pjp
/* passlist "these hosts" { .. } */
1510
2020-07-16
pjp
1511
2020-07-16
pjp
passlist:
1512
2020-07-16
pjp
PASSLIST passlistlabel passlistcontent
1513
2020-07-16
pjp
{
1514
2020-07-16
pjp
if ((confstatus & CONFIG_VERSION) != CONFIG_VERSION) {
1515
2020-07-16
pjp
dolog(LOG_INFO, "There must be a version at the top of the first configfile\n");
1516
2020-07-16
pjp
return (-1);
1517
2020-07-16
pjp
}
1518
2020-07-16
pjp
}
1519
2020-07-16
pjp
;
1520
2020-07-16
pjp
1521
2020-07-16
pjp
passlistlabel:
1522
2020-07-16
pjp
QUOTEDSTRING
1523
2020-07-16
pjp
;
1524
2020-07-16
pjp
1525
2020-07-16
pjp
passlistcontent:
1526
2020-07-16
pjp
OBRACE passliststatements EBRACE
1527
2020-07-16
pjp
| OBRACE CRLF passliststatements EBRACE
1528
2020-07-16
pjp
;
1529
2020-07-16
pjp
1530
2020-07-16
pjp
passliststatements :
1531
2020-07-16
pjp
passliststatements passliststatement
1532
2020-07-16
pjp
| passliststatement
1533
2020-07-16
pjp
;
1534
2020-07-16
pjp
1535
2020-07-16
pjp
passliststatement : ipcidr SEMICOLON CRLF
1536
2020-07-16
pjp
{
1537
2014-11-14
pjp
char prefixlength[INET_ADDRSTRLEN];
1538
2014-11-14
pjp
char *dst;
1539
2014-11-14
pjp
1540
2014-11-14
pjp
1541
2018-07-11
pjp
if (file->descend == DESCEND_YES) {
1542
2018-07-11
pjp
if ((dst = get_prefixlen($1, (char *)&prefixlength, sizeof(prefixlength))) == NULL) {
1543
2018-07-11
pjp
return (-1);
1544
2018-07-11
pjp
}
1545
2014-11-14
pjp
1546
2020-07-16
pjp
if (insert_passlist(dst, prefixlength) < 0) {
1547
2020-07-16
pjp
dolog(LOG_ERR, "insert_passlist, line %d\n", file->lineno);
1548
2018-07-11
pjp
return (-1);
1549
2018-07-11
pjp
}
1550
2018-07-11
pjp
1551
2018-07-11
pjp
if (debug)
1552
2020-07-16
pjp
printf("passlist inserted %s address\n", $1);
1553
2018-07-11
pjp
1554
2020-07-16
pjp
passlist = 1;
1555
2018-07-11
pjp
1556
2018-07-11
pjp
free (dst);
1557
2014-11-14
pjp
}
1558
2015-12-19
pjp
1559
2014-11-14
pjp
free ($1);
1560
2014-11-14
pjp
}
1561
2014-11-14
pjp
| comment CRLF
1562
2014-11-14
pjp
;
1563
2014-11-14
pjp
1564
2020-06-30
pjp
/* forward "these hosts" { .. } */
1565
2020-06-30
pjp
1566
2020-06-30
pjp
forward:
1567
2020-06-30
pjp
FORWARD forwardlabel forwardcontent
1568
2020-06-30
pjp
{
1569
2020-06-30
pjp
if ((confstatus & CONFIG_VERSION) != CONFIG_VERSION) {
1570
2020-06-30
pjp
dolog(LOG_INFO, "There must be a version at the top of the first configfile\n");
1571
2020-06-30
pjp
return (-1);
1572
2020-06-30
pjp
}
1573
2020-06-30
pjp
1574
2020-06-30
pjp
forward = 1;
1575
2020-06-30
pjp
}
1576
2020-06-30
pjp
;
1577
2020-06-30
pjp
1578
2020-06-30
pjp
forwardlabel:
1579
2020-06-30
pjp
QUOTEDSTRING
1580
2020-06-30
pjp
;
1581
2020-06-30
pjp
1582
2020-06-30
pjp
forwardcontent:
1583
2020-06-30
pjp
OBRACE forwardstatements EBRACE
1584
2020-06-30
pjp
| OBRACE CRLF forwardstatements EBRACE
1585
2020-06-30
pjp
;
1586
2020-06-30
pjp
1587
2020-06-30
pjp
forwardstatements :
1588
2020-06-30
pjp
forwardstatements forwardstatement
1589
2020-06-30
pjp
| forwardstatement
1590
2020-06-30
pjp
;
1591
2020-06-30
pjp
1592
2020-07-01
pjp
forwardstatement : INCOMINGTSIG STRING SEMICOLON CRLF
1593
2020-06-30
pjp
{
1594
2020-07-01
pjp
if (strcmp($2, "yes") == 0 ||
1595
2020-07-01
pjp
strcmp($2, "on") == 0 ||
1596
2020-07-01
pjp
strcmp($2, "1") == 0) {
1597
2020-07-01
pjp
forwardtsig = 1;
1598
2020-07-01
pjp
}
1599
2020-07-01
pjp
1600
2020-07-01
pjp
free($2);
1601
2020-06-30
pjp
}
1602
2020-06-30
pjp
| DESTINATION ipcidr PORT NUMBER STRING STRING SEMICOLON CRLF
1603
2020-06-30
pjp
{
1604
2020-07-01
pjp
struct sockaddr_storage sso;
1605
2020-07-01
pjp
struct sockaddr_in *sin = (struct sockaddr_in *)&sso;
1606
2020-07-01
pjp
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sso;
1607
2020-07-01
pjp
1608
2020-07-01
pjp
memset(&sso, 0, sizeof(struct sockaddr_storage));
1609
2020-07-01
pjp
1610
2020-07-03
pjp
if (strchr($2, ':') != NULL) {
1611
2020-07-03
pjp
inet_pton(AF_INET6, $2, &sin6->sin6_addr);
1612
2020-07-03
pjp
sin6->sin6_family = AF_INET6;
1613
2020-07-03
pjp
sin6->sin6_port = htons($4);
1614
2020-07-13
pjp
#ifndef __linux__
1615
2020-07-03
pjp
sin6->sin6_len = sizeof(struct sockaddr_in6);
1616
2020-07-13
pjp
#endif
1617
2020-07-03
pjp
insert_forward(AF_INET6, &sso, $4, $6);
1618
2020-07-03
pjp
} else {
1619
2020-07-03
pjp
inet_pton(AF_INET, $2, &sin->sin_addr);
1620
2020-07-03
pjp
sin->sin_family = AF_INET;
1621
2020-07-03
pjp
sin->sin_port = htons($4);
1622
2020-07-03
pjp
insert_forward(AF_INET, &sso, $4, $6);
1623
2020-07-03
pjp
}
1624
2020-07-01
pjp
1625
2020-07-01
pjp
1626
2020-07-01
pjp
free($5);
1627
2020-07-01
pjp
free($6);
1628
2020-06-30
pjp
}
1629
2020-07-06
pjp
| CACHE STRING SEMICOLON CRLF
1630
2020-07-06
pjp
{
1631
2020-07-06
pjp
if (strcmp($2, "yes") == 0 ||
1632
2020-07-06
pjp
strcmp($2, "on") == 0)
1633
2020-07-06
pjp
1634
2020-07-06
pjp
cache = 1;
1635
2020-07-06
pjp
1636
2020-07-06
pjp
1637
2020-07-06
pjp
free ($2);
1638
2020-07-06
pjp
}
1639
2020-07-17
pjp
| STRICTX20 STRING SEMICOLON CRLF
1640
2020-07-17
pjp
{
1641
2020-07-17
pjp
if (strcmp($2, "no") == 0 ||
1642
2020-07-17
pjp
strcmp($2, "off") == 0)
1643
2020-07-17
pjp
1644
2020-07-17
pjp
strictx20i = 0;
1645
2020-07-17
pjp
1646
2020-07-17
pjp
free ($2);
1647
2020-07-17
pjp
}
1648
2021-01-07
pjp
| FUDGE NUMBER SEMICOLON CRLF
1649
2021-01-07
pjp
{
1650
2021-01-07
pjp
if ($2 > 65535 || $2 < 1) {
1651
2021-01-07
pjp
dolog(LOG_INFO, "Fudge value out of Range (1-65535)\n");
1652
2021-01-07
pjp
return (-1);
1653
2021-01-07
pjp
}
1654
2021-01-07
pjp
1655
2021-01-07
pjp
fudge_forward = $2;
1656
2021-01-07
pjp
}
1657
2021-01-08
pjp
| RDOMAIN NUMBER SEMICOLON CRLF
1658
2021-01-08
pjp
{
1659
2021-01-08
pjp
if ($2 > 255 || $2 < 0) {
1660
2021-01-08
pjp
dolog(LOG_INFO, "rdomain value out of Range (0-255)\n");
1661
2021-01-08
pjp
return (-1);
1662
2021-01-08
pjp
}
1663
2021-01-08
pjp
1664
2021-01-08
pjp
forward_rdomain = $2;
1665
2021-01-08
pjp
}
1666
2020-06-30
pjp
| comment CRLF
1667
2020-06-30
pjp
;
1668
2020-06-30
pjp
1669
2019-06-26
pjp
/* filter "these hosts" { .. } */
1670
2014-11-14
pjp
1671
2019-06-26
pjp
filter:
1672
2019-06-26
pjp
FILTER filterlabel filtercontent
1673
2014-11-14
pjp
{
1674
2014-11-14
pjp
if ((confstatus & CONFIG_VERSION) != CONFIG_VERSION) {
1675
2014-11-14
pjp
dolog(LOG_INFO, "There must be a version at the top of the first configfile\n");
1676
2014-11-14
pjp
return (-1);
1677
2014-11-14
pjp
}
1678
2014-11-14
pjp
}
1679
2014-11-14
pjp
;
1680
2014-11-14
pjp
1681
2019-06-26
pjp
filterlabel:
1682
2014-11-14
pjp
QUOTEDSTRING
1683
2014-11-14
pjp
;
1684
2014-11-14
pjp
1685
2019-06-26
pjp
filtercontent:
1686
2019-06-26
pjp
OBRACE filterstatements EBRACE
1687
2019-06-26
pjp
| OBRACE CRLF filterstatements EBRACE
1688
2014-11-14
pjp
;
1689
2014-11-14
pjp
1690
2019-06-26
pjp
filterstatements :
1691
2019-06-26
pjp
filterstatements filterstatement
1692
2019-06-26
pjp
| filterstatement
1693
2014-11-14
pjp
;
1694
2014-11-14
pjp
1695
2019-06-26
pjp
filterstatement : ipcidr SEMICOLON CRLF
1696
2015-12-19
pjp
{
1697
2014-11-14
pjp
char prefixlength[INET_ADDRSTRLEN];
1698
2014-11-14
pjp
char *dst;
1699
2015-12-19
pjp
1700
2014-11-14
pjp
1701
2018-07-11
pjp
if (file->descend == DESCEND_YES) {
1702
2018-07-11
pjp
if ((dst = get_prefixlen($1, (char *)&prefixlength, sizeof(prefixlength))) == NULL) {
1703
2018-07-11
pjp
return (-1);
1704
2018-07-11
pjp
}
1705
2015-12-19
pjp
1706
2019-06-26
pjp
if (insert_filter(dst, prefixlength) < 0) {
1707
2019-06-26
pjp
dolog(LOG_ERR, "insert_filter, line %d\n", file->lineno);
1708
2018-07-11
pjp
return (-1);
1709
2018-07-11
pjp
}
1710
2018-07-11
pjp
1711
2019-06-26
pjp
if (debug)
1712
2019-06-26
pjp
printf("filter inserted %s address\n", $1);
1713
2019-06-26
pjp
1714
2018-07-11
pjp
free (dst);
1715
2014-11-14
pjp
}
1716
2018-07-11
pjp
1717
2014-11-14
pjp
free ($1);
1718
2015-12-19
pjp
}
1719
2015-12-19
pjp
| comment CRLF
1720
2015-12-19
pjp
;
1721
2014-11-14
pjp
1722
2015-12-19
pjp
/* axfr-for "these hosts" { .. } */
1723
2014-11-14
pjp
1724
2015-12-19
pjp
axfr:
1725
2015-12-19
pjp
AXFRFOR axfrlabel axfrcontent
1726
2015-12-19
pjp
{
1727
2014-11-14
pjp
if ((confstatus & CONFIG_VERSION) != CONFIG_VERSION) {
1728
2014-11-14
pjp
dolog(LOG_INFO, "There must be a version at the top of the first configfile\n");
1729
2014-11-14
pjp
return (-1);
1730
2014-11-14
pjp
}
1731
2014-11-14
pjp
}
1732
2014-11-14
pjp
;
1733
2014-11-14
pjp
1734
2015-12-19
pjp
axfrlabel:
1735
2014-11-14
pjp
QUOTEDSTRING
1736
2014-11-14
pjp
;
1737
2014-11-14
pjp
1738
2015-12-19
pjp
axfrcontent:
1739
2015-12-19
pjp
OBRACE axfrstatements EBRACE
1740
2015-12-19
pjp
| OBRACE CRLF axfrstatements EBRACE
1741
2014-11-14
pjp
;
1742
2014-11-14
pjp
1743
2015-12-19
pjp
axfrstatements :
1744
2015-12-19
pjp
axfrstatements axfrstatement
1745
2015-12-19
pjp
| axfrstatement
1746
2014-11-14
pjp
;
1747
2014-11-14
pjp
1748
2015-12-19
pjp
axfrstatement : ipcidr SEMICOLON CRLF
1749
2015-12-19
pjp
{
1750
2014-11-14
pjp
char prefixlength[INET_ADDRSTRLEN];
1751
2014-11-14
pjp
char *dst;
1752
2015-12-19
pjp
1753
2014-11-14
pjp
1754
2018-07-11
pjp
if (file->descend == DESCEND_YES) {
1755
2018-07-11
pjp
if ((dst = get_prefixlen($1, (char *)&prefixlength, sizeof(prefixlength))) == NULL) {
1756
2018-07-11
pjp
return (-1);
1757
2018-07-11
pjp
}
1758
2015-12-19
pjp
1759
2018-07-11
pjp
if (insert_axfr(dst, prefixlength) < 0) {
1760
2018-07-11
pjp
dolog(LOG_ERR, "insert_axfr, line %d\n", file->lineno);
1761
2018-07-11
pjp
return (-1);
1762
2018-07-11
pjp
}
1763
2018-07-11
pjp
1764
2018-07-11
pjp
if (debug)
1765
2018-07-11
pjp
printf("axfr inserted %s address\n", $1);
1766
2018-07-11
pjp
1767
2018-07-11
pjp
free (dst);
1768
2018-07-11
pjp
1769
2014-11-14
pjp
}
1770
2014-11-14
pjp
1771
2014-11-14
pjp
free ($1);
1772
2015-12-19
pjp
}
1773
2015-12-19
pjp
| comment CRLF
1774
2015-12-19
pjp
;
1775
2014-11-14
pjp
1776
2014-11-14
pjp
/* region "lacnic" { .. } */
1777
2014-11-14
pjp
1778
2014-11-14
pjp
region:
1779
2014-11-14
pjp
REGION regionlabel regioncontent
1780
2014-11-14
pjp
{
1781
2014-11-14
pjp
if ((confstatus & CONFIG_VERSION) != CONFIG_VERSION) {
1782
2014-11-14
pjp
dolog(LOG_INFO, "There must be a version at the top of the first configfile\n");
1783
2014-11-14
pjp
return (-1);
1784
2014-11-14
pjp
}
1785
2014-11-14
pjp
1786
2014-11-14
pjp
region++;
1787
2014-11-14
pjp
}
1788
2014-11-14
pjp
;
1789
2014-11-14
pjp
1790
2014-11-14
pjp
regionlabel:
1791
2014-11-14
pjp
QUOTEDSTRING
1792
2014-11-14
pjp
;
1793
2014-11-14
pjp
1794
2014-11-14
pjp
regioncontent:
1795
2014-11-14
pjp
OBRACE regionstatements EBRACE
1796
2014-11-14
pjp
| OBRACE CRLF regionstatements EBRACE
1797
2014-11-14
pjp
;
1798
2014-11-14
pjp
1799
2014-11-14
pjp
regionstatements :
1800
2014-11-14
pjp
regionstatements regionstatement
1801
2014-11-14
pjp
| regionstatement
1802
2014-11-14
pjp
;
1803
2014-11-14
pjp
1804
2014-11-14
pjp
regionstatement : ipcidr SEMICOLON CRLF
1805
2014-11-14
pjp
{
1806
2014-11-14
pjp
char prefixlength[INET_ADDRSTRLEN];
1807
2014-11-14
pjp
char *dst;
1808
2014-11-14
pjp
1809
2018-07-11
pjp
if (file->descend == DESCEND_YES) {
1810
2018-07-11
pjp
if ((dst = get_prefixlen($1, (char *)&prefixlength, sizeof(prefixlength))) == NULL) {
1811
2018-07-11
pjp
return (-1);
1812
2018-07-11
pjp
}
1813
2014-11-14
pjp
1814
2018-07-11
pjp
if (insert_region(dst, prefixlength, region) < 0) {
1815
2018-07-11
pjp
dolog(LOG_ERR, "insert_region, line %d\n", file->lineno);
1816
2018-07-11
pjp
return (-1);
1817
2018-07-11
pjp
}
1818
2018-07-11
pjp
1819
2018-07-11
pjp
if (debug)
1820
2018-07-11
pjp
printf("%s ipv4 address\n", dst);
1821
2018-07-11
pjp
1822
2018-07-11
pjp
free (dst);
1823
2018-07-11
pjp
1824
2014-11-14
pjp
}
1825
2014-11-14
pjp
1826
2014-11-14
pjp
free ($1);
1827
2014-11-14
pjp
}
1828
2014-11-14
pjp
| comment CRLF
1829
2014-11-14
pjp
;
1830
2014-11-14
pjp
1831
2014-11-14
pjp
ipcidr:
1832
2014-11-14
pjp
IP
1833
2014-11-14
pjp
| IPV6
1834
2014-11-14
pjp
;
1835
2014-11-14
pjp
1836
2014-11-14
pjp
1837
2014-11-14
pjp
%%
1838
2014-11-14
pjp
1839
2014-11-14
pjp
struct tab {
1840
2014-11-14
pjp
char *val;
1841
2014-11-14
pjp
int num;
1842
2014-11-14
pjp
int state;
1843
2014-11-14
pjp
};
1844
2014-11-14
pjp
1845
2014-11-14
pjp
1846
2014-11-14
pjp
struct tab cmdtab[] = {
1847
2014-11-14
pjp
{ "axfrport", AXFRPORT, 0},
1848
2014-11-14
pjp
{ "axfr-for", AXFRFOR, STATE_IP },
1849
2020-09-24
pjp
{ "bytelimit", BYTELIMIT, 0 },
1850
2020-07-06
pjp
{ "cache", CACHE, 0 },
1851
2020-06-30
pjp
{ "destination", DESTINATION, 0 },
1852
2014-11-14
pjp
{ "filter", FILTER, STATE_IP },
1853
2020-06-30
pjp
{ "forward", FORWARD, 0 },
1854
2021-01-07
pjp
{ "fudge", FUDGE, 0 },
1855
2014-11-14
pjp
{ "include", INCLUDE, 0 },
1856
2020-07-01
pjp
{ "incoming-tsig", INCOMINGTSIG, 0 },
1857
2019-02-04
pjp
{ "master", MASTER, 0 },
1858
2019-02-04
pjp
{ "masterport", MASTERPORT, 0 },
1859
2019-06-26
pjp
{ "mzone", MZONE, 0},
1860
2019-06-26
pjp
{ "notifybind", NOTIFYBIND, 0},
1861
2019-06-26
pjp
{ "notifydest", NOTIFYDEST, 0},
1862
2014-11-14
pjp
{ "options", OPTIONS, 0 },
1863
2020-07-16
pjp
{ "passlist", PASSLIST, STATE_IP },
1864
2019-07-09
pjp
{ "port", PORT, 0},
1865
2021-01-08
pjp
{ "rdomain", RDOMAIN, 0 },
1866
2014-11-14
pjp
{ "region", REGION, STATE_IP },
1867
2019-02-04
pjp
{ "rzone", RZONE, 0 },
1868
2020-07-17
pjp
{ "strictx20", STRICTX20, 0},
1869
2019-02-24
pjp
{ "tsig", TSIG, 0 },
1870
2019-02-24
pjp
{ "tsig-auth", TSIGAUTH, 0 },
1871
2021-01-07
pjp
{ "tsigpassname", TSIGPASSNAME, 0 },
1872
2014-11-14
pjp
{ "wildcard-only-for", WOF, STATE_IP },
1873
2014-11-14
pjp
{ "version", VERSION, 0 },
1874
2018-07-11
pjp
{ "zinclude", ZINCLUDE, 0 },
1875
2014-11-14
pjp
{ "zone", ZONE, 0 },
1876
2014-11-14
pjp
{ NULL, 0, 0}};
1877
2014-11-14
pjp
1878
2014-11-14
pjp
1879
2014-11-14
pjp
1880
2014-11-14
pjp
void
1881
2014-11-14
pjp
yyerror(const char *str)
1882
2014-11-14
pjp
{
1883
2014-11-14
pjp
dolog(LOG_ERR, "%s file: %s line: %d\n", str, file->name, file->lineno);
1884
2020-06-25
pjp
ddd_shutdown();
1885
2014-11-14
pjp
exit (1);
1886
2014-11-14
pjp
}
1887
2014-11-14
pjp
1888
2014-11-14
pjp
int
1889
2014-11-14
pjp
yywrap()
1890
2014-11-14
pjp
{
1891
2014-11-14
pjp
return 1;
1892
2014-11-14
pjp
}
1893
2014-11-14
pjp
1894
2014-11-14
pjp
int
1895
2019-11-14
pjp
parse_file(ddDB *db, char *filename, uint32_t flags)
1896
2014-11-14
pjp
{
1897
2019-02-04
pjp
int errors = 0;
1898
2014-11-14
pjp
1899
2014-11-14
pjp
mydb = db;
1900
2014-11-14
pjp
1901
2019-11-14
pjp
if (flags & PARSEFILE_FLAG_NOSOCKET)
1902
2019-11-14
pjp
pullzone = 0;
1903
2014-11-14
pjp
1904
2019-11-14
pjp
1905
2019-02-04
pjp
(void)add_rzone();
1906
2019-02-04
pjp
1907
2019-02-04
pjp
if ((file = pushfile(filename, 0, DESCEND_YES, NO_RZONEFILE)) == NULL) {
1908
2014-11-14
pjp
return (-1);
1909
2014-11-14
pjp
}
1910
2014-11-14
pjp
1911
2014-11-14
pjp
topfile = file;
1912
2014-11-14
pjp
1913
2019-02-04
pjp
1914
2014-11-14
pjp
if (yyparse() < 0) {
1915
2019-02-04
pjp
dolog(LOG_ERR, "error %d: %s line: %d\n", errors, file->name, file->lineno);
1916
2014-11-14
pjp
return (-1);
1917
2014-11-14
pjp
}
1918
2014-11-14
pjp
errors = file->errors;
1919
2014-11-14
pjp
popfile();
1920
2014-11-14
pjp
1921
2019-02-04
pjp
1922
2019-11-12
pjp
while (!TAILQ_EMPTY(&rzonefiles)) {
1923
2019-02-04
pjp
/* handle the rzone files */
1924
2019-11-12
pjp
topfile = file = TAILQ_FIRST(&rzonefiles);
1925
2019-02-04
pjp
1926
2019-02-04
pjp
if (yyparse() < 0) {
1927
2019-02-04
pjp
dolog(LOG_ERR, "error: %s line: %d\n", file->name, file->lineno);
1928
2019-02-04
pjp
return (-1);
1929
2019-02-04
pjp
}
1930
2019-02-04
pjp
1931
2019-02-04
pjp
errors = file->errors;
1932
2019-02-04
pjp
popfile();
1933
2019-02-04
pjp
}
1934
2019-02-04
pjp
1935
2019-02-04
pjp
1936
2016-12-28
pjp
#if DEBUG
1937
2014-11-14
pjp
dolog(LOG_INFO, "configuration file read\n");
1938
2016-12-28
pjp
#endif
1939
2014-11-14
pjp
1940
2014-11-14
pjp
return 0;
1941
2014-11-14
pjp
}
1942
2014-11-14
pjp
1943
2014-11-14
pjp
int
1944
2018-07-14
pjp
yylex(void)
1945
2014-11-14
pjp
{
1946
2014-11-14
pjp
struct tab *p;
1947
2018-01-01
pjp
static char buf[4096];
1948
2014-11-14
pjp
static char dst[INET6_ADDRSTRLEN];
1949
2014-11-14
pjp
char *cp = NULL;
1950
2014-11-14
pjp
int c, cpos;
1951
2014-11-14
pjp
static int setupstate = 0;
1952
2015-06-20
pjp
const char *errstr;
1953
2014-11-14
pjp
1954
2014-11-14
pjp
1955
2014-11-14
pjp
do {
1956
2014-11-14
pjp
c = lgetc(0);
1957
2014-11-14
pjp
} while ((c == ' ') || (c == '\t'));
1958
2014-11-14
pjp
1959
2019-02-04
pjp
if (c == EOF)
1960
2014-11-14
pjp
return 0;
1961
2014-11-14
pjp
1962
2014-11-14
pjp
if (c == '\n') {
1963
2014-11-14
pjp
file->lineno++;
1964
2014-11-14
pjp
1965
2014-11-14
pjp
while ((c = lgetc(0)) != EOF && (c == '\n' || c == '\t'))
1966
2014-11-14
pjp
if (c == '\n')
1967
2014-11-14
pjp
file->lineno++;
1968
2014-11-14
pjp
lungetc(c);
1969
2014-11-14
pjp
1970
2014-11-14
pjp
1971
2014-11-14
pjp
#ifdef LEXDEBUG
1972
2014-11-14
pjp
if (debug)
1973
2014-11-14
pjp
printf("returning %s\n", "crlf");
1974
2014-11-14
pjp
#endif
1975
2014-11-14
pjp
1976
2014-11-14
pjp
return CRLF;
1977
2014-11-14
pjp
}
1978
2014-11-14
pjp
1979
2014-11-14
pjp
switch (state) {
1980
2014-11-14
pjp
case STATE_IP:
1981
2014-11-14
pjp
if (c == ':' || isalnum(c)) {
1982
2014-11-14
pjp
lungetc(c);
1983
2014-11-14
pjp
get_ip(buf, sizeof(buf) - 1);
1984
2014-11-14
pjp
1985
2014-11-14
pjp
yylval.v.string = strdup(buf);
1986
2014-11-14
pjp
if (yylval.v.string == NULL) {
1987
2014-11-14
pjp
dolog(LOG_ERR, "yylex: %s\n", strerror(errno));
1988
2020-06-25
pjp
ddd_shutdown();
1989
2014-11-14
pjp
exit(1);
1990
2014-11-14
pjp
}
1991
2014-11-14
pjp
#ifdef LEXDEBUG
1992
2014-11-14
pjp
if (debug)
1993
2014-11-14
pjp
printf("returning %s\n", "IP");
1994
2014-11-14
pjp
#endif
1995
2014-11-14
pjp
return (IP);
1996
2014-11-14
pjp
}
1997
2014-11-14
pjp
/* FALLTHROUGH */
1998
2014-11-14
pjp
default:
1999
2014-11-14
pjp
if (c == '}') {
2000
2014-11-14
pjp
#ifdef LEXDEBUG
2001
2014-11-14
pjp
if (debug)
2002
2014-11-14
pjp
printf("returning %s\n", "ebrace");
2003
2014-11-14
pjp
#endif
2004
2014-11-14
pjp
setupstate = 0;
2005
2014-11-14
pjp
state = 0;
2006
2014-11-14
pjp
return EBRACE;
2007
2014-11-14
pjp
}
2008
2014-11-14
pjp
2009
2014-11-14
pjp
if (c == '{') {
2010
2014-11-14
pjp
if (setupstate)
2011
2014-11-14
pjp
state = setupstate;
2012
2014-11-14
pjp
#ifdef LEXDEBUG
2013
2014-11-14
pjp
if (debug)
2014
2014-11-14
pjp
printf("returning %s\n", "obrace");
2015
2014-11-14
pjp
#endif
2016
2014-11-14
pjp
return OBRACE;
2017
2014-11-14
pjp
}
2018
2014-11-14
pjp
2019
2014-11-14
pjp
if (c == '/') {
2020
2014-11-14
pjp
#ifdef LEXDEBUG
2021
2014-11-14
pjp
if (debug)
2022
2014-11-14
pjp
printf("returning %s\n", "slash");
2023
2014-11-14
pjp
#endif
2024
2014-11-14
pjp
return SLASH;
2025
2014-11-14
pjp
}
2026
2014-11-14
pjp
2027
2014-11-14
pjp
if (c == ',') {
2028
2014-11-14
pjp
#ifdef LEXDEBUG
2029
2014-11-14
pjp
if (debug)
2030
2014-11-14
pjp
printf("returning %s\n", "comma");
2031
2014-11-14
pjp
#endif
2032
2014-11-14
pjp
return COMMA;
2033
2014-11-14
pjp
}
2034
2014-11-14
pjp
2035
2014-11-14
pjp
2036
2014-11-14
pjp
if (c == ';') {
2037
2014-11-14
pjp
while ((c = lgetc(0)) != EOF && c != '\n');
2038
2014-11-14
pjp
lungetc(c);
2039
2014-11-14
pjp
#ifdef LEXDEBUG
2040
2014-11-14
pjp
if (debug)
2041
2014-11-14
pjp
printf("returning %s\n", "semicolon");
2042
2014-11-14
pjp
#endif
2043
2014-11-14
pjp
return SEMICOLON;
2044
2014-11-14
pjp
}
2045
2014-11-14
pjp
2046
2014-11-14
pjp
if (c == '#') {
2047
2014-11-14
pjp
while ((c = lgetc(0)) != EOF && c != '\n');
2048
2014-11-14
pjp
lungetc(c);
2049
2014-11-14
pjp
#ifdef LEXDEBUG
2050
2014-11-14
pjp
if (debug)
2051
2014-11-14
pjp
printf("returning %s\n", "pound");
2052
2014-11-14
pjp
#endif
2053
2014-11-14
pjp
return POUND;
2054
2014-11-14
pjp
}
2055
2014-11-14
pjp
2056
2014-11-14
pjp
if (c == '"') {
2057
2014-11-14
pjp
get_quotedstring(buf, sizeof(buf) - 1);
2058
2014-11-14
pjp
2059
2014-11-14
pjp
if ((cp = strrchr(buf, '"'))) {
2060
2014-11-14
pjp
cpos = cp - buf;
2061
2014-11-14
pjp
c = buf[cpos];
2062
2014-11-14
pjp
buf[cpos] = '\0';
2063
2014-11-14
pjp
}
2064
2014-11-14
pjp
2065
2014-11-14
pjp
yylval.v.string = strdup(buf);
2066
2014-11-14
pjp
if (yylval.v.string == NULL) {
2067
2014-11-14
pjp
dolog(LOG_ERR, "yylex: %s\n", strerror(errno));
2068
2020-06-25
pjp
ddd_shutdown();
2069
2014-11-14
pjp
exit(1);
2070
2014-11-14
pjp
}
2071
2014-11-14
pjp
2072
2014-11-14
pjp
#ifdef LEXDEBUG
2073
2014-11-14
pjp
if (debug)
2074
2014-11-14
pjp
printf("returning %s\n", "quotedstring");
2075
2014-11-14
pjp
#endif
2076
2014-11-14
pjp
return QUOTEDSTRING;
2077
2014-11-14
pjp
}
2078
2014-11-14
pjp
2079
2014-11-14
pjp
if (c == '*') {
2080
2014-11-14
pjp
yylval.v.string = strdup("*");
2081
2014-11-14
pjp
if (yylval.v.string == NULL) {
2082
2014-11-14
pjp
dolog(LOG_ERR, "yylex: %s\n", strerror(errno));
2083
2020-06-25
pjp
ddd_shutdown();
2084
2014-11-14
pjp
exit(1);
2085
2014-11-14
pjp
}
2086
2014-11-14
pjp
#ifdef LEXDEBUG
2087
2014-11-14
pjp
if (debug)
2088
2014-11-14
pjp
printf("returning %s\n", "string");
2089
2014-11-14
pjp
#endif
2090
2014-11-14
pjp
return STRING;
2091
2014-11-14
pjp
}
2092
2014-11-14
pjp
2093
2014-11-14
pjp
if (isalnum(c) || c == '.' || c == ':' || c == '-' || c == '_') {
2094
2014-11-14
pjp
lungetc(c);
2095
2014-11-14
pjp
get_string(buf, sizeof(buf) - 1);
2096
2014-11-14
pjp
2097
2014-11-14
pjp
if ((cp = strpbrk(buf, " \n"))) {
2098
2014-11-14
pjp
cpos = cp - buf;
2099
2014-11-14
pjp
c = buf[cpos];
2100
2014-11-14
pjp
buf[cpos] = '\0';
2101
2014-11-14
pjp
}
2102
2014-11-14
pjp
2103
2014-11-14
pjp
p = lookup(cmdtab, buf);
2104
2014-11-14
pjp
if (p != NULL) {
2105
2014-11-14
pjp
#ifdef LEXDEBUG
2106
2014-11-14
pjp
if (debug)
2107
2014-11-14
pjp
printf("returning %s\n", p->val);
2108
2014-11-14
pjp
#endif
2109
2014-11-14
pjp
yylval.v.string = strdup(p->val);
2110
2014-11-14
pjp
if (yylval.v.string == NULL) {
2111
2014-11-14
pjp
dolog(LOG_ERR, "yylex: %s\n", strerror(errno));
2112
2020-06-25
pjp
ddd_shutdown();
2113
2014-11-14
pjp
exit(1);
2114
2014-11-14
pjp
}
2115
2014-11-14
pjp
setupstate = p->state;
2116
2014-11-14
pjp
return (p->num);
2117
2014-11-14
pjp
}
2118
2014-11-14
pjp
2119
2014-11-14
pjp
yylval.v.string = strdup(buf);
2120
2014-11-14
pjp
if (yylval.v.string == NULL) {
2121
2014-11-14
pjp
dolog(LOG_ERR, "yylex: %s\n", strerror(errno));
2122
2020-06-25
pjp
ddd_shutdown();
2123
2014-11-14
pjp
exit(1);
2124
2014-11-14
pjp
}
2125
2014-11-14
pjp
2126
2014-11-14
pjp
2127
2014-11-14
pjp
memset(&dst, 0, sizeof(dst));
2128
2014-11-14
pjp
if (strchr(buf, ':') != NULL) {
2129
2014-11-14
pjp
if (inet_net_pton(AF_INET6, buf, &dst, sizeof(dst)) == -1) {
2130
2014-11-14
pjp
if (errno == EAFNOSUPPORT &&
2131
2014-11-14
pjp
temp_inet_net_pton_ipv6(buf, &dst, sizeof(dst)) != -1)
2132
2014-11-14
pjp
#if LEXDEBUG
2133
2014-11-14
pjp
if (debug)
2134
2014-11-14
pjp
printf("returning IPV6\n");
2135
2014-11-14
pjp
#endif
2136
2014-11-14
pjp
return IPV6;
2137
2014-11-14
pjp
} else {
2138
2014-11-14
pjp
2139
2014-11-14
pjp
#if LEXDEBUG
2140
2014-11-14
pjp
if (debug)
2141
2014-11-14
pjp
printf("returning IPV6\n");
2142
2014-11-14
pjp
#endif
2143
2014-11-14
pjp
return IPV6;
2144
2014-11-14
pjp
}
2145
2014-11-14
pjp
}
2146
2014-11-14
pjp
2147
2014-11-14
pjp
memset(&dst, 0, sizeof(dst));
2148
2014-11-14
pjp
if (strchr(buf, '.') != NULL &&
2149
2014-11-14
pjp
inet_net_pton(AF_INET, buf, &dst, sizeof(dst)) != -1){
2150
2014-11-14
pjp
#if LEXDEBUG
2151
2014-11-14
pjp
if (debug)
2152
2014-11-14
pjp
printf("returning %s\n", "IP");
2153
2014-11-14
pjp
#endif
2154
2014-11-14
pjp
return IP;
2155
2014-11-14
pjp
}
2156
2014-11-14
pjp
2157
2014-11-14
pjp
for (cp = &buf[0]; *cp != '\0'; cp++) {
2158
2014-11-14
pjp
if ((! isdigit((int)*cp)) && (*cp != '.'))
2159
2014-11-14
pjp
break;
2160
2014-11-14
pjp
}
2161
2014-11-14
pjp
2162
2014-11-14
pjp
if (*cp != '\0' || (buf[0] == '.' && buf[1] == '\0')) {
2163
2014-11-14
pjp
#ifdef LEXDEBUG
2164
2014-11-14
pjp
printf("returning %s (%s)\n", "STRING", buf);
2165
2014-11-14
pjp
#endif
2166
2014-11-14
pjp
return (STRING);
2167
2014-11-14
pjp
}
2168
2014-11-14
pjp
2169
2014-11-14
pjp
#ifdef LEXDEBUG
2170
2014-11-14
pjp
dolog(LOG_DEBUG, "returning %s\n", "NUMBER");
2171
2014-11-14
pjp
#endif
2172
2014-11-14
pjp
2173
2014-11-14
pjp
free (yylval.v.string);
2174
2017-01-02
pjp
#if ! defined __APPLE__ && ! defined __NetBSD__
2175
2018-07-12
pjp
yylval.v.intval = strtonum(buf, 0, LLONG_MAX, &errstr);
2176
2015-06-20
pjp
#else
2177
2015-06-20
pjp
yylval.v.intval = atoll(buf);
2178
2015-06-20
pjp
#endif
2179
2014-11-14
pjp
2180
2014-11-14
pjp
return (NUMBER);
2181
2014-11-14
pjp
}
2182
2014-11-14
pjp
2183
2014-11-14
pjp
break;
2184
2014-11-14
pjp
}
2185
2014-11-14
pjp
2186
2014-11-14
pjp
return (c);
2187
2014-11-14
pjp
}
2188
2014-11-14
pjp
2189
2014-11-14
pjp
int
2190
2014-11-14
pjp
get_quotedstring(char *buf, int n)
2191
2014-11-14
pjp
{
2192
2014-11-14
pjp
int i, c;
2193
2014-11-14
pjp
int stack = 0;
2194
2014-11-14
pjp
char *cs;
2195
2014-11-14
pjp
2196
2014-11-14
pjp
cs = buf;
2197
2014-11-14
pjp
2198
2014-11-14
pjp
for (i = 0; --n > 0; ++i) {
2199
2014-11-14
pjp
c = lgetc(0);
2200
2014-11-14
pjp
if (c == '\n') {
2201
2014-11-14
pjp
*cs = '\0';
2202
2014-11-14
pjp
lungetc(c);
2203
2014-11-14
pjp
return (0);
2204
2014-11-14
pjp
} else if (c == '"') {
2205
2014-11-14
pjp
if (stack == 0) {
2206
2014-11-14
pjp
*cs++ = c;
2207
2014-11-14
pjp
*cs = '\0';
2208
2014-11-14
pjp
return (0);
2209
2014-11-14
pjp
} else {
2210
2014-11-14
pjp
stack--;
2211
2014-11-14
pjp
}
2212
2014-11-14
pjp
} else if (c == '\\') {
2213
2014-11-14
pjp
if (stack == 0) {
2214
2014-11-14
pjp
stack++;
2215
2014-11-14
pjp
continue;
2216
2014-11-14
pjp
} else {
2217
2014-11-14
pjp
stack--;
2218
2014-11-14
pjp
}
2219
2014-11-14
pjp
} else
2220
2014-11-14
pjp
stack = 0;
2221
2014-11-14
pjp
2222
2014-11-14
pjp
2223
2014-11-14
pjp
*cs++ = c;
2224
2014-11-14
pjp
}
2225
2014-11-14
pjp
2226
2014-11-14
pjp
return (1);
2227
2014-11-14
pjp
}
2228
2014-11-14
pjp
2229
2014-11-14
pjp
int
2230
2014-11-14
pjp
get_string(char *buf, int n)
2231
2014-11-14
pjp
{
2232
2014-11-14
pjp
int i, c;
2233
2014-11-14
pjp
char *cs;
2234
2014-11-14
pjp
2235
2014-11-14
pjp
cs = buf;
2236
2014-11-14
pjp
2237
2014-11-14
pjp
for (i = 0; --n > 0; ++i) {
2238
2014-11-14
pjp
c = lgetc(0);
2239
2014-11-14
pjp
if (c == '\n' || c == ' ' || c == ',' || c == ';' || ! (isprint(c) || c == '-' || c == '_')) {
2240
2014-11-14
pjp
*cs = '\0';
2241
2014-11-14
pjp
lungetc(c);
2242
2014-11-14
pjp
return (0);
2243
2014-11-14
pjp
}
2244
2014-11-14
pjp
2245
2014-11-14
pjp
*cs++ = c;
2246
2014-11-14
pjp
}
2247
2014-11-14
pjp
2248
2014-11-14
pjp
return (1);
2249
2014-11-14
pjp
}
2250
2014-11-14
pjp
2251
2014-11-14
pjp
struct tab *
2252
2014-11-14
pjp
lookup(struct tab *cmdtab, char *keyword)
2253
2014-11-14
pjp
{
2254
2014-11-14
pjp
struct tab *p;
2255
2014-11-14
pjp
2256
2014-11-14
pjp
for (p = cmdtab; p->val != NULL; p++) {
2257
2014-11-14
pjp
if (strcmp(p->val, keyword) == 0)
2258
2014-11-14
pjp
return (p);
2259
2014-11-14
pjp
}
2260
2014-11-14
pjp
2261
2014-11-14
pjp
return (NULL);
2262
2014-11-14
pjp
}
2263
2014-11-14
pjp
2264
2014-11-14
pjp
int
2265
2014-11-14
pjp
get_ip(char *buf, int n)
2266
2014-11-14
pjp
{
2267
2014-11-14
pjp
int i, c;
2268
2014-11-14
pjp
char *cs;
2269
2014-11-14
pjp
2270
2014-11-14
pjp
cs = buf;
2271
2014-11-14
pjp
2272
2014-11-14
pjp
for (i = 0; --n > 0; ++i) {
2273
2014-11-14
pjp
c = lgetc(0);
2274
2014-11-14
pjp
if (c == ',' || c == '\n' || ! (isalnum(c) || c == '/' || c == ':' || c == '.')) {
2275
2014-11-14
pjp
*cs = '\0';
2276
2014-11-14
pjp
lungetc(c);
2277
2014-11-14
pjp
return (0);
2278
2014-11-14
pjp
}
2279
2014-11-14
pjp
2280
2014-11-14
pjp
*cs++ = c;
2281
2014-11-14
pjp
}
2282
2014-11-14
pjp
2283
2014-11-14
pjp
return (1);
2284
2014-11-14
pjp
}
2285
2014-11-14
pjp
2286
2014-11-14
pjp
char *
2287
2014-11-14
pjp
check_rr(char *domainname, char *mytype, int itype, int *converted_namelen)
2288
2014-11-14
pjp
{
2289
2014-11-14
pjp
struct rrtab *rr;
2290
2014-11-14
pjp
char *converted_name, *p;
2291
2014-11-14
pjp
int i;
2292
2014-11-14
pjp
2293
2014-11-14
pjp
2294
2014-11-20
pjp
if ((rr = rrlookup(mytype)) == NULL) {
2295
2014-11-14
pjp
dolog(LOG_ERR, "error input line %d\n", file->lineno);
2296
2020-06-25
pjp
ddd_shutdown();
2297
2014-11-14
pjp
exit(1);
2298
2014-11-14
pjp
}
2299
2014-11-14
pjp
2300
2014-11-14
pjp
if (rr->type != itype) {
2301
2014-11-14
pjp
dolog(LOG_ERR, "error input line %d, expected itype = %d, had %d\n", file->lineno, itype, rr->type);
2302
2014-11-14
pjp
return NULL;
2303
2014-11-14
pjp
}
2304
2014-11-14
pjp
2305
2014-11-14
pjp
if (strlen(domainname) > (DNS_MAXNAME - 2)) {
2306
2014-11-14
pjp
dolog(LOG_ERR, "domain name too long, line %d\n", file->lineno);
2307
2020-06-25
pjp
ddd_shutdown();
2308
2014-11-14
pjp
exit(1);
2309
2014-11-14
pjp
}
2310
2014-11-14
pjp
2311
2014-11-14
pjp
for (i = 0, p = domainname; i < strlen(domainname); i++) {
2312
2014-11-14
pjp
*p = tolower((int)*p);
2313
2014-11-14
pjp
p++;
2314
2014-11-14
pjp
}
2315
2014-11-14
pjp
2316
2014-11-14
pjp
if ((strlen(domainname) == 1) && (domainname[0] == '.')) {
2317
2014-11-14
pjp
converted_name = malloc(1);
2318
2014-11-14
pjp
if (converted_name == NULL) {
2319
2014-11-14
pjp
dolog(LOG_ERR, "malloc failed\n");
2320
2020-06-25
pjp
ddd_shutdown();
2321
2014-11-14
pjp
exit(1);
2322
2014-11-14
pjp
}
2323
2014-11-14
pjp
2324
2014-11-14
pjp
*converted_namelen = 1;
2325
2014-11-14
pjp
*converted_name = '\0';
2326
2014-11-14
pjp
} else if ((strlen(domainname) == 1) && (domainname[0] == '*')) {
2327
2014-11-14
pjp
converted_name = malloc(1);
2328
2014-11-14
pjp
if (converted_name == NULL) {
2329
2014-11-14
pjp
dolog(LOG_ERR, "malloc failed\n");
2330
2020-06-25
pjp
ddd_shutdown();
2331
2014-11-14
pjp
exit(1);
2332
2014-11-14
pjp
}
2333
2014-11-14
pjp
2334
2014-11-14
pjp
*converted_namelen = 1;
2335
2014-11-14
pjp
*converted_name = '*';
2336
2014-11-14
pjp
} else {
2337
2014-11-14
pjp
converted_name = dns_label(domainname, converted_namelen);
2338
2014-11-14
pjp
2339
2014-11-14
pjp
if (converted_name == NULL) {
2340
2014-11-14
pjp
dolog(LOG_ERR, "error processing domain name line %d\n", file->lineno);
2341
2020-06-25
pjp
ddd_shutdown();
2342
2014-11-14
pjp
exit(1);
2343
2014-11-14
pjp
}
2344
2014-11-14
pjp
}
2345
2014-11-14
pjp
2346
2014-11-14
pjp
return (converted_name);
2347
2014-11-14
pjp
}
2348
2014-11-14
pjp
2349
2014-11-14
pjp
int
2350
2020-07-06
pjp
fill_cname(ddDB *db, char *name, char *type, int myttl, char *hostname)
2351
2014-11-14
pjp
{
2352
2019-02-15
pjp
struct rbtree *rbt;
2353
2019-02-15
pjp
struct cname *cname;
2354
2014-11-14
pjp
char *myname, *converted_name;
2355
2014-11-14
pjp
int len, converted_namelen;
2356
2019-02-15
pjp
int i;
2357
2014-11-14
pjp
2358
2014-11-14
pjp
for (i = 0; i < strlen(name); i++) {
2359
2014-11-14
pjp
name[i] = tolower((int)name[i]);
2360
2014-11-14
pjp
}
2361
2014-11-14
pjp
2362
2014-11-14
pjp
converted_name = check_rr(name, type, DNS_TYPE_CNAME, &converted_namelen);
2363
2014-11-14
pjp
if (converted_name == NULL) {
2364
2014-11-14
pjp
return -1;
2365
2014-11-14
pjp
}
2366
2014-11-14
pjp
2367
2019-02-15
pjp
if ((cname = calloc(1, sizeof(struct cname))) == NULL) {
2368
2019-02-15
pjp
dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
2369
2015-06-16
pjp
return -1;
2370
2014-11-14
pjp
}
2371
2014-11-14
pjp
2372
2014-11-14
pjp
2373
2014-11-14
pjp
myname = dns_label(hostname, (int *)&len);
2374
2014-11-14
pjp
if (myname == NULL) {
2375
2014-11-14
pjp
dolog(LOG_INFO, "illegal nameserver, skipping line %d\n", file->lineno);
2376
2014-11-14
pjp
return 0;
2377
2014-11-14
pjp
}
2378
2014-11-14
pjp
2379
2014-11-14
pjp
if (len > 0xff || len < 0) {
2380
2014-11-14
pjp
dolog(LOG_INFO, "illegal len value , line %d\n", file->lineno);
2381
2014-11-14
pjp
return -1;
2382
2014-11-14
pjp
}
2383
2014-11-14
pjp
2384
2019-02-15
pjp
cname->cnamelen = len;
2385
2019-02-15
pjp
memcpy((char *)cname->cname, myname, len);
2386
2014-11-14
pjp
2387
2014-11-14
pjp
free(myname);
2388
2014-11-14
pjp
2389
2020-07-15
pjp
rbt = create_rr(db, converted_name, converted_namelen, DNS_TYPE_CNAME, cname, myttl, 0);
2390
2019-02-15
pjp
if (rbt == NULL) {
2391
2019-02-15
pjp
dolog(LOG_ERR, "create_rr failed\n");
2392
2019-02-09
pjp
return -1;
2393
2019-02-15
pjp
}
2394
2014-11-14
pjp
2395
2014-11-14
pjp
if (converted_name)
2396
2014-11-14
pjp
free (converted_name);
2397
2015-06-16
pjp
2398
2014-11-14
pjp
2399
2014-11-14
pjp
return (0);
2400
2014-11-14
pjp
}
2401
2014-11-14
pjp
2402
2014-11-14
pjp
int
2403
2020-07-06
pjp
fill_ptr(ddDB *db, char *name, char *type, int myttl, char *hostname)
2404
2014-11-14
pjp
{
2405
2019-02-15
pjp
struct ptr *ptr;
2406
2019-02-15
pjp
struct rbtree *rbt;
2407
2014-11-14
pjp
int len, converted_namelen;
2408
2014-11-14
pjp
char *myname, *converted_name;
2409
2019-02-15
pjp
int i;
2410
2014-11-14
pjp
2411
2014-11-14
pjp
for (i = 0; i < strlen(name); i++) {
2412
2014-11-14
pjp
name[i] = tolower((int)name[i]);
2413
2014-11-14
pjp
}
2414
2014-11-14
pjp
2415
2014-11-14
pjp
converted_name = check_rr(name, type, DNS_TYPE_PTR, &converted_namelen);
2416
2014-11-14
pjp
if (converted_name == NULL) {
2417
2014-11-14
pjp
return -1;
2418
2014-11-14
pjp
}
2419
2014-11-14
pjp
2420
2014-11-14
pjp
myname = dns_label(hostname, (int *)&len);
2421
2014-11-14
pjp
if (myname == NULL) {
2422
2014-11-14
pjp
dolog(LOG_INFO, "illegal nameserver, skipping line %d\n", file->lineno);
2423
2014-11-14
pjp
return 0;
2424
2014-11-14
pjp
}
2425
2014-11-14
pjp
2426
2014-11-14
pjp
if (len > 0xff || len < 0) {
2427
2014-11-14
pjp
dolog(LOG_INFO, "illegal len value , line %d\n", file->lineno);
2428
2014-11-14
pjp
return -1;
2429
2014-11-14
pjp
}
2430
2014-11-14
pjp
2431
2019-02-15
pjp
if ((ptr = calloc(1, sizeof(struct ptr))) == NULL) {
2432
2019-02-15
pjp
dolog(LOG_ERR, "calloc %s\n", strerror(errno));
2433
2019-02-15
pjp
return -1;
2434
2019-02-15
pjp
}
2435
2014-11-14
pjp
2436
2019-02-15
pjp
ptr->ptrlen = len;
2437
2019-02-15
pjp
memcpy((char *)ptr->ptr, myname, len);
2438
2019-02-15
pjp
2439
2017-03-14
pjp
free(myname);
2440
2014-11-14
pjp
2441
2020-07-15
pjp
rbt = create_rr(db, converted_name, converted_namelen, DNS_TYPE_PTR, ptr, myttl, 0);
2442
2019-02-15
pjp
if (rbt == NULL) {
2443
2019-02-15
pjp
dolog(LOG_ERR, "create_rr failed\n");
2444
2019-02-09
pjp
return -1;
2445
2019-02-15
pjp
}
2446
2014-11-14
pjp
2447
2014-11-14
pjp
if (converted_name)
2448
2014-11-14
pjp
free (converted_name);
2449
2015-06-16
pjp
2450
2014-11-14
pjp
2451
2014-11-14
pjp
return (0);
2452
2014-11-14
pjp
2453
2014-11-14
pjp
}
2454
2014-11-14
pjp
2455
2014-11-21
pjp
/* first two dnssec RRs! */
2456
2014-11-21
pjp
int
2457
2020-07-06
pjp
fill_dnskey(ddDB *db, char *name, char *type, u_int32_t myttl, u_int16_t flags, u_int8_t protocol, u_int8_t algorithm, char *pubkey)
2458
2014-11-14
pjp
{
2459
2019-02-15
pjp
struct dnskey *dnskey;
2460
2019-02-15
pjp
struct rbtree *rbt;
2461
2014-11-14
pjp
int converted_namelen;
2462
2014-11-14
pjp
char *converted_name;
2463
2019-02-15
pjp
int i, ret;
2464
2014-11-14
pjp
2465
2014-11-14
pjp
for (i = 0; i < strlen(name); i++) {
2466
2014-11-14
pjp
name[i] = tolower((int)name[i]);
2467
2014-11-14
pjp
}
2468
2014-11-14
pjp
2469
2014-11-21
pjp
converted_name = check_rr(name, type, DNS_TYPE_DNSKEY, &converted_namelen);
2470
2014-11-21
pjp
if (converted_name == NULL) {
2471
2014-11-21
pjp
return -1;
2472
2014-11-21
pjp
}
2473
2014-11-21
pjp
2474
2019-02-15
pjp
if ((dnskey = calloc(1, sizeof(struct dnskey))) == NULL) {
2475
2019-02-15
pjp
dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
2476
2019-02-15
pjp
return -1;
2477
2014-11-21
pjp
}
2478
2014-11-21
pjp
2479
2019-02-15
pjp
dnskey->flags = flags;
2480
2019-02-15
pjp
dnskey->protocol = protocol;
2481
2019-02-15
pjp
dnskey->algorithm = algorithm;
2482
2014-11-21
pjp
2483
2014-11-21
pjp
/* feed our base64 key to the public key */
2484
2019-02-15
pjp
ret = mybase64_decode(pubkey, dnskey->public_key, sizeof(dnskey->public_key));
2485
2014-11-21
pjp
if (ret < 0)
2486
2014-11-21
pjp
return (-1);
2487
2014-11-21
pjp
2488
2019-02-15
pjp
dnskey->publickey_len = ret;
2489
2014-11-21
pjp
2490
2019-02-15
pjp
2491
2020-07-15
pjp
rbt = create_rr(db, converted_name, converted_namelen, DNS_TYPE_DNSKEY, dnskey, myttl, 0);
2492
2019-02-15
pjp
if (rbt == NULL) {
2493
2019-02-15
pjp
dolog(LOG_ERR, "create_rr failed\n");
2494
2019-02-09
pjp
return -1;
2495
2019-02-15
pjp
}
2496
2019-02-09
pjp
2497
2019-02-15
pjp
2498
2014-11-21
pjp
if (converted_name)
2499
2014-11-21
pjp
free (converted_name);
2500
2015-06-16
pjp
2501
2014-11-21
pjp
2502
2014-11-21
pjp
return (0);
2503
2014-11-21
pjp
2504
2014-11-21
pjp
}
2505
2014-11-21
pjp
2506
2014-11-21
pjp
int
2507
2020-07-06
pjp
fill_rrsig(ddDB *db, char *name, char *type, u_int32_t myttl, char *typecovered, u_int8_t algorithm, u_int8_t labels, u_int32_t original_ttl, u_int64_t sig_expiration, u_int64_t sig_inception, u_int16_t keytag, char *signers_name, char *signature)
2508
2014-11-21
pjp
{
2509
2019-04-07
pjp
ddDBT key, data;
2510
2019-02-15
pjp
struct rbtree *rbt;
2511
2015-06-22
pjp
struct rrsig *rrsig;
2512
2014-11-21
pjp
int converted_namelen, signers_namelen;
2513
2014-11-21
pjp
char *converted_name, *signers_name2;
2514
2014-11-21
pjp
struct rrtab *rr;
2515
2019-02-15
pjp
int i, ret;
2516
2015-06-20
pjp
char tmpbuf[32];
2517
2015-06-20
pjp
struct tm tmbuf;
2518
2015-06-20
pjp
time_t timebuf;
2519
2019-02-15
pjp
#if 0
2520
2019-02-15
pjp
int rrtype = RRSIG_RRSET;
2521
2019-02-15
pjp
#endif
2522
2014-11-21
pjp
2523
2014-11-21
pjp
for (i = 0; i < strlen(name); i++) {
2524
2014-11-21
pjp
name[i] = tolower((int)name[i]);
2525
2014-11-21
pjp
}
2526
2014-11-21
pjp
2527
2014-11-21
pjp
converted_name = check_rr(name, type, DNS_TYPE_RRSIG, &converted_namelen);
2528
2014-11-14
pjp
if (converted_name == NULL) {
2529
2014-11-14
pjp
return -1;
2530
2014-11-14
pjp
}
2531
2014-11-14
pjp
2532
2014-11-21
pjp
if ((rr = rrlookup(typecovered)) == NULL) {
2533
2014-11-14
pjp
return (-1);
2534
2014-11-14
pjp
}
2535
2014-11-14
pjp
2536
2014-11-21
pjp
switch (rr->type) {
2537
2014-11-21
pjp
case DNS_TYPE_RRSIG:
2538
2014-11-21
pjp
fprintf(stderr, "can't RRSIG an RRSIG!\n");
2539
2014-11-21
pjp
return (-1);
2540
2014-11-21
pjp
break;
2541
2014-11-21
pjp
}
2542
2014-11-20
pjp
2543
2019-02-15
pjp
if ((rrsig = calloc(1, sizeof(struct rrsig))) == NULL) {
2544
2019-02-15
pjp
dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
2545
2019-02-15
pjp
return -1;
2546
2015-06-20
pjp
}
2547
2014-11-20
pjp
2548
2019-02-15
pjp
2549
2015-06-22
pjp
rrsig->type_covered = rr->type;
2550
2015-06-22
pjp
rrsig->algorithm = algorithm;
2551
2015-06-22
pjp
rrsig->labels = labels;
2552
2015-06-22
pjp
rrsig->original_ttl = original_ttl;
2553
2020-05-07
pjp
2554
2015-06-20
pjp
snprintf(tmpbuf, sizeof(tmpbuf), "%llu", sig_expiration);
2555
2015-06-20
pjp
if (strptime(tmpbuf, "%Y%m%d%H%M%S", &tmbuf) == NULL) {
2556
2015-06-20
pjp
perror("sig_expiration");
2557
2015-06-20
pjp
return (-1);
2558
2015-06-16
pjp
}
2559
2015-06-20
pjp
timebuf = timegm(&tmbuf);
2560
2015-06-22
pjp
rrsig->signature_expiration = timebuf;
2561
2015-06-20
pjp
snprintf(tmpbuf, sizeof(tmpbuf), "%llu", sig_inception);
2562
2015-06-20
pjp
if (strptime(tmpbuf, "%Y%m%d%H%M%S", &tmbuf) == NULL) {
2563
2015-06-20
pjp
perror("sig_inception");
2564
2015-06-20
pjp
return (-1);
2565
2015-06-20
pjp
}
2566
2015-06-20
pjp
timebuf = timegm(&tmbuf);
2567
2015-06-22
pjp
rrsig->signature_inception = timebuf;
2568
2015-06-22
pjp
rrsig->key_tag = keytag;
2569
2015-06-16
pjp
2570
2014-11-21
pjp
signers_name2 = check_rr(signers_name, type, DNS_TYPE_RRSIG, &signers_namelen);
2571
2014-11-21
pjp
if (signers_name2 == NULL) {
2572
2014-11-21
pjp
return (-1);
2573
2014-11-21
pjp
}
2574
2014-11-21
pjp
2575
2019-02-15
pjp
memcpy(&rrsig->signers_name, signers_name2, signers_namelen);
2576
2015-06-22
pjp
rrsig->signame_len = signers_namelen;
2577
2014-11-21
pjp
2578
2014-11-20
pjp
2579
2014-11-21
pjp
/* feed our base64 key the signature */
2580
2015-06-22
pjp
ret = mybase64_decode(signature, rrsig->signature, sizeof(rrsig->signature));
2581
2014-11-21
pjp
2582
2014-11-21
pjp
if (ret < 0)
2583
2014-11-21
pjp
return (-1);
2584
2014-11-21
pjp
2585
2015-06-22
pjp
rrsig->signature_len = ret;
2586
2014-11-21
pjp
2587
2020-07-15
pjp
rbt = create_rr(db, converted_name, converted_namelen, DNS_TYPE_RRSIG, rrsig, original_ttl, 0);
2588
2019-02-15
pjp
if (rbt == NULL) {
2589
2019-02-15
pjp
dolog(LOG_ERR, "create_rr failed\n");
2590
2019-02-09
pjp
return -1;
2591
2019-02-15
pjp
}
2592
2019-04-07
pjp
2593
2019-04-07
pjp
/* flag this rrset as being a DNSSEC rrset */
2594
2019-04-07
pjp
2595
2021-01-08
pjp
flag_rr(rbt, RBT_DNSSEC);
2596
2019-04-07
pjp
2597
2019-04-07
pjp
memset(&key, 0, sizeof(key));
2598
2019-04-07
pjp
memset(&data, 0, sizeof(data));
2599
2019-04-07
pjp
2600
2019-04-07
pjp
key.data = (char *)converted_name;
2601
2019-04-07
pjp
key.size = converted_namelen;
2602
2019-04-07
pjp
2603
2019-04-07
pjp
data.data = (void*)rbt;
2604
2019-04-07
pjp
data.size = sizeof(struct rbtree);
2605
2019-04-07
pjp
2606
2019-04-07
pjp
if (db->put(db, &key, &data) != 0) {
2607
2019-04-15
pjp
return -1;
2608
2019-04-07
pjp
}
2609
2020-07-08
pjp
2610
2014-11-21
pjp
if (signers_name2)
2611
2019-02-15
pjp
free(signers_name2);
2612
2014-11-21
pjp
2613
2014-11-21
pjp
if (converted_name)
2614
2014-11-21
pjp
free (converted_name);
2615
2015-06-16
pjp
2616
2015-06-16
pjp
2617
2014-11-21
pjp
return (0);
2618
2014-11-21
pjp
2619
2014-11-21
pjp
}
2620
2014-11-21
pjp
2621
2014-11-21
pjp
int
2622
2020-07-06
pjp
fill_ds(ddDB *db, char *name, char *type, u_int32_t myttl, u_int16_t keytag, u_int8_t algorithm, u_int8_t digesttype, char *digest)
2623
2014-11-21
pjp
{
2624
2019-02-15
pjp
struct rbtree *rbt;
2625
2019-02-15
pjp
struct ds *ds;
2626
2014-11-21
pjp
int converted_namelen;
2627
2014-11-21
pjp
char *converted_name;
2628
2019-02-15
pjp
int i;
2629
2015-06-25
pjp
int ret;
2630
2014-11-21
pjp
2631
2014-11-21
pjp
for (i = 0; i < strlen(name); i++) {
2632
2014-11-21
pjp
name[i] = tolower((int)name[i]);
2633
2014-11-21
pjp
}
2634
2014-11-21
pjp
2635
2014-11-21
pjp
converted_name = check_rr(name, type, DNS_TYPE_DS, &converted_namelen);
2636
2014-11-21
pjp
if (converted_name == NULL) {
2637
2014-11-21
pjp
return -1;
2638
2014-11-21
pjp
}
2639
2014-11-21
pjp
2640
2019-02-15
pjp
if ((ds = calloc(1, sizeof(struct ds))) == NULL) {
2641
2019-02-15
pjp
dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
2642
2019-02-15
pjp
return -1;
2643
2015-06-27
pjp
}
2644
2014-11-21
pjp
2645
2019-02-15
pjp
ds->key_tag = keytag;
2646
2019-02-15
pjp
ds->algorithm = algorithm;
2647
2019-02-15
pjp
ds->digest_type = digesttype;
2648
2015-06-27
pjp
2649
2019-02-15
pjp
ret = hex2bin(digest, strlen(digest), ds->digest);
2650
2019-02-15
pjp
ds->digestlen = ret;
2651
2014-11-21
pjp
2652
2020-07-15
pjp
rbt = create_rr(db, converted_name, converted_namelen, DNS_TYPE_DS, ds, myttl, 0);
2653
2019-02-15
pjp
if (rbt == NULL) {
2654
2019-02-15
pjp
dolog(LOG_ERR, "create_rr failed\n");
2655
2019-02-09
pjp
return -1;
2656
2019-02-15
pjp
}
2657
2019-02-15
pjp
2658
2015-06-27
pjp
if (converted_name)
2659
2015-06-27
pjp
free (converted_name);
2660
2014-11-21
pjp
2661
2015-06-27
pjp
2662
2015-06-27
pjp
return (0);
2663
2015-06-27
pjp
2664
2015-06-27
pjp
}
2665
2015-06-27
pjp
2666
2015-06-27
pjp
int
2667
2020-07-06
pjp
fill_nsec3(ddDB *db, char *name, char *type, u_int32_t myttl, u_int8_t algorithm, u_int8_t flags, u_int16_t iterations, char *salt, char *nextname, char *bitmap)
2668
2015-06-27
pjp
{
2669
2019-02-15
pjp
struct nsec3 *nsec3;
2670
2019-02-15
pjp
struct rbtree *rbt;
2671
2019-02-15
pjp
int i;
2672
2019-12-03
pjp
int tmpbitmap;
2673
2015-06-27
pjp
2674
2015-06-27
pjp
for (i = 0; i < strlen(name); i++) {
2675
2015-06-27
pjp
name[i] = tolower((int)name[i]);
2676
2015-06-16
pjp
}
2677
2015-06-16
pjp
2678
2015-06-27
pjp
converted_name = check_rr(name, type, DNS_TYPE_NSEC3, &converted_namelen);
2679
2015-06-27
pjp
if (converted_name == NULL) {
2680
2015-06-27
pjp
return -1;
2681
2015-06-27
pjp
}
2682
2015-06-16
pjp
2683
2015-09-14
pjp
if (dnssec) {
2684
2015-09-14
pjp
#ifdef DEBUG
2685
2015-09-14
pjp
dolog(LOG_INFO, "inserting %s\n", name);
2686
2015-09-14
pjp
#endif
2687
2015-09-14
pjp
insert_nsec3(current_zone, name, converted_name, converted_namelen);
2688
2015-06-27
pjp
}
2689
2015-06-16
pjp
2690
2015-06-27
pjp
for (i = 0; i < strlen(nextname); i++) {
2691
2015-06-27
pjp
nextname[i] = tolower((int)nextname[i]);
2692
2015-06-27
pjp
}
2693
2015-06-16
pjp
2694
2019-02-15
pjp
2695
2019-02-15
pjp
if ((nsec3 = calloc(1, sizeof(struct nsec3))) == NULL) {
2696
2019-02-15
pjp
dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
2697
2019-02-15
pjp
return -1;
2698
2015-06-27
pjp
}
2699
2015-06-16
pjp
2700
2019-02-15
pjp
nsec3->algorithm = algorithm;
2701
2019-02-15
pjp
nsec3->flags = flags;
2702
2019-02-15
pjp
nsec3->iterations = iterations;
2703
2015-06-27
pjp
if (strcasecmp(salt, "-") == 0) {
2704
2019-02-15
pjp
nsec3->saltlen = 0;
2705
2015-06-27
pjp
} else {
2706
2019-02-15
pjp
nsec3->saltlen = (strlen(salt) / 2);
2707
2019-02-15
pjp
hex2bin(salt, strlen(salt), nsec3->salt);
2708
2015-06-27
pjp
}
2709
2015-06-16
pjp
2710
2019-02-15
pjp
nsec3->nextlen = base32hex_decode(nextname, (u_char*)&nsec3->next);
2711
2019-02-15
pjp
if (nsec3->nextlen == 0) {
2712
2015-11-17
pjp
dolog(LOG_INFO, "base32_decode faulty");
2713
2015-11-17
pjp
return -1;
2714
2015-11-17
pjp
}
2715
2015-06-25
pjp
2716
2015-06-27
pjp
/* XXX create/manage bitmap */
2717
2019-12-03
pjp
create_nsec_bitmap(bitmap, nsec3->bitmap, &tmpbitmap);
2718
2019-12-03
pjp
2719
2019-12-03
pjp
nsec3->bitmap_len = (uint16_t)tmpbitmap;
2720
2019-02-09
pjp
2721
2019-07-05
pjp
#if 0
2722
2019-07-05
pjp
/* we had a bug and this found it */
2723
2019-07-05
pjp
printf(";nsec3->bitmap == \"%s\", nsec3->bitmap_len == %d\n", bitmap, nsec3->bitmap_len);
2724
2019-07-05
pjp
#endif
2725
2019-07-05
pjp
2726
2020-07-15
pjp
rbt = create_rr(db, converted_name, converted_namelen, DNS_TYPE_NSEC3, nsec3, myttl, 0);
2727
2019-02-15
pjp
if (rbt == NULL) {
2728
2019-02-15
pjp
dolog(LOG_ERR, "create_rr failed\n");
2729
2019-02-09
pjp
return -1;
2730
2019-02-15
pjp
}
2731
2014-11-20
pjp
2732
2014-11-21
pjp
if (converted_name)
2733
2014-11-21
pjp
free (converted_name);
2734
2014-11-21
pjp
2735
2014-11-20
pjp
2736
2015-06-27
pjp
return (0);
2737
2014-11-21
pjp
}
2738
2014-11-21
pjp
2739
2014-11-21
pjp
int
2740
2020-07-06
pjp
fill_nsec3param(ddDB *db, char *name, char *type, u_int32_t myttl, u_int8_t algorithm, u_int8_t flags, u_int16_t iterations, char *salt)
2741
2014-11-21
pjp
{
2742
2019-02-15
pjp
struct rbtree *rbt;
2743
2019-02-15
pjp
struct nsec3param *nsec3param;
2744
2019-02-15
pjp
int i;
2745
2014-11-21
pjp
2746
2015-06-27
pjp
for (i = 0; i < strlen(name); i++) {
2747
2015-06-27
pjp
name[i] = tolower((int)name[i]);
2748
2015-06-27
pjp
}
2749
2014-11-21
pjp
2750
2015-06-27
pjp
converted_name = check_rr(name, type, DNS_TYPE_NSEC3PARAM, &converted_namelen);
2751
2015-06-27
pjp
if (converted_name == NULL) {
2752
2015-06-27
pjp
return -1;
2753
2015-06-27
pjp
}
2754
2014-11-21
pjp
2755
2019-02-15
pjp
if ((nsec3param = calloc(1, sizeof(struct nsec3param))) == NULL) {
2756
2019-02-15
pjp
dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
2757
2019-02-15
pjp
return -1;
2758
2015-06-27
pjp
}
2759
2014-11-21
pjp
2760
2019-02-15
pjp
nsec3param->algorithm = algorithm;
2761
2019-02-15
pjp
nsec3param->flags = flags;
2762
2019-02-15
pjp
nsec3param->iterations = iterations;
2763
2015-06-27
pjp
if (strcasecmp(salt, "-") == 0) {
2764
2019-02-15
pjp
nsec3param->saltlen = 0;
2765
2015-06-27
pjp
} else {
2766
2019-02-15
pjp
nsec3param->saltlen = (strlen(salt) / 2);
2767
2019-02-15
pjp
hex2bin(salt, strlen(salt), nsec3param->salt);
2768
2015-06-27
pjp
}
2769
2020-07-15
pjp
rbt = create_rr(db, converted_name, converted_namelen, DNS_TYPE_NSEC3PARAM, nsec3param, myttl, 0);
2770
2019-02-15
pjp
if (rbt == NULL) {
2771
2019-02-15
pjp
dolog(LOG_ERR, "create_rr failed\n");
2772
2019-02-09
pjp
return -1;
2773
2019-02-15
pjp
}
2774
2015-06-27
pjp
2775
2015-06-27
pjp
if (converted_name)
2776
2015-06-27
pjp
free (converted_name);
2777
2015-06-27
pjp
2778
2015-06-27
pjp
2779
2015-06-27
pjp
return (0);
2780
2015-06-26
pjp
}
2781
2014-11-21
pjp
2782
2015-06-26
pjp
int
2783
2020-07-06
pjp
fill_nsec(ddDB *db, char *name, char *type, u_int32_t myttl, char *domainname, char *bitmap)
2784
2015-06-26
pjp
{
2785
2019-02-15
pjp
struct nsec *nsec;
2786
2019-02-15
pjp
struct rbtree *rbt;
2787
2015-06-26
pjp
int converted_namelen, converted_domainnamelen;
2788
2015-06-26
pjp
char *converted_name, *converted_domainname;
2789
2019-02-15
pjp
int i;
2790
2015-06-16
pjp
2791
2015-06-26
pjp
for (i = 0; i < strlen(name); i++) {
2792
2015-06-26
pjp
name[i] = tolower((int)name[i]);
2793
2015-06-26
pjp
}
2794
2015-06-16
pjp
2795
2015-06-26
pjp
converted_name = check_rr(name, type, DNS_TYPE_NSEC, &converted_namelen);
2796
2015-06-26
pjp
if (converted_name == NULL) {
2797
2015-06-26
pjp
return -1;
2798
2015-06-26
pjp
}
2799
2015-06-26
pjp
2800
2014-11-21
pjp
for (i = 0; i < strlen(domainname); i++) {
2801
2014-11-21
pjp
domainname[i] = tolower((int)domainname[i]);
2802
2014-11-21
pjp
}
2803
2014-11-21
pjp
2804
2014-11-21
pjp
converted_domainname = check_rr(domainname, type, DNS_TYPE_NSEC, &converted_domainnamelen);
2805
2014-11-21
pjp
if (converted_name == NULL) {
2806
2015-06-17
pjp
if (debug)
2807
2015-06-17
pjp
dolog(LOG_INFO, "check_rr failed\n");
2808
2014-11-21
pjp
return -1;
2809
2014-11-21
pjp
}
2810
2014-11-21
pjp
2811
2019-02-15
pjp
if ((nsec = calloc(1, sizeof(struct nsec))) == NULL) {
2812
2019-02-15
pjp
dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
2813
2019-02-15
pjp
return -1;
2814
2015-06-16
pjp
}
2815
2014-11-21
pjp
2816
2019-02-15
pjp
memcpy(nsec->next_domain_name, converted_domainname, converted_domainnamelen);
2817
2019-02-15
pjp
nsec->ndn_len = converted_domainnamelen;
2818
2014-11-21
pjp
2819
2019-02-15
pjp
create_nsec_bitmap(bitmap, nsec->bitmap, (int *)&nsec->bitmap_len);
2820
2015-06-25
pjp
2821
2020-07-15
pjp
rbt = create_rr(db, converted_name, converted_namelen, DNS_TYPE_NSEC, nsec, myttl, 0);
2822
2019-02-15
pjp
if (rbt == NULL) {
2823
2019-02-15
pjp
dolog(LOG_ERR, "create_rr failed\n");
2824
2019-02-09
pjp
return -1;
2825
2019-02-15
pjp
}
2826
2014-11-21
pjp
2827
2014-11-20
pjp
if (converted_name)
2828
2014-11-20
pjp
free (converted_name);
2829
2014-11-20
pjp
2830
2015-06-16
pjp
2831
2014-11-20
pjp
return (0);
2832
2014-11-20
pjp
2833
2014-11-20
pjp
}
2834
2014-11-20
pjp
2835
2014-11-20
pjp
2836
2014-11-14
pjp
int
2837
2020-07-06
pjp
fill_naptr(ddDB *db, char *name, char *type, int myttl, int order, int preference, char *flags, char *services, char *regexp, char *replacement)
2838
2014-11-14
pjp
{
2839
2019-02-15
pjp
struct rbtree *rbt;
2840
2019-02-15
pjp
struct naptr *naptr;
2841
2014-11-14
pjp
int converted_namelen;
2842
2014-11-14
pjp
char *converted_name, *naptrname;
2843
2014-11-14
pjp
int flagslen, serviceslen, regexplen, replacementlen;
2844
2014-11-14
pjp
int i, naptr_namelen;
2845
2014-11-14
pjp
2846
2014-11-14
pjp
for (i = 0; i < strlen(name); i++) {
2847
2014-11-14
pjp
name[i] = tolower((int)name[i]);
2848
2014-11-14
pjp
}
2849
2014-11-14
pjp
2850
2014-11-14
pjp
if ((flagslen = strlen(flags)) > 255 ||
2851
2014-11-14
pjp
(serviceslen = strlen(services)) > 255 ||
2852
2014-11-14
pjp
(regexplen = strlen(regexp)) > 255 ||
2853
2014-11-14
pjp
(replacementlen = strlen(replacement)) > 255) {
2854
2014-11-14
pjp
2855
2014-11-14
pjp
dolog(LOG_ERR, "NAPTR record too long line %d\n", file->lineno);
2856
2014-11-14
pjp
return (-1);
2857
2014-11-14
pjp
}
2858
2014-11-14
pjp
2859
2014-11-14
pjp
converted_name = check_rr(name, type, DNS_TYPE_NAPTR, &converted_namelen);
2860
2014-11-14
pjp
if (converted_name == NULL) {
2861
2014-11-14
pjp
return -1;
2862
2014-11-14
pjp
}
2863
2014-11-14
pjp
2864
2019-02-15
pjp
if ((naptr = (struct naptr *)calloc(1, sizeof(struct naptr))) == NULL) {
2865
2019-02-15
pjp
dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
2866
2015-06-16
pjp
return -1;
2867
2014-11-14
pjp
}
2868
2014-11-14
pjp
2869
2019-02-15
pjp
naptr->order = order;
2870
2019-02-15
pjp
naptr->preference = preference;
2871
2014-11-14
pjp
2872
2019-02-15
pjp
memcpy(&naptr->flags, flags, flagslen);
2873
2019-02-15
pjp
naptr->flagslen = flagslen;
2874
2014-11-14
pjp
2875
2019-02-15
pjp
memcpy(&naptr->services, services, serviceslen);
2876
2019-02-15
pjp
naptr->serviceslen = serviceslen;
2877
2014-11-14
pjp
2878
2019-02-15
pjp
memcpy(&naptr->regexp, regexp, regexplen);
2879
2019-02-15
pjp
naptr->regexplen = regexplen;
2880
2014-11-14
pjp
2881
2014-11-14
pjp
naptrname = check_rr(replacement, type, DNS_TYPE_NAPTR, &naptr_namelen);
2882
2014-11-14
pjp
if (naptrname == NULL) {
2883
2014-11-14
pjp
return -1;
2884
2014-11-14
pjp
}
2885
2014-11-14
pjp
2886
2019-02-15
pjp
memcpy(&naptr->replacement, naptrname, naptr_namelen);
2887
2019-02-15
pjp
naptr->replacementlen = naptr_namelen;
2888
2014-11-14
pjp
2889
2020-07-15
pjp
rbt = create_rr(db, converted_name, converted_namelen, DNS_TYPE_NAPTR, naptr, myttl, 0);
2890
2019-02-15
pjp
if (rbt == NULL) {
2891
2019-02-15
pjp
dolog(LOG_ERR, "create_rr failed\n");
2892
2019-02-09
pjp
return -1;
2893
2019-02-15
pjp
}
2894
2014-11-14
pjp
2895
2014-11-14
pjp
if (naptrname)
2896
2014-11-14
pjp
free (naptrname);
2897
2014-11-14
pjp
2898
2014-11-14
pjp
if (converted_name)
2899
2014-11-14
pjp
free (converted_name);
2900
2015-06-16
pjp
2901
2014-11-14
pjp
2902
2014-11-14
pjp
return (0);
2903
2014-11-14
pjp
2904
2014-11-14
pjp
}
2905
2014-11-14
pjp
2906
2014-11-14
pjp
int
2907
2020-07-06
pjp
fill_txt(ddDB *db, char *name, char *type, int myttl, char *msg)
2908
2014-11-14
pjp
{
2909
2019-02-15
pjp
struct rbtree *rbt;
2910
2019-02-15
pjp
struct txt *txt;
2911
2014-11-14
pjp
int converted_namelen;
2912
2014-11-14
pjp
char *converted_name;
2913
2019-04-30
pjp
int len, i, j, tmplen, origlen;
2914
2019-04-30
pjp
u_char *tmp;
2915
2019-04-30
pjp
int messages = 1;
2916
2014-11-14
pjp
2917
2014-11-14
pjp
for (i = 0; i < strlen(name); i++) {
2918
2014-11-14
pjp
name[i] = tolower((int)name[i]);
2919
2014-11-14
pjp
}
2920
2014-11-14
pjp
2921
2019-04-30
pjp
origlen = tmplen = len = strlen(msg);
2922
2019-04-30
pjp
while (tmplen > 255) {
2923
2019-04-30
pjp
messages++;
2924
2019-04-30
pjp
tmplen -= 255;
2925
2014-11-14
pjp
}
2926
2014-11-14
pjp
2927
2019-04-30
pjp
len += messages;
2928
2019-04-30
pjp
2929
2019-04-30
pjp
if (len > 1024) {
2930
2019-04-30
pjp
dolog(LOG_ERR, "fill_txt: more than 1024 characters in TXT RR\n");
2931
2019-04-30
pjp
return -1;
2932
2019-04-30
pjp
}
2933
2019-04-30
pjp
2934
2019-04-30
pjp
tmp = malloc(len);
2935
2019-04-30
pjp
if (tmp == NULL) {
2936
2019-04-30
pjp
dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
2937
2019-04-30
pjp
return -1;
2938
2019-04-30
pjp
}
2939
2019-04-30
pjp
2940
2019-04-30
pjp
for (i = 0, j = 0, tmplen = origlen; tmplen > 0; tmplen -= 255) {
2941
2019-04-30
pjp
tmp[i] = ((tmplen >= 255) ? 255 : tmplen);
2942
2019-04-30
pjp
i++;
2943
2019-04-30
pjp
memcpy(&tmp[i], &msg[j], (tmplen >= 255) ? 255 : tmplen);
2944
2019-04-30
pjp
i += 255;
2945
2019-04-30
pjp
j += 255;
2946
2019-04-30
pjp
}
2947
2019-04-30
pjp
2948
2019-02-15
pjp
converted_name = check_rr(name, type, DNS_TYPE_TXT, &converted_namelen);
2949
2019-02-15
pjp
if (converted_name == NULL) {
2950
2014-11-14
pjp
return -1;
2951
2014-11-14
pjp
}
2952
2014-11-14
pjp
2953
2019-02-15
pjp
if ((txt = (struct txt *)calloc(1, sizeof(struct txt))) == NULL) {
2954
2019-02-15
pjp
dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
2955
2015-06-16
pjp
return -1;
2956
2014-11-14
pjp
}
2957
2014-11-14
pjp
2958
2019-04-30
pjp
memcpy(&txt->txt, tmp, len);
2959
2019-02-15
pjp
txt->txtlen = len;
2960
2014-11-14
pjp
2961
2020-07-15
pjp
rbt = create_rr(db, converted_name, converted_namelen, DNS_TYPE_TXT, txt, myttl, 0);
2962
2019-02-15
pjp
if (rbt == NULL) {
2963
2019-02-15
pjp
dolog(LOG_ERR, "create_rr failed\n");
2964
2019-02-09
pjp
return -1;
2965
2019-02-15
pjp
}
2966
2014-11-14
pjp
2967
2014-11-14
pjp
if (converted_name)
2968
2014-11-14
pjp
free (converted_name);
2969
2014-11-14
pjp
2970
2019-04-30
pjp
free (tmp);
2971
2015-06-16
pjp
2972
2015-06-16
pjp
2973
2014-11-14
pjp
return (0);
2974
2014-11-14
pjp
2975
2014-11-14
pjp
}
2976
2014-11-14
pjp
2977
2014-11-14
pjp
int
2978
2020-07-06
pjp
fill_tlsa(ddDB *db, char *name, char *type, int myttl, uint8_t usage, uint8_t selector, uint8_t matchtype, char *data)
2979
2014-11-14
pjp
{
2980
2019-02-15
pjp
struct rbtree *rbt;
2981
2019-02-15
pjp
struct tlsa *tlsa;
2982
2014-11-14
pjp
int converted_namelen;
2983
2014-11-14
pjp
char *converted_name;
2984
2014-11-14
pjp
char *p, *ep, save;
2985
2014-11-14
pjp
int len, i;
2986
2014-11-14
pjp
2987
2014-11-14
pjp
for (i = 0; i < strlen(name); i++) {
2988
2014-11-14
pjp
name[i] = tolower((int)name[i]);
2989
2014-11-14
pjp
}
2990
2014-11-14
pjp
2991
2015-11-10
pjp
converted_name = check_rr(name, type, DNS_TYPE_TLSA, &converted_namelen);
2992
2014-11-14
pjp
if (converted_name == NULL) {
2993
2014-11-14
pjp
return -1;
2994
2014-11-14
pjp
}
2995
2014-11-14
pjp
2996
2019-02-15
pjp
if ((tlsa = (struct tlsa *)calloc(1, sizeof(struct tlsa))) == NULL) {
2997
2019-02-15
pjp
dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
2998
2015-06-16
pjp
return -1;
2999
2014-11-14
pjp
}
3000
2014-11-14
pjp
3001
2019-02-15
pjp
tlsa->usage = usage;
3002
2019-02-15
pjp
tlsa->selector = selector;
3003
2019-02-15
pjp
tlsa->matchtype = matchtype;
3004
2015-11-10
pjp
3005
2015-11-10
pjp
switch (matchtype) {
3006
2015-11-10
pjp
case 1:
3007
2019-02-15
pjp
len = tlsa->datalen = DNS_TLSA_SIZE_SHA256;
3008
2015-11-10
pjp
break;
3009
2015-11-10
pjp
case 2:
3010
2019-02-15
pjp
len = tlsa->datalen = DNS_TLSA_SIZE_SHA512;
3011
2015-11-10
pjp
break;
3012
2015-11-10
pjp
default:
3013
2015-11-10
pjp
dolog(LOG_ERR, "tlsa: unknown match type!\n");
3014
2014-11-14
pjp
return -1;
3015
2014-11-14
pjp
}
3016
2014-11-14
pjp
3017
2015-11-10
pjp
p = data;
3018
2015-11-10
pjp
for (i = 0; i < len; i++) {
3019
2015-11-10
pjp
save = p[2];
3020
2015-11-10
pjp
p[2] = '\0';
3021
2019-02-15
pjp
tlsa->data[i] = strtol(p, &ep, 16);
3022
2015-11-10
pjp
p[2] = save;
3023
2015-11-10
pjp
p += 2;
3024
2015-11-10
pjp
}
3025
2014-11-14
pjp
3026
2015-11-10
pjp
3027
2015-11-10
pjp
3028
2020-07-15
pjp
rbt = create_rr(db, converted_name, converted_namelen, DNS_TYPE_TLSA, tlsa, myttl, 0);
3029
2019-02-15
pjp
if (rbt == NULL) {
3030
2019-02-15
pjp
dolog(LOG_ERR, "create_rr failed\n");
3031
2019-02-09
pjp
return -1;
3032
2019-02-15
pjp
}
3033
2019-02-15
pjp
3034
2015-11-10
pjp
if (converted_name)
3035
2015-11-10
pjp
free (converted_name);
3036
2015-06-16
pjp
3037
2015-11-10
pjp
3038
2015-11-10
pjp
return (0);
3039
2014-11-14
pjp
3040
2015-11-10
pjp
}
3041
2014-11-14
pjp
3042
2015-11-10
pjp
int
3043
2020-07-06
pjp
fill_sshfp(ddDB *db, char *name, char *type, int myttl, int alg, int fptype, char *fingerprint)
3044
2015-11-10
pjp
{
3045
2019-02-15
pjp
struct sshfp *sshfp;
3046
2019-02-15
pjp
struct rbtree *rbt;
3047
2015-11-10
pjp
int converted_namelen;
3048
2015-11-10
pjp
char *converted_name;
3049
2020-08-08
pjp
int i;
3050
2015-11-10
pjp
3051
2015-11-10
pjp
for (i = 0; i < strlen(name); i++) {
3052
2015-11-10
pjp
name[i] = tolower((int)name[i]);
3053
2014-11-14
pjp
}
3054
2014-11-14
pjp
3055
2015-11-10
pjp
converted_name = check_rr(name, type, DNS_TYPE_SSHFP, &converted_namelen);
3056
2015-11-10
pjp
if (converted_name == NULL) {
3057
2015-11-10
pjp
return -1;
3058
2014-11-14
pjp
}
3059
2014-11-14
pjp
3060
2019-02-15
pjp
if ((sshfp = (struct sshfp *)calloc(1, sizeof(struct sshfp))) == NULL) {
3061
2019-02-15
pjp
dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
3062
2015-11-10
pjp
return -1;
3063
2015-11-10
pjp
}
3064
2014-11-14
pjp
3065
2019-02-15
pjp
sshfp->algorithm = alg;
3066
2019-02-15
pjp
sshfp->fptype = fptype;
3067
2014-11-14
pjp
3068
2015-06-16
pjp
switch (fptype) {
3069
2015-06-16
pjp
case 1:
3070
2020-08-08
pjp
sshfp->fplen = DNS_SSHFP_SIZE_SHA1;
3071
2015-06-16
pjp
break;
3072
2015-06-16
pjp
case 2:
3073
2020-08-08
pjp
sshfp->fplen = DNS_SSHFP_SIZE_SHA256;
3074
2015-06-16
pjp
break;
3075
2015-06-16
pjp
default:
3076
2015-06-16
pjp
dolog(LOG_ERR, "sshfp: unknown fingerprint type!\n");
3077
2015-06-16
pjp
return -1;
3078
2014-11-14
pjp
}
3079
2014-11-14
pjp
3080
2019-02-18
pjp
memset(sshfp->fingerprint, 0, sizeof(sshfp->fingerprint));
3081
2020-08-08
pjp
hex2bin(fingerprint, strlen(fingerprint), sshfp->fingerprint);
3082
2014-11-14
pjp
3083
2014-11-14
pjp
3084
2020-07-15
pjp
rbt = create_rr(db, converted_name, converted_namelen, DNS_TYPE_SSHFP, sshfp, myttl, 0);
3085
2019-02-15
pjp
if (rbt == NULL) {
3086
2019-02-15
pjp
dolog(LOG_ERR, "create_rr failed\n");
3087
2019-02-15
pjp
return -1;
3088
2019-02-15
pjp
}
3089
2014-11-14
pjp
3090
2014-11-14
pjp
3091
2014-11-14
pjp
if (converted_name)
3092
2014-11-14
pjp
free (converted_name);
3093
2015-06-16
pjp
3094
2014-11-14
pjp
3095
2014-11-14
pjp
return (0);
3096
2014-11-14
pjp
3097
2014-11-14
pjp
}
3098
2014-11-14
pjp
3099
2014-11-14
pjp
int
3100
2020-07-06
pjp
fill_srv(ddDB *db, char *name, char *type, int myttl, int priority, int weight, int port, char *srvhost)
3101
2014-11-14
pjp
{
3102
2019-02-15
pjp
struct srv *srv;
3103
2019-02-15
pjp
struct rbtree *rbt;
3104
2014-11-14
pjp
int converted_namelen;
3105
2014-11-14
pjp
char *converted_name;
3106
2015-06-16
pjp
char *srvname;
3107
2014-11-14
pjp
int len, i;
3108
2014-11-14
pjp
3109
2014-11-14
pjp
for (i = 0; i < strlen(name); i++) {
3110
2014-11-14
pjp
name[i] = tolower((int)name[i]);
3111
2014-11-14
pjp
}
3112
2014-11-14
pjp
3113
2015-06-16
pjp
converted_name = check_rr(name, type, DNS_TYPE_SRV, &converted_namelen);
3114
2014-11-14
pjp
if (converted_name == NULL) {
3115
2014-11-14
pjp
return -1;
3116
2014-11-14
pjp
}
3117
2014-11-14
pjp
3118
2019-02-15
pjp
if ((srv = (struct srv *)calloc(1, sizeof(struct srv))) == NULL) {
3119
2019-02-15
pjp
dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
3120
2015-06-16
pjp
return -1;
3121
2014-11-14
pjp
}
3122
2014-11-14
pjp
3123
2019-02-15
pjp
srv->priority = priority;
3124
2019-02-15
pjp
srv->weight = weight;
3125
2019-02-15
pjp
srv->port = port;
3126
2014-11-14
pjp
3127
2015-06-16
pjp
srvname = dns_label(srvhost, &len);
3128
2015-06-16
pjp
if (srvname == NULL) {
3129
2015-06-16
pjp
dolog(LOG_INFO, "illegal srv server, skipping line %d\n", file->lineno);
3130
2014-11-14
pjp
return (-1);
3131
2014-11-14
pjp
}
3132
2014-11-14
pjp
3133
2019-02-15
pjp
srv->targetlen = len;
3134
2019-02-15
pjp
memcpy((char *)&srv->target, srvname, len);
3135
2014-11-14
pjp
3136
2015-06-16
pjp
/* bad hack workaround !!! */
3137
2015-06-16
pjp
if (strcmp(srvhost, ".") == 0 && len > 1)
3138
2019-02-15
pjp
srv->targetlen = 1;
3139
2014-11-14
pjp
3140
2015-06-16
pjp
free (srvname);
3141
2014-11-14
pjp
3142
2020-07-15
pjp
rbt = create_rr(db, converted_name, converted_namelen, DNS_TYPE_SRV, srv, myttl, 0);
3143
2019-02-15
pjp
if (rbt == NULL) {
3144
2019-02-15
pjp
dolog(LOG_ERR, "create_rr failed\n");
3145
2019-02-09
pjp
return -1;
3146
2019-02-15
pjp
}
3147
2014-11-14
pjp
3148
2014-11-14
pjp
if (converted_name)
3149
2014-11-14
pjp
free (converted_name);
3150
2014-11-14
pjp
3151
2015-06-16
pjp
3152
2014-11-14
pjp
return (0);
3153
2014-11-14
pjp
3154
2014-11-14
pjp
}
3155
2014-11-14
pjp
3156
2014-11-14
pjp
int
3157
2020-07-06
pjp
fill_mx(ddDB *db, char *name, char *type, int myttl, int priority, char *mxhost)
3158
2014-11-14
pjp
{
3159
2019-02-15
pjp
struct smx *mx;
3160
2019-02-15
pjp
struct rbtree *rbt;
3161
2014-11-14
pjp
int converted_namelen;
3162
2014-11-14
pjp
char *converted_name;
3163
2015-06-16
pjp
char *mxname;
3164
2015-06-16
pjp
int len, i;
3165
2014-11-14
pjp
3166
2014-11-14
pjp
for (i = 0; i < strlen(name); i++) {
3167
2014-11-14
pjp
name[i] = tolower((int)name[i]);
3168
2014-11-14
pjp
}
3169
2014-11-14
pjp
3170
2015-06-16
pjp
converted_name = check_rr(name, type, DNS_TYPE_MX, &converted_namelen);
3171
2014-11-14
pjp
if (converted_name == NULL) {
3172
2014-11-14
pjp
return -1;
3173
2014-11-14
pjp
}
3174