]> granicus.if.org Git - pdns/commitdiff
pdnssec: Throw an error on existing bind-dnssec-db
authorPieter Lexis <pieter.lexis@powerdns.com>
Fri, 2 Oct 2015 10:56:45 +0000 (12:56 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Mon, 26 Oct 2015 18:13:24 +0000 (19:13 +0100)
Closes #2403

pdns/pdnssec.cc
pdns/ssqlite3.cc

index e1585e001330d7a768d87fbba48c814cf68a685f..8c078bb8ddf73eca5533efc969d1683befb3fefb 100644 (file)
@@ -1407,7 +1407,7 @@ try
   if(cmds[0] == "create-bind-db") {
 #ifdef HAVE_SQLITE3
     if(cmds.size() != 2) {
-      cerr << "Syntax: pdnssec create-bind-db fname"<<endl;
+      cerr << "Syntax: pdnssec create-bind-db FNAME"<<endl;
       return 0;
     }
     try {
index db8062aa2d8c34e84e021f7fbca58d0669fc4e04..536442b4220f63356ef25259343f0ff44360ff8f 100644 (file)
@@ -139,10 +139,13 @@ private:
 // Constructor.
 SSQLite3::SSQLite3( const std::string & database, bool creat )
 {
-  // Open the database connection.
-  if(!creat) 
-    if ( access( database.c_str(), F_OK ) == -1 )
+  if (access( database.c_str(), F_OK ) == -1){
+    if (!creat)
       throw sPerrorException( "SQLite database '"+database+"' does not exist yet" );
+  } else {
+    if (creat)
+      throw sPerrorException( "SQLite database '"+database+"' already exists" );
+  }
 
   if ( sqlite3_open( database.c_str(), &m_pDB)!=SQLITE_OK )
     throw sPerrorException( "Could not connect to the SQLite database '" + database + "'" );