[PATCH nm-openconnect 1/3] Use more generic names for stoken_*

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

 



libopenconnect now supports both TOTP and RSA software tokens.  Change
our local naming to align with the new library APIs.

This shouldn't affect functionality, stored user settings, or
configuration import/export.
---
 auth-dialog/main.c                  |   16 +++++-----
 properties/nm-openconnect-dialog.ui |   16 +++++-----
 properties/nm-openconnect.c         |   56 +++++++++++++++++------------------
 src/nm-openconnect-service.c        |    4 +--
 src/nm-openconnect-service.h        |    4 +--
 5 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index 0dee11b..eadcce1 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -1025,8 +1025,8 @@ static int get_config (GHashTable *options, GHashTable *secrets,
 	char *csd_wrapper;
 	char *pem_passphrase_fsid;
 	char *cafile;
-	char *stoken_source;
-	char *stoken_string;
+	char *token_mode;
+	char *token_secret;
 
 	hostname = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_GATEWAY);
 	if (!hostname) {
@@ -1097,14 +1097,14 @@ 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) {
+	token_mode = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_TOKEN_MODE);
+	token_secret = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_TOKEN_SECRET);
+	if (token_mode) {
 		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"))
+		if (!strcmp(token_mode, "manual") && token_secret)
+			ret = openconnect_set_stoken_mode(vpninfo, 1, token_secret);
+		else if (!strcmp(token_mode, "stokenrc"))
 			ret = openconnect_set_stoken_mode(vpninfo, 1, NULL);
 
 		if (ret)
diff --git a/properties/nm-openconnect-dialog.ui b/properties/nm-openconnect-dialog.ui
index 26db4af..66b9119 100644
--- a/properties/nm-openconnect-dialog.ui
+++ b/properties/nm-openconnect-dialog.ui
@@ -553,7 +553,7 @@
           </packing>
         </child>
       </object>
-      <object class="GtkVBox" id="stoken_vbox">
+      <object class="GtkVBox" id="token_vbox">
         <property name="visible">True</property>
         <property name="homogeneous">False</property>
         <property name="spacing">6</property>
@@ -612,9 +612,9 @@
                     <property name="left_padding">0</property>
                     <property name="right_padding">0</property>
                     <child>
-                      <object class="GtkComboBox" id="stoken_source">
+                      <object class="GtkComboBox" id="token_mode">
                         <property name="visible">True</property>
-                        <property name="model">stoken_source_list</property>
+                        <property name="model">token_mode_list</property>
                         <property name="active">0</property>
                         <child>
                           <object class="GtkCellRendererText" id="renderer"/>
@@ -646,7 +646,7 @@
                     <property name="yalign">0.5</property>
                     <property name="xpad">0</property>
                     <property name="ypad">0</property>
-                    <property name="mnemonic_widget">stoken_source</property>
+                    <property name="mnemonic_widget">token_source</property>
                     <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
                     <property name="width_chars">-1</property>
                     <property name="single_line_mode">False</property>
@@ -661,7 +661,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="stoken_string_label">
+                  <object class="GtkLabel" id="token_secret_label">
                     <property name="visible">True</property>
                     <property name="label" translatable="yes">Token St_ring:</property>
                     <property name="use_underline">True</property>
@@ -673,7 +673,7 @@
                     <property name="yalign">0.5</property>
                     <property name="xpad">0</property>
                     <property name="ypad">0</property>
-                    <property name="mnemonic_widget">stoken_string</property>
+                    <property name="mnemonic_widget">token_secret</property>
                     <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
                     <property name="width_chars">-1</property>
                     <property name="single_line_mode">False</property>
@@ -700,7 +700,7 @@
                     <property name="left_padding">12</property>
                     <property name="right_padding">0</property>
                     <child>
-                      <object class="GtkTextView" id="stoken_string">
+                      <object class="GtkTextView" id="token_secret">
                         <property name="height-request">60</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
@@ -730,7 +730,7 @@
           </packing>
         </child>
       </object>
-      <object class="GtkListStore" id="stoken_source_list">
+      <object class="GtkListStore" id="token_mode_list">
         <columns>
           <!-- column-name legible -->
           <column type="gchararray"/>
diff --git a/properties/nm-openconnect.c b/properties/nm-openconnect.c
index 71cbe3c..4e1e5ea 100644
--- a/properties/nm-openconnect.c
+++ b/properties/nm-openconnect.c
@@ -175,15 +175,15 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
 	if (bval)
 		nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_PEM_PASSPHRASE_FSID, "yes");
 
