~ubuntu-branches/ubuntu/precise/network-manager/precise

« back to all changes in this revision

Viewing changes to src/supplicant-manager/nm-supplicant-config.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2012-02-09 16:45:41 UTC
  • mfrom: (1.1.53)
  • Revision ID: package-import@ubuntu.com-20120209164541-4h90zknlsfdb7x35
Tags: 0.9.2.0+git201202091925.c721477-0ubuntu1
* upstream snapshot 2012-02-09 19:25:59 (GMT)
  + c721477d11d4fe144111d6d2eec8f93f2e9186c9
* debian/patches/avoid-periodic-disk-wakeups.patch: refreshed.
* debian/patches/nl3-default-ip6-route.patch: refreshed.
* debian/libnm-glib4.symbols: add symbols:
  + nm_active_connection_get_master@Base
  + nm_client_new_async@Base
  + nm_client_new_finish@Base
  + nm_remote_settings_new_async@Base
  + nm_remote_settings_new_finish@Base
  + nm_device_get_state_reason@Base
* debian/libnm-util2.symbols: add symbols:
  + nm_setting_802_1x_get_pac_file@Base
  + nm_setting_infiniband_get_transport_mode@Base

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 * with this program; if not, write to the Free Software Foundation, Inc.,
16
16
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
17
 *
18
 
 * Copyright (C) 2006 - 2010 Red Hat, Inc.
 
18
 * Copyright (C) 2006 - 2012 Red Hat, Inc.
19
19
 * Copyright (C) 2007 - 2008 Novell, Inc.
20
20
 */
21
21
 
54
54
        GHashTable *config;
55
55
        GHashTable *blobs;
56
56
        guint32    ap_scan;
 
57
        gboolean   fast_required;
57
58
        gboolean   dispose_has_run;
58
59
} NMSupplicantConfigPrivate;
59
60
 
278
279
        NM_SUPPLICANT_CONFIG_GET_PRIVATE (self)->ap_scan = ap_scan;
279
280
}
280
281
 
 
282
gboolean
 
283
nm_supplicant_config_fast_required (NMSupplicantConfig *self)
 
284
{
 
285
        g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE);
 
286
 
 
287
        return NM_SUPPLICANT_CONFIG_GET_PRIVATE (self)->fast_required;
 
288
}
 
289
 
281
290
static void
282
291
get_hash_cb (gpointer key, gpointer value, gpointer user_data)
283
292
{
584
593
nm_supplicant_config_add_setting_wireless_security (NMSupplicantConfig *self,
585
594
                                                    NMSettingWirelessSecurity *setting,
586
595
                                                    NMSetting8021x *setting_8021x,
587
 
                                                    const char *connection_uid)
 
596
                                                    const char *con_uuid)
588
597
{
589
598
        char *value;
590
599
        gboolean success;
593
602
 
594
603
        g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE);
595
604
        g_return_val_if_fail (setting != NULL, FALSE);
596
 
        g_return_val_if_fail (connection_uid != NULL, FALSE);
 
605
        g_return_val_if_fail (con_uuid != NULL, FALSE);
597
606
 
598
607
        key_mgmt = nm_setting_wireless_security_get_key_mgmt (setting);
599
608
        if (!add_string_val (self, key_mgmt, "key_mgmt", TRUE, FALSE))
693
702
                if (!strcmp (key_mgmt, "ieee8021x") || !strcmp (key_mgmt, "wpa-eap")) {
694
703
                    if (!setting_8021x)
695
704
                        return FALSE;
696
 
                        if (!nm_supplicant_config_add_setting_8021x (self, setting_8021x, connection_uid, FALSE))
 
705
                        if (!nm_supplicant_config_add_setting_8021x (self, setting_8021x, con_uuid, FALSE))
697
706
                                return FALSE;
698
707
                }
699
708
 
712
721
gboolean
713
722
nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self,
714
723
                                        NMSetting8021x *setting,
715
 
                                        const char *connection_uid,
 
724
                                        const char *con_uuid,
716
725
                                        gboolean wired)
717
726
{
 
727
        NMSupplicantConfigPrivate *priv;
718
728
        char *tmp;
719
729
        const char *peapver, *value, *path;
720
730
        gboolean success, added;
721
731
        GString *phase1, *phase2;
722
732
        const GByteArray *array;
723
 
        gboolean peap = FALSE;
 
733
        gboolean peap = FALSE, fast = FALSE;
724
734
        guint32 i, num_eap;
 
735
        gboolean fast_provisoning_allowed = FALSE;
725
736
 
726
737
        g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE);
