Skip to content

Commit

Permalink
Merge pull request #15049 from miodvallat/zero
Browse files Browse the repository at this point in the history
Correctly report SQL insertion errors
  • Loading branch information
Habbie authored Jan 23, 2025
2 parents 2d3e3ea + ad57d1b commit d7910fc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/bindbackend/binddnssec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ bool Bind2Backend::addDomainKey(const DNSName& name, const KeyData& key, int64_t
ASSERT_ROW_COLUMNS("get-last-inserted-key-id-query", row, 1);
id = std::stoi(row[0]);
d_GetLastInsertedKeyIdQuery_stmt->reset();
if (id == 0) {
// No insert took place, report as error.
id = -1;
}
return true;
}
catch (SSqlException& e) {
Expand Down
4 changes: 4 additions & 0 deletions pdns/backends/gsql/gsqlbackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,10 @@ bool GSQLBackend::addDomainKey(const DNSName& name, const KeyData& key, int64_t&
ASSERT_ROW_COLUMNS("get-last-inserted-key-id-query", row, 1);
id = std::stoi(row[0]);
d_GetLastInsertedKeyIdQuery_stmt->reset();
if (id == 0) {
// No insert took place, report as error.
id = -1;
}
return true;
}
catch (SSqlException &e) {
Expand Down
18 changes: 18 additions & 0 deletions regression-tests.auth-py/test_GSSTSIG.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ class GSSTSIGBase(AuthTest):
'KRB5_KTNAME' : './kerberos-client/kt.keytab'
}

@classmethod
def secureZone(cls, confdir, zonename, key=None):
# This particular test uses a sqlite-only configuration, unlike
# all the other tests in that directory. Because of this, we
# need to perform an explicit create-zone, otherwise import-zone-key
# would fail.
zone = '.' if zonename == 'ROOT' else zonename
pdnsutilCmd = [os.environ['PDNSUTIL'],
'--config-dir=%s' % confdir,
'create-zone',
zone]
print(' '.join(pdnsutilCmd))
try:
subprocess.check_output(pdnsutilCmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
raise AssertionError('%s failed (%d): %s' % (pdnsutilCmd, e.returncode, e.output))
super(GSSTSIGBase, cls).secureZone(confdir, zonename, key)

@classmethod
def setUpClass(cls):
super(GSSTSIGBase, cls).setUpClass()
Expand Down

0 comments on commit d7910fc

Please sign in to comment.