-	/* Soft token source */
+	/* Soft token mode */
 	buf = g_key_file_get_string (keyfile, "openconnect", "StokenSource", NULL);
 	if (buf)
-		nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_SOURCE, buf);
+		nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_TOKEN_MODE, buf);
 
-	/* Soft token string */
+	/* Soft token secret */
 	buf = g_key_file_get_string (keyfile, "openconnect", "StokenString", NULL);
 	if (buf)
-		nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_STRING, buf);
+		nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_TOKEN_SECRET, buf);
 
 	return connection;
 }
@@ -205,8 +205,8 @@ export (NMVpnPluginUiInterface *iface,
 	const char *usercert = NULL;
 	const char *privkey = NULL;
 	gboolean pem_passphrase_fsid = FALSE;
-	const char *stoken_source = NULL;
-	const char *stoken_string = NULL;
+	const char *token_mode = NULL;
+	const char *token_secret = NULL;
 	gboolean success = FALSE;
 	FILE *f;
 
@@ -256,13 +256,13 @@ export (NMVpnPluginUiInterface *iface,
 	if (value && !strcmp (value, "yes"))
 		pem_passphrase_fsid = TRUE;
 
-	value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_SOURCE);
+	value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_TOKEN_MODE);
 	if (value && strlen (value))
-		stoken_source = value;
+		token_mode = value;
 
-	value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_STRING);
+	value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_TOKEN_SECRET);
 	if (value && strlen (value))
-		stoken_string = value;
+		token_secret = value;
 
 	fprintf (f,
 		 "[openconnect]\n"
@@ -286,8 +286,8 @@ export (NMVpnPluginUiInterface *iface,
 		 /* User Certificate */      usercert,
 		 /* Private Key */           privkey,
 		 /* FSID */                  pem_passphrase_fsid ? "1" : "0",
-		 /* Soft token source */     stoken_source ? stoken_source : "",
-		 /* Soft token string */     stoken_string ? stoken_string : "");
+		 /* Soft token mode */       token_mode ? token_mode : "",
+		 /* Soft token secret */     token_secret ? token_secret : "");
 
 	success = TRUE;
 
@@ -372,7 +372,7 @@ stuff_changed_cb (GtkWidget *widget, gpointer user_data)
 }
 
 static gboolean
-init_stoken_ui (OpenconnectPluginUiWidget *self,
+init_token_ui (OpenconnectPluginUiWidget *self,
 				OpenconnectPluginUiWidgetPrivate *priv,
 				NMSettingVPN *s_vpn)
 {
@@ -384,16 +384,16 @@ init_stoken_ui (OpenconnectPluginUiWidget *self,
 	if (!openconnect_has_stoken_support ())
 		return TRUE;
 
-	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stoken_vbox"));
+	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "token_vbox"));
 	if (!widget)
 		return FALSE;
 	gtk_box_pack_start (GTK_BOX (priv->widget), widget, FALSE, FALSE, 0);
 
-	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stoken_source"));
+	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "token_mode"));
 	if (!widget)
 		return FALSE;
 	if (s_vpn) {
-		value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_SOURCE);
+		value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_TOKEN_MODE);
 		if (value) {
 			if (!strcmp (value, "stokenrc"))
 				gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1);
@@ -405,14 +405,14 @@ init_stoken_ui (OpenconnectPluginUiWidget *self,
 	}
 	g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self);
 
-	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stoken_string"));
+	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "token_secret"));
 	if (!widget)
 		return FALSE;
 	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
 	if (!buffer)
 		return FALSE;
 	if (s_vpn) {
-		value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_STRING);
+		value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_TOKEN_SECRET);
 		if (value)
 			gtk_text_buffer_set_text (buffer, value, -1);
 	}
@@ -485,7 +485,7 @@ init_plugin_ui (OpenconnectPluginUiWidget *self, NMConnection *connection, GErro
 	}
 	g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self);
 
