~kernevil/ubuntu/trusty/bind9/sdlz-hmac-keys

« back to all changes in this revision

Viewing changes to lib/isccfg/namedconf.c

  • Committer: Package Import Robot
  • Author(s): LaMont Jones, Matthew Grant, LaMont Jones
  • Date: 2012-10-29 08:37:49 UTC
  • mfrom: (1.9.2)
  • Revision ID: package-import@ubuntu.com-20121029083749-r9inpzl0yuj9xdlu
Tags: 1:9.8.4.dfsg-1
[Matthew Grant]

* Turn off dlopen as it was causing test compile failures.
* Add missing library .postrm files for debhelper

[LaMont Jones]

* New upstream version
* soname fixup
* Ack NMUs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2004-2011  Internet Systems Consortium, Inc. ("ISC")
 
2
 * Copyright (C) 2004-2012  Internet Systems Consortium, Inc. ("ISC")
3
3
 * Copyright (C) 2002, 2003  Internet Software Consortium.
4
4
 *
5
5
 * Permission to use, copy, modify, and/or distribute this software for any
15
15
 * PERFORMANCE OF THIS SOFTWARE.
16
16
 */
17
17
 
18
 
/* $Id: namedconf.c,v 1.131.8.4 2011-05-23 20:56:11 each Exp $ */
 
18
/* $Id$ */
19
19
 
20
20
/*! \file */
21
21
 
1014
1014
 
1015
1015
 
1016
1016
 
1017
 
/*
 
1017
/*%
1018
1018
 *  response-policy {
1019
 
 *      zone <string> [ policy (given|no-op|nxdomain|nodata|cname <domain> ) ];
1020
 
 *  };
1021
 
 *
1022
 
 * this is a chimera of doc_optional_keyvalue() and cfg_doc_enum()
 
1019
 *      zone <string> [ policy (given|disabled|passthru|
 
1020
 *                                      nxdomain|nodata|cname <domain> ) ]
 
1021
 *                    [ recursive-only yes|no ]
 
1022
 *                    [ max-policy-ttl number ] ;
 
1023
 *  } [ recursive-only yes|no ] [ break-dnssec yes|no ]
 
1024
 *      [ max-policy-ttl number ] ;
1023
1025
 */
 
1026
 
1024
1027
static void
1025
 
doc_rpz_policies(cfg_printer_t *pctx, const cfg_type_t *type) {
1026
 
        const keyword_type_t *kw;
 
1028
doc_rpz_policy(cfg_printer_t *pctx, const cfg_type_t *type) {
1027
1029
        const char * const *p;
1028
 
 
1029
 
        kw = type->of;
1030
 
        cfg_print_chars(pctx, "[ ", 2);
1031
 
        cfg_print_cstr(pctx, kw->name);
1032
 
        cfg_print_chars(pctx, " ", 1);
1033
 
 
 
1030
        /*
 
1031
         * This is cfg_doc_enum() without the trailing " )".
 
1032
         */
1034
1033
        cfg_print_chars(pctx, "( ", 2);
1035
 
        for (p = kw->type->of; *p != NULL; p++) {
 
1034
        for (p = type->of; *p != NULL; p++) {
1036
1035
                cfg_print_cstr(pctx, *p);
1037
1036
                if (p[1] != NULL)
1038
1037
                        cfg_print_chars(pctx, " | ", 3);
1039
1038
        }
1040
1039
}
1041
1040
 
1042
 
/*
1043
 
 * print_qstring() from parser.c
1044
 
 */
1045
 
static void
1046
 
print_rpz_cname(cfg_printer_t *pctx, const cfg_obj_t *obj)
1047
 
{
1048
 
        cfg_print_chars(pctx, "\"", 1);
1049
 
        cfg_print_ustring(pctx, obj);
1050
 
        cfg_print_chars(pctx, "\"", 1);
1051
 
}
1052
 
 
1053
1041
static void
1054
1042
doc_rpz_cname(cfg_printer_t *pctx, const cfg_type_t *type) {
1055
1043
        cfg_doc_terminal(pctx, type);
1056
 
        cfg_print_chars(pctx, " ) ]", 4);
 
1044
        cfg_print_chars(pctx, " )", 2);
1057
1045
}
1058
1046
 
 
1047
/*
 
1048
 * Parse
 
1049
 *      given|disabled|passthru|nxdomain|nodata|cname <domain>
 
1050
 */
1059
1051
static isc_result_t
1060
 
parse_rpz(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
 
1052
cfg_parse_rpz_policy(cfg_parser_t *pctx, const cfg_type_t *type,
 
1053
                     cfg_obj_t **ret)
 
1054
{
1061
1055
        isc_result_t result;
1062
 
        cfg_obj_t *obj = NULL;
1063
 
        const cfg_tuplefielddef_t *fields = type->of;
 
1056
        cfg_obj_t *obj;
 
1057
        const cfg_tuplefielddef_t *fields;
1064
1058
 
1065
1059
        CHECK(cfg_create_tuple(pctx, type, &obj));
 
1060
 
 
1061
        fields = type->of;
1066
1062
        CHECK(cfg_parse_obj(pctx, fields[0].type, &obj->value.tuple[0]));
1067
 
        CHECK(cfg_parse_obj(pctx, fields[1].type, &obj->value.tuple[1]));
1068
1063
        /*
1069
1064
         * parse cname domain only after "policy cname"
1070
1065
         */
1071
 
        if (cfg_obj_isvoid(obj->value.tuple[1]) ||
1072
 
            strcasecmp("cname", cfg_obj_asstring(obj->value.tuple[1]))) {
1073
 
                CHECK(cfg_parse_void(pctx, NULL, &obj->value.tuple[2]));
 
1066
        if (strcasecmp("cname", cfg_obj_asstring(obj->value.tuple[0])) != 0) {
 
1067
                CHECK(cfg_parse_void(pctx, NULL, &obj->value.tuple[1]));
1074
1068
        } else {
1075
 
                CHECK(cfg_parse_obj(pctx, fields[2].type, &obj->value.tuple[2]));
1076
 
        }
1077
 
 
1078
 
        *ret = obj;
1079
 
        return (ISC_R_SUCCESS);
1080
 
 
1081
 
cleanup:
1082
 
        CLEANUP_OBJ(obj);
1083
 
        return (result);
1084
 
}
1085
 
 
 
1069
                CHECK(cfg_parse_obj(pctx, fields[1].type,
 
1070
                                    &obj->value.tuple[1]));
 
1071
        }
 
1072
 
 
1073
        *ret = obj;
 
1074
        return (ISC_R_SUCCESS);
 
1075
 
 
1076
cleanup:
 
1077
        CLEANUP_OBJ(obj);
 
1078
        return (result);
 
1079
}
 
1080
 
 
1081
/*
 
1082
 * Parse a tuple consisting of any kind of  required field followed
 
1083
 * by 2 or more optional keyvalues that can be in any order.
 
1084
 */
 
1085
static isc_result_t
 
1086
cfg_parse_kv_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
 
1087
        const cfg_tuplefielddef_t *fields, *f;
 
1088
        cfg_obj_t *obj;
 
1089
        int fn;
 
1090
        isc_result_t result;
 
1091
 
 
1092
        obj = NULL;
 
1093
        CHECK(cfg_create_tuple(pctx, type, &obj));
 
1094
 
 
1095
        /*
 
1096
         * The zone first field is required and always first.
 
1097
         */
 
1098
        fields = type->of;
 
1099
        CHECK(cfg_parse_obj(pctx, fields[0].type, &obj->value.tuple[0]));
 
1100
 
 
1101
        for (;;) {
 
1102
                CHECK(cfg_peektoken(pctx, CFG_LEXOPT_QSTRING));
 
1103
                if (pctx->token.type != isc_tokentype_string)
 
1104
                        break;
 
1105
 
 
1106
                for (fn = 1, f = &fields[1]; ; ++fn, ++f) {
 
1107
                        if (f->name == NULL) {
 
1108
                                cfg_parser_error(pctx, 0, "unexpected '%s'",
 
1109
                                                 TOKEN_STRING(pctx));
 
1110
                                result = ISC_R_UNEXPECTEDTOKEN;
 
1111
                                goto cleanup;
 
1112
                        }
 
1113
                        if (obj->value.tuple[fn] == NULL &&
 
1114
                            strcasecmp(f->name, TOKEN_STRING(pctx)) == 0)
 
1115
                                break;
 
1116
                }
 
1117
 
 
1118
                CHECK(cfg_gettoken(pctx, 0));
 
1119
                CHECK(cfg_parse_obj(pctx, f->type, &obj->value.tuple[fn]));
 
1120
        }
 
1121
 
 
1122
        for (fn = 1, f = &fields[1]; f->name != NULL; ++fn, ++f) {
 
1123
                if (obj->value.tuple[fn] == NULL)
 
1124
                        CHECK(cfg_parse_void(pctx, NULL,
 
1125
                                             &obj->value.tuple[fn]));
 
1126
        }
 
1127
 
 
1128
        *ret = obj;
 
1129
        return (ISC_R_SUCCESS);
 
1130
 
 
1131
cleanup:
 
1132
        CLEANUP_OBJ(obj);
 
1133
        return (result);
 
1134
}
 
1135
 
 
1136
static void
 
1137
cfg_print_kv_tuple(cfg_printer_t *pctx, const cfg_obj_t *obj) {
 
1138
        unsigned int i;
 
1139
        const cfg_tuplefielddef_t *fields, *f;
 
1140
        const cfg_obj_t *fieldobj;
 
1141
 
 
1142
        fields = obj->type->of;
 
1143
        for (f = fields, i = 0; f->name != NULL; f++, i++) {
 
1144
                fieldobj = obj->value.tuple[i];
 
1145
                if (fieldobj->type->print == cfg_print_void)
 
1146
                        continue;
 
1147
                if (i != 0) {
 
1148
                        cfg_print_chars(pctx, " ", 1);
 
1149
                        cfg_print_cstr(pctx, f->name);
 
1150
                        cfg_print_chars(pctx, " ", 1);
 
1151
                }
 
1152
                cfg_print_obj(pctx, fieldobj);
 
1153
        }
 
1154
}
 
1155
 
 
1156
static void
 
1157
cfg_doc_kv_tuple(cfg_printer_t *pctx, const cfg_type_t *type) {
 
1158
        const cfg_tuplefielddef_t *fields, *f;
 
1159
 
 
1160
        fields = type->of;
 
1161
        for (f = fields; f->name != NULL; f++) {
 
1162
                if (f != fields) {
 
1163
                        cfg_print_chars(pctx, " [ ", 3);
 
1164
                        cfg_print_cstr(pctx, f->name);
 
1165
                        if (f->type->doc != cfg_doc_void)
 
1166
                                cfg_print_chars(pctx, " ", 1);
 
1167
                }
 
1168
                cfg_doc_obj(pctx, f->type);
 
1169
                if (f != fields)
 
1170
                        cfg_print_chars(pctx, " ]", 2);
 
1171
        }
 
1172
}
 
1173
 
 
1174
static keyword_type_t zone_kw = {"zone", &cfg_type_qstring};
 
1175
static cfg_type_t cfg_type_rpz_zone = {
 
1176
        "zone", parse_keyvalue, print_keyvalue,
 
1177
        doc_keyvalue, &cfg_rep_string,
 
1178
        &zone_kw
 
1179
};
1086
1180
static const char *rpz_policies[] = {
1087
 
        "given", "no-op", "nxdomain", "nodata", "cname", NULL
1088
 
};
1089
 
static cfg_type_t cfg_type_rpz_policylist = {
1090
 
        "policies", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum,
1091
 
        &cfg_rep_string, &rpz_policies
1092
 
};
1093
 
static keyword_type_t rpz_policies_kw = {
1094
 
        "policy", &cfg_type_rpz_policylist
 
1181
        "given", "disabled", "passthru", "no-op", "nxdomain", "nodata",
 
1182
        "cname", NULL
 
1183
};
 
1184
static cfg_type_t cfg_type_rpz_policy_name = {
 
1185
        "policy name", cfg_parse_enum, cfg_print_ustring,
 
1186
        doc_rpz_policy, &cfg_rep_string,
 
1187
        &rpz_policies
 
1188
};
 
1189
static cfg_type_t cfg_type_rpz_cname = {
 
1190
        "quoted_string", cfg_parse_astring, NULL,
 
1191
        doc_rpz_cname, &cfg_rep_string,
 
1192
        NULL
 
1193
};
 
1194
static cfg_tuplefielddef_t rpz_policy_fields[] = {
 
1195
        { "policy name", &cfg_type_rpz_policy_name, 0 },
 
1196
        { "cname", &cfg_type_rpz_cname, 0 },
 
1197
        { NULL, NULL, 0 }
1095
1198
};
1096
1199
static cfg_type_t cfg_type_rpz_policy = {
1097
 
        "optional_policy", parse_optional_keyvalue, print_keyvalue,
1098
 
        doc_rpz_policies, &cfg_rep_string, &rpz_policies_kw
1099
 
};
1100
 
static cfg_type_t cfg_type_cname = {
1101
 
        "domain", cfg_parse_astring, print_rpz_cname, doc_rpz_cname,
1102
 
        &cfg_rep_string, NULL
1103
 
};
1104
 
static cfg_tuplefielddef_t rpzone_fields[] = {
1105
 
        { "name", &cfg_type_astring, 0 },
 
1200
        "policy tuple", cfg_parse_rpz_policy,
 
1201
        cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,
 
1202
        rpz_policy_fields
 
1203
};
 
1204
static cfg_tuplefielddef_t rpz_zone_fields[] = {
 
1205
        { "zone name", &cfg_type_rpz_zone, 0 },
1106
1206
        { "policy", &cfg_type_rpz_policy, 0 },
1107
 
        { "cname", &cfg_type_cname, 0 },
1108
 
        { NULL, NULL, 0 }
1109
 
};
1110
 
static cfg_type_t cfg_type_rpzone = {
1111
 
        "rpzone", parse_rpz, cfg_print_tuple, cfg_doc_tuple,
1112
 
        &cfg_rep_tuple, rpzone_fields
1113
 
};
1114
 
static cfg_clausedef_t rpz_clauses[] = {
1115
 
        { "zone", &cfg_type_rpzone, CFG_CLAUSEFLAG_MULTI },
1116
 
        { NULL, NULL, 0 }
1117
 
};
1118
 
static cfg_clausedef_t *rpz_clausesets[] = {
1119
 
        rpz_clauses,
1120
 
        NULL
 
1207
        { "recursive-only", &cfg_type_boolean, 0 },
 
1208
        { "max-policy-ttl", &cfg_type_uint32, 0 },
 
1209
        { NULL, NULL, 0 }
 
1210
};
 
1211
static cfg_type_t cfg_type_rpz_tuple = {
 
1212
        "rpz tuple", cfg_parse_kv_tuple,
 
1213
        cfg_print_kv_tuple, cfg_doc_kv_tuple, &cfg_rep_tuple,
 
1214
        rpz_zone_fields
 
1215
};
 
1216
static cfg_type_t cfg_type_rpz_list = {
 
1217
        "zone list", cfg_parse_bracketed_list, cfg_print_bracketed_list,
 
1218
        cfg_doc_bracketed_list, &cfg_rep_list,
 
1219
        &cfg_type_rpz_tuple
 
1220
};
 
1221
static cfg_tuplefielddef_t rpz_fields[] = {
 
1222
        { "zone list", &cfg_type_rpz_list, 0 },
 
1223
        { "recursive-only", &cfg_type_boolean, 0 },
 
1224
        { "break-dnssec", &cfg_type_boolean, 0 },
 
1225
        { "max-policy-ttl", &cfg_type_uint32, 0 },
 
1226
        { NULL, NULL, 0 }
1121
1227
};
1122
1228
static cfg_type_t cfg_type_rpz = {
1123
 
        "rpz", cfg_parse_map, cfg_print_map, cfg_doc_map,
1124
 
        &cfg_rep_map, rpz_clausesets
 
1229
        "rpz", cfg_parse_kv_tuple,
 
1230
        cfg_print_kv_tuple, cfg_doc_kv_tuple, &cfg_rep_tuple,
 
1231
        rpz_fields
1125
1232
};
1126
1233
 
1127
1234
 
1128
 
 
1129
1235
/*%
1130
1236
 * dnssec-lookaside
1131
1237
 */
1145
1251
static void
1146
1252
doc_lookaside(cfg_printer_t *pctx, const cfg_type_t *type) {
1147
1253
        UNUSED(type);
1148
 
        cfg_print_cstr(pctx, "( <string> trust-anchor <string> | auto )");
 
1254
        cfg_print_cstr(pctx, "( <string> trust-anchor <string> | auto | no )");
1149
1255
}
1150
1256
 
1151
1257
static keyword_type_t trustanchor_kw = { "trust-anchor", &cfg_type_astring };
1351
1457
        { "also-notify", &cfg_type_portiplist, 0 },
1352
1458
        { "alt-transfer-source", &cfg_type_sockaddr4wild, 0 },
1353
1459
        { "alt-transfer-source-v6", &cfg_type_sockaddr6wild, 0 },
 
1460
        { "auto-dnssec", &cfg_type_autodnssec, 0 },
1354
1461
        { "check-dup-records", &cfg_type_checkmode, 0 },
1355
1462
        { "check-integrity", &cfg_type_boolean, 0 },
1356
1463
        { "check-mx", &cfg_type_checkmode, 0 },
1420
1527
         */
1421
1528
        { "check-names", &cfg_type_checkmode, 0 },
1422
1529
        { "ixfr-from-differences", &cfg_type_boolean, 0 },
1423
 
        { "auto-dnssec", &cfg_type_autodnssec, 0 },
1424
1530
        { "server-addresses", &cfg_type_bracketed_sockaddrlist, 0 },
1425
1531
        { "server-names", &cfg_type_namelist, 0 },
1426
1532
        { NULL, NULL, 0 }