summaryrefslogtreecommitdiff
path: root/lib/isccfg
diff options
context:
space:
mode:
Diffstat (limited to 'lib/isccfg')
-rw-r--r--lib/isccfg/api6
-rw-r--r--lib/isccfg/include/isccfg/cfg.h12
-rw-r--r--lib/isccfg/include/isccfg/grammar.h7
-rw-r--r--lib/isccfg/namedconf.c6
-rw-r--r--lib/isccfg/parser.c54
5 files changed, 73 insertions, 12 deletions
diff --git a/lib/isccfg/api b/lib/isccfg/api
index 39585b0239db..749c3eb0c405 100644
--- a/lib/isccfg/api
+++ b/lib/isccfg/api
@@ -4,6 +4,6 @@
# 9.8: 80-89, 120-129
# 9.9: 90-109
# 9.9-sub: 130-139
-LIBINTERFACE = 82
-LIBREVISION = 7
-LIBAGE = 0
+LIBINTERFACE = 83
+LIBREVISION = 0
+LIBAGE = 1
diff --git a/lib/isccfg/include/isccfg/cfg.h b/lib/isccfg/include/isccfg/cfg.h
index b21a3d86babc..a99c7637bb85 100644
--- a/lib/isccfg/include/isccfg/cfg.h
+++ b/lib/isccfg/include/isccfg/cfg.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2007, 2010, 2013 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2007, 2010, 2013, 2014 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000-2002 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -380,10 +380,20 @@ void
cfg_print(const cfg_obj_t *obj,
void (*f)(void *closure, const char *text, int textlen),
void *closure);
+void
+cfg_printx(const cfg_obj_t *obj, unsigned int flags,
+ void (*f)(void *closure, const char *text, int textlen),
+ void *closure);
+
+#define CFG_PRINTER_XKEY 0x1 /* '?' out shared keys. */
+
/*%<
* Print the configuration object 'obj' by repeatedly calling the
* function 'f', passing 'closure' and a region of text starting
* at 'text' and comprising 'textlen' characters.
+ *
+ * If CFG_PRINTER_XKEY the contents of shared keys will be obscured
+ * by replacing them with question marks ('?')
*/
void
diff --git a/lib/isccfg/include/isccfg/grammar.h b/lib/isccfg/include/isccfg/grammar.h
index 2d7080c24c40..ee76ff29ce7d 100644
--- a/lib/isccfg/include/isccfg/grammar.h
+++ b/lib/isccfg/include/isccfg/grammar.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2011 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2011, 2014 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2002, 2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -86,6 +86,7 @@ struct cfg_printer {
void (*f)(void *closure, const char *text, int textlen);
void *closure;
int indent;
+ int flags;
};
/*% A clause definition. */
@@ -266,6 +267,7 @@ LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_uint64;
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_qstring;
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_astring;
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_ustring;
+LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_sstring;
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_sockaddr;
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_netaddr;
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_netaddr4;
@@ -314,6 +316,9 @@ isc_result_t
cfg_parse_astring(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
isc_result_t
+cfg_parse_sstring(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
+
+isc_result_t
cfg_parse_rawaddr(cfg_parser_t *pctx, unsigned int flags, isc_netaddr_t *na);
void
diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c
index 287ce141f4c7..6a7cfb40b6e5 100644
--- a/lib/isccfg/namedconf.c
+++ b/lib/isccfg/namedconf.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2013 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2002, 2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -368,7 +368,7 @@ parse_updatepolicy(cfg_parser_t *pctx, const cfg_type_t *type,
isc_mem_put(pctx->mctx, obj, sizeof(*obj));
return (ISC_R_NOMEMORY);
}
- memcpy(obj->value.string.base, "local", 5);
+ memmove(obj->value.string.base, "local", 5);
obj->value.string.base[5] = '\0';
*ret = obj;
return (ISC_R_SUCCESS);
@@ -1637,7 +1637,7 @@ static cfg_type_t cfg_type_dynamically_loadable_zones_opts = {
static cfg_clausedef_t
key_clauses[] = {
{ "algorithm", &cfg_type_astring, 0 },
- { "secret", &cfg_type_astring, 0 },
+ { "secret", &cfg_type_sstring, 0 },
{ NULL, NULL, 0 }
};
diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c
index de0fa31ee228..1708344e0607 100644
--- a/lib/isccfg/parser.c
+++ b/lib/isccfg/parser.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2013 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -183,14 +183,22 @@ cfg_print(const cfg_obj_t *obj,
void (*f)(void *closure, const char *text, int textlen),
void *closure)
{
+ cfg_printx(obj, 0, f, closure);
+}
+
+void
+cfg_printx(const cfg_obj_t *obj, unsigned int flags,
+ void (*f)(void *closure, const char *text, int textlen),
+ void *closure)
+{
cfg_printer_t pctx;
pctx.f = f;
pctx.closure = closure;
pctx.indent = 0;
+ pctx.flags = flags;
obj->type->print(&pctx, obj);
}
-
/* Tuples. */
isc_result_t
@@ -702,7 +710,7 @@ create_string(cfg_parser_t *pctx, const char *contents, const cfg_type_t *type,
isc_mem_put(pctx->mctx, obj, sizeof(*obj));
return (ISC_R_NOMEMORY);
}
- memcpy(obj->value.string.base, contents, len);
+ memmove(obj->value.string.base, contents, len);
obj->value.string.base[len] = '\0';
*ret = obj;
@@ -762,6 +770,22 @@ cfg_parse_astring(cfg_parser_t *pctx, const cfg_type_t *type,
return (result);
}
+isc_result_t
+cfg_parse_sstring(cfg_parser_t *pctx, const cfg_type_t *type,
+ cfg_obj_t **ret)
+{
+ isc_result_t result;
+ UNUSED(type);
+
+ CHECK(cfg_getstringtoken(pctx));
+ return (create_string(pctx,
+ TOKEN_STRING(pctx),
+ &cfg_type_sstring,
+ ret));
+ cleanup:
+ return (result);
+}
+
isc_boolean_t
cfg_is_enum(const char *s, const char *const *enums) {
const char * const *p;
@@ -819,6 +843,18 @@ print_qstring(cfg_printer_t *pctx, const cfg_obj_t *obj) {
}
static void
+print_sstring(cfg_printer_t *pctx, const cfg_obj_t *obj) {
+ cfg_print_chars(pctx, "\"", 1);
+ if ((pctx->flags & CFG_PRINTER_XKEY) != 0) {
+ unsigned int len = obj->value.string.length;
+ while (len-- > 0)
+ cfg_print_chars(pctx, "?", 1);
+ } else
+ cfg_print_ustring(pctx, obj);
+ cfg_print_chars(pctx, "\"", 1);
+}
+
+static void
free_string(cfg_parser_t *pctx, cfg_obj_t *obj) {
isc_mem_put(pctx->mctx, obj->value.string.base,
obj->value.string.length + 1);
@@ -855,6 +891,15 @@ cfg_type_t cfg_type_astring = {
};
/*
+ * Any string (quoted or unquoted); printed with quotes.
+ * If CFG_PRINTER_XKEY is set when printing the string will be '?' out.
+ */
+cfg_type_t cfg_type_sstring = {
+ "string", cfg_parse_sstring, print_sstring, cfg_doc_terminal,
+ &cfg_rep_string, NULL
+};
+
+/*
* Booleans
*/
@@ -1631,7 +1676,7 @@ parse_token(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
goto cleanup;
}
obj->value.string.length = r.length;
- memcpy(obj->value.string.base, r.base, r.length);
+ memmove(obj->value.string.base, r.base, r.length);
obj->value.string.base[r.length] = '\0';
*ret = obj;
return (result);
@@ -2480,5 +2525,6 @@ cfg_print_grammar(const cfg_type_t *type,
pctx.f = f;
pctx.closure = closure;
pctx.indent = 0;
+ pctx.flags = 0;
cfg_doc_obj(&pctx, type);
}