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