Skip to content

Instantly share code, notes, and snippets.

@Habbie
Created April 26, 2013 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Habbie/5466771 to your computer and use it in GitHub Desktop.
Save Habbie/5466771 to your computer and use it in GitHub Desktop.
Index: oraclebackend.cc
===================================================================
--- oraclebackend.cc (revision 2679)
+++ oraclebackend.cc (working copy)
@@ -24,27 +24,43 @@
#include <oci.h>
static const char *basicQueryKey = "PDNS_Basic_Query";
-static const char *basicQueryDefaultSQL =
+static const char *basicQueryDefaultAuthSQL =
"SELECT fqdn, ttl, type, content, zone_id, last_change, auth "
"FROM Records "
"WHERE type = :type AND fqdn = lower(:name)";
+static const char *basicQueryDefaultSQL = "SELECT fqdn, ttl, type, content, zone_id, last_change "
+ "FROM Records "
+ "WHERE type = :type AND fqdn = lower(:name)";
+
static const char *basicIdQueryKey = "PDNS_Basic_Id_Query";
-static const char *basicIdQueryDefaultSQL =
+static const char *basicIdQueryDefaultAuthSQL =
"SELECT fqdn, ttl, type, content, zone_id, last_change, auth "
"FROM Records "
"WHERE type = :type AND fqdn = lower(:name) AND zone_id = :zoneid";
+static const char *basicIdQueryDefaultSQL =
+ "SELECT fqdn, ttl, type, content, zone_id, last_change "
+ "FROM Records "
+ "WHERE type = :type AND fqdn = lower(:name) AND zone_id = :zoneid";
+
static const char *anyQueryKey = "PDNS_ANY_Query";
-static const char *anyQueryDefaultSQL =
+static const char *anyQueryDefaultAuthSQL =
"SELECT fqdn, ttl, type, content, zone_id, last_change, auth "
"FROM Records "
"WHERE fqdn = lower(:name)"
" AND type IS NOT NULL "
"ORDER BY type";
+static const char *anyQueryDefaultSQL =
+ "SELECT fqdn, ttl, type, content, zone_id, last_change "
+ "FROM Records "
+ "WHERE fqdn = lower(:name)"
+ " AND type IS NOT NULL "
+ "ORDER BY type";
+
static const char *anyIdQueryKey = "PDNS_ANY_Id_Query";
-static const char *anyIdQueryDefaultSQL =
+static const char *anyIdQueryDefaultAuthSQL =
"SELECT fqdn, ttl, type, content, zone_id, last_change, auth "
"FROM Records "
"WHERE fqdn = lower(:name)"
@@ -52,14 +68,31 @@
" AND type IS NOT NULL "
"ORDER BY type";
+static const char *anyIdQueryDefaultSQL =
+ "SELECT fqdn, ttl, type, content, zone_id, last_change "
+ "FROM Records "
+ "WHERE fqdn = lower(:name)"
+ " AND zone_id = :zoneid"
+ " AND type IS NOT NULL "
+ "ORDER BY type";
+
+
static const char *listQueryKey = "PDNS_List_Query";
-static const char *listQueryDefaultSQL =
+static const char *listQueryDefaultAuthSQL =
"SELECT fqdn, ttl, type, content, zone_id, last_change, auth "
"FROM Records "
"WHERE zone_id = :zoneid"
" AND type IS NOT NULL "
"ORDER BY fqdn, type";
+static const char *listQueryDefaultSQL =
+ "SELECT fqdn, ttl, type, content, zone_id, last_change "
+ "FROM Records "
+ "WHERE zone_id = :zoneid"
+ " AND type IS NOT NULL "
+ "ORDER BY fqdn, type";
+
+
static const char *zoneInfoQueryKey = "PDNS_Zone_Info_Query";
static const char *zoneInfoQueryDefaultSQL =
"SELECT id, name, type, last_check, serial, notified_serial "
@@ -230,13 +263,32 @@
curStmtHandle = NULL;
openTransactionZoneID = -1;
+ try
+ {
+ d_dnssecQueries = mustDo("dnssec");
+ }
+ catch (ArgException e)
+ {
+ d_dnssecQueries = false;
+ }
+
// Process configuration options
string_to_cbuf(myServerName, getArg("nameserver-name"), sizeof(myServerName));
- basicQuerySQL = getArg("basic-query");
- basicIdQuerySQL = getArg("basic-id-query");
- anyQuerySQL = getArg("any-query");
- anyIdQuerySQL = getArg("any-id-query");
- listQuerySQL = getArg("list-query");
+
+ if (d_dnssecQueries) {
+ basicQuerySQL = getArg("basic-query-auth");
+ basicIdQuerySQL = getArg("basic-id-query-auth");
+ anyQuerySQL = getArg("any-query-auth");
+ anyIdQuerySQL = getArg("any-id-query-auth");
+ listQuerySQL = getArg("list-query-auth");
+ } else {
+ basicQuerySQL = getArg("basic-query");
+ basicIdQuerySQL = getArg("basic-id-query");
+ anyQuerySQL = getArg("any-query");
+ anyIdQuerySQL = getArg("any-id-query");
+ listQuerySQL = getArg("list-query");
+ }
+
zoneInfoQuerySQL = getArg("zone-info-query");
alsoNotifyQuerySQL = getArg("also-notify-query");
zoneMastersQuerySQL = getArg("zone-masters-query");
@@ -381,6 +433,9 @@
uint32_t zoneId, const string& zone,
const string& name, string& before, string& after)
{
+ if(!d_dnssecQueries)
+ return -1;
+
sword rc;
OCIStmt *stmt;
@@ -418,6 +473,9 @@
OracleBackend::getBeforeAndAfterNamesAbsolute(uint32_t zoneId,
const string& name, string& unhashed, string& before, string& after)
{
+ if(!d_dnssecQueries)
+ return -1;
+
sword rc;
OCIStmt *stmt;
@@ -904,14 +962,18 @@
check_indicator(mResultContentInd, false);
check_indicator(mResultZoneIdInd, false);
check_indicator(mResultLastChangeInd, false);
- check_indicator(mResultIsAuthInd, false);
+ if (d_dnssecQueries)
+ check_indicator(mResultIsAuthInd, false);
rr.qname = mResultName;
rr.ttl = mResultTTL;
rr.qtype = mResultType;
rr.domain_id = mResultZoneId;
rr.last_modified = mResultLastChange;
- rr.auth = mResultIsAuth > 0;
+ if (d_dnssecQueries)
+ rr.auth = mResultIsAuth > 0;
+ else
+ rr.auth = 1;
if ((rr.qtype.getCode() == QType::MX) || (rr.qtype.getCode() == QType::SRV)) {
unsigned priority = 0;
@@ -1163,6 +1225,11 @@
OracleBackend::getDomainMetadata (const string& name, const string& kind,
vector<string>& meta)
{
+ if(!d_dnssecQueries)
+ return -1;
+ DomainInfo di;
+ if (getDomainInfo(name, di) == false) return false;
+
sword rc;
OCIStmt *stmt;
@@ -1198,6 +1265,11 @@
OracleBackend::setDomainMetadata(const string& name, const string& kind,
const vector<string>& meta)
{
+ if(!d_dnssecQueries)
+ return -1;
+ DomainInfo di;
+ if (getDomainInfo(name, di) == false) return false;
+
sword rc;
OCIStmt *stmt;
@@ -1256,6 +1328,11 @@
bool
OracleBackend::getTSIGKey (const string& name, string* algorithm, string* content)
{
+ if(!d_dnssecQueries)
+ return -1;
+ DomainInfo di;
+ if (getDomainInfo(name, di) == false) return false;
+
sword rc;
OCIStmt *stmt;
@@ -1287,6 +1364,11 @@
bool
OracleBackend::getDomainKeys (const string& name, unsigned int kind, vector<KeyData>& keys)
{
+ if(!d_dnssecQueries)
+ return -1;
+ DomainInfo di;
+ if (getDomainInfo(name, di) == false) return false;
+
sword rc;
OCIStmt *stmt;
@@ -1336,6 +1418,11 @@
bool
OracleBackend::removeDomainKey (const string& name, unsigned int id)
{
+ if(!d_dnssecQueries)
+ return -1;
+ DomainInfo di;
+ if (getDomainInfo(name, di) == false) return false;
+
sword rc;
OCIStmt *stmt;
@@ -1370,6 +1457,11 @@
int
OracleBackend::addDomainKey (const string& name, const KeyData& key)
{
+ if(!d_dnssecQueries)
+ return -1;
+ DomainInfo di;
+ if (getDomainInfo(name, di) == false) return false;
+
sword rc;
OCIStmt *stmt;
@@ -1416,6 +1508,11 @@
bool
OracleBackend::setDomainKeyState (const string& name, unsigned int id, int active)
{
+ if(!d_dnssecQueries)
+ return -1;
+ DomainInfo di;
+ if (getDomainInfo(name, di) == false) return false;
+
sword rc;
OCIStmt *stmt;
@@ -1625,7 +1722,8 @@
mResultContent, sizeof(mResultContent));
define_output_int(s, 5, &mResultZoneIdInd, &mResultZoneId);
define_output_int(s, 6, &mResultLastChangeInd, &mResultLastChange);
- define_output_int(s, 7, &mResultIsAuthInd, &mResultIsAuth);
+ if (d_dnssecQueries)
+ define_output_int(s, 7, &mResultIsAuthInd, &mResultIsAuth);
}
void
@@ -1919,14 +2017,19 @@
declare(suffix, "master-database", "Database to connect to for write access", "powerdns");
declare(suffix, "master-username", "Username to connect as for write access", "powerdns");
declare(suffix, "master-password", "Password to connect with for write access", "");
-
+ declare(suffix, "dnssec", "Assume DNSSEC Schema is in place", "no");
declare(suffix, "nameserver-name", "", "");
declare(suffix, "basic-query", "", basicQueryDefaultSQL);
+ declare(suffix, "basic-query-auth", "", basicQueryDefaultAuthSQL);
declare(suffix, "basic-id-query", "", basicIdQueryDefaultSQL);
+ declare(suffix, "basic-id-query-auth", "", basicIdQueryDefaultAuthSQL);
declare(suffix, "any-query", "", anyQueryDefaultSQL);
+ declare(suffix, "any-query-auth", "", anyQueryDefaultAuthSQL);
declare(suffix, "any-id-query", "", anyIdQueryDefaultSQL);
+ declare(suffix, "any-id-query-auth", "", anyIdQueryDefaultAuthSQL);
declare(suffix, "list-query", "", listQueryDefaultSQL);
+ declare(suffix, "list-query-auth", "", listQueryDefaultAuthSQL);
declare(suffix, "zone-info-query", "", zoneInfoQueryDefaultSQL);
declare(suffix, "also-notify-query", "", alsoNotifyQueryDefaultSQL);
declare(suffix, "zone-masters-query", "", zoneMastersQueryDefaultSQL);
Index: oraclebackend.hh
===================================================================
--- oraclebackend.hh (revision 2679)
+++ oraclebackend.hh (working copy)
@@ -164,6 +164,7 @@
sb2 mResultPrevNameInd;
char mResultNextName[512];
sb2 mResultNextNameInd;
+ bool d_dnssecQueries;
void Cleanup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment