connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] service: Fix native connection with wrong passphrase
       [not found] <20220121102736.3323889-1-Emmanuel.VAUTRIN@cpexterne.org>
@ 2022-01-21 10:36 ` VAUTRIN Emmanuel (Canal Plus Prestataire)
  2022-01-23 13:23   ` Daniel Wagner
  0 siblings, 1 reply; 6+ messages in thread
From: VAUTRIN Emmanuel (Canal Plus Prestataire) @ 2022-01-21 10:36 UTC (permalink / raw)
  To: connman

[-- Attachment #1: Type: text/plain, Size: 1466 bytes --]

When a native connection fails with a wrong passphrase, the user still
needs to be informed, via the agent.
However, in this case, the associated service is automatically
disconnected, canceling the pending agent requests.
The invalid key error shall be reported before this cancellation.

Commit b9a0a039ccc5 ("service: Report errors to user in native mode")
---
 src/service.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/service.c b/src/service.c
index 9141b85dbe9c..b2c01640bd5d 100644
--- a/src/service.c
+++ b/src/service.c
@@ -6023,6 +6023,13 @@ static int service_indicate_state(struct connman_service *service)
                 break;
 
         case CONNMAN_SERVICE_STATE_IDLE:
+               if ((old_state == CONNMAN_SERVICE_STATE_FAILURE &&
+       service->connect_reason == CONNMAN_SERVICE_CONNECT_REASON_NATIVE &&
+       service->error == CONNMAN_SERVICE_ERROR_INVALID_KEY)) {
+                       __connman_service_clear_error(service);
+                       service_complete(service);
+               }
+
                 if (old_state != CONNMAN_SERVICE_STATE_DISCONNECT)
                         __connman_service_disconnect(service);
 
-- 
2.25.1

> service_list_sort() and __connman_connection_update_gateway() are
> already called after the switch. This seems to be redundant.
Indeed Daniel, you are perfectly right.

Please find the well formated patch in attachment.

Emmanuel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: v3-0001-service-Fix-native-connection-with-wrong-passphra.patch --]
[-- Type: text/x-patch; name="v3-0001-service-Fix-native-connection-with-wrong-passphra.patch", Size: 1299 bytes --]

From a20048bfd8df802d4d5e191c6f6861726474c6c5 Mon Sep 17 00:00:00 2001
From: Emmanuel VAUTRIN <Emmanuel.VAUTRIN@cpexterne.org>
Date: Wed, 15 Dec 2021 15:06:59 +0100
Subject: [PATCH v3] service: Fix native connection with wrong passphrase

When a native connection fails with a wrong passphrase, the user still
needs to be informed, via the agent.
However, in this case, the associated service is automatically
disconnected, canceling the pending agent requests.
The invalid key error shall be reported before this cancellation.

Commit b9a0a039ccc5 ("service: Report errors to user in native mode")
---
 src/service.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/service.c b/src/service.c
index 9141b85dbe9c..b2c01640bd5d 100644
--- a/src/service.c
+++ b/src/service.c
@@ -6023,6 +6023,13 @@ static int service_indicate_state(struct connman_service *service)
 		break;
 
 	case CONNMAN_SERVICE_STATE_IDLE:
+		if ((old_state == CONNMAN_SERVICE_STATE_FAILURE &&
+	service->connect_reason == CONNMAN_SERVICE_CONNECT_REASON_NATIVE &&
+	service->error == CONNMAN_SERVICE_ERROR_INVALID_KEY)) {
+			__connman_service_clear_error(service);
+			service_complete(service);
+		}
+
 		if (old_state != CONNMAN_SERVICE_STATE_DISCONNECT)
 			__connman_service_disconnect(service);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] service: Fix native connection with wrong passphrase
  2022-01-21 10:36 ` [PATCH v3] service: Fix native connection with wrong passphrase VAUTRIN Emmanuel (Canal Plus Prestataire)
@ 2022-01-23 13:23   ` Daniel Wagner
       [not found]     ` <MRZP264MB1544FAB6EF32AED6479EC82D935D9@MRZP264MB1544.FRAP264.PROD.OUTLOOK.COM>
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Wagner @ 2022-01-23 13:23 UTC (permalink / raw)
  To: VAUTRIN Emmanuel (Canal Plus Prestataire); +Cc: connman

On Fri, Jan 21, 2022 at 10:36:52AM +0000, VAUTRIN Emmanuel (Canal Plus Prestataire) wrote:
> When a native connection fails with a wrong passphrase, the user still
> needs to be informed, via the agent.
> However, in this case, the associated service is automatically
> disconnected, canceling the pending agent requests.
> The invalid key error shall be reported before this cancellation.
> 
> Commit b9a0a039ccc5 ("service: Report errors to user in native mode")

Patch applied after reformatting slightly.

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] service: Fix native connection with wrong passphrase
       [not found]     ` <MRZP264MB1544FAB6EF32AED6479EC82D935D9@MRZP264MB1544.FRAP264.PROD.OUTLOOK.COM>
@ 2022-01-23 16:46       ` Daniel Wagner
  2022-01-23 17:04         ` VAUTRIN Emmanuel (Canal Plus Prestataire)
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Wagner @ 2022-01-23 16:46 UTC (permalink / raw)
  To: VAUTRIN Emmanuel (Canal Plus Prestataire); +Cc: connman

Hi Emmanuel,

On Sun, Jan 23, 2022 at 02:14:31PM +0000, VAUTRIN Emmanuel (Canal Plus Prestataire) wrote:
> For the formatting, as mentionned, it seems that
> gmail / office365 are both automatically reformating the messages,
> so I always add the original patch in attachment.

I used the patch from the attachment, not the email. I was not happy
with the indention levels and the useless brackets.

Daniel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH v3] service: Fix native connection with wrong passphrase
  2022-01-23 16:46       ` Daniel Wagner
@ 2022-01-23 17:04         ` VAUTRIN Emmanuel (Canal Plus Prestataire)
  2022-01-24  8:25           ` Daniel Wagner
  0 siblings, 1 reply; 6+ messages in thread
From: VAUTRIN Emmanuel (Canal Plus Prestataire) @ 2022-01-23 17:04 UTC (permalink / raw)
  To: connman

> I used the patch from the attachment, not the email. I was not happy
> with the indention levels and the useless brackets.
Ah sorry, I haven't noticed the double parentheses.
For the indentation, in order to respect the 80 line max size,
I never know how to format the test conditions. Is it 2 extra tabs to
differ from the execution code (1 extra tab)?

Emmanuel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] service: Fix native connection with wrong passphrase
  2022-01-23 17:04         ` VAUTRIN Emmanuel (Canal Plus Prestataire)
@ 2022-01-24  8:25           ` Daniel Wagner
  2022-01-24  8:36             ` VAUTRIN Emmanuel (Canal Plus Prestataire)
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Wagner @ 2022-01-24  8:25 UTC (permalink / raw)
  To: VAUTRIN Emmanuel (Canal Plus Prestataire); +Cc: connman

On Sun, Jan 23, 2022 at 05:04:33PM +0000, VAUTRIN Emmanuel (Canal Plus Prestataire) wrote:
> > I used the patch from the attachment, not the email. I was not happy
> > with the indention levels and the useless brackets.
> Ah sorry, I haven't noticed the double parentheses.
> For the indentation, in order to respect the 80 line max size,
> I never know how to format the test conditions. Is it 2 extra tabs to
> differ from the execution code (1 extra tab)?

There are no fixed rules. But the usual thing is to stay consistent with
the rest of the code. There are always variations between files but I
try to keep it consistent at least within a file. Obviously, these days
we have clang-reformat & Co and we could use them to get everything
consistently formatted. Though this boat has sailed long time ago.

Daniel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH v3] service: Fix native connection with wrong passphrase
  2022-01-24  8:25           ` Daniel Wagner
@ 2022-01-24  8:36             ` VAUTRIN Emmanuel (Canal Plus Prestataire)
  0 siblings, 0 replies; 6+ messages in thread
From: VAUTRIN Emmanuel (Canal Plus Prestataire) @ 2022-01-24  8:36 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: connman

> There are no fixed rules. But the usual thing is to stay consistent with
> the rest of the code. There are always variations between files but I
> try to keep it consistent at least within a file.
Alright Daniel, I will try to follow this.

Emmanuel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-24  8:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20220121102736.3323889-1-Emmanuel.VAUTRIN@cpexterne.org>
2022-01-21 10:36 ` [PATCH v3] service: Fix native connection with wrong passphrase VAUTRIN Emmanuel (Canal Plus Prestataire)
2022-01-23 13:23   ` Daniel Wagner
     [not found]     ` <MRZP264MB1544FAB6EF32AED6479EC82D935D9@MRZP264MB1544.FRAP264.PROD.OUTLOOK.COM>
2022-01-23 16:46       ` Daniel Wagner
2022-01-23 17:04         ` VAUTRIN Emmanuel (Canal Plus Prestataire)
2022-01-24  8:25           ` Daniel Wagner
2022-01-24  8:36             ` VAUTRIN Emmanuel (Canal Plus Prestataire)

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).