Install /pks/hashquery in Debian packaging
[onak.git] / keydb_db4.c
index eb41f86652fea31ba0ab3384cecb97883e447bc9..4e35bff934264bb8467bed73866a19d79b269f89 100644 (file)
@@ -2,6 +2,19 @@
  * keydb_db4.c - Routines to store and fetch keys in a DB4 database.
  *
  * Copyright 2002-2008 Jonathan McDowell <noodles@earth.li>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #include <sys/types.h>
@@ -296,7 +309,7 @@ static void db4_initdb(bool readonly)
        FILE      *numdb = NULL;
        int        ret = 0;
        int        i = 0;
-       u_int32_t  flags = 0;
+       uint32_t   flags = 0;
        struct stat statbuf;
        int        maxlocks;
 
@@ -874,7 +887,7 @@ static int db4_delete_key(uint64_t keyid, bool intrans)
                        worddb_data[ 8] = (keyid >> 24) & 0xFF;
                        worddb_data[ 9] = (keyid >> 16) & 0xFF;
                        worddb_data[10] = (keyid >>  8) & 0xFF;
-                       worddb_data[11] = keyid & 0xFF; 
+                       worddb_data[11] = keyid & 0xFF;
 
                        ret = cursor->c_get(cursor,
                                &key,
@@ -883,17 +896,14 @@ static int db4_delete_key(uint64_t keyid, bool intrans)
 
                        if (ret == 0) {
                                ret = cursor->c_del(cursor, 0);
-                               if (ret != 0) {
-                                       logthing(LOGTHING_ERROR,
-                                               "Problem deleting word: %s",
-                                               db_strerror(ret));
-                               }
                        }
 
                        if (ret != 0) {
                                logthing(LOGTHING_ERROR,
-                                       "Problem deleting word: %s",
-                                       db_strerror(ret));
+                                       "Problem deleting word: %s "
+                                       "(0x%016" PRIX64 ")",
+                                       db_strerror(ret),
+                                       keyid);
                                if (ret == DB_LOCK_DEADLOCK) {
                                        deadlock = true;
                                }
@@ -938,17 +948,14 @@ static int db4_delete_key(uint64_t keyid, bool intrans)
 
                if (ret == 0) {
                        ret = cursor->c_del(cursor, 0);
-                       if (ret != 0) {
-                               logthing(LOGTHING_ERROR,
-                                       "Problem deleting short keyid: %s",
-                                       db_strerror(ret));
-                       }
                }
 
                if (ret != 0) {
                        logthing(LOGTHING_ERROR,
-                               "Problem deleting short keyid: %s",
-                               db_strerror(ret));
+                               "Problem deleting short keyid: %s ",
+                               "(0x%016" PRIX64 ")",
+                               db_strerror(ret),
+                               keyid);
                        if (ret == DB_LOCK_DEADLOCK) {
                                deadlock = true;
                        }
@@ -973,18 +980,14 @@ static int db4_delete_key(uint64_t keyid, bool intrans)
 
                        if (ret == 0) {
                                ret = cursor->c_del(cursor, 0);
-                               if (ret != 0) {
-                                       logthing(LOGTHING_ERROR,
-                                               "Problem deleting short"
-                                               " keyid: %s",
-                                               db_strerror(ret));
-                               }
                        }
 
                        if (ret != 0) {
                                logthing(LOGTHING_ERROR,
-                                       "Problem deleting short keyid: %s",
-                                       db_strerror(ret));
+                                       "Problem deleting short keyid: %s ",
+                                       "(0x%016" PRIX64 ")",
+                                       db_strerror(ret),
+                                       keyid);
                                if (ret == DB_LOCK_DEADLOCK) {
                                        deadlock = true;
                                }
@@ -1000,6 +1003,10 @@ static int db4_delete_key(uint64_t keyid, bool intrans)
        }
 
        if (!deadlock) {
+               ret = skshashdb->cursor(skshashdb,
+                       txn,
+                       &cursor,
+                       0);   /* flags */
                get_skshash(publickey, &hash);
 
                memset(&key, 0, sizeof(key));
@@ -1020,8 +1027,10 @@ static int db4_delete_key(uint64_t keyid, bool intrans)
 
                if (ret != 0) {
                        logthing(LOGTHING_ERROR,
-                               "Problem deleting skshash: %s",
-                               db_strerror(ret));
+                               "Problem deleting skshash: %s ",
+                               "(0x%016" PRIX64 ")",
+                               db_strerror(ret),
+                               keyid);
                        if (ret == DB_LOCK_DEADLOCK) {
                                deadlock = true;
                        }