Skip to content

pdnsutil import-zone-key silently fails on mixed bind+sql configuration #15045

Open
@miodvallat

Description

@miodvallat

Short description

While working on adding the "does the key really exist" checks adedd to pdnsutil add-zone-key to the similar import-zone-key and import-zone-key-pem, some tests started to fail due to this check.

It turns out that, on a bind + sql configuration, where the bind zones do not have any keys, adding (or importing) a zone key fails at the sql level, because the domain does not exist in the database.

This turns out to be a can of worms larger than expected, so I'm opening an issue to keep track of this until I can find a proper way to solve the problem (issueing pdns create-zone won't work as the zones are existing in the bind configuration which takes precedence).

Environment

Does not matter

Steps to reproduce

  • cd regression-tests.auth-py
  • Run one of the tests which uses bind + sql, e.g. ./runtests test_XFRIncomplete.py
  • Run ../pdns/pdnsutil --config-dir=configs/auth list-all-zones to confirm example.org exists
  • Run ../pdns/pdnsutil --config-dir=configs/auth list-keys example.org to confirm no key exists
  • Run ../pdns/pdnsutil --config-dir=configs/auth import-zone-key example.org configs/auth/dnssec.key, it outputs 0 which is not a valid key id.
  • Run ../pdns/pdnsutil --config-dir=configs/auth list-keys example.org to confirm no key exists.

Expected behaviour

The key is correctly inserted into the database, with a non-zero key id.

Actual behaviour

SQL INSERT request fails because the zone does not exist in the database. Because of this, the select LAST_INSERT_ID() request returns a value of 0 (no insertion took place), which is not handled as an error.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pdnsutil import-zone-key silently fails on mixed bind+sql configuration · Issue #15045 · PowerDNS/pdns