#include "soracle.hh"
#include <sstream>
-gOracleBackend::gOracleBackend(const string &mode, const string &suffix) : GSQLBackend(mode,suffix)
+gOracleBackend::gOracleBackend(const string &mode, const string &suffix) : GSQLBackend(mode, suffix)
{
try {
- // set some envionment variables
+ // set Oracle envionment variables
setenv("ORACLE_HOME", getArg("home").c_str(), 1);
setenv("ORACLE_SID", getArg("sid").c_str(), 1);
setenv("NLS_LANG", getArg("nls-lang").c_str(), 1);
}
catch (SSqlException &e) {
- L<<Logger::Error<<mode<<" Connection failed: "<<e.txtReason()<<endl;
- throw PDNSException("Unable to launch "+mode+" connection: "+e.txtReason());
+ L<<Logger::Error << mode << " Connection failed: " << e.txtReason() << endl;
+ throw PDNSException("Unable to launch " + mode + " connection: " + e.txtReason());
}
- L<<Logger::Info<<mode<<" Connection successful"<<endl;
+ L<<Logger::Info << mode << " Connection successful" << endl;
}
+
+string gOracleBackend::sqlEscape(const string &name)
+{
+ return boost::replace_all_copy(name, "'", "''");
+}
+
+
class gOracleFactory : public BackendFactory
{
public:
- gOracleFactory(const string &mode) : BackendFactory(mode),d_mode(mode) {}
+ gOracleFactory(const string &mode) : BackendFactory(mode), d_mode(mode) {}
void declareArguments(const string &suffix="") {
declare(suffix,"home", "Oracle home path", "");
DNSBackend* make(const string &suffix="") {
return new gOracleBackend(d_mode,suffix);
}
+
private:
const string d_mode;
};
//! This reports us to the main UeberBackend class
gOracleLoader() {
BackendMakers().report(new gOracleFactory("goracle"));
- L<<Logger::Warning<<"This is module goraclebackend.so reporting"<<endl;
+ L<<Logger::Warning<<"This is module goraclebackend reporting"<<endl;
}
};
+
+//! Reports the backendloader to the UeberBackend.
static gOracleLoader goracleloader;
goracle-nodnssec | goracle | goracle-nsec3 | goracle-nsec3-optout)
-
echo "DROP USER pdns CASCADE;" | sqlplus -S powerdns/powerdns > oracle.log || true
echo "CREATE USER pdns IDENTIFIED BY pdns;" | sqlplus -S powerdns/powerdns >> oracle.log
echo "GRANT CONNECT, RESOURCE TO pdns;" | sqlplus -S powerdns/powerdns >> oracle.log
fi
set -e
sqlite3 pdns.sqlite31 ANALYZE;
+ elif [ ${presignedcontext:0:7} = goracle ]
+ then
+ context=${context}-presigned
+ echo "DROP USER pdns2 CASCADE;" | sqlplus -S powerdns/powerdns > oracle2.log || true
+ echo "CREATE USER pdns2 IDENTIFIED BY pdns;" | sqlplus -S powerdns/powerdns >> oracle2.log
+ echo "GRANT CONNECT, RESOURCE TO pdns2;" | sqlplus -S powerdns/powerdns >> oracle2.log
+ sqlplus -S pdns2/pdns@xe < ../modules/goraclebackend/goracle-schema.sql >> oracle2.log
+
+ cat > pdns-goracle2.conf << __EOF__
+launch=goracle
+goracle-home=$ORACLE_HOME
+goracle-sid=$ORACLE_SID
+goracle-nls-lang=$NLS_LANG
+
+goracle-tnsname=xe
+goracle-user=pdns2
+goracle-password=pdns
+goracle-dnssec
+__EOF__
+
+ for zone in $(grep zone named.conf | cut -f2 -d\" | tac)
+ do
+ echo "INSERT INTO domains (id, name, type, master) VALUES(domains_id_sequence.nextval, '$zone', 'SLAVE', '127.0.0.1:$port');" | sqlplus -S pdns2/pdns@xe >> oracle2.log
+ done
+
+ set +e
+ echo $skipreasons | grep -q nodnssec
+ if [ $? -ne 0 ]; then
+ ../pdns/pdnssec --config-dir=. --config-name=goracle2 import-tsig-key test $ALGORITHM $KEY
+ ../pdns/pdnssec --config-dir=. --config-name=goracle2 activate-tsig-key tsig.com test master
+ echo $skipreasons | grep -q nolua
+ if [ $? -ne 0 ]; then
+ ../pdns/pdnssec --config-dir=. --config-name=goracle2 set-meta stest.com AXFR-SOURCE 127.0.0.2
+ fi
+ fi
+ set -e
+
+ port=$((port+100))
+
+ $RUNWRAPPER $PDNS2 --daemon=no --local-port=$port --config-dir=. \
+ --config-name=goracle2 --socket-dir=./ --no-shuffle \
+ --send-root-referral --slave --retrieval-threads=4 \
+ --slave-cycle-interval=300 --config-name=goracle2 &
+ echo 'waiting for zones to be slaved'
+
+ loopcount=0
+ while [ $loopcount -lt 40 ]
+ do
+ sleep 5
+ todo=$(sqlplus -S pdns2/pdns@xe << __EOF__
+set pagesize 0 feedback off verify off heading off echo off;
+SELECT COUNT(id) FROM domains WHERE last_check IS NULL;
+exit;
+__EOF__
+)
+ if [ $todo = 0 ]
+ then
+ break
+ fi
+ let loopcount=loopcount+1
+ done
+ if [ $todo -ne 0 ]; then
+ echo "AXFR FAILED" >> failed_tests
+ fi
+
elif [ ${presignedcontext:0:4} = bind ]
then
context=${context}-presigned