-more revocation
[oweals/gnunet.git] / src / identity-provider / plugin_identity_provider_sqlite.c
1  /*
2   * This file is part of GNUnet
3   * Copyright (C) 2009-2017 GNUnet e.V.
4   *
5   * GNUnet is free software; you can redistribute it and/or modify
6   * it under the terms of the GNU General Public License as published
7   * by the Free Software Foundation; either version 3, or (at your
8   * option) any later version.
9   *
10   * GNUnet is distributed in the hope that it will be useful, but
11   * WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   * General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with GNUnet; see the file COPYING.  If not, write to the
17   * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18   * Boston, MA 02110-1301, USA.
19   */
20
21 /**
22  * @file identity-provider/plugin_identity_provider_sqlite.c
23  * @brief sqlite-based idp backend
24  * @author Martin Schanzenbach
25  */
26
27 #include "platform.h"
28 #include "gnunet_identity_provider_service.h"
29 #include "gnunet_identity_provider_plugin.h"
30 #include "identity_attribute.h"
31 #include "gnunet_sq_lib.h"
32 #include <sqlite3.h>
33
34 /**
35  * After how many ms "busy" should a DB operation fail for good?  A
36  * low value makes sure that we are more responsive to requests
37  * (especially PUTs).  A high value guarantees a higher success rate
38  * (SELECTs in iterate can take several seconds despite LIMIT=1).
39  *
40  * The default value of 1s should ensure that users do not experience
41  * huge latencies while at the same time allowing operations to
42  * succeed with reasonable probability.
43  */
44 #define BUSY_TIMEOUT_MS 1000
45
46
47 /**
48  * Log an error message at log-level 'level' that indicates
49  * a failure of the command 'cmd' on file 'filename'
50  * with the message given by strerror(errno).
51  */
52 #define LOG_SQLITE(db, level, cmd) do { GNUNET_log_from (level, "identity-provider", _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, sqlite3_errmsg(db->dbh)); } while(0)
53
54 #define LOG(kind,...) GNUNET_log_from (kind, "identity-provider-sqlite", __VA_ARGS__)
55
56
57 /**
58  * Context for all functions in this plugin.
59  */
60 struct Plugin
61 {
62
63   const struct GNUNET_CONFIGURATION_Handle *cfg;
64
65   /**
66    * Database filename.
67    */
68   char *fn;
69
70   /**
71    * Native SQLite database handle.
72    */
73   sqlite3 *dbh;
74
75   /**
76    * Precompiled SQL to store ticket.
77    */
78   sqlite3_stmt *store_ticket;
79
80   /**
81    * Precompiled SQL to delete existing ticket.
82    */
83   sqlite3_stmt *delete_ticket;
84
85   /**
86    * Precompiled SQL to iterate tickets.
87    */
88   sqlite3_stmt *iterate_tickets;
89
90   /**
91    * Precompiled SQL to iterate tickets by audience.
92    */
93   sqlite3_stmt *iterate_tickets_by_audience;
94 };
95
96
97 /**
98  * @brief Prepare a SQL statement
99  *
100  * @param dbh handle to the database
101  * @param zSql SQL statement, UTF-8 encoded
102  * @param ppStmt set to the prepared statement
103  * @return 0 on success
104  */
105 static int
106 sq_prepare (sqlite3 *dbh,
107             const char *zSql,
108             sqlite3_stmt **ppStmt)
109 {
110   char *dummy;
111   int result;
112
113   result =
114       sqlite3_prepare_v2 (dbh,
115                           zSql,
116                           strlen (zSql),
117                           ppStmt,
118                           (const char **) &dummy);
119   LOG (GNUNET_ERROR_TYPE_DEBUG,
120        "Prepared `%s' / %p: %d\n",
121        zSql,
122        *ppStmt,
123        result);
124   return result;
125 }
126
127 /**
128  * Create our database indices.
129  *
130  * @param dbh handle to the database
131  */
132 static void
133 create_indices (sqlite3 * dbh)
134 {
135   /* create indices */
136   if ( (SQLITE_OK !=
137         sqlite3_exec (dbh,
138                       "CREATE INDEX IF NOT EXISTS identity_reverse ON identity001tickets (identity,audience)",
139                       NULL, NULL, NULL)) ||
140        (SQLITE_OK !=
141         sqlite3_exec (dbh,
142                       "CREATE INDEX IF NOT EXISTS it_iter ON identity001tickets (rnd)",
143                       NULL, NULL, NULL)) )
144     LOG (GNUNET_ERROR_TYPE_ERROR,
145          "Failed to create indices: %s\n",
146          sqlite3_errmsg (dbh));
147 }
148
149
150
151 #if 0
152 #define CHECK(a) GNUNET_break(a)
153 #define ENULL NULL
154 #else
155 #define ENULL &e
156 #define ENULL_DEFINED 1
157 #define CHECK(a) if (! (a)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "%s\n", e); sqlite3_free(e); }
158 #endif
159
160
161 /**
162  * Initialize the database connections and associated
163  * data structures (create tables and indices
164  * as needed as well).
165  *
166  * @param plugin the plugin context (state for this module)
167  * @return #GNUNET_OK on success
168  */
169 static int
170 database_setup (struct Plugin *plugin)
171 {
172   sqlite3_stmt *stmt;
173   char *afsdir;
174 #if ENULL_DEFINED
175   char *e;
176 #endif
177
178   if (GNUNET_OK !=
179       GNUNET_CONFIGURATION_get_value_filename (plugin->cfg,
180                                                "identity-provider-sqlite",
181                                                "FILENAME",
182                                                &afsdir))
183   {
184     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
185                                "identity-provider-sqlite",
186                                "FILENAME");
187     return GNUNET_SYSERR;
188   }
189   if (GNUNET_OK !=
190       GNUNET_DISK_file_test (afsdir))
191   {
192     if (GNUNET_OK !=
193         GNUNET_DISK_directory_create_for_file (afsdir))
194     {
195       GNUNET_break (0);
196       GNUNET_free (afsdir);
197       return GNUNET_SYSERR;
198     }
199   }
200   /* afsdir should be UTF-8-encoded. If it isn't, it's a bug */
201   plugin->fn = afsdir;
202
203   /* Open database and precompile statements */
204   if (sqlite3_open (plugin->fn, &plugin->dbh) != SQLITE_OK)
205   {
206     LOG (GNUNET_ERROR_TYPE_ERROR,
207          _("Unable to initialize SQLite: %s.\n"),
208          sqlite3_errmsg (plugin->dbh));
209     return GNUNET_SYSERR;
210   }
211   CHECK (SQLITE_OK ==
212          sqlite3_exec (plugin->dbh,
213                        "PRAGMA temp_store=MEMORY", NULL, NULL,
214                        ENULL));
215   CHECK (SQLITE_OK ==
216          sqlite3_exec (plugin->dbh,
217                        "PRAGMA synchronous=NORMAL", NULL, NULL,
218                        ENULL));
219   CHECK (SQLITE_OK ==
220          sqlite3_exec (plugin->dbh,
221                        "PRAGMA legacy_file_format=OFF", NULL, NULL,
222                        ENULL));
223   CHECK (SQLITE_OK ==
224          sqlite3_exec (plugin->dbh,
225                        "PRAGMA auto_vacuum=INCREMENTAL", NULL,
226                        NULL, ENULL));
227   CHECK (SQLITE_OK ==
228          sqlite3_exec (plugin->dbh,
229                        "PRAGMA encoding=\"UTF-8\"", NULL,
230                        NULL, ENULL));
231   CHECK (SQLITE_OK ==
232          sqlite3_exec (plugin->dbh,
233                        "PRAGMA locking_mode=EXCLUSIVE", NULL, NULL,
234                        ENULL));
235   CHECK (SQLITE_OK ==
236          sqlite3_exec (plugin->dbh,
237                        "PRAGMA page_size=4092", NULL, NULL,
238                        ENULL));
239
240   CHECK (SQLITE_OK ==
241          sqlite3_busy_timeout (plugin->dbh,
242                                BUSY_TIMEOUT_MS));
243
244
245   /* Create table */
246   CHECK (SQLITE_OK ==
247          sq_prepare (plugin->dbh,
248                      "SELECT 1 FROM sqlite_master WHERE tbl_name = 'identity001tickets'",
249                      &stmt));
250   if ((sqlite3_step (stmt) == SQLITE_DONE) &&
251       (sqlite3_exec
252        (plugin->dbh,
253         "CREATE TABLE identity001tickets ("
254         " identity BLOB NOT NULL DEFAULT '',"
255         " audience BLOB NOT NULL DEFAULT '',"
256               " rnd INT8 NOT NULL DEFAULT '',"
257         " attributes BLOB NOT NULL DEFAULT ''"
258         ")",
259         NULL, NULL, NULL) != SQLITE_OK))
260   {
261     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR,
262                 "sqlite3_exec");
263     sqlite3_finalize (stmt);
264     return GNUNET_SYSERR;
265   }
266   sqlite3_finalize (stmt);
267
268   create_indices (plugin->dbh);
269
270   if ( (SQLITE_OK !=
271         sq_prepare (plugin->dbh,
272                     "INSERT INTO identity001tickets (identity, audience, rnd, attributes)"
273                     " VALUES (?, ?, ?, ?)",
274                     &plugin->store_ticket)) ||
275        (SQLITE_OK !=
276         sq_prepare (plugin->dbh,
277                     "DELETE FROM identity001tickets WHERE identity=? AND rnd=?",
278                     &plugin->delete_ticket)) ||
279        (SQLITE_OK !=
280         sq_prepare (plugin->dbh,
281                     "SELECT identity,audience,rnd,attributes"
282                     " FROM identity001tickets WHERE identity=?"
283                     " ORDER BY rnd LIMIT 1 OFFSET ?",
284                     &plugin->iterate_tickets)) ||
285        (SQLITE_OK !=
286         sq_prepare (plugin->dbh,
287                     "SELECT identity,audience,rnd,attributes"
288                     " FROM identity001tickets WHERE audience=?"
289                     " ORDER BY rnd LIMIT 1 OFFSET ?",
290                     &plugin->iterate_tickets_by_audience)) ) 
291   {
292     LOG_SQLITE (plugin,
293                 GNUNET_ERROR_TYPE_ERROR,
294                 "precompiling");
295     return GNUNET_SYSERR;
296   }
297   return GNUNET_OK;
298 }
299
300
301 /**
302  * Shutdown database connection and associate data
303  * structures.
304  * @param plugin the plugin context (state for this module)
305  */
306 static void
307 database_shutdown (struct Plugin *plugin)
308 {
309   int result;
310   sqlite3_stmt *stmt;
311
312   if (NULL != plugin->store_ticket)
313     sqlite3_finalize (plugin->store_ticket);
314   if (NULL != plugin->delete_ticket)
315     sqlite3_finalize (plugin->delete_ticket);
316   if (NULL != plugin->iterate_tickets)
317     sqlite3_finalize (plugin->iterate_tickets);
318   if (NULL != plugin->iterate_tickets_by_audience)
319     sqlite3_finalize (plugin->iterate_tickets_by_audience);
320   result = sqlite3_close (plugin->dbh);
321   if (result == SQLITE_BUSY)
322   {
323     LOG (GNUNET_ERROR_TYPE_WARNING,
324          _("Tried to close sqlite without finalizing all prepared statements.\n"));
325     stmt = sqlite3_next_stmt (plugin->dbh,
326                               NULL);
327     while (NULL != stmt)
328     {
329       GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
330                        "sqlite",
331                        "Closing statement %p\n",
332                        stmt);
333       result = sqlite3_finalize (stmt);
334       if (result != SQLITE_OK)
335         GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,
336                          "sqlite",
337                          "Failed to close statement %p: %d\n",
338                          stmt,
339                          result);
340       stmt = sqlite3_next_stmt (plugin->dbh,
341                                 NULL);
342     }
343     result = sqlite3_close (plugin->dbh);
344   }
345   if (SQLITE_OK != result)
346     LOG_SQLITE (plugin,
347                 GNUNET_ERROR_TYPE_ERROR,
348                 "sqlite3_close");
349
350   GNUNET_free_non_null (plugin->fn);
351 }
352
353
354 /**
355  * Store a ticket in the database.
356  *
357  * @param cls closure (internal context for the plugin)
358  * @param ticket the ticket to persist
359  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
360  */
361 static int
362 identity_provider_sqlite_store_ticket (void *cls,
363                                        const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
364                                        const struct GNUNET_IDENTITY_PROVIDER_AttributeList *attrs)
365 {
366   struct Plugin *plugin = cls;
367   size_t attrs_len;
368   char *attrs_ser;
369   int n;
370
371   { 
372     /* First delete duplicates */
373     struct GNUNET_SQ_QueryParam dparams[] = {
374       GNUNET_SQ_query_param_auto_from_type (&ticket->identity),
375       GNUNET_SQ_query_param_uint64 (&ticket->rnd),
376       GNUNET_SQ_query_param_end
377     };
378     if (GNUNET_OK !=
379         GNUNET_SQ_bind (plugin->delete_ticket,
380                         dparams))
381     {
382       LOG_SQLITE (plugin,
383                   GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
384                   "sqlite3_bind_XXXX");
385       GNUNET_SQ_reset (plugin->dbh,
386                        plugin->delete_ticket);
387       return GNUNET_SYSERR;
388     }
389     n = sqlite3_step (plugin->delete_ticket);
390     GNUNET_SQ_reset (plugin->dbh,
391                      plugin->delete_ticket);
392     
393     attrs_len = attribute_list_serialize_get_size (attrs);
394     attrs_ser = GNUNET_malloc (attrs_len);
395     attribute_list_serialize (attrs,
396                               attrs_ser);
397     struct GNUNET_SQ_QueryParam sparams[] = {
398       GNUNET_SQ_query_param_auto_from_type (&ticket->identity),
399       GNUNET_SQ_query_param_auto_from_type (&ticket->audience),
400       GNUNET_SQ_query_param_uint64 (&ticket->rnd),
401       GNUNET_SQ_query_param_fixed_size (attrs_ser, attrs_len),
402       GNUNET_SQ_query_param_end
403     };
404
405     if (GNUNET_OK !=
406         GNUNET_SQ_bind (plugin->store_ticket,
407                         sparams))
408     {
409       LOG_SQLITE (plugin,
410                   GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
411                   "sqlite3_bind_XXXX");
412       GNUNET_SQ_reset (plugin->dbh,
413                        plugin->store_ticket);
414       return GNUNET_SYSERR;
415     }
416     n = sqlite3_step (plugin->store_ticket);
417     GNUNET_SQ_reset (plugin->dbh,
418                      plugin->store_ticket);
419     GNUNET_free (attrs_ser);
420   }
421   switch (n)
422   {
423     case SQLITE_DONE:
424       GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
425                        "sqlite",
426                        "Ticket stored\n");
427       return GNUNET_OK;
428     case SQLITE_BUSY:
429       LOG_SQLITE (plugin,
430                   GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
431                   "sqlite3_step");
432       return GNUNET_NO;
433     default:
434       LOG_SQLITE (plugin,
435                   GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
436                   "sqlite3_step");
437       return GNUNET_SYSERR;
438   }
439 }
440
441
442 /**
443  * Store a ticket in the database.
444  *
445  * @param cls closure (internal context for the plugin)
446  * @param ticket the ticket to delete
447  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
448  */
449 static int
450 identity_provider_sqlite_delete_ticket (void *cls,
451                                         const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket)
452 {
453   struct Plugin *plugin = cls;
454   int n;
455
456   {  
457     struct GNUNET_SQ_QueryParam sparams[] = {
458       GNUNET_SQ_query_param_auto_from_type (&ticket->identity),
459       GNUNET_SQ_query_param_uint64 (&ticket->rnd),
460       GNUNET_SQ_query_param_end
461     };
462
463     if (GNUNET_OK !=
464         GNUNET_SQ_bind (plugin->delete_ticket,
465                         sparams))
466     {
467       LOG_SQLITE (plugin,
468                   GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
469                   "sqlite3_bind_XXXX");
470       GNUNET_SQ_reset (plugin->dbh,
471                        plugin->store_ticket);
472       return GNUNET_SYSERR;
473     }
474     n = sqlite3_step (plugin->delete_ticket);
475     GNUNET_SQ_reset (plugin->dbh,
476                      plugin->delete_ticket);
477   }
478   switch (n)
479   {
480     case SQLITE_DONE:
481       GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
482                        "sqlite",
483                        "Ticket deleted\n");
484       return GNUNET_OK;
485     case SQLITE_BUSY:
486       LOG_SQLITE (plugin,
487                   GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
488                   "sqlite3_step");
489       return GNUNET_NO;
490     default:
491       LOG_SQLITE (plugin,
492                   GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
493                   "sqlite3_step");
494       return GNUNET_SYSERR;
495   }
496 }
497
498
499 /**
500  * The given 'sqlite' statement has been prepared to be run.
501  * It will return a record which should be given to the iterator.
502  * Runs the statement and parses the returned record.
503  *
504  * @param plugin plugin context
505  * @param stmt to run (and then clean up)
506  * @param iter iterator to call with the result
507  * @param iter_cls closure for @a iter
508  * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
509  */
510 static int
511 get_ticket_and_call_iterator (struct Plugin *plugin,
512                               sqlite3_stmt *stmt,
513                               GNUNET_IDENTITY_PROVIDER_TicketIterator iter,
514                               void *iter_cls)
515 {
516   struct GNUNET_IDENTITY_PROVIDER_Ticket ticket;
517   struct GNUNET_IDENTITY_PROVIDER_AttributeList *attrs;
518   int ret;
519   int sret;
520   size_t attrs_len;
521   char *attrs_ser;
522
523   ret = GNUNET_NO;
524   if (SQLITE_ROW == (sret = sqlite3_step (stmt)))
525   {
526     struct GNUNET_SQ_ResultSpec rs[] = {
527       GNUNET_SQ_result_spec_auto_from_type (&ticket.identity),
528       GNUNET_SQ_result_spec_auto_from_type (&ticket.audience),
529       GNUNET_SQ_result_spec_uint64 (&ticket.rnd),
530       GNUNET_SQ_result_spec_variable_size ((void**)&attrs_ser,
531                                            &attrs_len),
532       GNUNET_SQ_result_spec_end
533
534     };
535     ret = GNUNET_SQ_extract_result (stmt,
536                                     rs);
537     if (GNUNET_OK != ret)
538     {
539       GNUNET_break (0);
540       ret = GNUNET_SYSERR;
541     }
542     else
543     {
544       attrs = attribute_list_deserialize (attrs_ser,
545                                           attrs_len);
546       if (NULL != iter)
547         iter (iter_cls,
548               &ticket,
549               attrs);
550       ret = GNUNET_YES;
551     }
552     GNUNET_SQ_cleanup_result (rs);
553   }
554   else
555   {
556     if (SQLITE_DONE != sret)
557       LOG_SQLITE (plugin,
558                   GNUNET_ERROR_TYPE_ERROR,
559                   "sqlite_step");
560   }
561   GNUNET_SQ_reset (plugin->dbh,
562                    stmt);
563   return ret;
564 }
565
566 /**
567  * Iterate over the results for a particular key and zone in the
568  * datastore.  Will return at most one result to the iterator.
569  *
570  * @param cls closure (internal context for the plugin)
571  * @param identity the issuing identity or audience (depending on audience switch)
572  * @param audience GNUNET_YES if identity is audience
573  * @param offset offset in the list of all matching records
574  * @param iter function to call with the result
575  * @param iter_cls closure for @a iter
576  * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
577  */
578 static int
579 identity_provider_sqlite_iterate_tickets (void *cls,
580                                           const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
581                                           int audience,
582                                           uint64_t offset,
583                                           GNUNET_IDENTITY_PROVIDER_TicketIterator iter,
584                                           void *iter_cls)
585 {
586   struct Plugin *plugin = cls;
587   sqlite3_stmt *stmt;
588   int err;
589
590   if (NULL == identity)
591   {
592     GNUNET_break (0);
593     return GNUNET_SYSERR;
594   }
595   struct GNUNET_SQ_QueryParam params[] = {
596     GNUNET_SQ_query_param_auto_from_type (identity),
597     GNUNET_SQ_query_param_uint64 (&offset),
598     GNUNET_SQ_query_param_end
599   };
600   if (GNUNET_YES == audience)
601   {
602     stmt = plugin->iterate_tickets_by_audience;
603     err = GNUNET_SQ_bind (stmt,
604                           params);
605   }
606   else
607   {
608     stmt = plugin->iterate_tickets;
609     err = GNUNET_SQ_bind (stmt,
610                           params);
611   }
612   if (GNUNET_OK != err)
613   {
614     LOG_SQLITE (plugin,
615                 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
616                 "sqlite3_bind_XXXX");
617     GNUNET_SQ_reset (plugin->dbh,
618                      stmt);
619     return GNUNET_SYSERR;
620   }
621   return get_ticket_and_call_iterator (plugin,
622                                        stmt,
623                                        iter,
624                                        iter_cls);
625 }
626
627
628 /**
629  * Entry point for the plugin.
630  *
631  * @param cls the "struct GNUNET_IDENTITY_PROVIDER_PluginEnvironment*"
632  * @return NULL on error, otherwise the plugin context
633  */
634 void *
635 libgnunet_plugin_identity_provider_sqlite_init (void *cls)
636 {
637   static struct Plugin plugin;
638   const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
639   struct GNUNET_IDENTITY_PROVIDER_PluginFunctions *api;
640
641   if (NULL != plugin.cfg)
642     return NULL;                /* can only initialize once! */
643   memset (&plugin, 0, sizeof (struct Plugin));
644   plugin.cfg = cfg;
645   if (GNUNET_OK != database_setup (&plugin))
646   {
647     database_shutdown (&plugin);
648     return NULL;
649   }
650   api = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_PluginFunctions);
651   api->cls = &plugin;
652   api->store_ticket = &identity_provider_sqlite_store_ticket;
653   api->delete_ticket = &identity_provider_sqlite_delete_ticket;
654   api->iterate_tickets = &identity_provider_sqlite_iterate_tickets;
655   LOG (GNUNET_ERROR_TYPE_INFO,
656        _("Sqlite database running\n"));
657   return api;
658 }
659
660
661 /**
662  * Exit point from the plugin.
663  *
664  * @param cls the plugin context (as returned by "init")
665  * @return always NULL
666  */
667 void *
668 libgnunet_plugin_identity_provider_sqlite_done (void *cls)
669 {
670   struct GNUNET_IDENTITY_PROVIDER_PluginFunctions *api = cls;
671   struct Plugin *plugin = api->cls;
672
673   database_shutdown (plugin);
674   plugin->cfg = NULL;
675   GNUNET_free (api);
676   LOG (GNUNET_ERROR_TYPE_DEBUG,
677        "sqlite plugin is finished\n");
678   return NULL;
679 }
680
681 /* end of plugin_identity_provider_sqlite.c */