Package: network-manager-vpnc
Version: 0.8.1-1
Tags: patch

Attached is a patch to add UI support for the vpnc options "IKE Authmode" and
"CA-File".  Now that GnuTLS support is in vpnc, this was the last missing
piece: with this patch applied I can connect to my university's VPN from
NetworkManager.

Note that there are still some rough edges:

 * Import from/export to .pcf of the new parameters is not yet supported.
   Does anyone know how they look like in a .pcf file?

 * When the user clicks on the FileChooserButton to selecte a CA-File and then
   cancels the dialog, any filename chosen previously vanishes.  No idea how
   to prevent this, maybe some GTK-wizard has some advise?

Bye,
Jö.

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing-proposed-updates
  APT policy: (500, 'testing-proposed-updates'), (500, 'testing')
Architecture: i386 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages network-manager-vpnc depends on:
ii  libc6                        2.11.2-7    Embedded GNU C Library: Shared lib
ii  libdbus-1-3                  1.2.24-3    simple interprocess messaging syst
ii  libdbus-glib-1-2             0.88-2      simple interprocess messaging syst
ii  libglib2.0-0                 2.24.2-1    The GLib library of C routines
ii  libnm-glib-vpn1              0.8.1-3     network management framework (GLib
ii  libnm-glib2                  0.8.1-3     network management framework (GLib
ii  libnm-util1                  0.8.1-3     network management framework (shar
ii  vpnc                         0.5.3r449-2 Cisco-compatible VPN client

network-manager-vpnc recommends no packages.

network-manager-vpnc suggests no packages.

-- no debconf information

-- 
"Ich habe eine Maschine erfunden, die den Kommerz aus Weihnachten
entfernt." -- "Lass uns ganz viele davon bauen und für viel Geld
verkaufen."
-- http://www.nichtlustig.de/toondb/021220.html
diff --git a/properties/nm-vpnc-dialog.glade b/properties/nm-vpnc-dialog.glade
index 7e07e7d..760c698 100644
--- a/properties/nm-vpnc-dialog.glade
+++ b/properties/nm-vpnc-dialog.glade
@@ -235,7 +235,7 @@
                 <child>
                   <widget class="GtkTable" id="table3">
                     <property name="visible">True</property>
-                    <property name="n_rows">5</property>
+                    <property name="n_rows">7</property>
                     <property name="n_columns">2</property>
                     <property name="column_spacing">6</property>
                     <property name="row_spacing">6</property>
@@ -250,8 +250,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">4</property>
-                        <property name="bottom_attach">5</property>
+                        <property name="top_attach">6</property>
+                        <property name="bottom_attach">7</property>
                       </packing>
                     </child>
                     <child>
@@ -332,8 +332,8 @@
                         <property name="label" translatable="yes">NAT traversal:</property>
                       </widget>
                       <packing>
-                        <property name="top_attach">3</property>
-                        <property name="bottom_attach">4</property>
+                        <property name="top_attach">5</property>
+                        <property name="bottom_attach">6</property>
                       </packing>
                     </child>
                     <child>
@@ -344,6 +344,51 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
+                        <property name="top_attach">5</property>
+                        <property name="bottom_attach">6</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkFileChooserButton" id="ca_file_filechooserbutton">
+                        <property name="visible">True</property>
+                      </widget>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">4</property>
+                        <property name="bottom_attach">5</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkLabel" id="label5">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">CA File:</property>
+                      </widget>
+                      <packing>
+                        <property name="top_attach">4</property>
+                        <property name="bottom_attach">5</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkComboBox" id="authmode_combo">
+                        <property name="visible">True</property>
+                        <property name="items" translatable="yes"> </property>
+                      </widget>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkLabel" id="label6">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Authorization method:</property>
+                      </widget>
+                      <packing>
                         <property name="top_attach">3</property>
                         <property name="bottom_attach">4</property>
                       </packing>
diff --git a/properties/nm-vpnc.c b/properties/nm-vpnc.c
index b0286ed..0bcaca7 100644
--- a/properties/nm-vpnc.c
+++ b/properties/nm-vpnc.c
@@ -366,6 +366,42 @@ init_one_pw_combo (VpncPluginUiWidget *self,
 	g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (pw_type_combo_changed_cb), self);
 }
 
+static void
+update_sensitive(VpncPluginUiWidget *self)
+{
+	VpncPluginUiWidgetPrivate *priv = VPNC_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
+	GtkWidget *widget;
+	GtkComboBox *combo;
+	GtkTreeIter iter;
+	GtkTreeModel *model;
+	const char *authmode = NULL;
+	gboolean sensitive = TRUE;
+
+	widget = glade_xml_get_widget (priv->xml, "authmode_combo");
+	g_assert (widget);
+	combo = GTK_COMBO_BOX (widget);
+
+	model = gtk_combo_box_get_model (combo);
+	if (gtk_combo_box_get_active_iter (combo, &iter))
+		gtk_tree_model_get (model, &iter, 1, &authmode, -1);
+	if (!(authmode && strlen(authmode)))
+		authmode = NM_VPNC_AUTHMODE_HYBRID;
+
+	if(!strcmp(authmode, NM_VPNC_AUTHMODE_PSK))
+		sensitive = FALSE;
+
+	widget = glade_xml_get_widget (priv->xml, "ca_file_filechooserbutton");
+	g_assert (widget);
+	gtk_widget_set_sensitive (widget, sensitive);
+}
+
+static void
+authmode_changed_cb (GtkComboBox *combo, VpncPluginUiWidget *self)
+{
+	update_sensitive(self);
+	stuff_changed_cb (GTK_WIDGET(combo), self);
+}
+
 static gboolean
 init_plugin_ui (VpncPluginUiWidget *self, NMConnection *connection, GError **error)
 {
@@ -376,6 +412,7 @@ init_plugin_ui (VpncPluginUiWidget *self, NMConnection *connection, GError **err
 	GtkTreeIter iter;
 	const char *value = NULL;
 	int active = -1;
+	const char *authmode = NULL;
 	const char *natt_mode = NULL;
 
 	s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
@@ -432,6 +469,47 @@ init_plugin_ui (VpncPluginUiWidget *self, NMConnection *connection, GError **err
 	gtk_combo_box_set_active (GTK_COMBO_BOX (widget), active < 0 ? 0 : active);
 	g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self);
 
+	widget = glade_xml_get_widget (priv->xml, "authmode_combo");
+	g_return_val_if_fail (widget != NULL, FALSE);
+	gtk_size_group_add_widget (priv->group, GTK_WIDGET (widget));
+
+	active = -1;
+	store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+	if (s_vpn)
+		authmode = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_AUTHMODE);
+
+	gtk_list_store_append (store, &iter);
+	gtk_list_store_set (store, &iter, 0, _("Hybrid (default)"),
+						1, NM_VPNC_AUTHMODE_HYBRID, -1);
+	if ((active < 0) && authmode) {
+		if (!strcmp (authmode, NM_VPNC_AUTHMODE_HYBRID))
+			active = 0;
+	}
+
+	gtk_list_store_append (store, &iter);
+	gtk_list_store_set (store, &iter, 0, _("Pre-shared key (insecure)"),
+						1, NM_VPNC_AUTHMODE_PSK, -1);
+	if ((active < 0) && authmode) {
+		if (!strcmp (authmode, NM_VPNC_AUTHMODE_PSK))
+			active = 1;
+	}
+
+	gtk_combo_box_set_model (GTK_COMBO_BOX (widget), GTK_TREE_MODEL (store));
+	g_object_unref (store);
+	gtk_combo_box_set_active (GTK_COMBO_BOX (widget), active < 0 ? 0 : active);
+	g_signal_connect (G_OBJECT (widget), "changed",
+					  G_CALLBACK (authmode_changed_cb), self);
+
+	widget = glade_xml_get_widget (priv->xml, "ca_file_filechooserbutton");
+	g_return_val_if_fail (widget != NULL, FALSE);
+	gtk_size_group_add_widget (priv->group, GTK_WIDGET (widget));
+	if (s_vpn && authmode && !strcmp (authmode, NM_VPNC_AUTHMODE_HYBRID)) {
+		value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_CA_FILE);
+		if (value && strlen (value))
+			gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), value);
+	}
+	g_signal_connect (G_OBJECT (widget), "file-set", G_CALLBACK (stuff_changed_cb), self);
+
 	/* Fill the VPN passwords *before* initializing the PW type combos, since
 	 * knowing if there are passwords when initializing the combos is helpful.
 	 */
