Fix bandb's interaction with --enable-fhs-paths by storing ban.db in the correct directory, pkglocalstatedir.
This commit is contained in:
parent
e8da6ccee6
commit
6bdef3d52f
|
@ -57,19 +57,19 @@ mlog(const char *errstr, ...)
|
||||||
int
|
int
|
||||||
rsdb_init(rsdb_error_cb * ecb)
|
rsdb_init(rsdb_error_cb * ecb)
|
||||||
{
|
{
|
||||||
const char *bandb_dpath;
|
const char *bandb_dbpath_env;
|
||||||
char dbpath[PATH_MAX];
|
char dbpath[PATH_MAX];
|
||||||
char errbuf[128];
|
char errbuf[128];
|
||||||
error_cb = ecb;
|
error_cb = ecb;
|
||||||
|
|
||||||
/* try a path from the environment first, useful for basedir overrides */
|
/* try a path from the environment first, useful for basedir overrides */
|
||||||
bandb_dpath = getenv("BANDB_DPATH");
|
bandb_dbpath_env = getenv("BANDB_DBPATH");
|
||||||
|
|
||||||
if(bandb_dpath != NULL)
|
if(bandb_dbpath_env != NULL)
|
||||||
rb_snprintf(dbpath, sizeof(dbpath), "%s/etc/ban.db", bandb_dpath);
|
rb_strlcpy(dbpath, bandb_dbpath_env, sizeof(dbpath));
|
||||||
else
|
else
|
||||||
rb_strlcpy(dbpath, DBPATH, sizeof(dbpath));
|
rb_strlcpy(dbpath, DBPATH, sizeof(dbpath));
|
||||||
|
|
||||||
if(sqlite3_open(dbpath, &rb_bandb) != SQLITE_OK)
|
if(sqlite3_open(dbpath, &rb_bandb) != SQLITE_OK)
|
||||||
{
|
{
|
||||||
rb_snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database: %s",
|
rb_snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database: %s",
|
||||||
|
|
|
@ -82,7 +82,7 @@ start_bandb(void)
|
||||||
const char *suffix = "";
|
const char *suffix = "";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rb_setenv("BANDB_DPATH", ConfigFileEntry.dpath, 1);
|
rb_setenv("BANDB_DBPATH", PKGLOCALSTATEDIR "/ban.db", 1);
|
||||||
if(bandb_path == NULL)
|
if(bandb_path == NULL)
|
||||||
{
|
{
|
||||||
rb_snprintf(fullpath, sizeof(fullpath), "%s/bandb%s", PKGLIBEXECDIR, suffix);
|
rb_snprintf(fullpath, sizeof(fullpath), "%s/bandb%s", PKGLIBEXECDIR, suffix);
|
||||||
|
|
Loading…
Reference in New Issue