From 8c79f16f5d6362c8ee8813fae3c7af3d887b6d47 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 1 Jul 2008 20:21:31 +0000 Subject: [PATCH] 2008-07-01 Dan Williams Fix mobile broadband username/password issues. NM was never requesting mobile broadband secrets, nor was it passing back the username and password if it had them. * marshallers/nm-marshal.list - Add some new types for activation request objects * src/nm-activation-request.c src/nm-activation-request.h - (get_secrets_cb): pass the caller type in the signal - (nm_act_request_request_connection_secrets): take a caller type, so that GetSecrets() reply handlers know who asked for the secrets in the first place; use secret hints too so the settings service can figure out exactly what NM wants (ie, PIN or the PPP password) * src/ppp-manager/nm-ppp-manager.c src/ppp-manager/nm-ppp-manager.h - (impl_ppp_manager_need_secrets): nm_connection_need_secrets() won't detect needed secrets when the secret could be blank, like GSM/CDMA passwords. So always ask for secrets, and send a hint as to what secret we really want. - (nm_ppp_manager_update_secrets): make function more generic by making the device specific class figure out the username and password, and accept an error argument to return back over D-Bus * src/nm-device-wifi.c - (link_timeout_cb, handle_auth_or_fail): update for changes to nm_act_request_request_connection_secrets() - (real_connection_secrets_updated): update for 'caller' changes * src/nm-device.c src/nm-device.h - (connection_secrets_updated_cb, connection_secrets_failed_cb): update for 'caller' changes * src/nm-device-ethernet.c - (real_connection_secrets_updated): update for 'caller' changes and move logic for getting PPPoE username and password here before calling nm_ppp_manager_update_secrets() - (link_timeout_cb, handle_auth_or_fail): update for changes to nm_act_request_request_connection_secrets() * src/nm-cdma-device.c - (real_connection_secrets_updated): pass username and password back to the PPP manager when required * src/nm-gsm-device.c - (enter_pin): send the required secret name to the settings service - (real_connection_secrets_updated): pass username and password back to the PPP manager when required git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3794 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 53 +++++++++++++++ marshallers/nm-marshal.list | 2 + src/nm-activation-request.c | 32 ++++++--- src/nm-activation-request.h | 20 +++++- src/nm-cdma-device.c | 30 ++++++++- src/nm-device-ethernet.c | 35 ++++++++-- src/nm-device-wifi.c | 11 +++- src/nm-device.c | 4 +- src/nm-device.h | 3 +- src/nm-gsm-device.c | 37 ++++++++++- src/ppp-manager/nm-ppp-manager.c | 108 +++++++++++++++++++++---------- src/ppp-manager/nm-ppp-manager.h | 6 +- 12 files changed, 276 insertions(+), 65 deletions(-) diff --git a/ChangeLog b/ChangeLog index 18098d4405..3f0b41069b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,56 @@ +2008-07-01 Dan Williams + + Fix mobile broadband username/password issues. NM was never requesting + mobile broadband secrets, nor was it passing back the username and password + if it had them. + + * marshallers/nm-marshal.list + - Add some new types for activation request objects + + * src/nm-activation-request.c + src/nm-activation-request.h + - (get_secrets_cb): pass the caller type in the signal + - (nm_act_request_request_connection_secrets): take a caller type, so + that GetSecrets() reply handlers know who asked for the secrets in + the first place; use secret hints too so the settings service can + figure out exactly what NM wants (ie, PIN or the PPP password) + + * src/ppp-manager/nm-ppp-manager.c + src/ppp-manager/nm-ppp-manager.h + - (impl_ppp_manager_need_secrets): nm_connection_need_secrets() won't + detect needed secrets when the secret could be blank, like GSM/CDMA + passwords. So always ask for secrets, and send a hint as to what + secret we really want. + - (nm_ppp_manager_update_secrets): make function more generic by making + the device specific class figure out the username and password, and + accept an error argument to return back over D-Bus + + * src/nm-device-wifi.c + - (link_timeout_cb, handle_auth_or_fail): update for changes to + nm_act_request_request_connection_secrets() + - (real_connection_secrets_updated): update for 'caller' changes + + * src/nm-device.c + src/nm-device.h + - (connection_secrets_updated_cb, connection_secrets_failed_cb): update + for 'caller' changes + + * src/nm-device-ethernet.c + - (real_connection_secrets_updated): update for 'caller' changes and + move logic for getting PPPoE username and password here before + calling nm_ppp_manager_update_secrets() + - (link_timeout_cb, handle_auth_or_fail): update for changes to + nm_act_request_request_connection_secrets() + + * src/nm-cdma-device.c + - (real_connection_secrets_updated): pass username and password back + to the PPP manager when required + + * src/nm-gsm-device.c + - (enter_pin): send the required secret name to the settings service + - (real_connection_secrets_updated): pass username and password back + to the PPP manager when required + 2008-06-30 Dan Williams * src/nm-device-wifi.c diff --git a/marshallers/nm-marshal.list b/marshallers/nm-marshal.list index d29f7992f9..b3d2517699 100644 --- a/marshallers/nm-marshal.list +++ b/marshallers/nm-marshal.list @@ -1,7 +1,9 @@ VOID:OBJECT VOID:OBJECT,STRING +VOID:OBJECT,STRING,UINT VOID:OBJECT,UINT VOID:OBJECT,POINTER +VOID:OBJECT,POINTER,UINT VOID:POINTER VOID:STRING,STRING,STRING VOID:UINT,UINT diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c index 2496c2430c..63b8c993f5 100644 --- a/src/nm-activation-request.c +++ b/src/nm-activation-request.c @@ -311,9 +311,9 @@ nm_act_request_class_init (NMActRequestClass *req_class) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (NMActRequestClass, connection_secrets_updated), NULL, NULL, - nm_marshal_VOID__OBJECT_POINTER, - G_TYPE_NONE, 2, - G_TYPE_OBJECT, G_TYPE_POINTER); + nm_marshal_VOID__OBJECT_POINTER_UINT, + G_TYPE_NONE, 3, + G_TYPE_OBJECT, G_TYPE_POINTER, G_TYPE_UINT); signals[CONNECTION_SECRETS_FAILED] = g_signal_new ("connection-secrets-failed", @@ -321,9 +321,9 @@ nm_act_request_class_init (NMActRequestClass *req_class) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (NMActRequestClass, connection_secrets_failed), NULL, NULL, - nm_marshal_VOID__OBJECT_STRING, - G_TYPE_NONE, 2, - G_TYPE_OBJECT, G_TYPE_STRING); + nm_marshal_VOID__OBJECT_STRING_UINT, + G_TYPE_NONE, 3, + G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_UINT); signals[PROPERTIES_CHANGED] = nm_properties_changed_signal_new (object_class, @@ -371,6 +371,7 @@ device_state_changed (NMDevice *device, NMDeviceState state, gpointer user_data) typedef struct GetSecretsInfo { NMActRequest *req; char *setting_name; + RequestSecretsCaller caller; } GetSecretsInfo; static void @@ -480,7 +481,8 @@ get_secrets_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data) signals[CONNECTION_SECRETS_FAILED], 0, priv->connection, - info->setting_name); + info->setting_name, + info->caller); return; } @@ -511,7 +513,8 @@ get_secrets_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data) signals[CONNECTION_SECRETS_UPDATED], 0, priv->connection, - updated); + updated, + info->caller); } else { nm_warning ("No secrets updated because not valid settings were received!"); } @@ -524,7 +527,10 @@ out: gboolean nm_act_request_request_connection_secrets (NMActRequest *req, const char *setting_name, - gboolean request_new) + gboolean request_new, + RequestSecretsCaller caller, + const char *hint1, + const char *hint2) { DBusGProxy *proxy; DBusGProxyCall *call; @@ -555,9 +561,15 @@ nm_act_request_request_connection_secrets (NMActRequest *req, } /* Empty for now */ - hints = g_ptr_array_new (); + hints = g_ptr_array_sized_new (2); + + if (hint1) + g_ptr_array_add (hints, g_strdup (hint1)); + if (hint2) + g_ptr_array_add (hints, g_strdup (hint2)); info->req = req; + info->caller = caller; call = dbus_g_proxy_begin_call_with_timeout (proxy, "GetSecrets", get_secrets_cb, info, diff --git a/src/nm-activation-request.h b/src/nm-activation-request.h index 3355d98c47..ff26cc4e35 100644 --- a/src/nm-activation-request.h +++ b/src/nm-activation-request.h @@ -38,16 +38,27 @@ typedef struct { GObject parent; } NMActRequest; +typedef enum { + SECRETS_CALLER_NONE = 0, + SECRETS_CALLER_ETHERNET, + SECRETS_CALLER_WIFI, + SECRETS_CALLER_GSM, + SECRETS_CALLER_CDMA, + SECRETS_CALLER_PPP +} RequestSecretsCaller; + typedef struct { GObjectClass parent; /* Signals */ void (*connection_secrets_updated) (NMActRequest *req, NMConnection *connection, - GSList *updated_settings); + GSList *updated_settings, + RequestSecretsCaller caller); void (*connection_secrets_failed) (NMActRequest *req, NMConnection *connection, - const char * setting); + const char *setting, + RequestSecretsCaller caller); void (*properties_changed) (NMActRequest *req, GHashTable *properties); } NMActRequestClass; @@ -62,7 +73,10 @@ NMActRequest *nm_act_request_new (NMConnection *connection, NMConnection *nm_act_request_get_connection (NMActRequest *req); gboolean nm_act_request_request_connection_secrets (NMActRequest *req, const char *setting_name, - gboolean request_new); + gboolean request_new, + RequestSecretsCaller caller, + const char *hint1, + const char *hint2); const char * nm_act_request_get_specific_object (NMActRequest *req); void nm_act_request_set_specific_object (NMActRequest *req, diff --git a/src/nm-cdma-device.c b/src/nm-cdma-device.c index 47c91a2887..900b70a9e6 100644 --- a/src/nm-cdma-device.c +++ b/src/nm-cdma-device.c @@ -214,14 +214,40 @@ real_get_generic_capabilities (NMDevice *dev) static void real_connection_secrets_updated (NMDevice *dev, NMConnection *connection, - GSList *updated_settings) + GSList *updated_settings, + RequestSecretsCaller caller) { NMActRequest *req; gboolean found = FALSE; GSList *iter; - if (nm_device_get_state (dev) != NM_DEVICE_STATE_NEED_AUTH) + if (caller == SECRETS_CALLER_PPP) { + NMPPPManager *ppp_manager; + NMSettingCdma *s_cdma = NULL; + + ppp_manager = nm_serial_device_get_ppp_manager (NM_SERIAL_DEVICE (dev)); + g_return_if_fail (ppp_manager != NULL); + + s_cdma = (NMSettingCdma *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA); + if (!s_cdma) { + /* Shouldn't ever happen */ + nm_ppp_manager_update_secrets (ppp_manager, + nm_device_get_iface (dev), + NULL, + NULL, + "missing CDMA setting; no secrets could be found."); + } else { + nm_ppp_manager_update_secrets (ppp_manager, + nm_device_get_iface (dev), + s_cdma->username ? s_cdma->username : "", + s_cdma->password ? s_cdma->password : "", + NULL); + } return; + } + + g_return_if_fail (caller == SECRETS_CALLER_CDMA); + g_return_if_fail (nm_device_get_state (dev) == NM_DEVICE_STATE_NEED_AUTH); for (iter = updated_settings; iter; iter = g_slist_next (iter)) { const char *setting_name = (const char *) iter->data; diff --git a/src/nm-device-ethernet.c b/src/nm-device-ethernet.c index 956222a632..64bdefb37a 100644 --- a/src/nm-device-ethernet.c +++ b/src/nm-device-ethernet.c @@ -565,7 +565,8 @@ real_get_best_auto_connection (NMDevice *dev, static void real_connection_secrets_updated (NMDevice *dev, NMConnection *connection, - GSList *updated_settings) + GSList *updated_settings, + RequestSecretsCaller caller) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (dev); NMActRequest *req; @@ -575,12 +576,32 @@ real_connection_secrets_updated (NMDevice *dev, if (nm_device_get_state (dev) != NM_DEVICE_STATE_NEED_AUTH) return; - if (priv->ppp_manager) { - /* PPPoE */ - nm_ppp_manager_update_secrets (priv->ppp_manager, nm_device_get_iface (dev), connection); + /* PPPoE? */ + if (caller == SECRETS_CALLER_PPP) { + NMSettingPPPOE *s_pppoe; + + g_assert (priv->ppp_manager); + + s_pppoe = (NMSettingPPPOE *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPPOE); + if (!s_pppoe) { + nm_ppp_manager_update_secrets (priv->ppp_manager, + nm_device_get_iface (dev), + NULL, + NULL, + "missing PPPoE setting; no secrets could be found."); + } else { + nm_ppp_manager_update_secrets (priv->ppp_manager, + nm_device_get_iface (dev), + s_pppoe->username ? s_pppoe->username : "", + s_pppoe->password ? s_pppoe->password : "", + NULL); + } return; } + /* Only caller could be ourselves for 802.1x */ + g_return_if_fail (caller == SECRETS_CALLER_ETHERNET); + for (iter = updated_settings; iter; iter = g_slist_next (iter)) { const char *setting_name = (const char *) iter->data; @@ -715,7 +736,8 @@ link_timeout_cb (gpointer user_data) supplicant_interface_clean (self); nm_device_state_changed (dev, NM_DEVICE_STATE_NEED_AUTH); - nm_act_request_request_connection_secrets (req, setting_name, TRUE); + nm_act_request_request_connection_secrets (req, setting_name, TRUE, + SECRETS_CALLER_ETHERNET, NULL, NULL); return FALSE; @@ -975,7 +997,8 @@ handle_auth_or_fail (NMDeviceEthernet *self, * only ask for new secrets after the first failure. */ get_new = new_secrets ? TRUE : (tries ? TRUE : FALSE); - nm_act_request_request_connection_secrets (req, setting_name, get_new); + nm_act_request_request_connection_secrets (req, setting_name, get_new, + SECRETS_CALLER_ETHERNET, NULL, NULL); g_object_set_data (G_OBJECT (connection), WIRED_SECRETS_TRIES, GUINT_TO_POINTER (++tries)); } else diff --git a/src/nm-device-wifi.c b/src/nm-device-wifi.c index 7a40cf7b64..29a2ba7621 100644 --- a/src/nm-device-wifi.c +++ b/src/nm-device-wifi.c @@ -2042,7 +2042,8 @@ link_timeout_cb (gpointer user_data) " asking for new key.", nm_device_get_iface (dev)); cleanup_association_attempt (self, TRUE); nm_device_state_changed (dev, NM_DEVICE_STATE_NEED_AUTH); - nm_act_request_request_connection_secrets (req, setting_name, TRUE); + nm_act_request_request_connection_secrets (req, setting_name, TRUE, + SECRETS_CALLER_WIFI, NULL, NULL); return FALSE; } @@ -2391,7 +2392,8 @@ handle_auth_or_fail (NMDeviceWifi *self, * only ask for new secrets after the first failure. */ get_new = new_secrets ? TRUE : (tries ? TRUE : FALSE); - nm_act_request_request_connection_secrets (req, setting_name, get_new); + nm_act_request_request_connection_secrets (req, setting_name, get_new, + SECRETS_CALLER_WIFI, NULL, NULL); g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, GUINT_TO_POINTER (++tries)); } else { @@ -2695,12 +2697,15 @@ real_act_stage1_prepare (NMDevice *dev) static void real_connection_secrets_updated (NMDevice *dev, NMConnection *connection, - GSList *updated_settings) + GSList *updated_settings, + RequestSecretsCaller caller) { NMActRequest *req; gboolean valid = FALSE; GSList *iter; + g_return_if_fail (caller == SECRETS_CALLER_WIFI); + if (nm_device_get_state (dev) != NM_DEVICE_STATE_NEED_AUTH) return; diff --git a/src/nm-device.c b/src/nm-device.c index bc3d870506..453b4e0fab 100644 --- a/src/nm-device.c +++ b/src/nm-device.c @@ -1113,18 +1113,20 @@ static void connection_secrets_updated_cb (NMActRequest *req, NMConnection *connection, GSList *updated_settings, + RequestSecretsCaller caller, gpointer user_data) { NMDevice *self = NM_DEVICE (user_data); if (NM_DEVICE_GET_CLASS (self)->connection_secrets_updated) - NM_DEVICE_GET_CLASS (self)->connection_secrets_updated (self, connection, updated_settings); + NM_DEVICE_GET_CLASS (self)->connection_secrets_updated (self, connection, updated_settings, caller); } static void connection_secrets_failed_cb (NMActRequest *req, NMConnection *connection, const char *setting_name, + RequestSecretsCaller caller, gpointer user_data) { NMDevice *self = NM_DEVICE (user_data); diff --git a/src/nm-device.h b/src/nm-device.h index 7c059f9a21..093097bdca 100644 --- a/src/nm-device.h +++ b/src/nm-device.h @@ -91,7 +91,8 @@ struct _NMDeviceClass void (* connection_secrets_updated) (NMDevice *self, NMConnection *connection, - GSList *updated_settings); + GSList *updated_settings, + RequestSecretsCaller caller); gboolean (* check_connection_compatible) (NMDevice *self, NMConnection *connection, diff --git a/src/nm-gsm-device.c b/src/nm-gsm-device.c index 6436857118..a0241963cf 100644 --- a/src/nm-gsm-device.c +++ b/src/nm-gsm-device.c @@ -444,7 +444,12 @@ enter_pin (NMGsmDevice *device, gboolean retry) } else { nm_info ("(%s): GSM %s secret required", nm_device_get_iface (NM_DEVICE (device)), secret_name); nm_device_state_changed (NM_DEVICE (device), NM_DEVICE_STATE_NEED_AUTH); - nm_act_request_request_connection_secrets (req, NM_SETTING_GSM_SETTING_NAME, retry); + nm_act_request_request_connection_secrets (req, + NM_SETTING_GSM_SETTING_NAME, + retry, + SECRETS_CALLER_GSM, + secret_name, + NULL); } } @@ -567,14 +572,40 @@ real_get_generic_capabilities (NMDevice *dev) static void real_connection_secrets_updated (NMDevice *dev, NMConnection *connection, - GSList *updated_settings) + GSList *updated_settings, + RequestSecretsCaller caller) { NMActRequest *req; gboolean found = FALSE; GSList *iter; - if (nm_device_get_state (dev) != NM_DEVICE_STATE_NEED_AUTH) + if (caller == SECRETS_CALLER_PPP) { + NMPPPManager *ppp_manager; + NMSettingGsm *s_gsm = NULL; + + ppp_manager = nm_serial_device_get_ppp_manager (NM_SERIAL_DEVICE (dev)); + g_return_if_fail (ppp_manager != NULL); + + s_gsm = (NMSettingGsm *) nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM); + if (!s_gsm) { + /* Shouldn't ever happen */ + nm_ppp_manager_update_secrets (ppp_manager, + nm_device_get_iface (dev), + NULL, + NULL, + "missing GSM setting; no secrets could be found."); + } else { + nm_ppp_manager_update_secrets (ppp_manager, + nm_device_get_iface (dev), + s_gsm->username ? s_gsm->username : "", + s_gsm->password ? s_gsm->password : "", + NULL); + } return; + } + + g_return_if_fail (caller == SECRETS_CALLER_GSM); + g_return_if_fail (nm_device_get_state (dev) == NM_DEVICE_STATE_NEED_AUTH); for (iter = updated_settings; iter; iter = g_slist_next (iter)) { const char *setting_name = (const char *) iter->data; diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c index 78ec76bc04..6a7258e7fb 100644 --- a/src/ppp-manager/nm-ppp-manager.c +++ b/src/ppp-manager/nm-ppp-manager.c @@ -23,6 +23,8 @@ #include "nm-setting-connection.h" #include "nm-setting-ppp.h" #include "nm-setting-pppoe.h" +#include "nm-setting-gsm.h" +#include "nm-setting-cdma.h" #include "nm-dbus-manager.h" #include "nm-utils.h" #include "nm-marshal.h" @@ -254,30 +256,62 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager, { NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); NMConnection *connection; + NMSettingConnection *s_con; + NMSetting *setting; const char *setting_name; + guint32 tries; + char *hint1 = NULL; remove_timeout_handler (manager); connection = nm_act_request_get_connection (priv->act_req); + s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION)); + g_assert (s_con); + g_assert (s_con->type); + nm_connection_clear_secrets (connection); setting_name = nm_connection_need_secrets (connection, NULL); if (setting_name) { - guint32 tries; - - tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), PPP_MANAGER_SECRET_TRIES)); - nm_act_request_request_connection_secrets (priv->act_req, setting_name, tries == 0 ? TRUE : FALSE); - g_object_set_data (G_OBJECT (connection), PPP_MANAGER_SECRET_TRIES, GUINT_TO_POINTER (++tries)); - priv->pending_secrets_context = context; + setting = nm_connection_get_setting_by_name (connection, setting_name); } else { - GError *err = NULL; + /* Always ask for secrets unless the connection's type setting doesn't + * even exist (which shouldn't happen). Empty username and password are + * valid, but we need to tell the pppd plugin that this is valid by + * sending back blank secrets. + */ + setting = nm_connection_get_setting_by_name (connection, s_con->type); + if (!setting) { + GError *err = NULL; - g_set_error (&err, NM_PPP_MANAGER_ERROR, NM_PPP_MANAGER_ERROR_UNKOWN, - "Cleared secrets, but setting didn't need any secrets."); - - nm_warning ("%s", err->message); - dbus_g_method_return_error (context, err); + g_set_error (&err, NM_PPP_MANAGER_ERROR, NM_PPP_MANAGER_ERROR_UNKOWN, + "Missing type-specific setting; no secrets could be found."); + nm_warning ("%s", err->message); + dbus_g_method_return_error (context, err); + return; + } + setting_name = nm_setting_get_name (setting); } + + /* FIXME: figure out some way of pushing this down to the settings + * themselves and keeping the PPP Manager generic. + */ + if (NM_IS_SETTING_PPPOE (setting)) + hint1 = NM_SETTING_PPPOE_PASSWORD; + else if (NM_IS_SETTING_GSM (setting)) + hint1 = NM_SETTING_GSM_PASSWORD; + else if (NM_IS_SETTING_CDMA (setting)) + hint1 = NM_SETTING_CDMA_PASSWORD; + + tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), PPP_MANAGER_SECRET_TRIES)); + nm_act_request_request_connection_secrets (priv->act_req, + setting_name, + tries == 0 ? TRUE : FALSE, + SECRETS_CALLER_PPP, + hint1, + NULL); + g_object_set_data (G_OBJECT (connection), PPP_MANAGER_SECRET_TRIES, GUINT_TO_POINTER (++tries)); + priv->pending_secrets_context = context; } static gboolean impl_ppp_manager_set_state (NMPPPManager *manager, @@ -764,38 +798,44 @@ nm_ppp_manager_start (NMPPPManager *manager, void nm_ppp_manager_update_secrets (NMPPPManager *manager, - const char *device, - NMConnection *connection) + const char *device, + const char *username, + const char *password, + const char *error_message) { NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); - NMSettingConnection *s_connection; - NMSettingPPPOE *pppoe_setting; g_return_if_fail (NM_IS_PPP_MANAGER (manager)); g_return_if_fail (device != NULL); - g_return_if_fail (NM_IS_CONNECTION (connection)); g_return_if_fail (priv->pending_secrets_context != NULL); - s_connection = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION)); - g_assert (s_connection); + if (error_message) { + g_return_if_fail (username == NULL); + g_return_if_fail (password == NULL); + } else { + g_return_if_fail (username != NULL); + g_return_if_fail (password != NULL); + } - if (strcmp (s_connection->type, NM_SETTING_PPPOE_SETTING_NAME)) - /* Not for us */ - return; + if (error_message) { + GError *err = NULL; - /* This is sort of a hack but... - pppd plugin only ever needs username and password. - Passing the full connection there would mean some bloat: - the plugin would need to link against libnm-util just to parse this. - So instead, let's just send what it needs */ + g_set_error (&err, NM_PPP_MANAGER_ERROR, NM_PPP_MANAGER_ERROR_UNKOWN, error_message); + nm_warning ("%s", error_message); + dbus_g_method_return_error (priv->pending_secrets_context, err); + g_error_free (err); + } else { + /* This is sort of a hack but... + pppd plugin only ever needs username and password. + Passing the full connection there would mean some bloat: + the plugin would need to link against libnm-util just to parse this. + So instead, let's just send what it needs */ - pppoe_setting = NM_SETTING_PPPOE (nm_connection_get_setting (connection, NM_TYPE_SETTING_PPPOE)); - g_assert (pppoe_setting); - - /* FIXME: Do we have to strdup the values here? */ - dbus_g_method_return (priv->pending_secrets_context, - g_strdup (pppoe_setting->username), - g_strdup (pppoe_setting->password)); + /* FIXME: Do we have to strdup the values here? */ + dbus_g_method_return (priv->pending_secrets_context, + g_strdup (username), + g_strdup (password)); + } priv->pending_secrets_context = NULL; } diff --git a/src/ppp-manager/nm-ppp-manager.h b/src/ppp-manager/nm-ppp-manager.h index 38fd1e3e5e..ac6543d88c 100644 --- a/src/ppp-manager/nm-ppp-manager.h +++ b/src/ppp-manager/nm-ppp-manager.h @@ -42,8 +42,10 @@ gboolean nm_ppp_manager_start (NMPPPManager *manager, GError **err); void nm_ppp_manager_update_secrets (NMPPPManager *manager, - const char *device, - NMConnection *connection); + const char *device, + const char *username, + const char *password, + const char *error_message); void nm_ppp_manager_stop (NMPPPManager *manager);