Commit 70cc3b33 authored by Daniel Salzman's avatar Daniel Salzman

utils: remove obsolete knot1to2 utility

parent 4667b87c
......@@ -75,7 +75,6 @@
/src/khost
/src/kjournalprint
/src/keymgr
/src/knot1to2
/src/knotc
/src/knotd
/src/knsec3hash
......
......@@ -459,17 +459,6 @@ src/utils/khost/khost_main.c
src/utils/khost/khost_params.c
src/utils/khost/khost_params.h
src/utils/kjournalprint/main.c
src/utils/knot1to2/cf-lex.c
src/utils/knot1to2/cf-lex.l
src/utils/knot1to2/cf-parse.tab.c
src/utils/knot1to2/cf-parse.tab.h
src/utils/knot1to2/cf-parse.y
src/utils/knot1to2/extra.c
src/utils/knot1to2/extra.h
src/utils/knot1to2/includes.c
src/utils/knot1to2/includes.h
src/utils/knot1to2/main.c
src/utils/knot1to2/scheme.h
src/utils/knotc/commands.c
src/utils/knotc/commands.h
src/utils/knotc/estimator.c
......
......@@ -8,7 +8,6 @@ MANPAGES_IN = \
man/khost.1in \
man/kjournalprint.1in \
man/knsupdate.1in \
man/knot1to2.1in \
man/knsec3hash.1in \
man/kzonecheck.1in
......@@ -22,7 +21,6 @@ MANPAGES_RST = \
man_khost.rst \
man_kjournalprint.rst \
man_knsupdate.rst \
man_knot1to2.rst \
man_knsec3hash.rst \
man_kzonecheck.rst
......@@ -84,8 +82,7 @@ if HAVE_DAEMON
man_MANS += \
man/knot.conf.5 \
man/knotc.8 \
man/knotd.8 \
man/knot1to2.1
man/knotd.8
endif # HAVE_DAEMON
if HAVE_UTILS
......@@ -113,7 +110,6 @@ man/kdig.1: man/kdig.1in
man/khost.1: man/khost.1in
man/kjournalprint.1: man/kjournalprint.1in
man/knsupdate.1: man/knsupdate.1in
man/knot1to2.1: man/knot1to2.1in
man/knsec3hash.1: man/knsec3hash.1in
man/kzonecheck.1: man/kzonecheck.1in
......
......@@ -226,7 +226,6 @@ man_pages = [
('man_kdig', 'kdig', 'Advanced DNS lookup utility', author, 1),
('man_khost', 'khost', 'Simple DNS lookup utility', author, 1),
('man_kjournalprint', 'kjournalprint', 'Knot DNS journal print utility', author, 1),
('man_knot1to2', 'knot1to2', 'Knot DNS configuration conversion utility', author, 1),
('man_knsec3hash', 'knsec3hash', 'Simple utility to compute NSEC3 hash', author, 1),
('man_knsupdate', 'knsupdate', 'Dynamic DNS update utility', author, 1),
('man_kzonecheck', 'kzonecheck', 'Knot DNS zone check tool', author, 1),
......
.\" Man page generated from reStructuredText.
.
.TH "KNOT1TO2" "1" "@RELEASE_DATE@" "@VERSION@" "Knot DNS"
.SH NAME
knot1to2 \- Knot DNS configuration conversion utility
.
.nr rst2man-indent-level 0
.
.de1 rstReportMargin
\\$1 \\n[an-margin]
level \\n[rst2man-indent-level]
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
-
\\n[rst2man-indent0]
\\n[rst2man-indent1]
\\n[rst2man-indent2]
..
.de1 INDENT
.\" .rstReportMargin pre:
. RS \\$1
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
. nr rst2man-indent-level +1
.\" .rstReportMargin post:
..
.de UNINDENT
. RE
.\" indent \\n[an-margin]
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
.nr rst2man-indent-level -1
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.SH SYNOPSIS
.sp
\fBknot1to2\fP [\fIoptions\fP] \-i \fIfile\fP \-o \fIfile\fP
.SH DESCRIPTION
.sp
This utility generates Knot DNS configuration file version 2.x from configuration
file version 1.x.
.SS Parameters
.INDENT 0.0
.TP
\fB\-i\fP, \fB\-\-in\fP \fIfile\fP
Input configuration file (Knot version 1.x).
.TP
\fB\-o\fP, \fB\-\-out\fP \fIfile\fP
Output configuration file (Knot version 2.x).
.UNINDENT
.SS Options
.INDENT 0.0
.TP
\fB\-r\fP, \fB\-\-raw\fP
Raw output, do not reformat via \fBknotc\fP\&.
.TP
\fB\-p\fP, \fB\-\-path\fP \fIdirectory\fP
Path to \fBknotc\fP utility.
.TP
\fB\-h\fP, \fB\-\-help\fP
Print the program help.
.TP
\fB\-V\fP, \fB\-\-version\fP
Print the program version.
.UNINDENT
.SH SEE ALSO
.sp
\fBknotc(8)\fP, \fBknotd(8)\fP, \fBknot.conf(5)\fP\&.
.SH AUTHOR
CZ.NIC Labs <http://www.knot-dns.cz>
.SH COPYRIGHT
Copyright 2010–2017, CZ.NIC, z.s.p.o.
.\" Generated by docutils manpage writer.
.
.. highlight:: console
knot1to2 – Knot DNS configuration conversion utility
====================================================
Synopsis
--------
:program:`knot1to2` [*options*] -i *file* -o *file*
Description
-----------
This utility generates Knot DNS configuration file version 2.x from configuration
file version 1.x.
Parameters
..........
**-i**, **--in** *file*
Input configuration file (Knot version 1.x).
**-o**, **--out** *file*
Output configuration file (Knot version 2.x).
Options
.......
**-r**, **--raw**
Raw output, do not reformat via :program:`knotc`.
**-p**, **--path** *directory*
Path to :program:`knotc` utility.
**-h**, **--help**
Print the program help.
**-V**, **--version**
Print the program version.
See Also
--------
:manpage:`knotc(8)`, :manpage:`knotd(8)`, :manpage:`knot.conf(5)`.
......@@ -15,7 +15,6 @@ the server. This section collects manual pages for all provided binaries:
man_pykeymgr
man_khost
man_kjournalprint
man_knot1to2
man_knotc
man_knotd
man_knsec3hash
......
......@@ -48,12 +48,3 @@ sed -i '/static\ const\ int\ yparser_/d' $OUT_Y
sed -i 's/\s*$//g' $OUT_Y
popd
### KNOT1TO2 ###
pushd ../src/utils/knot1to2/
flex cf-lex.l
bison -d -b cf-parse cf-parse.y
popd
......@@ -418,13 +418,8 @@ libknotd_la_LIBADD = libknot.la libknot-yparser.la zscanner/libzscanner.la $(lib
if HAVE_DAEMON
sbin_PROGRAMS = knotc knotd keymgr
libexec_PROGRAMS = knot1to2
noinst_LTLIBRARIES += libknotd.la libknotus.la
EXTRA_DIST += \
utils/knot1to2/cf-lex.l \
utils/knot1to2/cf-parse.y
knotc_SOURCES = \
utils/knotc/commands.c \
utils/knotc/commands.h \
......@@ -446,17 +441,6 @@ keymgr_SOURCES = \
utils/keymgr/functions.h \
utils/keymgr/main.c
knot1to2_SOURCES = \
utils/knot1to2/cf-lex.c \
utils/knot1to2/cf-parse.tab.c \
utils/knot1to2/cf-parse.tab.h \
utils/knot1to2/extra.c \
utils/knot1to2/extra.h \
utils/knot1to2/includes.c \
utils/knot1to2/includes.h \
utils/knot1to2/main.c \
utils/knot1to2/scheme.h
knotd_CPPFLAGS = $(AM_CPPFLAGS) $(liburcu_CFLAGS)
knotd_LDADD = libknotd.la libcontrib.la $(liburcu_LIBS)
knotc_CPPFLAGS = $(AM_CPPFLAGS) $(libedit_CFLAGS)
......@@ -466,7 +450,6 @@ keymgr_CPPFLAGS = $(AM_CPPFLAGS) $(liburcu_CFLAGS) -I$(srcdir)/dnssec/lib/dnssec
keymgr_LDADD = $(libidn_LIBS) $(liburcu_LIBS) libknotd.la libcontrib.la \
libknotus.la dnssec/libdnssec.la dnssec/libshared.la \
zscanner/libzscanner.la $(gnutls_LIBS)
knot1to2_LDADD = libcontrib.la
####################################
# Optional Knot DNS Daemon modules #
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_CF_CF_PARSE_TAB_H_INCLUDED
# define YY_CF_CF_PARSE_TAB_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int cf_debug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
END = 258,
INVALID_TOKEN = 259,
TEXT = 260,
NUM = 261,
INTERVAL = 262,
SIZE = 263,
BOOL = 264,
SYSTEM = 265,
IDENTITY = 266,
HOSTNAME = 267,
SVERSION = 268,
NSID = 269,
KEY = 270,
KEYS = 271,
MAX_UDP_PAYLOAD = 272,
TSIG_ALGO_NAME = 273,
WORKERS = 274,
BACKGROUND_WORKERS = 275,
ASYNC_START = 276,
USER = 277,
RUNDIR = 278,
PIDFILE = 279,
REMOTES = 280,
GROUPS = 281,
ZONES = 282,
FILENAME = 283,
DISABLE_ANY = 284,
SEMANTIC_CHECKS = 285,
NOTIFY_RETRIES = 286,
NOTIFY_TIMEOUT = 287,
DBSYNC_TIMEOUT = 288,
IXFR_FSLIMIT = 289,
MAX_ZONE_SIZE = 290,
XFR_IN = 291,
XFR_OUT = 292,
UPDATE_IN = 293,
NOTIFY_IN = 294,
NOTIFY_OUT = 295,
BUILD_DIFFS = 296,
MAX_CONN_IDLE = 297,
MAX_CONN_HS = 298,
MAX_CONN_REPLY = 299,
MAX_TCP_CLIENTS = 300,
RATE_LIMIT = 301,
RATE_LIMIT_SIZE = 302,
RATE_LIMIT_SLIP = 303,
TRANSFERS = 304,
STORAGE = 305,
TIMER_DB = 306,
DNSSEC_ENABLE = 307,
DNSSEC_KEYDIR = 308,
SIGNATURE_LIFETIME = 309,
SERIAL_POLICY = 310,
SERIAL_POLICY_VAL = 311,
QUERY_MODULE = 312,
INTERFACES = 313,
ADDRESS = 314,
PORT = 315,
IPA = 316,
IPA6 = 317,
VIA = 318,
CONTROL = 319,
ALLOW = 320,
LISTEN_ON = 321,
LOG = 322,
LOG_DEST = 323,
LOG_SRC = 324,
LOG_LEVEL = 325
};
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 352 "cf-parse.y" /* yacc.c:1909 */
struct {
char *t;
long i;
size_t l;
} tok;
#line 133 "cf-parse.tab.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
int cf_parse (void *scanner);
#endif /* !YY_CF_CF_PARSE_TAB_H_INCLUDED */
This diff is collapsed.
/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include "utils/knot1to2/includes.h"
#include "utils/knot1to2/extra.h"
/*!
* \brief Init structure with custom data for config parser.
*/
conf_extra_t *conf_extra_init(const char *file, int run, share_t *share)
{
conf_extra_t *extra = calloc(1, sizeof(conf_extra_t));
if (!extra) {
return NULL;
}
conf_includes_t *includes = conf_includes_init();
if (!includes) {
free(extra);
return NULL;
}
if (!conf_includes_push(includes, file)) {
conf_includes_free(includes);
free(extra);
return NULL;
}
extra->error = false;
extra->includes = includes;
extra->run = run;
extra->share = share;
return extra;
}
/*!
* \brief Free structure with custom data for config parser.
*/
void conf_extra_free(conf_extra_t *extra)
{
if (!extra)
return;
conf_includes_free(extra->includes);
free(extra);
}
/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdbool.h>
#include "utils/knot1to2/includes.h"
#include "utils/knot1to2/scheme.h"
#include "contrib/qp-trie/trie.h"
typedef struct {
FILE *out;
bool have_sections[S_LAST - S_FIRST + 1];
trie_t *ifaces;
trie_t *groups;
trie_t *remotes;
trie_t *acl_xfer;
trie_t *acl_notify;
trie_t *acl_update;
trie_t *acl_control;
} share_t;
/*!
* \brief Custom data held within the parser context.
*/
typedef struct {
bool error; // Indicates that error was set.
conf_includes_t *includes; // Used to handle filenames in includes.
int run; // Current run number.
share_t *share; // Variables shared among all runs.
trie_t *current_trie;
const char *current_key;
} conf_extra_t;
/*!
* \brief Init structure with custom data for config parser.
*
* \param file Name of the main configuration file.
*
* \return Initialized structure or NULL.
*/
conf_extra_t *conf_extra_init(const char *file, int run, share_t *share);
/*!
* \brief Free structure with custom data for config parser.
*
* \param extra Structure to be freed.
*/
void conf_extra_free(conf_extra_t *extra);
/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "utils/knot1to2/includes.h"
#define INCLUDES_CAPACITY_BLOCK 128 // Size of included files block.
/*!
* \brief Structure to store names of files included into the config.
*/
struct conf_includes {
int free_index; //!< First free index in 'names'.
int capacity; //!< Maximal capacity.
conf_include_t *files; //!< Stored includes.
};
/*!
* \brief Initialize structure for storing names of included files.
*/
conf_includes_t *conf_includes_init(void)
{
conf_includes_t *includes = calloc(1, sizeof(conf_includes_t));
if (!includes) {
return NULL;
}
conf_include_t *files = calloc(INCLUDES_CAPACITY_BLOCK,
sizeof(conf_include_t));
if (!files) {
free(includes);
return NULL;
}
includes->capacity = INCLUDES_CAPACITY_BLOCK;
includes->files = files;
return includes;
}
/*!
* \brief Free structure for storing the names of included files.
*/
void conf_includes_free(conf_includes_t *includes)
{
if (!includes) {
return;
}
while (conf_includes_remove(includes));
free(includes->files);
free(includes);
}
/**
* \brief Constructs a path relative to a reference file.
*
* e.g. path_relative_to("b.conf", "samples/a.conf") == "samples/b.conf"
*
* \param filename File name of the target file.
* \param reference Reference file name (just path is used).
*
* \return Relative path to a reference file.
*/
static char *path_relative_to(const char *filename, const char *reference)
{
char *path_end = strrchr(reference, '/');
if (!path_end) {
return strdup(filename);
}
int path_len = (int)(path_end - reference);
size_t result_len = path_len + 1 + strlen(filename) + 1;
char *result = malloc(result_len * sizeof(char));
if (!result) {
return NULL;
}
int ret = snprintf(result, result_len, "%.*s/%s", path_len, reference, filename);
if (ret < 0 || ret >= result_len) {
free(result);
return NULL;
}
return result;
}
/**
* \brief Pushes a file name onto the stack of files.
*/
bool conf_includes_push(conf_includes_t *includes, const char *filename)
{
if (!includes || !filename) {
return false;
}
char *store = NULL;
if (includes->free_index == 0 || filename[0] == '/') {
store = strdup(filename);
} else {
conf_include_t *previous = &includes->files[includes->free_index - 1];
store = path_relative_to(filename, previous->filename);
}
for (int i = 0; i < includes->free_index; i++) {
// Check for include loop.
if (strcmp(includes->files[i].filename, store) == 0) {
free(store);
return false;
}
}
// Extend the stack if full.
if (includes->free_index >= includes->capacity) {
size_t new_size = (includes->capacity + INCLUDES_CAPACITY_BLOCK) *
sizeof(conf_include_t);
conf_include_t *new_files = realloc(includes->files, new_size);
if (new_files == NULL) {
free(store);
return false;
}
includes->capacity = new_size;
includes->files = new_files;
}
conf_include_t new_include = {
.filename = store,
.handle = NULL
};
includes->files[includes->free_index++] = new_include;
return store != NULL;
}
/**
* \brief Returns an include on the top of the stack.
*/
conf_include_t *conf_includes_top(conf_includes_t *includes)
{
if (!includes || includes->free_index == 0) {
return NULL;
}
return includes->files + includes->free_index - 1;
}
/**
* \brief Returns an include on the top of the stack and removes it.
*/
conf_include_t *conf_includes_pop(conf_includes_t *includes)
{
conf_include_t *result = conf_includes_top(includes);
if (result) {
includes->free_index -= 1;
}
return result;
}
/**
* \brief Returns an include on the top of the stack and removes it.
*/
bool conf_includes_remove(conf_includes_t *includes)
{
conf_include_t *top = conf_includes_pop(includes);
if (top) {
if (top->filename) {
free(top->filename);
top->filename = NULL;
}
if (top->handle) {
fclose(top->handle);
top->handle = NULL;
}
return true;
}
return false;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment