diff options
author | Dan Williams <dcbw@redhat.com> | 2015-07-16 09:44:59 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2015-07-16 10:04:44 -0500 |
commit | 6a81daf1cb1fe68feb37296adcbcbcf7d2289d54 (patch) | |
tree | cfc66a4900e490e9615f669280e10030bc4a5869 /src/nm-connectivity.c | |
parent | 2a3a4eb16f9119bf434a28adc94c2684da8fd5e4 (diff) | |
download | NetworkManager-6a81daf1cb1fe68feb37296adcbcbcf7d2289d54.tar.gz |
connectivity: explicitly check for 511/Network Authentication Required (RFC6585) (bgo #670394)
If the response affirmatively indicates you're behind a portal, we might as well
use that information.
https://bugzilla.gnome.org/show_bug.cgi?id=670394
Diffstat (limited to 'src/nm-connectivity.c')
-rw-r--r-- | src/nm-connectivity.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/nm-connectivity.c b/src/nm-connectivity.c index 81ac8f9de4..cb1423dbad 100644 --- a/src/nm-connectivity.c +++ b/src/nm-connectivity.c @@ -151,25 +151,31 @@ nm_connectivity_check_cb (SoupSession *session, SoupMessage *msg, gpointer user_ goto done; } - /* Check headers; if we find the NM-specific one we're done */ - nm_header = soup_message_headers_get_one (msg->response_headers, "X-NetworkManager-Status"); - if (g_strcmp0 (nm_header, "online") == 0) { - _LOGD ("check for uri '%s' with Status header successful.", uri); - new_state = NM_CONNECTIVITY_FULL; - } else if (msg->status_code == SOUP_STATUS_OK) { - /* check response */ - if (msg->response_body->data && g_str_has_prefix (msg->response_body->data, response)) { - _LOGD ("check for uri '%s' successful.", uri); + if (msg->status_code == 511) { + _LOGD ("check for uri '%s' returned status '%d %s'; captive portal present.", + uri, msg->status_code, msg->reason_phrase); + new_state = NM_CONNECTIVITY_PORTAL; + } else { + /* Check headers; if we find the NM-specific one we're done */ + nm_header = soup_message_headers_get_one (msg->response_headers, "X-NetworkManager-Status"); + if (g_strcmp0 (nm_header, "online") == 0) { + _LOGD ("check for uri '%s' with Status header successful.", uri); new_state = NM_CONNECTIVITY_FULL; + } else if (msg->status_code == SOUP_STATUS_OK) { + /* check response */ + if (msg->response_body->data && g_str_has_prefix (msg->response_body->data, response)) { + _LOGD ("check for uri '%s' successful.", uri); + new_state = NM_CONNECTIVITY_FULL; + } else { + _LOGI ("check for uri '%s' did not match expected response '%s'; assuming captive portal.", + uri, response); + new_state = NM_CONNECTIVITY_PORTAL; + } } else { - _LOGI ("check for uri '%s' did not match expected response '%s'; assuming captive portal.", - uri, response); + _LOGI ("check for uri '%s' returned status '%d %s'; assuming captive portal.", + uri, msg->status_code, msg->reason_phrase); new_state = NM_CONNECTIVITY_PORTAL; } - } else { - _LOGI ("check for uri '%s' returned status '%d %s'; assuming captive portal.", - uri, msg->status_code, msg->reason_phrase); - new_state = NM_CONNECTIVITY_PORTAL; } done: |