From 62afe341b7c6d4c33faea3d913b8322738258e8a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 16 Apr 2017 17:21:26 +0200 Subject: [PATCH] fix #4984 --- src/auditor/taler-auditor.c | 6 ++++-- src/exchangedb/plugin_exchangedb_postgres.c | 9 +++++++-- src/exchangedb/test_exchangedb.c | 4 +++- src/include/taler_exchangedb_plugin.h | 4 +++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c index b94b1e868..1667c7b32 100644 --- a/src/auditor/taler-auditor.c +++ b/src/auditor/taler-auditor.c @@ -832,6 +832,7 @@ handle_payback_by_reserve (void *cls, struct GNUNET_TIME_Absolute expiry; struct TALER_PaybackRequestPS pr; struct TALER_MasterSignatureP msig; + uint64_t rev_rowid; int ret; /* should be monotonically increasing */ @@ -866,7 +867,8 @@ handle_payback_by_reserve (void *cls, ret = edb->get_denomination_revocation (edb->cls, esession, &pr.h_denom_pub, - &msig); + &msig, + &rev_rowid); if (GNUNET_SYSERR == ret) { GNUNET_break (0); @@ -893,7 +895,7 @@ handle_payback_by_reserve (void *cls, &master_pub.eddsa_pub)) { report_row_inconsistency ("denomination_revocations", - 0, /* FIXME: modify DB API to return rowid! (#4984) */ + rev_rowid, "master signature invalid"); } /* TODO: cache result so we don't do this every time! (#4983) */ diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index c9c3d5fd4..916c502c7 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -317,7 +317,8 @@ postgres_create_tables (void *cls) add denom_pub_hash column to denominations, changing other REFERENCEs also to the hash!? */ SQLEXEC ("CREATE TABLE IF NOT EXISTS denomination_revocations" - "(denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)" + "(denom_revocations_serial_id BIGSERIAL" + ",denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)" ",master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)" ")"); @@ -667,6 +668,7 @@ postgres_prepare (PGconn *db_conn) PREPARE ("denomination_revocation_get", "SELECT" " master_sig" + ",denom_revocations_serial_id" " FROM denomination_revocations" " WHERE denom_pub_hash=$1;", 1, NULL); @@ -6042,6 +6044,7 @@ postgres_insert_denomination_revocation (void *cls, * @param session a session * @param denom_pub_hash hash of the revoked denomination key * @param[out] master_sig signature affirming the revocation + * @param[out] rowid row where the information is stored * @return #GNUNET_OK on success, * #GNUNET_NO no such entry exists * #GNUNET_SYSERR on DB errors @@ -6050,7 +6053,8 @@ static int postgres_get_denomination_revocation (void *cls, struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *denom_pub_hash, - struct TALER_MasterSignatureP *master_sig) + struct TALER_MasterSignatureP *master_sig, + uint64_t *rowid) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (denom_pub_hash), @@ -6058,6 +6062,7 @@ postgres_get_denomination_revocation (void *cls, }; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("master_sig", master_sig), + GNUNET_PQ_result_spec_uint64 ("denom_revocations_serial_id", rowid), GNUNET_PQ_result_spec_end }; PGresult *result; diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index f3a5adcb8..330380d31 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -1823,12 +1823,14 @@ run (void *cls) session)); { struct TALER_MasterSignatureP msig; + uint64_t rev_rowid; FAILIF (GNUNET_OK != plugin->get_denomination_revocation (plugin->cls, session, &dkp_pub_hash, - &msig)); + &msig, + &rev_rowid)); FAILIF (0 != memcmp (&msig, &master_sig, sizeof (msig))); diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index a287ea563..fe08bd27e 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -2040,6 +2040,7 @@ struct TALER_EXCHANGEDB_Plugin * @param session a session * @param denom_pub_hash hash of the revoked denomination key * @param[out] master_sig signature affirming the revocation + * @param[out] rowid row where the information is stored * @return #GNUNET_OK on success, * #GNUNET_NO no such entry exists * #GNUNET_SYSERR on DB errors @@ -2048,7 +2049,8 @@ struct TALER_EXCHANGEDB_Plugin (*get_denomination_revocation)(void *cls, struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *denom_pub_hash, - struct TALER_MasterSignatureP *master_sig); + struct TALER_MasterSignatureP *master_sig, + uint64_t *rowid); };