Changeset 4257
- Timestamp:
- 08/19/08 17:19:45 (3 months ago)
- Files:
-
- trunk/src/charon/plugins/nm/Makefile.am (modified) (1 diff)
- trunk/src/charon/plugins/nm/gnome/Makefile.am (modified) (1 diff)
- trunk/src/charon/plugins/nm/gnome/auth-dialog (added)
- trunk/src/charon/plugins/nm/gnome/auth-dialog/Makefile.am (added)
- trunk/src/charon/plugins/nm/gnome/auth-dialog/main.c (added)
- trunk/src/charon/plugins/nm/gnome/configure.in (modified) (1 diff)
- trunk/src/charon/plugins/nm/gnome/properties/nm-strongswan-dialog.glade (modified) (2 diffs)
- trunk/src/charon/plugins/nm/gnome/properties/nm-strongswan.c (modified) (4 diffs)
- trunk/src/charon/plugins/nm/nm_creds.c (added)
- trunk/src/charon/plugins/nm/nm_creds.h (added)
- trunk/src/charon/plugins/nm/nm_plugin.c (modified) (5 diffs)
- trunk/src/charon/plugins/nm/nm_service.c (modified) (7 diffs)
- trunk/src/charon/plugins/nm/nm_service.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/charon/plugins/nm/Makefile.am
r4238 r4257 6 6 plugin_LTLIBRARIES = libstrongswan-nm.la 7 7 libstrongswan_nm_la_SOURCES = \ 8 nm_plugin.h nm_plugin.c nm_service.h nm_service.c 8 nm_plugin.h nm_plugin.c nm_service.h nm_service.c nm_creds.h nm_creds.c 9 9 libstrongswan_nm_la_LDFLAGS = -module 10 10 libstrongswan_nm_la_LIBADD = ${nm_LIBS} trunk/src/charon/plugins/nm/gnome/Makefile.am
r4241 r4257 1 1 AUTOMAKE_OPTIONS = foreign 2 2 3 SUBDIRS = properties po3 SUBDIRS = properties auth-dialog po 4 4 5 5 dbusservicedir = $(sysconfdir)/dbus-1/system.d trunk/src/charon/plugins/nm/gnome/configure.in
r4241 r4257 117 117 Makefile 118 118 properties/Makefile 119 auth-dialog/Makefile 119 120 po/Makefile.in 120 121 ]) trunk/src/charon/plugins/nm/gnome/properties/nm-strongswan-dialog.glade
r4241 r4257 79 79 </child> 80 80 <child> 81 <widget class="GtkButton" id="certificate-button"> 82 <property name="visible">True</property> 83 <property name="can_focus">True</property> 84 <property name="receives_default">True</property> 85 <property name="has_tooltip">True</property> 86 <property name="tooltip_text">A trusted certificate to use to authenticate the Gateway.</property> 87 <property name="label" translatable="yes">(none)</property> 88 <property name="response_id">0</property> 89 </widget> 90 <packing> 91 <property name="left_attach">1</property> 92 <property name="right_attach">2</property> 93 <property name="top_attach">1</property> 94 <property name="bottom_attach">2</property> 95 <property name="y_options"></property> 81 <widget class="GtkFileChooserButton" id="certificate-button"> 82 <property name="visible">True</property> 83 </widget> 84 <packing> 85 <property name="left_attach">1</property> 86 <property name="right_attach">2</property> 87 <property name="top_attach">1</property> 88 <property name="bottom_attach">2</property> 96 89 </packing> 97 90 </child> … … 166 159 <widget class="GtkComboBox" id="method-combo"> 167 160 <property name="visible">True</property> 168 <property name="sensitive">False</property>169 161 <property name="has_tooltip">True</property> 170 162 <property name="tooltip_text">Authentication Method to use for authentication against the Gateway. </property> trunk/src/charon/plugins/nm/gnome/properties/nm-strongswan.c
r4256 r4257 160 160 g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self); 161 161 162 widget = glade_xml_get_widget (priv->xml, "certificate-button"); 163 if (!widget) 164 return FALSE; 165 value = g_hash_table_lookup (settings->data, "certificate"); 166 if (value) 167 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), value); 168 g_signal_connect (G_OBJECT (widget), "selection-changed", G_CALLBACK (stuff_changed_cb), self); 169 162 170 widget = glade_xml_get_widget (priv->xml, "user-entry"); 163 171 if (!widget) … … 167 175 gtk_entry_set_text (GTK_ENTRY (widget), value); 168 176 g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self); 177 178 widget = glade_xml_get_widget (priv->xml, "method-combo"); 179 if (!widget) 180 return FALSE; 181 gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "EAP"); 182 value = g_hash_table_lookup (settings->data, "method"); 183 if (value) { 184 if (g_strcasecmp (value, "EAP") == 0) { 185 gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); 186 } 187 } 188 g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self); 189 if (gtk_combo_box_get_active (GTK_COMBO_BOX (widget)) == -1) 190 { /* default to EAP */ 191 gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); 192 } 169 193 170 194 widget = glade_xml_get_widget (priv->xml, "virtual-check"); … … 236 260 } 237 261 262 widget = glade_xml_get_widget (priv->xml, "certificate-button"); 263 str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); 264 if (str) { 265 g_hash_table_insert (settings->data, g_strdup ("certificate"), g_strdup(str)); 266 } 267 238 268 widget = glade_xml_get_widget (priv->xml, "user-entry"); 239 269 str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); … … 242 272 } 243 273 274 widget = glade_xml_get_widget (priv->xml, "method-combo"); 275 str = (char *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (widget)); 276 if (str) { 277 g_hash_table_insert (settings->data, g_strdup ("method"), g_strdup(str)); 278 } 279 244 280 widget = glade_xml_get_widget (priv->xml, "virtual-check"); 245 281 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); trunk/src/charon/plugins/nm/nm_plugin.c
r4238 r4257 18 18 #include "nm_plugin.h" 19 19 #include "nm_service.h" 20 #include "nm_creds.h" 20 21 21 22 #include <daemon.h> … … 34 35 nm_plugin_t public; 35 36 37 /** 38 * Glib main loop for a thread, handles DBUS calls 39 */ 36 40 GMainLoop *loop; 41 42 /** 43 * credential set registered at the daemon 44 */ 45 nm_creds_t *creds; 37 46 }; 38 47 … … 45 54 GMainLoop *loop; 46 55 47 plugin = nm_strongswan_plugin_new( );56 plugin = nm_strongswan_plugin_new(this->creds); 48 57 49 58 this->loop = loop = g_main_loop_new(NULL, FALSE); … … 65 74 g_main_loop_quit(this->loop); 66 75 } 76 charon->credentials->remove_set(charon->credentials, &this->creds->set); 77 this->creds->destroy(this->creds); 67 78 free(this); 68 79 } … … 84 95 } 85 96 97 this->creds = nm_creds_create(); 98 charon->credentials->add_set(charon->credentials, &this->creds->set); 99 86 100 charon->processor->queue_job(charon->processor, 87 101 (job_t*)callback_job_create((callback_job_cb_t)run, this, NULL, NULL)); trunk/src/charon/plugins/nm/nm_service.c
r4256 r4257 37 37 ike_sa_t *ike_sa; 38 38 NMVPNPlugin *plugin; 39 nm_creds_t *creds; 39 40 } NMStrongswanPluginPrivate; 40 41 … … 162 163 GError **err) 163 164 { 165 nm_creds_t *creds; 164 166 NMSettingVPN *settings; 165 167 identification_t *user = NULL; … … 178 180 NM_TYPE_SETTING_VPN)); 179 181 180 DBG 2(DBG_CFG, "received NetworkManager connection: %s",182 DBG1(DBG_CFG, "received NetworkManager connection: %s", 181 183 nm_setting_to_string(NM_SETTING(settings))); 182 184 str = g_hash_table_lookup(settings->data, "user"); … … 208 210 209 211 /** 212 * Register credentials 213 */ 214 creds = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin)->creds; 215 216 str = g_hash_table_lookup(settings->data, "certificate"); 217 if (str) 218 { 219 certificate_t *cert; 220 221 cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509, 222 BUILD_FROM_FILE, str, BUILD_END); 223 creds->set_certificate(creds, cert); 224 } 225 str = g_hash_table_lookup(settings->data, "password"); 226 if (str) 227 { 228 creds->set_password(creds, str); 229 } 230 231 /** 210 232 * Set up configurations 211 233 */ … … 214 236 peer_cfg = peer_cfg_create(CONFIG_NAME, 2, ike_cfg, user, 215 237 identification_create_from_encoding(ID_ANY, chunk_empty), 216 CERT_SEND_IF_ASKED, UNIQUE_REPLACE, CONF_AUTH_P UBKEY,238 CERT_SEND_IF_ASKED, UNIQUE_REPLACE, CONF_AUTH_PSK, 217 239 0, 0, 1, /* EAP method, vendor, keyingtries */ 218 240 18000, 0, /* rekey 5h, reauth none */ … … 273 295 char **setting_name, GError **error) 274 296 { 297 NMSettingVPN *settings; 298 299 settings = NM_SETTING_VPN(nm_connection_get_setting(connection, 300 NM_TYPE_SETTING_VPN)); 301 if (!g_hash_table_lookup(settings->data, "password")) 302 { 303 *setting_name = NM_SETTING_VPN_SETTING_NAME; 304 return TRUE; 305 } 275 306 return FALSE; 276 307 } … … 328 359 * Object constructor 329 360 */ 330 NMStrongswanPlugin *nm_strongswan_plugin_new(void) 331 { 332 return (NMStrongswanPlugin *)g_object_new ( 333 NM_TYPE_STRONGSWAN_PLUGIN, NM_VPN_PLUGIN_DBUS_SERVICE_NAME, 334 NM_DBUS_SERVICE_STRONGSWAN, NULL); 335 } 336 361 NMStrongswanPlugin *nm_strongswan_plugin_new(nm_creds_t *creds) 362 { 363 NMStrongswanPlugin *plugin = (NMStrongswanPlugin *)g_object_new ( 364 NM_TYPE_STRONGSWAN_PLUGIN, 365 NM_VPN_PLUGIN_DBUS_SERVICE_NAME, NM_DBUS_SERVICE_STRONGSWAN, 366 NULL); 367 368 NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin)->creds = creds; 369 370 return plugin; 371 } 372 trunk/src/charon/plugins/nm/nm_service.h
r4240 r4257 28 28 #include <nm-vpn-plugin.h> 29 29 30 #include "nm_creds.h" 31 30 32 #define NM_TYPE_STRONGSWAN_PLUGIN (nm_strongswan_plugin_get_type ()) 31 33 #define NM_STRONGSWAN_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_STRONGSWAN_PLUGIN, NMSTRONGSWANPlugin)) … … 49 51 GType nm_strongswan_plugin_get_type(void); 50 52 51 NMStrongswanPlugin *nm_strongswan_plugin_new( void);53 NMStrongswanPlugin *nm_strongswan_plugin_new(nm_creds_t *creds); 52 54 53 55 #endif /* NM_SERVICE_H_ */
