summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2008-08-04 19:17:10 +0000
committerDan Williams <dcbw@redhat.com>2008-08-04 19:17:10 +0000
commite2aa0872810364a4ead6e74e5edcd07c9cd4ec92 (patch)
tree0fe64b1574ac62f6bc4741cc37fcb2681139af23
parentb3c09d38d5e0ec92f0f2d628242a9e72426398cd (diff)
downloadNetworkManager-e2aa0872810364a4ead6e74e5edcd07c9cd4ec92.tar.gz
2008-08-04 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-setting-cdma.c libnm-util/nm-setting-gsm.c - (verify): validate username & password if they exist - (need_secrets): if username given, require a password too git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3892 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
-rw-r--r--ChangeLog7
-rw-r--r--libnm-util/nm-setting-cdma.c34
-rw-r--r--libnm-util/nm-setting-gsm.c34
3 files changed, 75 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 9ba233f766..32014c84a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2008-08-04 Dan Williams <dcbw@redhat.com>
+ * libnm-util/nm-setting-cdma.c
+ libnm-util/nm-setting-gsm.c
+ - (verify): validate username & password if they exist
+ - (need_secrets): if username given, require a password too
+
+2008-08-04 Dan Williams <dcbw@redhat.com>
+
* src/dnsmasq-manager/nm-dnsmasq-manager.c
- (create_dm_cmd_line): really don't listen on lo, despite what the
manpage says about --listen-address without --interface
diff --git a/libnm-util/nm-setting-cdma.c b/libnm-util/nm-setting-cdma.c
index 3ca41bedb1..5955963c7c 100644
--- a/libnm-util/nm-setting-cdma.c
+++ b/libnm-util/nm-setting-cdma.c
@@ -117,9 +117,42 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
+ if (self->username && !strlen (self->username)) {
+ g_set_error (error,
+ NM_SETTING_CDMA_ERROR,
+ NM_SETTING_CDMA_ERROR_INVALID_PROPERTY,
+ NM_SETTING_CDMA_USERNAME);
+ return FALSE;
+ }
+
+ if (self->password && !strlen (self->password)) {
+ g_set_error (error,
+ NM_SETTING_CDMA_ERROR,
+ NM_SETTING_CDMA_ERROR_INVALID_PROPERTY,
+ NM_SETTING_CDMA_PASSWORD);
+ return FALSE;
+ }
+
return TRUE;
}
+static GPtrArray *
+need_secrets (NMSetting *setting)
+{
+ NMSettingCdma *self = NM_SETTING_CDMA (setting);
+ GPtrArray *secrets = NULL;
+
+ if (self->password)
+ return NULL;
+
+ if (self->username) {
+ secrets = g_ptr_array_sized_new (1);
+ g_ptr_array_add (secrets, NM_SETTING_CDMA_PASSWORD);
+ }
+
+ return secrets;
+}
+
static void
nm_setting_cdma_init (NMSettingCdma *setting)
{
@@ -196,6 +229,7 @@ nm_setting_cdma_class_init (NMSettingCdmaClass *setting_class)
object_class->get_property = get_property;
object_class->finalize = finalize;
parent_class->verify = verify;
+ parent_class->need_secrets = need_secrets;
/* Properties */
g_object_class_install_property
diff --git a/libnm-util/nm-setting-gsm.c b/libnm-util/nm-setting-gsm.c
index 97bc3ea2ca..b65fa65a22 100644
--- a/libnm-util/nm-setting-gsm.c
+++ b/libnm-util/nm-setting-gsm.c
@@ -133,9 +133,42 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
+ if (self->username && !strlen (self->username)) {
+ g_set_error (error,
+ NM_SETTING_GSM_ERROR,
+ NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
+ NM_SETTING_GSM_USERNAME);
+ return FALSE;
+ }
+
+ if (self->password && !strlen (self->password)) {
+ g_set_error (error,
+ NM_SETTING_GSM_ERROR,
+ NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
+ NM_SETTING_GSM_USERNAME);
+ return FALSE;
+ }
+
return TRUE;
}
+static GPtrArray *
+need_secrets (NMSetting *setting)
+{
+ NMSettingGsm *self = NM_SETTING_GSM (setting);
+ GPtrArray *secrets = NULL;
+
+ if (self->password)
+ return NULL;
+
+ if (self->username) {
+ secrets = g_ptr_array_sized_new (1);
+ g_ptr_array_add (secrets, NM_SETTING_GSM_PASSWORD);
+ }
+
+ return secrets;
+}
+
static void
nm_setting_gsm_init (NMSettingGsm *setting)
{
@@ -256,6 +289,7 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
object_class->get_property = get_property;
object_class->finalize = finalize;
parent_class->verify = verify;
+ parent_class->need_secrets = need_secrets;
/* Properties */
g_object_class_install_property