src: Disable use of getpass() when it is not available

For example, getpass is not available on Android platform.

Change-Id: I4c3039a3fcf188fd9343d625a551d268a4a20a93
diff --git a/src/security/sec-tpm.cpp b/src/security/sec-tpm.cpp
index 375aa1b..eb107b1 100644
--- a/src/security/sec-tpm.cpp
+++ b/src/security/sec-tpm.cpp
@@ -26,6 +26,7 @@
 #include "../encoding/oid.hpp"
 #include "../encoding/buffer-stream.hpp"
 #include "cryptopp.hpp"
+#include <unistd.h>
 
 namespace ndn {
 
@@ -362,6 +363,7 @@
 {
   bool isInitialized = false;
 
+#ifndef NDN_CXX_HAVE_GETPASS
   char* pw0 = 0;
 
   pw0 = getpass(prompt.c_str());
@@ -389,6 +391,8 @@
   if (password.empty())
     return false;
 
+#endif // NDN_CXX_HAVE_GETPASS
+
   return isInitialized;
 }
 
diff --git a/tools/ndnsec/unlock-tpm.hpp b/tools/ndnsec/unlock-tpm.hpp
index 23cfc83..607efb1 100644
--- a/tools/ndnsec/unlock-tpm.hpp
+++ b/tools/ndnsec/unlock-tpm.hpp
@@ -29,6 +29,7 @@
 int
 ndnsec_unlock_tpm(int argc, char** argv)
 {
+#ifndef NDN_CXX_HAVE_GETPASS
   using namespace ndn;
   namespace po = boost::program_options;
 
@@ -78,6 +79,10 @@
       std::cerr << "ERROR: TPM is still locked" << std::endl;
       return 1;
     }
+#else
+  std::cerr << "ERROR: Command not supported on this platform" << std::endl;
+  return 1;
+#endif // NDN_CXX_HAVE_GETPASS
 }
 
 #endif // NDN_TOOLS_NDNSEC_UNLOCK_TPM_HPP
diff --git a/tools/ndnsec/util.hpp b/tools/ndnsec/util.hpp
index 6f55478..2de9ff1 100644
--- a/tools/ndnsec/util.hpp
+++ b/tools/ndnsec/util.hpp
@@ -46,6 +46,7 @@
 bool
 getPassword(std::string& password, const std::string& prompt)
 {
+#ifndef NDN_CXX_HAVE_GETPASS
   bool isReady = false;
 
   char* pw0 = 0;
@@ -78,6 +79,9 @@
     return false;
 
   return isReady;
+#else
+  return false;
+#endif // NDN_CXX_HAVE_GETPASS
 }
 
 ndn::shared_ptr<ndn::IdentityCertificate>
diff --git a/wscript b/wscript
index 45dbef1..7107235 100644
--- a/wscript
+++ b/wscript
@@ -52,6 +52,7 @@
                    mandatory=False)
     conf.check_cxx(lib='rt', uselib_store='RT', define_name='HAVE_RT', mandatory=False)
     conf.check_cxx(cxxflags=['-fPIC'], uselib_store='PIC', mandatory=False)
+    conf.check_cxx(function_name='getpass', header_name='unistd.h', mandatory=False)
 
     conf.check_osx_security(mandatory=False)