face+security: Introduce environment variables to set/override transport, pib, and tpm configurations.
- NDN_CLIENT_TRANSPORT: equivalent of transport in client.conf
- NDN_CLIENT_PIB: equivalent of pib in client.conf
- NDN_CLIENT_TPM: equivalent of tpm in client.conf
Whenever an environment variable is set, it takes precedence over any
values specified in the configuration file.
Change-Id: I44c2347168616387a0489b6bf5c2c3a12db29863
Refs: #2925, #2514
diff --git a/src/security/sec-public-info-sqlite3.cpp b/src/security/sec-public-info-sqlite3.cpp
index 462f215..9974336 100644
--- a/src/security/sec-public-info-sqlite3.cpp
+++ b/src/security/sec-public-info-sqlite3.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -114,10 +114,23 @@
, m_database(nullptr)
{
boost::filesystem::path identityDir;
- if (dir == "")
- identityDir = boost::filesystem::path(getenv("HOME")) / ".ndn";
- else
- identityDir = boost::filesystem::path(dir) / ".ndn";
+ if (dir == "") {
+#ifdef NDN_CXX_HAVE_TESTS
+ if (getenv("TEST_HOME") != nullptr) {
+ identityDir = boost::filesystem::path(getenv("TEST_HOME")) / ".ndn";
+ }
+ else
+#endif // NDN_CXX_HAVE_TESTS
+ if (getenv("HOME") != nullptr) {
+ identityDir = boost::filesystem::path(getenv("HOME")) / ".ndn";
+ }
+ else {
+ identityDir = boost::filesystem::path(".") / ".ndn";
+ }
+ }
+ else {
+ identityDir = boost::filesystem::path(dir);
+ }
boost::filesystem::create_directories(identityDir);
/// @todo Add define for windows/unix in wscript. The following may completely fail on windows