Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the problem when assigning tsig key #120

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions powerdns_sync/lib/Atomia/DNS/PowerDNSDatabase.pm
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,16 @@ sub assign_tsig_key {

$domain_id = $self->dbi->quote($domain_id);
my $tsigkey_name = $self->dbi->quote($domainmetadata->{"tsigkey_name"});
my $kind = $self->dbi->quote($domainmetadata->{"kind"});
my $tsigkey_kind = $self->dbi->quote($domainmetadata->{"kind"});

$self->dbi->do("DELETE FROM domainmetadata WHERE domain_id = $domain_id") || die "error removing previous assignment to the same domain in assign_tsig_key: $DBI::errstr";

my $query = "INSERT INTO domainmetadata (domain_id, kind, content) VALUES ($domain_id, $kind, $tsigkey_name)";
my $query;
my $domain_id_check = $self->dbi->selectrow_arrayref("SELECT id FROM domainmetadata WHERE domain_id = $domain_id AND kind = $tsigkey_kind");
if (defined($domain_id_check) && ref($domain_id_check) eq "ARRAY") {
$query = "UPDATE domainmetadata SET content = $tsigkey_name WHERE domain_id = $domain_id AND kind = $tsigkey_kind";
}
else {
$query = "INSERT INTO domainmetadata (domain_id, kind, content) VALUES ($domain_id, $tsigkey_kind, $tsigkey_name)";
}

$self->dbi->do($query) || die "error inserting row: $DBI::errstr";

Expand Down