* 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.
+ * this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <postgresql/libpq-fe.h>
/**
* delete_key - Given a keyid delete the key from storage.
- * @keyid: The keyid to delete.
+ * @fp: The fingerprint of the key to delete.
* @intrans: If we're already in a transaction.
*
* This function deletes a public key from whatever storage mechanism we
* are using. Returns 0 if the key existed.
*/
-static int pg_delete_key(struct onak_dbctx *dbctx, uint64_t keyid, bool intrans)
+static int pg_delete_key(struct onak_dbctx *dbctx,
+ struct openpgp_fingerprint *fp, bool intrans)
{
PGconn *dbconn = (PGconn *) dbctx->priv;
PGresult *result = NULL;
int found = 1;
int i;
Oid key_oid;
+ uint64_t keyid;
if (!intrans) {
result = PQexec(dbconn, "BEGIN");
PQclear(result);
}
+
+ keyid = fingerprint2keyid(fp);
snprintf(statement, 1023,
"SELECT keydata FROM onak_keys WHERE keyid = '%"
int i;
uint64_t keyid;
struct pg_fc_ctx fcctx;
+ struct openpgp_fingerprint fp;
if (!intrans) {
result = PQexec(dbconn, "BEGIN");
* it definitely needs updated.
*/
if (update) {
- pg_delete_key(dbctx, keyid, true);
+ get_fingerprint(publickey->publickey, &fp);
+ pg_delete_key(dbctx, &fp, true);
}
next = publickey->next;
/*
* Include the basic keydb routines.
*/
-#define NEED_GETFULLKEYID 1
#define NEED_UPDATEKEYS 1
#define NEED_GET_FP 1
#include "keydb.c"
dbctx->getkeysigs = pg_getkeysigs;
dbctx->cached_getkeysigs = generic_cached_getkeysigs;
dbctx->keyid2uid = pg_keyid2uid;
- dbctx->getfullkeyid = generic_getfullkeyid;
dbctx->iterate_keys = pg_iterate_keys;
return dbctx;