~network-manager/network-manager/ubuntu.hardy.07

« back to all changes in this revision

Viewing changes to vpn-daemons/pptp/src/nm-pptp-service.c

* merge 0.7~~svn20080905t025540+eni0 snapshot to hardy branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
236
236
        memset (priv->password, 0, sizeof (priv->password));
237
237
 
238
238
        s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
239
 
        if (!s_vpn || !s_vpn->data) {
 
239
        if (!s_vpn || !s_vpn->secrets || !s_vpn->data) {
240
240
                g_set_error (error,
241
241
                             NM_VPN_PLUGIN_ERROR,
242
242
                             NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
268
268
                }
269
269
        }
270
270
 
271
 
        password = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_PASSWORD);
 
271
        password = g_hash_table_lookup (s_vpn->secrets, NM_PPTP_KEY_PASSWORD);
272
272
        if (!password || !strlen (password)) {
273
273
                g_set_error (error,
274
274
                             NM_VPN_PLUGIN_ERROR,
475
475
}
476
476
 
477
477
static gboolean
478
 
nm_pptp_properties_validate (GHashTable *properties, GError **error)
 
478
nm_pptp_properties_validate (GHashTable *properties,
 
479
                             gboolean check_required,
 
480
                             GError **error)
479
481
{
480
482
        int i;
481
483
 
492
494
        if (*error)
493
495
                return FALSE;
494
496
 
495
 
        /* Ensure required properties exist */
496
 
        for (i = 0; valid_properties[i].name; i++) {
497
 
                ValidProperty prop = valid_properties[i];
498
 
                const char *value;
499
 
 
500
 
                if (!prop.required)
501
 
                        continue;
502
 
 
503
 
                value = g_hash_table_lookup (properties, prop.name);
504
 
                if (!value || !strlen (value)) {
505
 
                        g_set_error (error,
506
 
                                     NM_VPN_PLUGIN_ERROR,
507
 
                                     NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
508
 
                                     "Missing required option '%s'.",
509
 
                                     prop.name);
510
 
                        return FALSE;
 
497
        if (check_required) {
 
498
                /* Ensure required properties exist */
 
499
                for (i = 0; valid_properties[i].name; i++) {
 
500
                        ValidProperty prop = valid_properties[i];
 
501
                        const char *value;
 
502
 
 
503
                        if (!prop.required)
 
504
                                continue;
 
505
 
 
506
                        value = g_hash_table_lookup (properties, prop.name);
 
507
                        if (!value || !strlen (value)) {
 
508
                                g_set_error (error,
 
509
                                             NM_VPN_PLUGIN_ERROR,
 
510
                                             NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
 
511
                                             "Missing required option '%s'.",
 
512
                                             prop.name);
 
513
                                return FALSE;
 
514
                        }
511
515
                }
512
516
        }
513
517
 
863
867
 
864
868
        s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN));
865
869
        g_assert (s_vpn);
866
 
        if (!nm_pptp_properties_validate (s_vpn->data, error))
 
870
 
 
871
        if (!nm_pptp_properties_validate (s_vpn->data, TRUE, error))
 
872
                return FALSE;
 
873
 
 
874
        if (!nm_pptp_properties_validate (s_vpn->secrets, FALSE, error))
867
875
                return FALSE;
868
876
 
869
877
        /* Start our pppd plugin helper service */
907
915
        g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
908
916
 
909
917
        s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN));
910
 
        if (!s_vpn) {
 
918
        if (!s_vpn || !s_vpn->secrets) {
911
919
        g_set_error (error,
912
920
                             NM_VPN_PLUGIN_ERROR,
913
921
                             NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
916
924
                return FALSE;
917
925
        }
918
926
 
919
 
        if (!g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_PASSWORD)) {
 
927
        if (!g_hash_table_lookup (s_vpn->secrets, NM_PPTP_KEY_PASSWORD)) {
920
928
                *setting_name = NM_SETTING_VPN_SETTING_NAME;
921
929
                return TRUE;
922
930
        }