727
738
        g_return_val_if_fail (setting != NULL, FALSE);
728
 
        g_return_val_if_fail (connection_uid != NULL, FALSE);
 
739
        g_return_val_if_fail (con_uuid != NULL, FALSE);
 
740
 
 
741
        priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self);
729
742
 
730
743
        value = nm_setting_802_1x_get_password (setting);
731
744
        if (value) {
733
746
                        return FALSE;
734
747
        } else {
735
748
                array = nm_setting_802_1x_get_password_raw (setting);
736
 
                success = nm_supplicant_config_add_option (self,
737
 
                                                           "password",
738
 
                                                           (const char *)array->data,
739
 
                                                           array->len,
740
 
                                                           TRUE);
741
 
                if (!success) {
742
 
                        nm_log_warn (LOGD_SUPPLICANT, "Error adding password-raw to supplicant config.");
743
 
                        return FALSE;
 
749
                if (array) {
 
750
                        success = nm_supplicant_config_add_option (self,
 
751
                                                                   "password",
 
752
                                                                   (const char *)array->data,
 
753
                                                                   array->len,
 
754
                                                                   TRUE);
 
755
                        if (!success) {
 
756
                                nm_log_warn (LOGD_SUPPLICANT, "Error adding password-raw to supplicant config.");
 
757
                                return FALSE;
 
758
                        }
744
759
                }
745
760
        }
746
761
        value = nm_setting_802_1x_get_pin (setting);
758
773
 
759
774
        ADD_STRING_LIST_VAL (setting, 802_1x, eap_method, eap_methods, "eap", ' ', TRUE, FALSE);
760
775
 
761
 
        /* Check for PEAP + GTC */
 
776
        /* Check EAP method for special handling: PEAP + GTC, FAST */
762
777
        num_eap = nm_setting_802_1x_get_num_eap_methods (setting);
763
778
        for (i = 0; i < num_eap; i++) {
764
779
                const char *method = nm_setting_802_1x_get_eap_method (setting, i);
765
780
 
766
 
                if (method && (strcasecmp (method, "peap") == 0)) {
 
781
                if (method && (strcasecmp (method, "peap") == 0))
767
782
                        peap = TRUE;
768
 
                        break;
 
783
                if (method && (strcasecmp (method, "fast") == 0)) {
 
784
                        fast = TRUE;
 
785
                        priv->fast_required = TRUE;
769
786
                }
770
787
        }
771
788
 
799
816
                g_string_append_printf (phase1, "peaplabel=%s", nm_setting_802_1x_get_phase1_peaplabel (setting));
800
817
        }
801
818
 
 
819
        value = nm_setting_802_1x_get_phase1_fast_provisioning (setting);
 
820
        if (value) {
 
821
                if (phase1->len)
 
822
                        g_string_append_c (phase1, ' ');
 
823
                g_string_append_printf (phase1, "fast_provisioning=%s", value);
 
824
                
 
825
                if (strcmp (value, "0") != 0)
 
826
                        fast_provisoning_allowed = TRUE;
 
827
        }
 
828
 
802
829
        if (phase1->len) {
803
830
                if (!add_string_val (self, phase1->str, "phase1", FALSE, FALSE)) {
804
831
                        g_string_free (phase1, TRUE);
808
835
        g_string_free (phase1, TRUE);
809
836
 
810
837
        phase2 = g_string_new (NULL);
811
 
        if (nm_setting_802_1x_get_phase2_auth (setting)) {
 
838
        if (nm_setting_802_1x_get_phase2_auth (setting) && !fast_provisoning_allowed) {
812
839
                tmp = g_ascii_strup (nm_setting_802_1x_get_phase2_auth (setting), -1);
813
840
                g_string_append_printf (phase2, "auth=%s", tmp);
814
841
                g_free (tmp);
830
857
        }
831
858
        g_string_free (phase2, TRUE);
832
859
 
 
860
        /* PAC file */
 
861
        path = nm_setting_802_1x_get_pac_file (setting);
 
862
        if (path) {
 
863
                if (!add_string_val (self, path, "pac_file", FALSE, FALSE))
 
864
                        return FALSE;
 
865
        } else {
 
866
                /* PAC file is not specified.
 
867
                 * If provisioning is allowed, use an blob format.
 
868
                 */
 
869
                if (fast_provisoning_allowed) {
 
870
                        char *blob_name = g_strdup_printf ("blob://pac-blob-%s", con_uuid);
 
871
                        if (!add_string_val (self, blob_name, "pac_file", FALSE, FALSE)) {
 
872
                                g_free (blob_name);
 
873
                                return FALSE;
 
874
                        }
 
875
                        g_free (blob_name);
 
876
                } else {
 
877
                        /* This is only error for EAP-FAST; don't disturb other methods. */
 
878
                        if (fast) {
 
879
                                nm_log_err (LOGD_SUPPLICANT, "EAP-FAST error: no PAC file provided and "
 
880
                                                              "automatic PAC provisioning is disabled.");
 
881
                                return FALSE;
 
882
                        }
 
883
                }
 
884
        }
 
885
 
833
886
        /* CA path */
834
887
        path = nm_setting_802_1x_get_ca_path (setting);
835
888
        if (nm_setting_802_1x_get_system_ca_certs (setting))
852
905
        switch (nm_setting_802_1x_get_ca_cert_scheme (setting)) {
853
906
        case NM_SETTING_802_1X_CK_SCHEME_BLOB:
854
907
                array = nm_setting_802_1x_get_ca_cert_blob (setting);
855
 
                ADD_BLOB_VAL (array, "ca_cert", connection_uid);
 
908
                ADD_BLOB_VAL (array, "ca_cert", con_uuid);
856
909
                break;
857
910
        case NM_SETTING_802_1X_CK_SCHEME_PATH:
858
911
                path = nm_setting_802_1x_get_ca_cert_path (setting);
867
920
        switch (nm_setting_802_1x_get_phase2_ca_cert_scheme (setting)) {
868
921
        case NM_SETTING_802_1X_CK_SCHEME_BLOB:
869
922
                array = nm_setting_802_1x_get_phase2_ca_cert_blob (setting);
870
 
                ADD_BLOB_VAL (array, "ca_cert2", connection_uid);
 
923
                ADD_BLOB_VAL (array, "ca_cert2", con_uuid);
871
924
                break;
872
925
        case NM_SETTING_802_1X_CK_SCHEME_PATH:
873
926
                path = nm_setting_802_1x_get_phase2_ca_cert_path (setting);
895
948
        switch (nm_setting_802_1x_get_private_key_scheme (setting)) {
896
949
        case NM_SETTING_802_1X_CK_SCHEME_BLOB:
897
950
                array = nm_setting_802_1x_get_private_key_blob (setting);
898
 
                ADD_BLOB_VAL (array, "private_key", connection_uid);
 
951
                ADD_BLOB_VAL (array, "private_key", con_uuid);
899
952
                added = TRUE;
900
953
                break;
901
954
        case NM_SETTING_802_1X_CK_SCHEME_PATH:
933
986
                        switch (nm_setting_802_1x_get_client_cert_scheme (setting)) {
934
987
                        case NM_SETTING_802_1X_CK_SCHEME_BLOB:
935
988
                                array = nm_setting_802_1x_get_client_cert_blob (setting);
936
 
                                ADD_BLOB_VAL (array, "client_cert", connection_uid);
 
989
                                ADD_BLOB_VAL (array, "client_cert", con_uuid);
937
990
                                break;
938
991
                        case NM_SETTING_802_1X_CK_SCHEME_PATH:
939
992
                                path = nm_setting_802_1x_get_client_cert_path (setting);
951
1004
        switch (nm_setting_802_1x_get_phase2_private_key_scheme (setting)) {
952
1005
        case NM_SETTING_802_1X_CK_SCHEME_BLOB:
953
1006
                array = nm_setting_802_1x_get_phase2_private_key_blob (setting);
954
 
                ADD_BLOB_VAL (array, "private_key2", connection_uid);
 
1007
                ADD_BLOB_VAL (array, "private_key2", con_uuid);
955
1008
                added = TRUE;
956
1009
                break;
957
1010
        case NM_SETTING_802_1X_CK_SCHEME_PATH:
989
1042
                        switch (nm_setting_802_1x_get_phase2_client_cert_scheme (setting)) {
990
1043
                        case NM_SETTING_802_1X_CK_SCHEME_BLOB:
991
1044
                                array = nm_setting_802_1x_get_phase2_client_cert_blob (setting);
992
 
                                ADD_BLOB_VAL (array, "client_cert2", connection_uid);
 
1045
                                ADD_BLOB_VAL (array, "client_cert2", con_uuid);
993
1046
                                break;
994
1047
                        case NM_SETTING_802_1X_CK_SCHEME_PATH:
995
1048
                                path = nm_setting_802_1x_get_phase2_client_cert_path (setting);