]> granicus.if.org Git - pdns/commitdiff
goracle backend presigned fix and regression tests
authorKees Monshouwer <mind04@monshouwer.org>
Sat, 4 Jan 2014 00:44:49 +0000 (01:44 +0100)
committermind04 <mind04@monshouwer.org>
Sat, 4 Jan 2014 13:53:00 +0000 (14:53 +0100)
modules/goraclebackend/goraclebackend.cc
modules/goraclebackend/goraclebackend.hh
regression-tests/.gitignore
regression-tests/cname-to-unauth/skip-unboundhost [new file with mode: 0644]
regression-tests/start-test-stop

index a63df28628cb650cd9918e238bf2a59bf756b2fd..39fc1d490edf2ac8ddb099e5ab37647474f9f4e7 100644 (file)
 #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);
@@ -28,16 +28,23 @@ gOracleBackend::gOracleBackend(const string &mode, const string &suffix)  : GSQL
   }
 
   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", "");
@@ -140,6 +147,7 @@ public:
   DNSBackend* make(const string &suffix="") {
     return new gOracleBackend(d_mode,suffix);
   }
+
 private:
   const string d_mode;
 };
@@ -152,7 +160,9 @@ public:
   //! 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;
index 1ca3b8b05f6233f2d340d21863fa3decde0756e4..d8e9f6309de1fc234d0234561bfef712fe0c1db5 100644 (file)
@@ -10,4 +10,5 @@ class gOracleBackend : public GSQLBackend
 {
 public:
   gOracleBackend(const string &mode, const string &suffix); //!< Makes our connection to the database. Throws an exception if it fails.
+  virtual string sqlEscape(const string &name);
 };
index afe907e23009a56a7e91ce96a9525037f0d525f4..41ef4df72b4b21e7d2c3f35c5986a26a47668516 100644 (file)
@@ -39,3 +39,4 @@ real_result
 /bind.conf
 /bind-slave.conf
 /oracle.log
+/oracle2.log
diff --git a/regression-tests/cname-to-unauth/skip-unboundhost b/regression-tests/cname-to-unauth/skip-unboundhost
new file mode 100644 (file)
index 0000000..e69de29
index bf8d81cdcdcb47e9a33c6b31e0ad51cfc11b2046..0dcb15367376a4b1649d0e30141e41252c97bf3d 100755 (executable)
@@ -808,7 +808,6 @@ __EOF__
 
 
                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
@@ -1132,6 +1131,71 @@ startslave ()
                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