diff options
Diffstat (limited to 'vpn/plugins/pptp.c')
-rwxr-xr-x | vpn/plugins/pptp.c | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/vpn/plugins/pptp.c b/vpn/plugins/pptp.c index 3dc93b03..5fc861e4 100755 --- a/vpn/plugins/pptp.c +++ b/vpn/plugins/pptp.c @@ -137,7 +137,8 @@ static int pptp_notify(DBusMessage *msg, struct vpn_provider *provider) DBG("authentication failure"); vpn_provider_set_string(provider, "PPTP.User", NULL); - vpn_provider_set_string(provider, "PPTP.Password", NULL); + vpn_provider_set_string_hide_value(provider, "PPTP.Password", + NULL); return VPN_STATE_AUTH_FAILURE; } @@ -282,16 +283,28 @@ struct request_input_reply { static void request_input_reply(DBusMessage *reply, void *user_data) { struct request_input_reply *pptp_reply = user_data; + struct pptp_private_data *data; const char *error = NULL; char *username = NULL, *password = NULL; char *key; DBusMessageIter iter, dict; + int err; DBG("provider %p", pptp_reply->provider); - if (!reply || dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) { - if (reply) - error = dbus_message_get_error_name(reply); + if (!reply) + goto done; + + data = pptp_reply->user_data; + + err = vpn_agent_check_and_process_reply_error(reply, + pptp_reply->provider, data->task, data->cb, + data->user_data); + if (err) { + /* Ensure cb is called only once */ + data->cb = NULL; + data->user_data = NULL; + error = dbus_message_get_error_name(reply); goto done; } @@ -384,6 +397,9 @@ static int request_input(struct vpn_provider *provider, connman_dbus_dict_open(&iter, &dict); + if (vpn_provider_get_authentication_errors(provider)) + vpn_agent_append_auth_failure(&dict, provider, NULL); + vpn_agent_append_user_info(&dict, provider, "PPTP.User"); vpn_agent_append_host_and_name(&dict, provider); @@ -424,13 +440,6 @@ static int run_connect(struct vpn_provider *provider, char *str; int err, i; - host = vpn_provider_get_string(provider, "Host"); - if (!host) { - connman_error("Host not set; cannot enable VPN"); - err = -EINVAL; - goto done; - } - if (!username || !password) { DBG("Cannot connect username %s password %p", username, password); @@ -440,6 +449,7 @@ static int run_connect(struct vpn_provider *provider, DBG("username %s password %p", username, password); + host = vpn_provider_get_string(provider, "Host"); str = g_strdup_printf("%s %s --nolaunchpppd --loglevel 2", PPTP, host); if (!str) { @@ -594,7 +604,12 @@ static int pptp_error_code(struct vpn_provider *provider, int exit_code) static void pptp_disconnect(struct vpn_provider *provider) { - vpn_provider_set_string(provider, "PPTP.Password", NULL); + if (!provider) + return; + + vpn_provider_set_string_hide_value(provider, "PPTP.Password", NULL); + + connman_agent_cancel(provider); } static struct vpn_driver vpn_driver = { |