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
13889bfe
Commit
13889bfe
authored
Jan 29, 2018
by
Daniel Salzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confio: unify return codes from conf_get if invalid ID
parent
bd7dcde3
Pipeline
#32446
passed with stages
in 11 minutes and 27 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
16 deletions
+20
-16
src/knot/conf/conf.c
src/knot/conf/conf.c
+1
-0
src/knot/conf/confdb.c
src/knot/conf/confdb.c
+4
-1
tests/test_confio.c
tests/test_confio.c
+15
-15
No files found.
src/knot/conf/conf.c
View file @
13889bfe
...
...
@@ -187,6 +187,7 @@ conf_val_t conf_zone_get_txn(
C_ZONE
+
1
,
C_TPL
+
1
,
knot_strerror
(
val
.
code
));
// FALLTHROUGH
case
KNOT_ENOENT
:
case
KNOT_YP_EINVAL_ID
:
// Use the default template.
conf_db_get
(
conf
,
txn
,
C_TPL
,
key1_name
,
CONF_DEFAULT_ID
+
1
,
CONF_DEFAULT_ID
[
0
],
&
val
);
...
...
src/knot/conf/confdb.c
View file @
13889bfe
/* Copyright (C) 201
5
CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 201
8
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
...
...
@@ -667,6 +667,9 @@ int conf_db_get(
// Set the key0 code.
out
.
code
=
db_code
(
conf
,
txn
,
KEY0_ROOT
,
key0
,
DB_GET
,
&
k
[
KEY0_POS
]);
if
(
out
.
code
!=
KNOT_EOK
)
{
if
(
id_len
>
0
)
{
out
.
code
=
KNOT_YP_EINVAL_ID
;
}
goto
get_error
;
}
...
...
tests/test_confio.c
View file @
13889bfe
/* Copyright (C) 201
7
CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 201
8
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
...
...
@@ -547,7 +547,7 @@ static void test_conf_io_unset(void)
ok
(
conf_io_unset
(
"zone"
,
"file"
,
ZONE1
,
"name"
)
==
KNOT_EOK
,
"unset zone file"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_FILE
,
zone1
);
ok
(
val
.
code
==
KNOT_
ENOENT
,
"check entry"
);
ok
(
val
.
code
==
KNOT_
YP_EINVAL_ID
,
"check entry"
);
// Multi group, single bad value, all ids.
ok
(
conf_io_unset
(
"zone"
,
"comment"
,
NULL
,
"other"
)
==
...
...
@@ -567,9 +567,9 @@ static void test_conf_io_unset(void)
ok
(
conf_io_unset
(
"zone"
,
"comment"
,
NULL
,
"abc"
)
==
KNOT_EOK
,
"unset some zones comment"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_COMMENT
,
zone1
);
ok
(
val
.
code
==
KNOT_
ENOENT
,
"check entry"
);
ok
(
val
.
code
==
KNOT_
YP_EINVAL_ID
,
"check entry"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_COMMENT
,
zone2
);
ok
(
val
.
code
==
KNOT_
ENOENT
,
"check entry"
);
ok
(
val
.
code
==
KNOT_
YP_EINVAL_ID
,
"check entry"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_COMMENT
,
zone3
);
ok
(
val
.
code
==
KNOT_EOK
,
"check entry"
);
...
...
@@ -581,11 +581,11 @@ static void test_conf_io_unset(void)
ok
(
conf_io_unset
(
"zone"
,
"comment"
,
NULL
,
NULL
)
==
KNOT_EOK
,
"unset all zones comment"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_COMMENT
,
zone1
);
ok
(
val
.
code
==
KNOT_
ENOENT
,
"check entry"
);
ok
(
val
.
code
==
KNOT_
YP_EINVAL_ID
,
"check entry"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_COMMENT
,
zone2
);
ok
(
val
.
code
==
KNOT_
ENOENT
,
"check entry"
);
ok
(
val
.
code
==
KNOT_
YP_EINVAL_ID
,
"check entry"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_COMMENT
,
zone3
);
ok
(
val
.
code
==
KNOT_
ENOENT
,
"check entry"
);
ok
(
val
.
code
==
KNOT_
YP_EINVAL_ID
,
"check entry"
);
// Restart transaction.
conf_io_abort
(
false
);
...
...
@@ -595,9 +595,9 @@ static void test_conf_io_unset(void)
ok
(
conf_io_unset
(
"zone"
,
NULL
,
ZONE1
,
NULL
)
==
KNOT_EOK
,
"unset zone items"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_FILE
,
zone1
);
ok
(
val
.
code
==
KNOT_
ENOENT
,
"check entry"
);
ok
(
val
.
code
==
KNOT_
YP_EINVAL_ID
,
"check entry"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_COMMENT
,
zone1
);
ok
(
val
.
code
==
KNOT_
ENOENT
,
"check entry"
);
ok
(
val
.
code
==
KNOT_
YP_EINVAL_ID
,
"check entry"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_COMMENT
,
zone2
);
ok
(
val
.
code
==
KNOT_EOK
,
"check entry"
);
...
...
@@ -609,11 +609,11 @@ static void test_conf_io_unset(void)
ok
(
conf_io_unset
(
"zone"
,
NULL
,
NULL
,
NULL
)
==
KNOT_EOK
,
"unset zone items"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_FILE
,
zone1
);
ok
(
val
.
code
==
KNOT_
ENOENT
,
"check entry"
);
ok
(
val
.
code
==
KNOT_
YP_EINVAL_ID
,
"check entry"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_COMMENT
,
zone1
);
ok
(
val
.
code
==
KNOT_
ENOENT
,
"check entry"
);
ok
(
val
.
code
==
KNOT_
YP_EINVAL_ID
,
"check entry"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_COMMENT
,
zone2
);
ok
(
val
.
code
==
KNOT_
ENOENT
,
"check entry"
);
ok
(
val
.
code
==
KNOT_
YP_EINVAL_ID
,
"check entry"
);
// Restart transaction.
conf_io_abort
(
false
);
...
...
@@ -627,11 +627,11 @@ static void test_conf_io_unset(void)
val
=
conf_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_SERVER
,
C_LISTEN
);
ok
(
val
.
code
==
KNOT_ENOENT
,
"check entry"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_FILE
,
zone1
);
ok
(
val
.
code
==
KNOT_
ENOENT
,
"check entry"
);
ok
(
val
.
code
==
KNOT_
YP_EINVAL_ID
,
"check entry"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_COMMENT
,
zone1
);
ok
(
val
.
code
==
KNOT_
ENOENT
,
"check entry"
);
ok
(
val
.
code
==
KNOT_
YP_EINVAL_ID
,
"check entry"
);
val
=
conf_zone_get_txn
(
conf
(),
conf
()
->
io
.
txn
,
C_COMMENT
,
zone2
);
ok
(
val
.
code
==
KNOT_
ENOENT
,
"check entry"
);
ok
(
val
.
code
==
KNOT_
YP_EINVAL_ID
,
"check entry"
);
knot_dname_free
(
&
zone1
,
NULL
);
knot_dname_free
(
&
zone2
,
NULL
);
...
...
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