-	if (init_stoken_ui (self, priv, s_vpn) == FALSE)
+	if (init_token_ui (self, priv, s_vpn) == FALSE)
 		return FALSE;
 
 	tls_pw_init_auth_widget (priv->builder, priv->group, s_vpn, stuff_changed_cb, self);
@@ -513,7 +513,7 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
 	GtkWidget *widget;
 	char *str;
 	gint idx;
-	gboolean stoken_string_editable = FALSE;
+	gboolean token_secret_editable = FALSE;
 	GtkTextIter iter_start, iter_end;
 	GtkTextBuffer *buffer;
 	const char *auth_type = NULL;
@@ -544,7 +544,7 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
 	if (str && strlen (str))
 		nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_CSD_WRAPPER, str);
 
-	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stoken_source"));
+	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "token_mode"));
 	idx = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
 	str = NULL;
 	switch (idx) {
@@ -556,17 +556,17 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
 		break;
 	case 2:
 		str = "manual";
-		stoken_string_editable = TRUE;
+		token_secret_editable = TRUE;
 		break;
 	}
 	if (str)
-		nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_SOURCE, str);
+		nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_TOKEN_MODE, str);
 
-	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stoken_string_label"));
-	gtk_widget_set_sensitive (widget, stoken_string_editable);
+	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "token_secret_label"));
+	gtk_widget_set_sensitive (widget, token_secret_editable);
 
-	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stoken_string"));
-	gtk_widget_set_sensitive (widget, stoken_string_editable);
+	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "token_secret"));
+	gtk_widget_set_sensitive (widget, token_secret_editable);
 
 	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
 	gtk_text_buffer_get_start_iter (buffer, &iter_start);
@@ -582,7 +582,7 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
 		*dst = 0;
 
 		if (strlen (str))
-			nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_STRING, str);
+			nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_TOKEN_SECRET, str);
 	}
 
 	if (!check_validity (self, error))
diff --git a/src/nm-openconnect-service.c b/src/nm-openconnect-service.c
index 53f299d..7dcf964 100644
--- a/src/nm-openconnect-service.c
+++ b/src/nm-openconnect-service.c
@@ -91,8 +91,8 @@ static ValidProperty valid_properties[] = {
 	{ NM_OPENCONNECT_KEY_PROXY,       G_TYPE_STRING, 0, 0 },
 	{ NM_OPENCONNECT_KEY_CSD_ENABLE,  G_TYPE_BOOLEAN, 0, 0 },
 	{ NM_OPENCONNECT_KEY_CSD_WRAPPER, G_TYPE_STRING, 0, 0 },
-	{ NM_OPENCONNECT_KEY_STOKEN_SOURCE, G_TYPE_STRING, 0, 0 },
-	{ NM_OPENCONNECT_KEY_STOKEN_STRING, G_TYPE_STRING, 0, 0 },
+	{ NM_OPENCONNECT_KEY_TOKEN_MODE,  G_TYPE_STRING, 0, 0 },
+	{ NM_OPENCONNECT_KEY_TOKEN_SECRET, G_TYPE_STRING, 0, 0 },
 	{ NULL,                           G_TYPE_NONE, 0, 0 }
 };
 
diff --git a/src/nm-openconnect-service.h b/src/nm-openconnect-service.h
index f54c829..2de79cf 100644
--- a/src/nm-openconnect-service.h
+++ b/src/nm-openconnect-service.h
@@ -51,8 +51,8 @@
 #define NM_OPENCONNECT_KEY_PROXY "proxy"
 #define NM_OPENCONNECT_KEY_CSD_ENABLE "enable_csd_trojan"
 #define NM_OPENCONNECT_KEY_CSD_WRAPPER "csd_wrapper"
-#define NM_OPENCONNECT_KEY_STOKEN_SOURCE "stoken_source"
-#define NM_OPENCONNECT_KEY_STOKEN_STRING "stoken_string"
+#define NM_OPENCONNECT_KEY_TOKEN_MODE "stoken_source"
+#define NM_OPENCONNECT_KEY_TOKEN_SECRET "stoken_string"
 
 typedef struct {
 	NMVPNPlugin parent;
-- 
1.7.10.4




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux