result = cfg_map_get(synthrecordcfg, "prefix", &obj);
if (result != ISC_R_SUCCESS) {
+ isc_log_write(NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_HOOKS,
+ ISC_LOG_ERROR, "synthrecord: prefix not found");
return result;
}
}
static isc_result_t
-synthrecord_initorigin(synthrecord_t *inst, const cfg_obj_t *synthrecordcfg) {
+synthrecord_initorigin(synthrecord_t *inst, const cfg_obj_t *synthrecordcfg,
+ const dns_name_t *zname) {
isc_result_t result;
const cfg_obj_t *obj = NULL;
const char *originstr = NULL;
result = cfg_map_get(synthrecordcfg, "origin", &obj);
- if (result != ISC_R_SUCCESS) {
+ if (inst->mode == REVERSE && result != ISC_R_SUCCESS) {
+ isc_log_write(NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_HOOKS,
+ ISC_LOG_ERROR,
+ "'origin' must be set when configuring "
+ "'synthrecord' for a reverse zone");
return result;
}
- originstr = cfg_obj_asstring(obj);
dns_name_init(&inst->origin);
- result = dns_name_fromstring(&inst->origin, originstr, NULL, 0,
- inst->mctx);
- if (result != ISC_R_SUCCESS) {
- return result;
- }
+ if (result == ISC_R_SUCCESS) {
+ originstr = cfg_obj_asstring(obj);
+ result = dns_name_fromstring(&inst->origin, originstr, NULL, 0,
+ inst->mctx);
+ if (result != ISC_R_SUCCESS) {
+ return result;
+ }
- if (!dns_name_isabsolute(&inst->origin)) {
- isc_log_write(NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_HOOKS,
- ISC_LOG_ERROR,
- "synthrecord: origin '%s' is not absolute",
- originstr);
- return ISC_R_FAILURE;
+ if (!dns_name_isabsolute(&inst->origin)) {
+ isc_log_write(NS_LOGCATEGORY_GENERAL,
+ NS_LOGMODULE_HOOKS, ISC_LOG_ERROR,
+ "synthrecord: origin '%s' not absolute",
+ originstr);
+ return ISC_R_FAILURE;
+ }
+ } else {
+ dns_name_dup(zname, inst->mctx, &inst->origin);
}
- return result;
+ return ISC_R_SUCCESS;
}
static void
&synthrecord_cfgparams, 0, &synthrecordcfg));
synthrecord_setconfigmode(inst, zname);
- CHECK(synthrecord_initorigin(inst, synthrecordcfg));
+ CHECK(synthrecord_initorigin(inst, synthrecordcfg, zname));
CHECK(synthrecord_initprefix(inst, synthrecordcfg));
CHECK(synthrecord_parseallowsynth(inst, cfg, aclctx, synthrecordcfg));
CHECK(synthrecord_parsettl(inst, synthrecordcfg));
Parameters
~~~~~~~~~~
-The following parameters are mandatory:
-
``prefix``
Specifies the prefix of the synthesized name. It must be a single-label
- name.
+ name. This parameter is mandatory.
``origin``
Specifies the origin of the synthesized name. This may be the same as
the zone origin, or a descendent. It cannot be below a delegation point.
-
-The following parameters are optional:
+ This parameter is mandatory for reverse zones, but when configured in
+ forward mode, it defaults to the zone name.
``allow-synth``
This option is an address-match list, which can be used to restrict