diff options
author | Simon Josefsson <simon@josefsson.org> | 2008-06-04 07:20:23 +0200 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2008-06-04 07:20:23 +0200 |
commit | 204658e6002cd8eef33baff0865e9f1237fd08f2 (patch) | |
tree | 9a8bff7a3a22da579cb60aef4a9d7d874b34718d /src | |
parent | 427fc5c608d1d9c171d550864ec45ffd91e792c5 (diff) | |
download | gnutls-204658e6002cd8eef33baff0865e9f1237fd08f2.tar.gz |
Allow --pskusername to be specified to avoid query in PSK callback.
Diffstat (limited to 'src')
-rw-r--r-- | src/cli.c | 38 |
1 files changed, 22 insertions, 16 deletions
@@ -983,8 +983,6 @@ static int psk_callback (gnutls_session_t session, { const char *hint = gnutls_psk_client_get_hint (session); char *passwd; - char *tmp = NULL; - ssize_t n, len; int ret; printf ("- PSK client callback. "); @@ -993,23 +991,31 @@ static int psk_callback (gnutls_session_t session, else printf ("No PSK hint\n"); - printf ("Enter PSK identity: "); - fflush (stdout); - len = getline (&tmp, &n, stdin); - - if (tmp == NULL) + if (info.psk_username) + *username = gnutls_strdup (info.psk_username); + else { - fprintf (stderr, "No username given, aborting...\n"); - return GNUTLS_E_INSUFFICIENT_CREDENTIALS; - } + char *tmp = NULL; + ssize_t n, len; - if (tmp[strlen (tmp) - 1] == '\n') - tmp[strlen (tmp) - 1] = '\0'; - if (tmp[strlen (tmp) - 1] == '\r') - tmp[strlen (tmp) - 1] = '\0'; + printf ("Enter PSK identity: "); + fflush (stdout); + len = getline (&tmp, &n, stdin); - *username = gnutls_strdup (tmp); - free (tmp); + if (tmp == NULL) + { + fprintf (stderr, "No username given, aborting...\n"); + return GNUTLS_E_INSUFFICIENT_CREDENTIALS; + } + + if (tmp[strlen (tmp) - 1] == '\n') + tmp[strlen (tmp) - 1] = '\0'; + if (tmp[strlen (tmp) - 1] == '\r') + tmp[strlen (tmp) - 1] = '\0'; + + *username = gnutls_strdup (tmp); + free (tmp); + } if (!*username) return GNUTLS_E_MEMORY_ERROR; |