AC_CHECK_LIB(dl, dlopen, , AC_MSG_ERROR([*** PAM requires a working dynamic loader (libdl)]))
AC_CHECK_LIB(z, deflate, , AC_MSG_ERROR([*** must have zlib]))
AC_CHECK_LIB(bz2, BZ2_bzWriteOpen, , AC_MSG_ERROR([*** must have bzlib]))
+AC_CHECK_LIB(gdbm, gdbm_open, , AC_MSG_ERROR([*** must have gdbm]))
clients=
extlibs=
#include <wchar.h>
#include <iconv.h>
#include <arpa/inet.h>
+#include <gdbm.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
if(state != 0)
flog(LOG_WARNING, "unexpected end of file");
}
+
+/* {store,fetch}var re-opens the database every time, just in case two
+ * doldacond processes would be running simultaneously. */
+void storevar(char *key, void *val, size_t len)
+{
+ char *dbname;
+ GDBM_FILE db;
+ datum k, v;
+
+ dbname = findfile("dc-vardb", "dc-vardb", NULL, 1);
+ if((db = gdbm_open(dbname, 0, GDBM_WRCREAT, 0666, NULL)) == NULL)
+ {
+ flog(LOG_CRIT, "could not open var database for writing, cannot continue: %s", gdbm_strerror(gdbm_errno));
+ abort();
+ }
+ free(dbname);
+ k.dptr = key;
+ k.dsize = strlen(key);
+ v.dptr = val;
+ v.dsize = len;
+ gdbm_store(db, k, v, GDBM_REPLACE);
+ gdbm_close(db);
+}
+
+void *fetchvar(char *key, size_t *lenb)
+{
+ char *dbname;
+ GDBM_FILE db;
+ datum k, v;
+
+ if((dbname = findfile("dc-vardb", "dc-vardb", NULL, 0)) == NULL)
+ return(NULL);
+ if((db = gdbm_open(dbname, 0, GDBM_READER, 0666, NULL)) == NULL)
+ return(NULL);
+ free(dbname);
+ k.dptr = key;
+ k.dsize = strlen(key);
+ v = gdbm_fetch(db, k);
+ gdbm_close(db);
+ if(v.dptr == NULL)
+ return(NULL);
+ if(lenb != NULL)
+ *lenb = v.dsize;
+ return(v.dptr);
+}
#define confgetstr(m, v) (confgetvar((m), (v))->val.str)
void confregmod(struct configmod *mod);
void readconfig(FILE *stream);
+void storevar(char *key, void *val, size_t len);
+void *fetchvar(char *key, size_t *lenb);
#endif