diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-20 10:33:02 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-20 10:33:02 +0300 |
commit | b32cc9bd4d9695fee857e71520833ce89134169e (patch) | |
tree | b287eb71b864835d04f05afc401c65266715e95d | |
parent | 3bf6241deeaebd9b5dc16a26b214559d3d45838b (diff) | |
download | nssync-b32cc9bd4d9695fee857e71520833ce89134169e.tar.gz nssync-b32cc9bd4d9695fee857e71520833ce89134169e.tar.bz2 |
Use per-view file name patterns.
* src/bindcf.c (bind_zonefile_dir): Remove.
(zone_file_pattern): Change default value.
(bindcf_lookup): expand $synctag.
* src/config.c (sync_kw) <zonefile-pattern>: New statement.
(nssync_kw) <zonefile-dir>: Remove.
(config_help): Update for the latest grecs.
(synclist_fixup): New function.
(config_parse): Call synclist_fixup.
* src/nssync.h (bind_zonefile_dir): Remove.
(nssync)<zone_file_pattern>: New field.
m--------- | grecs | 0 | ||||
-rw-r--r-- | src/bindcf.c | 29 | ||||
-rw-r--r-- | src/config.c | 33 | ||||
-rw-r--r-- | src/nssync.h | 3 |
4 files changed, 43 insertions, 22 deletions
diff --git a/grecs b/grecs -Subproject 9388982950195420a96db58f04a5e6d0f292559 +Subproject d253fa956809a1497583212109d33fd4f1a05b3 diff --git a/src/bindcf.c b/src/bindcf.c index d87f64b..9dae53a 100644 --- a/src/bindcf.c +++ b/src/bindcf.c @@ -18,8 +18,7 @@ char *named_conf_file; struct grecs_list *bind_include_path; -char *bind_zonefile_dir; -char *zone_file_pattern = "$zone"; +char *zone_file_pattern = "$zone.$synctag"; static char *bind_working_dir; static struct grecs_node *bind_tree; @@ -58,18 +57,14 @@ source_named_conf() bind_working_dir = node->v.value->v.string; } - if (!bind_zonefile_dir) { - if (bind_working_dir) { - bind_zonefile_dir = bind_working_dir; - error("warning: no zonefile-dir set; " - "assuming %s", bind_zonefile_dir); - } else if (bind_include_path) { - bind_zonefile_dir = bind_include_path->head->data; - error("warning: no zonefile-dir set; " - "assuming %s", bind_zonefile_dir); + if (!bind_working_dir) { + if (bind_include_path) { + bind_working_dir = bind_include_path->head->data; + error("warning: bind working dir not set; " + "assuming %s", bind_working_dir); } - if (!bind_zonefile_dir) { + if (!bind_working_dir) { error("cannot determine directory name for generated" " zone files; set zonefile-dir to fix"); exit(EX_CONFIG); @@ -203,7 +198,7 @@ safe_filename(const char *file) char * bindcf_lookup(struct nssync *sp, const char *zone) { - char *env[3]; + char *env[5]; struct wordsplit ws; char *name; struct grecs_node *node; @@ -243,9 +238,11 @@ bindcf_lookup(struct nssync *sp, const char *zone) /* No zone statement: new zone */ env[0] = "zone"; env[1] = safe_filename(zone); - env[2] = NULL; + env[2] = "synctag"; + env[3] = sp->tag; + env[4] = NULL; ws.ws_env = (const char**)env; - if (wordsplit(zone_file_pattern, &ws, + if (wordsplit(sp->zone_file_pattern, &ws, WRDSF_NOCMD | WRDSF_ENV | WRDSF_ENV_KV | WRDSF_NOSPLIT | WRDSF_KEEPUNDEF)) { error("cannot split zone-file-pattern: %s", @@ -253,7 +250,7 @@ bindcf_lookup(struct nssync *sp, const char *zone) exit(EX_SOFTWARE); } grecs_free(env[1]); - name = absolute_name(ws.ws_wordv[0], bind_zonefile_dir); + name = absolute_name(ws.ws_wordv[0], bind_working_dir); wordsplit_free(&ws); new_zone(sp, zone, name); diff --git a/src/config.c b/src/config.c index aad39cc..ff9c9e4 100644 --- a/src/config.c +++ b/src/config.c @@ -23,6 +23,9 @@ static struct grecs_keyword sync_kw[] = { { "zone-conf", NULL, "zone configuration file", grecs_type_string, NULL, offsetof(struct nssync, zone_conf_file) }, + { "zonefile-pattern", + NULL, "Pattern for new zone file names", + grecs_type_string, NULL, offsetof(struct nssync, zone_file_pattern) }, { "soa-query", NULL, "Set query for retrieving SOA records", grecs_type_string, NULL, offsetof(struct nssync, soa_query) }, @@ -128,9 +131,6 @@ static struct grecs_keyword nssync_kw[] = { { "bind-include-path", NULL, "Set include path for BIND configuration", grecs_type_string|GRECS_LIST, &bind_include_path }, - { "zonefile-dir", - NULL, "Directory for new zone files", - grecs_type_string, &bind_zonefile_dir }, { "zonefile-pattern", NULL, "Pattern for new zone file names", grecs_type_string, &zone_file_pattern }, @@ -153,8 +153,8 @@ config_help() { static char docstring[] = N_("Configuration file structure for NSsync.\n"); - grecs_format_docstring(docstring, 0, stdout); - grecs_format_statement_array(nssync_kw, 1, 0, stdout); + grecs_print_docstring(docstring, 0, stdout); + grecs_print_statement_array(nssync_kw, 1, 0, stdout); } void @@ -201,6 +201,26 @@ sql_host_fixup() return 0; } +static int +synclist_fixup() +{ + int err = 0; + struct grecs_list_entry *ep; + + for (ep = synclist->head; ep; ep = ep->next) { + struct nssync *sp = ep->data; + if (!sp->zone_file_pattern) { + if (!zone_file_pattern) { + error("%s: zonefile-pattern not defined", + sp->tag); + err = 1; + } else + sp->zone_file_pattern = zone_file_pattern; + } + } + return err; +} + void config_parse() { @@ -217,6 +237,9 @@ config_parse() error("nothing to do!"); err = 1; } + + if (synclist_fixup()) + err = 1; if (sql_host_fixup()) err = 1; diff --git a/src/nssync.h b/src/nssync.h index bb15d82..52c317a 100644 --- a/src/nssync.h +++ b/src/nssync.h @@ -51,7 +51,7 @@ extern int sql_port; extern char *named_conf_file; extern struct grecs_list *bind_include_path; -extern char *bind_zonefile_dir; + extern char *zone_file_pattern; extern struct grecs_list *synclist; @@ -88,6 +88,7 @@ int sql_get_slave_status(char **pfile, char **poff); struct nssync { char *tag; char *zone_conf_file; + char *zone_file_pattern; struct grecs_node *zone_tree; char *soa_query; |