[network-manager-openconnect] auth-dialog: Configure soft token mode based on GUI settings



commit 3a1833b7d3052f7386280507daef3f49ea0a8d4a
Author: Kevin Cernekee <cernekee gmail com>
Date:   Sat Oct 13 17:43:39 2012 -0700

    auth-dialog: Configure soft token mode based on GUI settings

 auth-dialog/main.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index 289428d..1b4fca6 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -64,6 +64,10 @@
 #define OPENCONNECT_OPENSSL
 #endif
 
+#if !OPENCONNECT_CHECK_VER(2,1)
+#define openconnect_set_stoken_mode(...) -EOPNOTSUPP
+#endif
+
 #ifdef OPENCONNECT_OPENSSL
 #include <openssl/ssl.h>
 #include <openssl/bio.h>
@@ -1043,6 +1047,8 @@ static int get_config (GHashTable *options, GHashTable *secrets,
 	char *csd_wrapper;
 	char *pem_passphrase_fsid;
 	char *cafile;
+	char *stoken_source;
+	char *stoken_string;
 
 	hostname = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_GATEWAY);
 	if (!hostname) {
@@ -1113,6 +1119,20 @@ static int get_config (GHashTable *options, GHashTable *secrets,
 	if (pem_passphrase_fsid && cert && !strcmp(pem_passphrase_fsid, "yes"))
 		openconnect_passphrase_from_fsid(vpninfo);
 
+	stoken_source = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_STOKEN_SOURCE);
+	stoken_string = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_STOKEN_STRING);
+	if (stoken_source) {
+		int ret = 0;
+
+		if (!strcmp(stoken_source, "manual") && stoken_string)
+			ret = openconnect_set_stoken_mode(vpninfo, 1, stoken_string);
+		else if (!strcmp(stoken_source, "stokenrc"))
+			ret = openconnect_set_stoken_mode(vpninfo, 1, NULL);
+
+		if (ret)
+			fprintf(stderr, "Failed to initialize stoken: %d\n", ret);
+	}
+
 	return 0;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]