Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Knot DNS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
22
Issues
22
List
Boards
Labels
Service Desk
Milestones
Merge Requests
17
Merge Requests
17
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Knot projects
Knot DNS
Commits
75b286ea
Commit
75b286ea
authored
Feb 28, 2017
by
Libor Peltan
Committed by
Daniel Salzman
Mar 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: enabled two-ciphers long indexes in filename pattern
parent
66b0f287
Pipeline
#2178
passed with stages
in 41 minutes and 47 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
51 deletions
+55
-51
doc/man/knot.conf.5in
doc/man/knot.conf.5in
+13
-6
doc/reference.rst
doc/reference.rst
+9
-6
src/knot/conf/conf.c
src/knot/conf/conf.c
+24
-37
tests/test_conf.c
tests/test_conf.c
+9
-2
No files found.
doc/man/knot.conf.5in
View file @
75b286ea
...
...
@@ -769,7 +769,7 @@ A data directory for storing zone files, journal database, and timers database.
\fIDefault:\fP \fB${localstatedir}/lib/knot\fP (configured with \fB\-\-with\-storage=path\fP)
.SS file
.sp
A path to the zone file. Non
absolute path is relative to
A path to the zone file. Non
\-
absolute path is relative to
\fI\%storage\fP\&. It is also possible to use the following formatters:
.INDENT 0.0
.IP \(bu 2
...
...
@@ -783,14 +783,21 @@ one) are considered. If the character is not available, the formatter has no eff
(see \fB%s\fP). The index is counted from 0 from the right (0 ~ TLD).
If the label is not available, the formatter has no effect.
.IP \(bu 2
\fB%s\fP – means the current zone name in the textual representation (beware
of special characters which are escaped or encoded in the \eDDD form where
DDD is corresponding decimal ASCII code). The zone name doesn\(aqt include the
terminating dot (the result for the root zone is the empty string!).
\fB%s\fP – means the current zone name in the textual representation.
The zone name doesn\(aqt include the terminating dot (the result for the root
zone is the empty string!).
.IP \(bu 2
\fB%%\fP – means the \fB%\fP character
.UNINDENT
.sp
\fBWARNING:\fP
.INDENT 0.0
.INDENT 3.5
Beware of special characters which are escaped or encoded in the \eDDD form
where DDD is corresponding decimal ASCII code.
.UNINDENT
.UNINDENT
.sp
\fIDefault:\fP \fI\%storage\fP/\fB%s\fP\&.zone
.SS master
.sp
...
...
@@ -961,7 +968,7 @@ value can be used for the default policy settings.
\fIRequired\fP
.SS kasp\-db
.sp
A KASP database path. Non
absolute path is relative to
A KASP database path. Non
\-
absolute path is relative to
\fI\%storage\fP\&.
.sp
\fIDefault:\fP \fI\%storage\fP/keys
...
...
doc/reference.rst
View file @
75b286ea
...
...
@@ -905,7 +905,7 @@ A data directory for storing zone files, journal database, and timers database.
file
----
A path to the zone file. Non
absolute path is relative to
A path to the zone file. Non
-
absolute path is relative to
:ref:`storage<zone_storage>`. It is also possible to use the following formatters:
- ``%c[``\ *N*\ ``]`` or ``%c[``\ *N*\ ``-``\ *M*\ ``]`` – means the *N*\ th
...
...
@@ -916,12 +916,15 @@ A path to the zone file. Non absolute path is relative to
- ``%l[``\ *N*\ ``]`` – means the *N*\ th label of the textual zone name
(see ``%s``). The index is counted from 0 from the right (0 ~ TLD).
If the label is not available, the formatter has no effect.
- ``%s`` – means the current zone name in the textual representation (beware
of special characters which are escaped or encoded in the \\DDD form where
DDD is corresponding decimal ASCII code). The zone name doesn't include the
terminating dot (the result for the root zone is the empty string!).
- ``%s`` – means the current zone name in the textual representation.
The zone name doesn't include the terminating dot (the result for the root
zone is the empty string!).
- ``%%`` – means the ``%`` character
.. WARNING::
Beware of special characters which are escaped or encoded in the \\DDD form
where DDD is corresponding decimal ASCII code.
*Default:* :ref:`storage<zone_storage>`/``%s``\ .zone
.. _zone_master:
...
...
@@ -1111,7 +1114,7 @@ value can be used for the default policy settings.
kasp-db
-------
A KASP database path. Non
absolute path is relative to
A KASP database path. Non
-
absolute path is relative to
:ref:`storage<zone_storage>`.
*Default:* :ref:`storage<zone_storage>`/keys
...
...
src/knot/conf/conf.c
View file @
75b286ea
/* Copyright (C) 201
6
CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 201
7
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
...
...
@@ -17,6 +17,7 @@
#include <assert.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
#include "knot/conf/base.h"
#include "knot/conf/confdb.h"
...
...
@@ -782,48 +783,34 @@ void conf_free_mod_id(
static
int
get_index
(
const
char
**
start
,
const
char
*
end
,
u
int8_t
*
index1
,
u
int8_t
*
index2
)
u
nsigned
*
index1
,
u
nsigned
*
index2
)
{
const
char
*
pos
=
*
start
;
uint8_t
i1
,
i2
;
// At least [n] must fit into.
if
(
end
-
pos
<
3
||
pos
[
0
]
!=
'['
)
{
char
c
,
*
p
;
if
(
sscanf
(
*
start
,
"[%u%c"
,
index1
,
&
c
)
!=
2
)
{
return
KNOT_EINVAL
;
}
// Check for the variant [n] or [m-n].
switch
(
pos
[
2
])
{
case
']'
:
i1
=
pos
[
1
]
-
'0'
;
i2
=
i1
;
if
(
i1
>
9
)
{
return
KNOT_EINVAL
;
}
*
start
+=
3
;
break
;
switch
(
c
)
{
case
'-'
:
if
(
index2
==
NULL
||
end
-
pos
<
5
||
pos
[
4
]
!=
']'
)
{
p
=
strchr
(
*
start
,
'-'
)
+
1
;
if
(
end
-
p
<
2
||
index2
==
NULL
||
sscanf
(
p
,
"%u%c"
,
index2
,
&
c
)
!=
2
||
c
!=
']'
)
{
return
KNOT_EINVAL
;
}
i1
=
pos
[
1
]
-
'0'
;
i2
=
pos
[
3
]
-
'0'
;
if
(
i
1
>
9
||
i2
>
9
||
i1
>
i2
)
{
return
KNOT_EINVAL
;
break
;
case
']'
:
if
(
i
ndex2
!=
NULL
)
{
*
index2
=
*
index1
;
}
*
start
+=
5
;
break
;
default:
return
KNOT_EINVAL
;
}
*
index1
=
i1
;
if
(
index2
!=
NULL
)
{
*
index2
=
i2
;
}
return
KNOT_EOK
;
*
start
=
strchr
(
*
start
,
']'
)
+
1
;
return
((
*
index1
<
256
&&
(
index2
==
NULL
||
*
index2
<
256
)
&&
end
-
*
start
>=
0
&&
(
index2
==
NULL
||
*
index2
>=
*
index1
))
?
KNOT_EOK
:
KNOT_EINVAL
);
}
static
void
replace_slashes
(
...
...
@@ -849,8 +836,8 @@ static int str_char(
const
knot_dname_t
*
zone
,
char
*
buff
,
size_t
buff_len
,
u
int8_t
index1
,
u
int8_t
index2
)
u
nsigned
index1
,
u
nsigned
index2
)
{
if
(
knot_dname_to_str
(
buff
,
zone
,
buff_len
)
==
NULL
)
{
return
KNOT_EINVAL
;
...
...
@@ -901,7 +888,7 @@ static int str_label(
const
knot_dname_t
*
zone
,
char
*
buff
,
size_t
buff_len
,
u
int8_t
right_index
)
u
nsigned
right_index
)
{
int
labels
=
knot_dname_labels
(
zone
,
NULL
);
...
...
@@ -919,11 +906,11 @@ static int str_label(
// Compute the index from the left.
assert
(
labels
>
right_index
);
u
int8_t
index
=
labels
-
right_index
-
1
;
u
nsigned
index
=
labels
-
right_index
-
1
;
// Create a dname from the single label.
int
prefix
=
(
index
>
0
)
?
knot_dname_prefixlen
(
zone
,
index
,
NULL
)
:
0
;
u
int8_t
label_len
=
*
(
zone
+
prefix
);
u
nsigned
label_len
=
*
(
zone
+
prefix
);
memcpy
(
label
,
zone
+
prefix
,
1
+
label_len
);
label
[
1
+
label_len
]
=
'\0'
;
...
...
@@ -968,7 +955,7 @@ static char* get_filename(
name
=
pos
+
2
;
char
buff
[
512
]
=
""
;
u
int8_t
idx1
,
idx2
;
u
nsigned
idx1
,
idx2
;
bool
failed
=
false
;
const
char
type
=
*
(
pos
+
1
);
...
...
tests/test_conf.c
View file @
75b286ea
/* Copyright (C) 201
6
CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 201
7
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
...
...
@@ -63,16 +63,20 @@ static void test_get_filename(void)
check_name
(
zone
,
"/%c[3]"
,
"/."
);
check_name
(
zone
,
"/%c[8]"
,
"/g"
);
check_name
(
zone
,
"/%c[9]"
,
"/."
);
check_name
(
zone
,
"/%c[10]"
,
"/"
);
check_name
(
zone
,
"/%c[255]"
,
"/"
);
check_name
(
zone
,
"/%c[0-1]"
,
"/ab"
);
check_name
(
zone
,
"/%c[1-1]"
,
"/b"
);
check_name
(
zone
,
"/%c[1-3]"
,
"/bc."
);
check_name
(
zone
,
"/%c[1-4]"
,
"/bc.d"
);
check_name
(
zone
,
"/%c[254-255]"
,
"/"
);
check_name_err
(
zone
,
"/%c"
);
check_name_err
(
zone
,
"/%cx"
);
check_name_err
(
zone
,
"/%c[a]"
);
check_name_err
(
zone
,
"/%c[:]"
);
check_name_err
(
zone
,
"/%c[/]"
);
check_name_err
(
zone
,
"/%c[10]"
);
check_name_err
(
zone
,
"/%c[-1]"
);
check_name_err
(
zone
,
"/%c[256]"
);
check_name_err
(
zone
,
"/%c["
);
check_name_err
(
zone
,
"/%c[1"
);
check_name_err
(
zone
,
"/%c[1-"
);
...
...
@@ -95,8 +99,11 @@ static void test_get_filename(void)
check_name
(
zone
,
"/%l[1]"
,
"/def"
);
check_name
(
zone
,
"/%l[2]"
,
"/abc"
);
check_name
(
zone
,
"/%l[3]"
,
"/"
);
check_name
(
zone
,
"/%l[255]"
,
"/"
);
check_name
(
zone
,
"/%l[0]-%l[1]-%l[2]"
,
"/gh-def-abc"
);
check_name_err
(
zone
,
"/%l[0-1]"
);
check_name_err
(
zone
,
"/%l[-1]"
);
check_name_err
(
zone
,
"/%l[256]"
);
zone
=
"."
;
check_name
(
zone
,
"/%l[0]"
,
"/"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment