From: "VAUTRIN Emmanuel (Canal Plus Prestataire)" <Emmanuel.VAUTRIN@cpexterne.org>
To: "connman@lists.linux.dev" <connman@lists.linux.dev>
Subject: [PATCH] service: Fix hidden service with wrong passphrase
Date: Mon, 27 Feb 2023 17:19:37 +0000 [thread overview]
Message-ID: <MRZP264MB154400DDFBFE8E6BE89E250193AF9@MRZP264MB1544.FRAP264.PROD.OUTLOOK.COM> (raw)
[-- Attachment #1: Type: text/plain, Size: 2065 bytes --]
Two cases need to be fixed during the connection to a hidden service
with a wrong passphrase:
* the invalid key error shall be reported to the user,
* another attempt to connect to this hidden service shall be possible,
and succeed with the right passphrase
---
src/service.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/service.c b/src/service.c
index 6f31adb33d6a..06d02322f437 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3241,6 +3241,9 @@ int __connman_service_check_passphrase(enum connman_service_security security,
return 0;
}
+static void set_error(struct connman_service *service,
+ enum connman_service_error error);
+
int __connman_service_set_passphrase(struct connman_service *service,
const char *passphrase)
{
@@ -3265,6 +3268,10 @@ int __connman_service_set_passphrase(struct connman_service *service,
connman_network_set_string(service->network, "WiFi.Passphrase",
service->passphrase);
+ if (service->hidden_service &&
+ service->error == CONNMAN_SERVICE_ERROR_INVALID_KEY)
+ set_error(service, CONNMAN_SERVICE_ERROR_UNKNOWN);
+
return 0;
}
@@ -3617,9 +3624,6 @@ void __connman_service_wispr_start(struct connman_service *service,
__connman_wispr_start(service, type);
}
-static void set_error(struct connman_service *service,
- enum connman_service_error error);
-
static DBusMessage *set_property(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
@@ -6824,6 +6828,13 @@ int __connman_service_connect(struct connman_service *service,
service->pending = NULL;
}
+ if (service->hidden_service &&
+ service->error == CONNMAN_SERVICE_ERROR_INVALID_KEY) {
+ __connman_service_indicate_error(service,
+ CONNMAN_SERVICE_ERROR_INVALID_KEY);
+ return err;
+ }
+
err = __connman_agent_request_passphrase_input(service,
request_input_cb,
dbus_sender,
--
2.25.1
Hello,
Please find the right formatted patch in attachment.
Emmanuel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-service-Fix-hidden-service-with-wrong-passphrase.patch --]
[-- Type: text/x-patch; name="0001-service-Fix-hidden-service-with-wrong-passphrase.patch", Size: 2161 bytes --]
From f9d13c1cedb1d67fd1fd22f4e2d2970dc233ec77 Mon Sep 17 00:00:00 2001
From: Emmanuel VAUTRIN <Emmanuel.VAUTRIN@cpexterne.org>
Date: Mon, 27 Feb 2023 14:50:25 +0100
Subject: [PATCH] service: Fix hidden service with wrong passphrase
Two cases need to be fixed during the connection to a hidden service
with a wrong passphrase:
* the invalid key error shall be reported to the user,
* another attempt to connect to this hidden service shall be possible,
and succeed with the right passphrase
---
src/service.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/service.c b/src/service.c
index 6f31adb33d6a..06d02322f437 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3241,6 +3241,9 @@ int __connman_service_check_passphrase(enum connman_service_security security,
return 0;
}
+static void set_error(struct connman_service *service,
+ enum connman_service_error error);
+
int __connman_service_set_passphrase(struct connman_service *service,
const char *passphrase)
{
@@ -3265,6 +3268,10 @@ int __connman_service_set_passphrase(struct connman_service *service,
connman_network_set_string(service->network, "WiFi.Passphrase",
service->passphrase);
+ if (service->hidden_service &&
+ service->error == CONNMAN_SERVICE_ERROR_INVALID_KEY)
+ set_error(service, CONNMAN_SERVICE_ERROR_UNKNOWN);
+
return 0;
}
@@ -3617,9 +3624,6 @@ void __connman_service_wispr_start(struct connman_service *service,
__connman_wispr_start(service, type);
}
-static void set_error(struct connman_service *service,
- enum connman_service_error error);
-
static DBusMessage *set_property(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
@@ -6824,6 +6828,13 @@ int __connman_service_connect(struct connman_service *service,
service->pending = NULL;
}
+ if (service->hidden_service &&
+ service->error == CONNMAN_SERVICE_ERROR_INVALID_KEY) {
+ __connman_service_indicate_error(service,
+ CONNMAN_SERVICE_ERROR_INVALID_KEY);
+ return err;
+ }
+
err = __connman_agent_request_passphrase_input(service,
request_input_cb,
dbus_sender,
--
2.25.1
next reply other threads:[~2023-02-27 17:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-27 17:19 VAUTRIN Emmanuel (Canal Plus Prestataire) [this message]
2023-03-22 14:14 ` [PATCH] service: Fix hidden service with wrong passphrase VAUTRIN Emmanuel (Canal Plus Prestataire)
2023-04-11 7:28 ` Daniel Wagner
2023-04-11 9:00 ` VAUTRIN Emmanuel (Canal Plus Prestataire)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MRZP264MB154400DDFBFE8E6BE89E250193AF9@MRZP264MB1544.FRAP264.PROD.OUTLOOK.COM \
--to=emmanuel.vautrin@cpexterne.org \
--cc=connman@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).