summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2015-07-16 09:44:59 -0500
committerThomas Haller <thaller@redhat.com>2015-07-16 17:11:02 +0200
commit171b54b11c3ab8cc8353deb12b8a9eaf9d4434f2 (patch)
tree63287ab2aac5bd6fd1d6a5ea9c5777ec8970da4c
parent5316d4dec78dc56cf456de25d9abe4f356b93276 (diff)
downloadNetworkManager-171b54b11c3ab8cc8353deb12b8a9eaf9d4434f2.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 (cherry picked from commit 6a81daf1cb1fe68feb37296adcbcbcf7d2289d54)
-rw-r--r--src/nm-connectivity.c36
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: