Change default database path and configuration directory
Now respectively ${LOCALSTATEDIR}/lib/ndn/ndns/ndns.db
and ${SYSCONFDIR}/ndn/ndns
Refs: #4810
Change-Id: I351a6a15f8daa0a032845cb26d5d76179faa7b27
diff --git a/src/daemon/db-mgr.cpp b/src/daemon/db-mgr.cpp
index ef5f23c..da40d58 100644
--- a/src/daemon/db-mgr.cpp
+++ b/src/daemon/db-mgr.cpp
@@ -20,6 +20,7 @@
#include "db-mgr.hpp"
#include "logger.hpp"
#include "clients/response.hpp"
+#include "util/util.hpp"
namespace ndn {
namespace ndns {
@@ -53,12 +54,12 @@
ON rrsets (zone_id, label, type, version);
)VALUE";
-DbMgr::DbMgr(const std::string& dbFile/* = DEFAULT_CONFIG_PATH "/" "ndns.db"*/)
+DbMgr::DbMgr(const std::string& dbFile)
: m_dbFile(dbFile)
, m_conn(nullptr)
{
- if (dbFile.empty())
- m_dbFile = DEFAULT_DATABASE_PATH "/" "ndns.db";
+ if (m_dbFile.empty())
+ m_dbFile = getDefaultDatabaseFile();
open();
diff --git a/src/daemon/db-mgr.hpp b/src/daemon/db-mgr.hpp
index c21b3e0..a41380a 100644
--- a/src/daemon/db-mgr.hpp
+++ b/src/daemon/db-mgr.hpp
@@ -65,7 +65,7 @@
public:
explicit
- DbMgr(const std::string& dbFile = DEFAULT_DATABASE_PATH "/" "ndns.db");
+ DbMgr(const std::string& dbFile = "");
~DbMgr();
diff --git a/src/util/util.cpp b/src/util/util.cpp
index 47fbc52..7d350a5 100644
--- a/src/util/util.cpp
+++ b/src/util/util.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California.
+ * Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -18,15 +18,20 @@
*/
#include "util.hpp"
+#include "config.hpp"
-#include <ndn-cxx/security/transform.hpp>
+#include <ndn-cxx/security/transform/base64-encode.hpp>
+#include <ndn-cxx/security/transform/buffer-source.hpp>
+#include <ndn-cxx/security/transform/stream-sink.hpp>
namespace ndn {
namespace ndns {
-using security::transform::base64Encode;
-using security::transform::streamSink;
-using security::transform::bufferSource;
+std::string
+getDefaultDatabaseFile()
+{
+ return NDNS_DEFAULT_DBFILE;
+}
NdnsContentType
toNdnsContentType(const std::string& str)
@@ -48,8 +53,12 @@
}
void
-output(const Data& data, std::ostream& os, const bool isPretty)
+output(const Data& data, std::ostream& os, bool isPretty)
{
+ using security::transform::base64Encode;
+ using security::transform::bufferSource;
+ using security::transform::streamSink;
+
const Block& block = data.wireEncode();
if (!isPretty) {
bufferSource(block.wire(), block.size()) >> base64Encode() >> streamSink(os);
diff --git a/src/util/util.hpp b/src/util/util.hpp
index 24aa179..56515e8 100644
--- a/src/util/util.hpp
+++ b/src/util/util.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California.
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -21,11 +21,15 @@
#define NDNS_UTIL_UTIL_HPP
#include "ndns-enum.hpp"
+
#include <ndn-cxx/data.hpp>
namespace ndn {
namespace ndns {
+std::string
+getDefaultDatabaseFile();
+
NdnsContentType
toNdnsContentType(const std::string& str);
@@ -36,7 +40,7 @@
* @param isPretty whether to use pretty way
*/
void
-output(const Data& data, std::ostream& os, const bool isPretty);
+output(const Data& data, std::ostream& os, bool isPretty);
} // namespace ndns
} // namespace ndn
diff --git a/src/validator/validator.cpp b/src/validator/validator.cpp
index 6c6e53a..1e14f92 100644
--- a/src/validator/validator.cpp
+++ b/src/validator/validator.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -29,7 +29,7 @@
NDNS_LOG_INIT(Validator);
-std::string NdnsValidatorBuilder::VALIDATOR_CONF_FILE = DEFAULT_CONFIG_PATH "/" "validator.conf";
+std::string NdnsValidatorBuilder::VALIDATOR_CONF_FILE(NDNS_CONFDIR "/validator.conf");
unique_ptr<security::v2::Validator>
NdnsValidatorBuilder::create(Face& face,
@@ -41,7 +41,7 @@
make_unique<CertificateFetcherNdnsCert>(face,
nsCacheSize,
startComponentIndex));
- security::v2::ValidationPolicyConfig& policy = dynamic_cast<security::v2::ValidationPolicyConfig&>(validator->getPolicy());
+ auto& policy = dynamic_cast<security::v2::ValidationPolicyConfig&>(validator->getPolicy());
policy.load(confFile);
NDNS_LOG_TRACE("Validator loads configuration: " << confFile);