summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--lib/libfrr.c7
-rw-r--r--mgmtd/mgmt_ds.h4
-rw-r--r--mgmtd/mgmt_history.c31
4 files changed, 22 insertions, 22 deletions
diff --git a/configure.ac b/configure.ac
index 38f6624c7..440131941 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2741,8 +2741,6 @@ AC_DEFINE_UNQUOTED([FRR_LIBSTATE_PATH], ["$CFG_LIBSTATE"], [/var/lib/frr equival
AC_DEFINE_UNQUOTED([YANG_MODELS_PATH], ["$CFG_YANGMODELS"], [path to YANG data models])
AC_DEFINE_UNQUOTED([WATCHFRR_SH_PATH], ["${CFG_SBIN%/}/watchfrr.sh"], [path to watchfrr.sh])
-AC_DEFINE_UNQUOTED([DAEMON_DB_DIR], ["$CFG_STATE"], [daemon database directory])
-
dnl various features
AM_CONDITIONAL([SUPPORT_REALMS], [test "$enable_realms" = "yes"])
AM_CONDITIONAL([ENABLE_BGP_VNC], [test "$enable_bgp_vnc" != "no"])
diff --git a/lib/libfrr.c b/lib/libfrr.c
index 131453c4d..fe2c8fa82 100644
--- a/lib/libfrr.c
+++ b/lib/libfrr.c
@@ -47,9 +47,6 @@ DEFINE_KOOH(frr_fini, (), ());
const char frr_sysconfdir[] = SYSCONFDIR;
char frr_runstatedir[256] = FRR_RUNSTATE_PATH;
char frr_libstatedir[256] = FRR_LIBSTATE_PATH;
-#ifdef HAVE_SQLITE3
-const char frr_dbdir[] = DAEMON_DB_DIR;
-#endif
const char frr_moduledir[] = MODULE_PATH;
const char frr_scriptdir[] = SCRIPT_PATH;
@@ -347,7 +344,7 @@ void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv)
snprintf(frr_zclientpath, sizeof(frr_zclientpath), ZAPI_SOCK_NAME);
#ifdef HAVE_SQLITE3
snprintf(dbfile_default, sizeof(dbfile_default), "%s/%s.db",
- frr_dbdir, di->name);
+ frr_libstatedir, di->name);
#endif
strlcpy(frr_protoname, di->logname, sizeof(frr_protoname));
@@ -728,7 +725,7 @@ struct event_loop *frr_init(void)
frr_runstatedir, di->name, p_instance);
#ifdef HAVE_SQLITE3
snprintf(dbfile_default, sizeof(dbfile_default), "%s/%s%s%s.db",
- frr_dbdir, p_pathspace, di->name, p_instance);
+ frr_libstatedir, p_pathspace, di->name, p_instance);
#endif
zprivs_preinit(di->privs);
diff --git a/mgmtd/mgmt_ds.h b/mgmtd/mgmt_ds.h
index ca08e37da..b8e77e330 100644
--- a/mgmtd/mgmt_ds.h
+++ b/mgmtd/mgmt_ds.h
@@ -29,8 +29,8 @@
#define MGMTD_MAX_COMMIT_LIST 10
-#define MGMTD_COMMIT_FILE_PATH DAEMON_DB_DIR "/commit-%s.json"
-#define MGMTD_COMMIT_INDEX_FILE_NAME DAEMON_DB_DIR "/commit-index.dat"
+#define MGMTD_COMMIT_FILE_PATH(id) "%s/commit-%s.json", frr_libstatedir, id
+#define MGMTD_COMMIT_INDEX_FILE_PATH "%s/commit-index.dat", frr_libstatedir
extern struct nb_config *running_config;
diff --git a/mgmtd/mgmt_history.c b/mgmtd/mgmt_history.c
index ddc5a1844..c97cb7f0f 100644
--- a/mgmtd/mgmt_history.c
+++ b/mgmtd/mgmt_history.c
@@ -63,7 +63,7 @@ static struct mgmt_cmt_info_t *mgmt_history_new_cmt_info(void)
mgmt_time_to_string(&tv, true, new->time_str, sizeof(new->time_str));
mgmt_time_to_string(&tv, false, new->cmtid_str, sizeof(new->cmtid_str));
snprintf(new->cmt_json_file, sizeof(new->cmt_json_file),
- MGMTD_COMMIT_FILE_PATH, new->cmtid_str);
+ MGMTD_COMMIT_FILE_PATH(new->cmtid_str));
return new;
}
@@ -104,18 +104,21 @@ mgmt_history_find_cmt_record(const char *cmtid_str)
static bool mgmt_history_read_cmt_record_index(void)
{
+ char index_path[MAXPATHLEN];
FILE *fp;
struct mgmt_cmt_info_t cmt_info;
struct mgmt_cmt_info_t *new;
int cnt = 0;
- if (!file_exists(MGMTD_COMMIT_FILE_PATH))
- return false;
+ snprintf(index_path, sizeof(index_path), MGMTD_COMMIT_INDEX_FILE_PATH);
- fp = fopen(MGMTD_COMMIT_INDEX_FILE_NAME, "rb");
+ fp = fopen(index_path, "rb");
if (!fp) {
- zlog_err("Failed to open commit history %s for reading: %s",
- MGMTD_COMMIT_INDEX_FILE_NAME, safe_strerror(errno));
+ if (errno == ENOENT || errno == ENOTDIR)
+ return false;
+
+ zlog_err("Failed to open commit history %pSQq for reading: %m",
+ index_path);
return false;
}
@@ -132,9 +135,8 @@ static bool mgmt_history_read_cmt_record_index(void)
memcpy(new, &cmt_info, sizeof(struct mgmt_cmt_info_t));
mgmt_cmt_infos_add_tail(&mm->cmts, new);
} else {
- zlog_warn(
- "More records found in commit history file %s than expected",
- MGMTD_COMMIT_INDEX_FILE_NAME);
+ zlog_warn("More records found in commit history file %pSQq than expected",
+ index_path);
fclose(fp);
return false;
}
@@ -148,16 +150,19 @@ static bool mgmt_history_read_cmt_record_index(void)
static bool mgmt_history_dump_cmt_record_index(void)
{
+ char index_path[MAXPATHLEN];
FILE *fp;
int ret = 0;
struct mgmt_cmt_info_t *cmt_info;
struct mgmt_cmt_info_t cmt_info_set[10];
int cnt = 0;
- fp = fopen(MGMTD_COMMIT_INDEX_FILE_NAME, "wb");
+ snprintf(index_path, sizeof(index_path), MGMTD_COMMIT_INDEX_FILE_PATH);
+
+ fp = fopen(index_path, "wb");
if (!fp) {
- zlog_err("Failed to open commit history %s for writing: %s",
- MGMTD_COMMIT_INDEX_FILE_NAME, safe_strerror(errno));
+ zlog_err("Failed to open commit history %pSQq for writing: %m",
+ index_path);
return false;
}
@@ -176,7 +181,7 @@ static bool mgmt_history_dump_cmt_record_index(void)
fclose(fp);
if (ret != cnt) {
zlog_err("Failed to write full commit history, removing file");
- remove_file(MGMTD_COMMIT_INDEX_FILE_NAME);
+ remove_file(index_path);
return false;
}
return true;