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