* 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 <stdbool.h>
+#include <stdint.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "cleankey.h"
-#include "decodekey.h"
-#include "hash.h"
#include "keydb.h"
-#include "keyid.h"
#include "keystructs.h"
+#include "ll.h"
#include "log.h"
-#include "mem.h"
-#include "merge.h"
#include "onak-conf.h"
-#include "openpgp.h"
-#include "parsekey.h"
-#include "sendsync.h"
struct onak_stacked_dbctx {
struct ll *backends;
(struct onak_dbctx *) privctx->backends->object;
struct openpgp_publickey *curkey;
- cleankeys(publickey);
+ cleankeys(&publickey, config.clean_policies);
/*
* If we walked the stack at all, store the key in the first
* backend if configured to do so. It's not an update as we
return res;
}
+/*
+ * Include the basic keydb routines so we can use them for fall back.
+ * For all of the following we try the top keydb backend and if that doesn't
+ * have answer fall back to the generics, which will do a retrieve from a
+ * backend further down the stack, then a fallback store.
+ */
+#define NEED_KEYID2UID 1
+#define NEED_GETKEYSIGS 1
+#define NEED_GETFULLKEYID 1
+#define NEED_UPDATEKEYS 1
+#include "keydb.c"
+
static struct ll *stacked_getkeysigs(struct onak_dbctx *dbctx,
uint64_t keyid, bool *revoked)
{
struct onak_stacked_dbctx *privctx =
(struct onak_stacked_dbctx *) dbctx->priv;
- struct onak_dbctx *backend;
- struct ll *cur;
- struct ll *res = NULL;
+ struct onak_dbctx *backend =
+ (struct onak_dbctx *) privctx->backends->object;
+ struct ll *res;
- for (cur = privctx->backends; cur != NULL && res == NULL;
- cur = cur->next) {
- backend = (struct onak_dbctx *) cur->object;
- res = backend->getkeysigs(backend, keyid, revoked);
+ res = backend->getkeysigs(backend, keyid, revoked);
+ if (res == NULL) {
+ res = generic_getkeysigs(dbctx, keyid, revoked);
}
return res;
{
struct onak_stacked_dbctx *privctx =
(struct onak_stacked_dbctx *) dbctx->priv;
- struct onak_dbctx *backend;
- struct ll *cur;
- struct ll *res = NULL;
+ struct onak_dbctx *backend =
+ (struct onak_dbctx *) privctx->backends->object;
+ struct ll *res;
- for (cur = privctx->backends; cur != NULL && res == NULL;
- cur = cur->next) {
- backend = (struct onak_dbctx *) cur->object;
- res = backend->cached_getkeysigs(backend, keyid);
+ res = backend->cached_getkeysigs(backend, keyid);
+ if (res == NULL) {
+ res = generic_cached_getkeysigs(dbctx, keyid);
}
return res;
{
struct onak_stacked_dbctx *privctx =
(struct onak_stacked_dbctx *) dbctx->priv;
- struct onak_dbctx *backend;
- struct ll *cur;
+ struct onak_dbctx *backend =
+ (struct onak_dbctx *) privctx->backends->object;
char *res = NULL;
- for (cur = privctx->backends; cur != NULL && res == NULL;
- cur = cur->next) {
- backend = (struct onak_dbctx *) cur->object;
- res = backend->keyid2uid(backend, keyid);
+ res = backend->keyid2uid(backend, keyid);
+ if (!res) {
+ res = generic_keyid2uid(dbctx, keyid);
}
return res;
{
struct onak_stacked_dbctx *privctx =
(struct onak_stacked_dbctx *) dbctx->priv;
- struct onak_dbctx *backend;
- struct ll *cur;
+ struct onak_dbctx *backend =
+ (struct onak_dbctx *) privctx->backends->object;
uint64_t res = 0;
- for (cur = privctx->backends; cur != NULL && res == 0;
- cur = cur->next) {
- backend = (struct onak_dbctx *) cur->object;
- res = backend->getfullkeyid(backend, keyid);
+ res = backend->getfullkeyid(backend, keyid);
+ if (res == 0) {
+ res = generic_getfullkeyid(dbctx, keyid);
}
return res;