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-tpm-file.cpp b/src/security/sec-tpm-file.cpp
index e20fa94..306a062 100644
--- a/src/security/sec-tpm-file.cpp
+++ b/src/security/sec-tpm-file.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).
  *
@@ -51,11 +51,26 @@
   explicit
   Impl(const string& dir)
   {
-    if (dir.empty())
-      m_keystorePath = boost::filesystem::path(getenv("HOME")) / ".ndn" / "ndnsec-tpm-file";
-    else
-      m_keystorePath = boost::filesystem::path(dir) / ".ndn" / "ndnsec-tpm-file";
+    boost::filesystem::path actualDir;
+    if (dir.empty()) {
+#ifdef NDN_CXX_HAVE_TESTS
+      if (getenv("TEST_HOME") != nullptr) {
+        actualDir = boost::filesystem::path(getenv("TEST_HOME")) / ".ndn";
+      }
+      else
+#endif // NDN_CXX_HAVE_TESTS
+      if (getenv("HOME") != nullptr) {
+        actualDir = boost::filesystem::path(getenv("HOME")) / ".ndn";
+      }
+      else {
+        actualDir = boost::filesystem::path(".") / ".ndn";
+      }
+    }
+    else {
+      actualDir = boost::filesystem::path(dir);
+    }
 
+    m_keystorePath = actualDir / "ndnsec-tpm-file";
     boost::filesystem::create_directories(m_keystorePath);
   }