From patchwork Tue Jul 3 00:29:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: akhouderchah@chromium.org X-Patchwork-Id: 938550 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="o2T2cqDr"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="LW20WtrO"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41Kdtd1L0Wz9s2g for ; Tue, 3 Jul 2018 19:22:17 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=hmDOC5hBtzVoxZ1CU4cgP6VZxtiYF36ppT0It/IMDy0=; b=o2T 2cqDrswyUhXranvvo8F6lvwmBPOWHUstNs51VkDAoWOGzVHAx/+5xuNEb3NxJaQAo3eitQpbg1USd VZnkT8wASGcB842MnRAa6AW7nB00owhI2jBhAoFPy/HQeIcRYct9InN/K6wAJtJqcjFFfDYz6XKP0 7B/eDVnu3Rr1aRbAWHRwTbZZYqhtkEmMBtaJhZM1DT9yG9ylEdDLvxA1LqIR7p1AqAS5FcLmOwOus 5Qn6ouQyBgqlvdw0bEZ2jDzGIyxjfJoUmOBTBSC2XOlJ8GLU+Rf0icutw6lABepBxvrvY4tZlTRV0 O3JgihG9QzMfBN7syiSVjE2C91KKVQg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1faHVY-0007qJ-2b; Tue, 03 Jul 2018 09:22:00 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fa9Cc-0004hc-N8 for hostap@lists.infradead.org; Tue, 03 Jul 2018 00:29:56 +0000 Received: by mail-pf0-x244.google.com with SMTP id b17-v6so110994pfi.0 for ; Mon, 02 Jul 2018 17:29:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=/Fz4GhSiRB44xj2WOW1NCvQQg3rQJD2I2hR1nJM/RO0=; b=LW20WtrOr7Xqm9tec+UqQdyeOgjevGupQeVQrRGmg98vQrIrFtIVYe/bq1k5JHoT9W NTiI6NESEOb46/s2T+biSJkiaMXWj6d8sjCzqoLRDEEd+IiUhdq5ywNNuUYV8efZPbfl sO3yy2svdw8KS0wPYtsiOhlXICeUuVY5PMuy8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=/Fz4GhSiRB44xj2WOW1NCvQQg3rQJD2I2hR1nJM/RO0=; b=ncG2sTI8SrOVmB7S8cEJro5cBAElUdE6d7omUo/fGcQEAMSZNAE8SFiWD7QgnbJCza 1TTZpe/RfblaDzjCZHrRYHpAiG0oauyA76rQlkKiY7jSneLmmblbjfHaIRXQdAybA+qq O8Y1BKo0ujz0Z0uGq6+gJdNk56ZHW8atAVdgq83YWx1WoQOGJNGdKxW59RrOtOC5DC4/ uCBkiz+ROhCpHF7PW+9zPdxyIW91x8f7uVgx6e+PqzqgyefhjcFl6sa9Ev4qRKxjWczU aipz9sU07PpNkWSRdQZQiqBWO69QKrDnjbgauPwZF1yn3of2rhKd1asGs+agFFR4DUvd uEJw== X-Gm-Message-State: APt69E0yZPGACOL4bdjdYMw5lwljDcwlhgigRBadwQgqyjT957ZQBi6X DloPZWh7VFAVIovYOqm/U2SySw== X-Google-Smtp-Source: ADUXVKJG5PLCV4scMmk6IJv1gRPYmHeSXzPvK0cVysDdARDGbxeaj4TyNURc0a+/DQMeTak9v1XqxQ== X-Received: by 2002:a65:538e:: with SMTP id x14-v6mr23096322pgq.388.1530577783661; Mon, 02 Jul 2018 17:29:43 -0700 (PDT) Received: from akhouderchah.mtv.corp.google.com ([2620:0:1000:1511:965b:9cd2:6c20:46f0]) by smtp.gmail.com with ESMTPSA id s27-v6sm40568339pfk.184.2018.07.02.17.29.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 17:29:43 -0700 (PDT) From: akhouderchah@chromium.org To: j@w1.fi Subject: [PATCH] dbus: Expose authentication status to D-Bus Date: Mon, 2 Jul 2018 17:29:24 -0700 Message-Id: <20180703002924.119226-1-akhouderchah@chromium.org> X-Mailer: git-send-email 2.18.0.399.gad0ab374a1-goog X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180702_172954_779132_1BD130B5 X-CRM114-Status: GOOD ( 14.05 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400e:c00:0:0:0:244 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-Mailman-Approved-At: Tue, 03 Jul 2018 02:21:59 -0700 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: akhouderchah@chromium.org, hostap@lists.infradead.org MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Alex Khouderchah wpa_supplicant currently logs CTRL-EVENT-AUTH-FAILED errors when authentication fails, but doesn't expose any property to the D-Bus interface related to this. This change adds the "AuthStatusCode" property to the interface, which contains the IEEE 802.11 status code of the last authentication. Signed-off-by: Alex Khouderchah --- doc/dbus.doxygen | 5 +++++ wpa_supplicant/dbus/dbus_new.c | 9 +++++++++ wpa_supplicant/dbus/dbus_new.h | 1 + wpa_supplicant/dbus/dbus_new_handlers.c | 21 +++++++++++++++++++++ wpa_supplicant/dbus/dbus_new_handlers.h | 1 + wpa_supplicant/events.c | 2 ++ wpa_supplicant/notify.c | 8 ++++++++ wpa_supplicant/notify.h | 1 + wpa_supplicant/wpa_supplicant_i.h | 3 +++ 9 files changed, 51 insertions(+) diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen index 2ca40ae9b..833995bc9 100644 --- a/doc/dbus.doxygen +++ b/doc/dbus.doxygen @@ -769,6 +769,11 @@ fi.w1.wpa_supplicant1.CreateInterface.

The most recent IEEE 802.11 status code for association rejection.

+
  • +

    AuthStatusCode - i - (read)

    +

    The most recent IEEE 802.11 status code for authentication rejection.

    +
  • +
  • EapolVersion - s - (read/write)

    IEEE 802.1X/EAPOL version number

    diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index e0f16bbda..b8e9154a9 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -2158,6 +2158,10 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s, prop = "DisconnectReason"; flush = TRUE; break; + case WPAS_DBUS_PROP_AUTH_STATUS_CODE: + prop = "AuthStatusCode"; + flush = TRUE; + break; case WPAS_DBUS_PROP_ASSOC_STATUS_CODE: prop = "AssocStatusCode"; flush = TRUE; @@ -3484,6 +3488,11 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = { NULL, NULL }, + { "AuthStatusCode", WPAS_DBUS_NEW_IFACE_INTERFACE, "i", + wpas_dbus_getter_auth_status_code, + NULL, + NULL + }, { "AssocStatusCode", WPAS_DBUS_NEW_IFACE_INTERFACE, "i", wpas_dbus_getter_assoc_status_code, NULL, diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h index e68acb7a1..8f17a3148 100644 --- a/wpa_supplicant/dbus/dbus_new.h +++ b/wpa_supplicant/dbus/dbus_new.h @@ -30,6 +30,7 @@ enum wpas_dbus_prop { WPAS_DBUS_PROP_CURRENT_AUTH_MODE, WPAS_DBUS_PROP_BSSS, WPAS_DBUS_PROP_DISCONNECT_REASON, + WPAS_DBUS_PROP_AUTH_STATUS_CODE, WPAS_DBUS_PROP_ASSOC_STATUS_CODE, }; diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index a3c98fadd..d76c612ca 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -3088,6 +3088,27 @@ dbus_bool_t wpas_dbus_getter_fast_reauth( &fast_reauth, error); } +/** + * wpas_dbus_getter_auth_status_code - Get most recent reason for auth reject + * @iter: Pointer to incoming dbus message iter + * @error: Location to store error on failure + * @user_data: Function specific data + * Returns: TRUE on success, FALSE on failure + * + * Getter for "AuthStatusCode" property. The reason is negative if it is + * locally generated. + */ +dbus_bool_t wpas_dbus_getter_auth_status_code( + const struct wpa_dbus_property_desc *property_desc, + DBusMessageIter *iter, DBusError *error, void *user_data) +{ + struct wpa_supplicant *wpa_s = user_data; + dbus_int32_t reason = wpa_s->auth_status_code; + + return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32, + &reason, error); +} + /** * wpas_dbus_setter_fast_reauth - Control fast diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h index 26652ad3d..e1550da31 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.h +++ b/wpa_supplicant/dbus/dbus_new_handlers.h @@ -146,6 +146,7 @@ DECLARE_ACCESSOR(wpas_dbus_setter_pmf); DECLARE_ACCESSOR(wpas_dbus_getter_fast_reauth); DECLARE_ACCESSOR(wpas_dbus_setter_fast_reauth); DECLARE_ACCESSOR(wpas_dbus_getter_disconnect_reason); +DECLARE_ACCESSOR(wpas_dbus_getter_auth_status_code); DECLARE_ACCESSOR(wpas_dbus_getter_disassociate_reason); DECLARE_ACCESSOR(wpas_dbus_getter_assoc_status_code); DECLARE_ACCESSOR(wpas_dbus_getter_bss_expire_age); diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index fb77f1dbd..6dc865e56 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -4027,6 +4027,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, "FST: MB IEs updated from auth IE"); #endif /* CONFIG_FST */ sme_event_auth(wpa_s, data); + wpa_s->auth_status_code = data->auth.status_code; + wpas_notify_auth_status_code(wpa_s); break; case EVENT_ASSOC: #ifdef CONFIG_TESTING_OPTIONS diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index 83df04f39..04a82c18b 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -139,6 +139,14 @@ void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s) wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON); } +void wpas_notify_auth_status_code(struct wpa_supplicant *wpa_s) +{ + if (wpa_s->p2p_mgmt) + return; + + wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AUTH_STATUS_CODE); +} + void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s) { diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h index 3ca933c76..9801c2818 100644 --- a/wpa_supplicant/notify.h +++ b/wpa_supplicant/notify.h @@ -23,6 +23,7 @@ void wpas_notify_state_changed(struct wpa_supplicant *wpa_s, enum wpa_states new_state, enum wpa_states old_state); void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s); +void wpas_notify_auth_status_code(struct wpa_supplicant *wpa_s); void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s); void wpas_notify_network_changed(struct wpa_supplicant *wpa_s); void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s); diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 2b0dca0ef..8efba3f70 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1014,6 +1014,9 @@ struct wpa_supplicant { /* WLAN_REASON_* reason codes. Negative if locally generated. */ int disconnect_reason; + /* WLAN_STATUS_* status codes from Authentication Response frame. */ + u16 auth_status_code; + /* WLAN_STATUS_* status codes from (Re)Association Response frame. */ u16 assoc_status_code;