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