2008-07-01 Dan Williams <dcbw@redhat.com>

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
This commit is contained in:
Dan Williams
2008-07-01 20:21:31 +00:00
parent 2ed3b011d8
commit 8c79f16f5d
12 changed files with 276 additions and 65 deletions

View File

@@ -1,3 +1,56 @@
2008-07-01 Dan Williams <dcbw@redhat.com>
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 <dcbw@redhat.com> 2008-06-30 Dan Williams <dcbw@redhat.com>
* src/nm-device-wifi.c * src/nm-device-wifi.c

View File

@@ -1,7 +1,9 @@
VOID:OBJECT VOID:OBJECT
VOID:OBJECT,STRING VOID:OBJECT,STRING
VOID:OBJECT,STRING,UINT
VOID:OBJECT,UINT VOID:OBJECT,UINT
VOID:OBJECT,POINTER VOID:OBJECT,POINTER
VOID:OBJECT,POINTER,UINT
VOID:POINTER VOID:POINTER
VOID:STRING,STRING,STRING VOID:STRING,STRING,STRING
VOID:UINT,UINT VOID:UINT,UINT

View File

@@ -311,9 +311,9 @@ nm_act_request_class_init (NMActRequestClass *req_class)
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMActRequestClass, connection_secrets_updated), G_STRUCT_OFFSET (NMActRequestClass, connection_secrets_updated),
NULL, NULL, NULL, NULL,
nm_marshal_VOID__OBJECT_POINTER, nm_marshal_VOID__OBJECT_POINTER_UINT,
G_TYPE_NONE, 2, G_TYPE_NONE, 3,
G_TYPE_OBJECT, G_TYPE_POINTER); G_TYPE_OBJECT, G_TYPE_POINTER, G_TYPE_UINT);
signals[CONNECTION_SECRETS_FAILED] = signals[CONNECTION_SECRETS_FAILED] =
g_signal_new ("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_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMActRequestClass, connection_secrets_failed), G_STRUCT_OFFSET (NMActRequestClass, connection_secrets_failed),
NULL, NULL, NULL, NULL,
nm_marshal_VOID__OBJECT_STRING, nm_marshal_VOID__OBJECT_STRING_UINT,
G_TYPE_NONE, 2, G_TYPE_NONE, 3,
G_TYPE_OBJECT, G_TYPE_STRING); G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_UINT);
signals[PROPERTIES_CHANGED] = signals[PROPERTIES_CHANGED] =
nm_properties_changed_signal_new (object_class, nm_properties_changed_signal_new (object_class,
@@ -371,6 +371,7 @@ device_state_changed (NMDevice *device, NMDeviceState state, gpointer user_data)
typedef struct GetSecretsInfo { typedef struct GetSecretsInfo {
NMActRequest *req; NMActRequest *req;
char *setting_name; char *setting_name;
RequestSecretsCaller caller;
} GetSecretsInfo; } GetSecretsInfo;
static void static void
@@ -480,7 +481,8 @@ get_secrets_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
signals[CONNECTION_SECRETS_FAILED], signals[CONNECTION_SECRETS_FAILED],
0, 0,
priv->connection, priv->connection,
info->setting_name); info->setting_name,
info->caller);
return; return;
} }
@@ -511,7 +513,8 @@ get_secrets_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
signals[CONNECTION_SECRETS_UPDATED], signals[CONNECTION_SECRETS_UPDATED],
0, 0,
priv->connection, priv->connection,
updated); updated,
info->caller);
} else { } else {
nm_warning ("No secrets updated because not valid settings were received!"); nm_warning ("No secrets updated because not valid settings were received!");
} }
@@ -524,7 +527,10 @@ out:
gboolean gboolean
nm_act_request_request_connection_secrets (NMActRequest *req, nm_act_request_request_connection_secrets (NMActRequest *req,
const char *setting_name, const char *setting_name,
gboolean request_new) gboolean request_new,
RequestSecretsCaller caller,
const char *hint1,
const char *hint2)
{ {
DBusGProxy *proxy; DBusGProxy *proxy;
DBusGProxyCall *call; DBusGProxyCall *call;
@@ -555,9 +561,15 @@ nm_act_request_request_connection_secrets (NMActRequest *req,
} }
/* Empty for now */ /* 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->req = req;
info->caller = caller;
call = dbus_g_proxy_begin_call_with_timeout (proxy, "GetSecrets", call = dbus_g_proxy_begin_call_with_timeout (proxy, "GetSecrets",
get_secrets_cb, get_secrets_cb,
info, info,

View File

@@ -38,16 +38,27 @@ typedef struct {
GObject parent; GObject parent;
} NMActRequest; } 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 { typedef struct {
GObjectClass parent; GObjectClass parent;
/* Signals */ /* Signals */
void (*connection_secrets_updated) (NMActRequest *req, void (*connection_secrets_updated) (NMActRequest *req,
NMConnection *connection, NMConnection *connection,
GSList *updated_settings); GSList *updated_settings,
RequestSecretsCaller caller);
void (*connection_secrets_failed) (NMActRequest *req, void (*connection_secrets_failed) (NMActRequest *req,
NMConnection *connection, NMConnection *connection,
const char * setting); const char *setting,
RequestSecretsCaller caller);
void (*properties_changed) (NMActRequest *req, GHashTable *properties); void (*properties_changed) (NMActRequest *req, GHashTable *properties);
} NMActRequestClass; } NMActRequestClass;
@@ -62,7 +73,10 @@ NMActRequest *nm_act_request_new (NMConnection *connection,
NMConnection *nm_act_request_get_connection (NMActRequest *req); NMConnection *nm_act_request_get_connection (NMActRequest *req);
gboolean nm_act_request_request_connection_secrets (NMActRequest *req, gboolean nm_act_request_request_connection_secrets (NMActRequest *req,
const char *setting_name, 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); const char * nm_act_request_get_specific_object (NMActRequest *req);
void nm_act_request_set_specific_object (NMActRequest *req, void nm_act_request_set_specific_object (NMActRequest *req,

View File

@@ -214,14 +214,40 @@ real_get_generic_capabilities (NMDevice *dev)
static void static void
real_connection_secrets_updated (NMDevice *dev, real_connection_secrets_updated (NMDevice *dev,
NMConnection *connection, NMConnection *connection,
GSList *updated_settings) GSList *updated_settings,
RequestSecretsCaller caller)
{ {
NMActRequest *req; NMActRequest *req;
gboolean found = FALSE; gboolean found = FALSE;
GSList *iter; 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; 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)) { for (iter = updated_settings; iter; iter = g_slist_next (iter)) {
const char *setting_name = (const char *) iter->data; const char *setting_name = (const char *) iter->data;

View File

@@ -565,7 +565,8 @@ real_get_best_auto_connection (NMDevice *dev,
static void static void
real_connection_secrets_updated (NMDevice *dev, real_connection_secrets_updated (NMDevice *dev,
NMConnection *connection, NMConnection *connection,
GSList *updated_settings) GSList *updated_settings,
RequestSecretsCaller caller)
{ {
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (dev); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (dev);
NMActRequest *req; NMActRequest *req;
@@ -575,12 +576,32 @@ real_connection_secrets_updated (NMDevice *dev,
if (nm_device_get_state (dev) != NM_DEVICE_STATE_NEED_AUTH) if (nm_device_get_state (dev) != NM_DEVICE_STATE_NEED_AUTH)
return; return;
if (priv->ppp_manager) { /* PPPoE? */
/* PPPoE */ if (caller == SECRETS_CALLER_PPP) {
nm_ppp_manager_update_secrets (priv->ppp_manager, nm_device_get_iface (dev), connection); 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; 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)) { for (iter = updated_settings; iter; iter = g_slist_next (iter)) {
const char *setting_name = (const char *) iter->data; const char *setting_name = (const char *) iter->data;
@@ -715,7 +736,8 @@ link_timeout_cb (gpointer user_data)
supplicant_interface_clean (self); supplicant_interface_clean (self);
nm_device_state_changed (dev, NM_DEVICE_STATE_NEED_AUTH); 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; return FALSE;
@@ -975,7 +997,8 @@ handle_auth_or_fail (NMDeviceEthernet *self,
* only ask for new secrets after the first failure. * only ask for new secrets after the first failure.
*/ */
get_new = new_secrets ? TRUE : (tries ? TRUE : FALSE); 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)); g_object_set_data (G_OBJECT (connection), WIRED_SECRETS_TRIES, GUINT_TO_POINTER (++tries));
} else } else

View File

@@ -2042,7 +2042,8 @@ link_timeout_cb (gpointer user_data)
" asking for new key.", nm_device_get_iface (dev)); " asking for new key.", nm_device_get_iface (dev));
cleanup_association_attempt (self, TRUE); cleanup_association_attempt (self, TRUE);
nm_device_state_changed (dev, NM_DEVICE_STATE_NEED_AUTH); 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; return FALSE;
} }
@@ -2391,7 +2392,8 @@ handle_auth_or_fail (NMDeviceWifi *self,
* only ask for new secrets after the first failure. * only ask for new secrets after the first failure.
*/ */
get_new = new_secrets ? TRUE : (tries ? TRUE : FALSE); 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)); g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, GUINT_TO_POINTER (++tries));
} else { } else {
@@ -2695,12 +2697,15 @@ real_act_stage1_prepare (NMDevice *dev)
static void static void
real_connection_secrets_updated (NMDevice *dev, real_connection_secrets_updated (NMDevice *dev,
NMConnection *connection, NMConnection *connection,
GSList *updated_settings) GSList *updated_settings,
RequestSecretsCaller caller)
{ {
NMActRequest *req; NMActRequest *req;
gboolean valid = FALSE; gboolean valid = FALSE;
GSList *iter; GSList *iter;
g_return_if_fail (caller == SECRETS_CALLER_WIFI);
if (nm_device_get_state (dev) != NM_DEVICE_STATE_NEED_AUTH) if (nm_device_get_state (dev) != NM_DEVICE_STATE_NEED_AUTH)
return; return;

View File

@@ -1113,18 +1113,20 @@ static void
connection_secrets_updated_cb (NMActRequest *req, connection_secrets_updated_cb (NMActRequest *req,
NMConnection *connection, NMConnection *connection,
GSList *updated_settings, GSList *updated_settings,
RequestSecretsCaller caller,
gpointer user_data) gpointer user_data)
{ {
NMDevice *self = NM_DEVICE (user_data); NMDevice *self = NM_DEVICE (user_data);
if (NM_DEVICE_GET_CLASS (self)->connection_secrets_updated) 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 static void
connection_secrets_failed_cb (NMActRequest *req, connection_secrets_failed_cb (NMActRequest *req,
NMConnection *connection, NMConnection *connection,
const char *setting_name, const char *setting_name,
RequestSecretsCaller caller,
gpointer user_data) gpointer user_data)
{ {
NMDevice *self = NM_DEVICE (user_data); NMDevice *self = NM_DEVICE (user_data);

View File

@@ -91,7 +91,8 @@ struct _NMDeviceClass
void (* connection_secrets_updated) (NMDevice *self, void (* connection_secrets_updated) (NMDevice *self,
NMConnection *connection, NMConnection *connection,
GSList *updated_settings); GSList *updated_settings,
RequestSecretsCaller caller);
gboolean (* check_connection_compatible) (NMDevice *self, gboolean (* check_connection_compatible) (NMDevice *self,
NMConnection *connection, NMConnection *connection,

View File

@@ -444,7 +444,12 @@ enter_pin (NMGsmDevice *device, gboolean retry)
} else { } else {
nm_info ("(%s): GSM %s secret required", nm_device_get_iface (NM_DEVICE (device)), secret_name); 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_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 static void
real_connection_secrets_updated (NMDevice *dev, real_connection_secrets_updated (NMDevice *dev,
NMConnection *connection, NMConnection *connection,
GSList *updated_settings) GSList *updated_settings,
RequestSecretsCaller caller)
{ {
NMActRequest *req; NMActRequest *req;
gboolean found = FALSE; gboolean found = FALSE;
GSList *iter; 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; 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)) { for (iter = updated_settings; iter; iter = g_slist_next (iter)) {
const char *setting_name = (const char *) iter->data; const char *setting_name = (const char *) iter->data;

View File

@@ -23,6 +23,8 @@
#include "nm-setting-connection.h" #include "nm-setting-connection.h"
#include "nm-setting-ppp.h" #include "nm-setting-ppp.h"
#include "nm-setting-pppoe.h" #include "nm-setting-pppoe.h"
#include "nm-setting-gsm.h"
#include "nm-setting-cdma.h"
#include "nm-dbus-manager.h" #include "nm-dbus-manager.h"
#include "nm-utils.h" #include "nm-utils.h"
#include "nm-marshal.h" #include "nm-marshal.h"
@@ -254,30 +256,62 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
{ {
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
NMConnection *connection; NMConnection *connection;
NMSettingConnection *s_con;
NMSetting *setting;
const char *setting_name; const char *setting_name;
guint32 tries;
char *hint1 = NULL;
remove_timeout_handler (manager); remove_timeout_handler (manager);
connection = nm_act_request_get_connection (priv->act_req); 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); nm_connection_clear_secrets (connection);
setting_name = nm_connection_need_secrets (connection, NULL); setting_name = nm_connection_need_secrets (connection, NULL);
if (setting_name) { if (setting_name) {
guint32 tries; setting = nm_connection_get_setting_by_name (connection, setting_name);
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;
} else { } 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, g_set_error (&err, NM_PPP_MANAGER_ERROR, NM_PPP_MANAGER_ERROR_UNKOWN,
"Cleared secrets, but setting didn't need any secrets."); "Missing type-specific setting; no secrets could be found.");
nm_warning ("%s", err->message);
nm_warning ("%s", err->message); dbus_g_method_return_error (context, err);
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, static gboolean impl_ppp_manager_set_state (NMPPPManager *manager,
@@ -764,38 +798,44 @@ nm_ppp_manager_start (NMPPPManager *manager,
void void
nm_ppp_manager_update_secrets (NMPPPManager *manager, nm_ppp_manager_update_secrets (NMPPPManager *manager,
const char *device, const char *device,
NMConnection *connection) const char *username,
const char *password,
const char *error_message)
{ {
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); 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 (NM_IS_PPP_MANAGER (manager));
g_return_if_fail (device != NULL); g_return_if_fail (device != NULL);
g_return_if_fail (NM_IS_CONNECTION (connection));
g_return_if_fail (priv->pending_secrets_context != NULL); g_return_if_fail (priv->pending_secrets_context != NULL);
s_connection = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION)); if (error_message) {
g_assert (s_connection); 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)) if (error_message) {
/* Not for us */ GError *err = NULL;
return;
/* This is sort of a hack but... g_set_error (&err, NM_PPP_MANAGER_ERROR, NM_PPP_MANAGER_ERROR_UNKOWN, error_message);
pppd plugin only ever needs username and password. nm_warning ("%s", error_message);
Passing the full connection there would mean some bloat: dbus_g_method_return_error (priv->pending_secrets_context, err);
the plugin would need to link against libnm-util just to parse this. g_error_free (err);
So instead, let's just send what it needs */ } 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)); /* FIXME: Do we have to strdup the values here? */
g_assert (pppoe_setting); dbus_g_method_return (priv->pending_secrets_context,
g_strdup (username),
/* FIXME: Do we have to strdup the values here? */ g_strdup (password));
dbus_g_method_return (priv->pending_secrets_context, }
g_strdup (pppoe_setting->username),
g_strdup (pppoe_setting->password));
priv->pending_secrets_context = NULL; priv->pending_secrets_context = NULL;
} }

View File

@@ -42,8 +42,10 @@ gboolean nm_ppp_manager_start (NMPPPManager *manager,
GError **err); GError **err);
void nm_ppp_manager_update_secrets (NMPPPManager *manager, void nm_ppp_manager_update_secrets (NMPPPManager *manager,
const char *device, const char *device,
NMConnection *connection); const char *username,
const char *password,
const char *error_message);
void nm_ppp_manager_stop (NMPPPManager *manager); void nm_ppp_manager_stop (NMPPPManager *manager);