aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2014-05-29 12:25:21 +0200
committerTobias Brunner <tobias@strongswan.org>2014-05-29 12:28:53 +0200
commitb2b54bd71dec810fe374d230947f734cfccd6f5d (patch)
tree09ba8fe6fb28671e018eee218a518ae9ab241de8 /src
parent95d13fcc3f88dd26b354c99ec4b8b9cd5a6ad2e1 (diff)
downloadstrongswan-b2b54bd71dec810fe374d230947f734cfccd6f5d.tar.bz2
strongswan-b2b54bd71dec810fe374d230947f734cfccd6f5d.tar.xz
Make sure getpass() is available
It's not on Android for example.
Diffstat (limited to 'src')
-rw-r--r--src/charon-cmd/cmd/cmd_creds.c4
-rw-r--r--src/pki/pki.c4
-rw-r--r--src/swanctl/commands/load_creds.c4
3 files changed, 9 insertions, 3 deletions
diff --git a/src/charon-cmd/cmd/cmd_creds.c b/src/charon-cmd/cmd/cmd_creds.c
index 7fee85d78..45d008e7b 100644
--- a/src/charon-cmd/cmd/cmd_creds.c
+++ b/src/charon-cmd/cmd/cmd_creds.c
@@ -72,7 +72,7 @@ static shared_key_t* callback_shared(private_cmd_creds_t *this,
id_match_t *match_me, id_match_t *match_other)
{
shared_key_t *shared;
- char *label, *pwd;
+ char *label, *pwd = NULL;
if (type == this->prompted)
{
@@ -95,7 +95,9 @@ static shared_key_t* callback_shared(private_cmd_creds_t *this,
default:
return NULL;
}
+#ifdef HAVE_GETPASS
pwd = getpass(label);
+#endif
if (!pwd || strlen(pwd) == 0)
{
return NULL;
diff --git a/src/pki/pki.c b/src/pki/pki.c
index ae4ef1cb0..8d880f066 100644
--- a/src/pki/pki.c
+++ b/src/pki/pki.c
@@ -165,7 +165,7 @@ static shared_key_t* cb(void *data, shared_key_type_t type,
identification_t *me, identification_t *other,
id_match_t *match_me, id_match_t *match_other)
{
- char buf[64], *label, *secret;
+ char buf[64], *label, *secret = NULL;
switch (type)
{
@@ -179,7 +179,9 @@ static shared_key_t* cb(void *data, shared_key_type_t type,
return NULL;
}
snprintf(buf, sizeof(buf), "%s: ", label);
+#ifdef HAVE_GETPASS
secret = getpass(buf);
+#endif
if (secret)
{
if (match_me)
diff --git a/src/swanctl/commands/load_creds.c b/src/swanctl/commands/load_creds.c
index 94d31f49f..ee792adb0 100644
--- a/src/swanctl/commands/load_creds.c
+++ b/src/swanctl/commands/load_creds.c
@@ -144,13 +144,15 @@ CALLBACK(password_cb, shared_key_t*,
identification_t *me, identification_t *other,
id_match_t *match_me, id_match_t *match_other)
{
- char *pwd;
+ char *pwd = NULL;
if (type != SHARED_PRIVATE_KEY_PASS)
{
return NULL;
}
+#ifdef HAVE_GETPASS
pwd = getpass(prompt);
+#endif
if (!pwd || strlen(pwd) == 0)
{
return NULL;