PREFIX ""
COMPILE_FLAGS "-fvisibility=hidden"
)
-TARGET_LINK_LIBRARIES(${TARGET} ${PKGS_LDFLAGS} -lsqlite3)
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(SQLITE_PKGS REQUIRED sqlite3 libtzplatform-config)
+SET(EXTRA_LDFLAGS "${PKGS_LDFLAGS}")
+FOREACH(flag ${SQLITE_PKGS_LDFLAGS})
+ SET(EXTRA_LDFLAGS "${EXTRA_LDFLAGS} ${flag}")
+ENDFOREACH()
+
+TARGET_LINK_LIBRARIES(${TARGET} ${EXTRA_LDFLAGS})
INSTALL(TARGETS ${TARGET} DESTINATION ${MODULE_DIR} COMPONENT RuntimeLibraries)
#include <glib.h>
#include <sqlite3.h>
+#include <tzplatform_config.h>
#include "backend.h"
#include "log.h"
+#define BUXTON_DEFAULT_WAL_AUTOCHECKPOINT 100
+#define BASE_DB_PATH tzplatform_getenv(TZ_SYS_RO_ETC)
+
#define QUERY_MAX_LEN 8192
#define QUERY_CREATE_TABLE_BUXTON "create table if not exists buxton " \
"(key text, " \
if (db_exist && r == SQLITE_CORRUPT) {
bxt_err("Open '%s' failed: %s", dbpath, sqlite3_errmsg(db));
- if (!strncmp("/etc", dbpath, 4)) {
+ if (!strncmp(BASE_DB_PATH, dbpath, strlen(dbpath))) {
free(nm);
return NULL;
}
}
if (!db_exist) {
- if (strncmp("/etc", dbpath, 4)) {
+ if (strncmp(BASE_DB_PATH, dbpath, strlen(dbpath))) {
r = sqlite3_exec(db, "PRAGMA journal_mode = WAL",
NULL, NULL, NULL);
if (r) {
}
}
+ if (strncmp(BASE_DB_PATH, dbpath, strlen(dbpath))) {
+ r = sqlite3_wal_autocheckpoint(db, BUXTON_DEFAULT_WAL_AUTOCHECKPOINT);
+ if (r != SQLITE_OK)
+ bxt_err("SET DEFAULT_WAL_AUTOCHECKPOINT failed : %d", r);
+ }
+
g_hash_table_insert(dbs, nm, db);
bxt_dbg("Open '%s'", dbpath);
BuildRequires: pkgconfig(cynara-client-async)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(sqlite3)
+BuildRequires: pkgconfig(libtzplatform-config)
Requires: security-config
Requires(post): /usr/bin/getent
Requires(post): /usr/bin/chown