@@ -527,6 +605,8 @@ init_plugin_ui (VpncPluginUiWidget *self, NMConnection *connection, GError **err
 	                  (GCallback) show_toggled_cb,
 	                  self);
 
+	update_sensitive(self);
+
 	return TRUE;
 }
 
@@ -580,6 +660,7 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
 	GtkTreeModel *model;
 	GtkTreeIter iter;
 	guint32 upw_type, gpw_type;
+	const char *authmode = NULL;
 
 	if (!check_validity (self, error))
 		return FALSE;
@@ -622,6 +703,21 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
 		break;
 	}
 
+	widget = glade_xml_get_widget (priv->xml, "authmode_combo");
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
+	if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
+		gtk_tree_model_get (model, &iter, 1, &authmode, -1);
+	if (!(authmode && strlen(authmode)))
+		authmode = NM_VPNC_AUTHMODE_HYBRID;
+	nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_AUTHMODE, authmode);
+
+	if (!strcmp(authmode, NM_VPNC_AUTHMODE_HYBRID)) {
+		widget = glade_xml_get_widget (priv->xml, "ca_file_filechooserbutton");
+		str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
+		if (str && strlen (str))
+			nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_CA_FILE, str);
+	}
+
 	widget = glade_xml_get_widget (priv->xml, "natt_combo");
 	model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
 	if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) {
diff --git a/src/nm-vpnc-service.c b/src/nm-vpnc-service.c
index 3cf288a..9a7a357 100644
--- a/src/nm-vpnc-service.c
+++ b/src/nm-vpnc-service.c
@@ -72,6 +72,8 @@ static ValidProperty valid_properties[] = {
 	{ NM_VPNC_KEY_APP_VERSION,           G_TYPE_STRING, 0, 0 },
 	{ NM_VPNC_KEY_SINGLE_DES,            G_TYPE_BOOLEAN, 0, 0 },
 	{ NM_VPNC_KEY_NO_ENCRYPTION,         G_TYPE_BOOLEAN, 0, 0 },
+	{ NM_VPNC_KEY_AUTHMODE,              G_TYPE_STRING, 0, 0 },
+	{ NM_VPNC_KEY_CA_FILE,               G_TYPE_STRING, 0, 0 },
 	{ NM_VPNC_KEY_DPD_IDLE_TIMEOUT,      G_TYPE_INT, 0, 86400 },
 	{ NM_VPNC_KEY_NAT_TRAVERSAL_MODE,    G_TYPE_STRING, 0, 0 },
 	{ NM_VPNC_KEY_CISCO_UDP_ENCAPS_PORT, G_TYPE_INT, 0, 65535 },
diff --git a/src/nm-vpnc-service.h b/src/nm-vpnc-service.h
index da4c2b7..33c395b 100644
--- a/src/nm-vpnc-service.h
+++ b/src/nm-vpnc-service.h
@@ -51,10 +51,15 @@
 #define NM_VPNC_KEY_APP_VERSION "Application Version"
 #define NM_VPNC_KEY_SINGLE_DES "Enable Single DES"
 #define NM_VPNC_KEY_NO_ENCRYPTION "Enable no encryption"
+#define NM_VPNC_KEY_AUTHMODE "IKE Authmode"
+#define NM_VPNC_KEY_CA_FILE "CA-File"
 #define NM_VPNC_KEY_NAT_TRAVERSAL_MODE "NAT Traversal Mode"
 #define NM_VPNC_KEY_DPD_IDLE_TIMEOUT "DPD idle timeout (our side)"
 #define NM_VPNC_KEY_CISCO_UDP_ENCAPS_PORT "Cisco UDP Encapsulation Port"
 
+#define NM_VPNC_AUTHMODE_PSK    "psk"
+#define NM_VPNC_AUTHMODE_HYBRID "hybrid"
+
 #define NM_VPNC_NATT_MODE_NATT        "natt"
 #define NM_VPNC_NATT_MODE_NONE        "none"
 #define NM_VPNC_NATT_MODE_NATT_ALWAYS "force-natt"

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Pkg-utopia-maintainers mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/pkg-utopia-maintainers

Reply via email to