Send connman mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."
Today's Topics:
1. [PATCH 07/10] service: Implement function to set service
autoconnect value (Jussi Laakkonen)
2. [PATCH 08/10] provider: Implement function to set VPN service
autoconnect value (Jussi Laakkonen)
3. [PATCH 09/10] error: Implement OperationCanceled error type
(Jussi Laakkonen)
4. [PATCH 10/10] vpn: Handle OperationCanceled D-Bus message
reply (Jussi Laakkonen)
----------------------------------------------------------------------
Message: 1
Date: Mon, 24 Jun 2019 17:37:50 +0300
From: Jussi Laakkonen <[email protected]>
To: [email protected]
Subject: [PATCH 07/10] service: Implement function to set service
autoconnect value
Message-ID: <[email protected]>
Setter function for service autoconnect value. Calls
autoconnect_changed() if change took place. Can be used to check if the
change was made to, e.g., trigger saving of a service.
---
include/service.h | 2 ++
src/service.c | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/include/service.h b/include/service.h
index 97fdf7d5..4a129b49 100644
--- a/include/service.h
+++ b/include/service.h
@@ -131,6 +131,8 @@ const char *connman_service_get_proxy_url(struct
connman_service *service);
const char *connman_service_get_proxy_autoconfig(struct connman_service
*service);
bool connman_service_get_favorite(struct connman_service *service);
bool connman_service_get_autoconnect(struct connman_service *service);
+bool connman_service_set_autoconnect(struct connman_service *service,
+ bool autoconnect);
/* Return non-zero value to terminate the loop, zero to continue */
typedef int (* connman_service_iterate_cb) (struct connman_service *service,
diff --git a/src/service.c b/src/service.c
index 0c5e647e..f71a3de7 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1705,6 +1705,18 @@ static void autoconnect_changed(struct connman_service
*service)
DBUS_TYPE_BOOLEAN, &autoconnect);
}
+bool connman_service_set_autoconnect(struct connman_service *service,
+ bool autoconnect)
+{
+ if (service->autoconnect == autoconnect)
+ return false;
+
+ service->autoconnect = autoconnect;
+ autoconnect_changed(service);
+
+ return true;
+}
+
static void append_security(DBusMessageIter *iter, void *user_data)
{
struct connman_service *service = user_data;
--
2.20.1
------------------------------
Message: 2
Date: Mon, 24 Jun 2019 17:37:51 +0300
From: Jussi Laakkonen <[email protected]>
To: [email protected]
Subject: [PATCH 08/10] provider: Implement function to set VPN service
autoconnect value
Message-ID: <[email protected]>
Add connman_provider_set_autoconnect() for setting the VPN autoconnect
value. If a change took place save the VPN service.
It is imperative to save the VPN service when autoconnect changes since
otherwise the change is done only to run-time service settings and not
written to disk if user has canceled VPN agent dialog, for example.
Otherwise the data within connman and service file is out of sync, and
next restart of connman will be a race between each VPNs that were
attempted to connect but canceled by user.
---
include/provider.h | 2 ++
src/provider.c | 11 +++++++++++
2 files changed, 13 insertions(+)
diff --git a/include/provider.h b/include/provider.h
index d28651ad..aa563edf 100644
--- a/include/provider.h
+++ b/include/provider.h
@@ -111,6 +111,8 @@ int connman_provider_set_domain(struct connman_provider
*provider,
const char *domain);
int connman_provider_set_nameservers(struct connman_provider *provider,
char * const *nameservers);
+void connman_provider_set_autoconnect(struct connman_provider *provider,
+ bool flag);
int connman_provider_append_route(struct connman_provider *provider,
const char *key, const char *value);
diff --git a/src/provider.c b/src/provider.c
index 9d9741e1..33671b2f 100644
--- a/src/provider.c
+++ b/src/provider.c
@@ -579,6 +579,17 @@ int connman_provider_set_nameservers(struct
connman_provider *provider,
return 0;
}
+void connman_provider_set_autoconnect(struct connman_provider *provider,
+ bool flag)
+{
+ if (provider && provider->vpn_service) {
+ /* Save VPN service if autoconnect value changes */
+ if (connman_service_set_autoconnect(provider->vpn_service,
+ flag))
+ __connman_service_save(provider->vpn_service);
+ }
+}
+
static void unregister_provider(gpointer data)
{
struct connman_provider *provider = data;
--
2.20.1
------------------------------
Message: 3
Date: Mon, 24 Jun 2019 17:37:52 +0300
From: Jussi Laakkonen <[email protected]>
To: [email protected]
Subject: [PATCH 09/10] error: Implement OperationCanceled error type
Message-ID: <[email protected]>
ECANCELED error should be handled with ".OperationCanceled" D-Bus error
type. This is returned, e.g., by VPN agent when user has canceled the
dialog.
---
src/connman.h | 1 +
src/error.c | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/src/connman.h b/src/connman.h
index 8101c7b2..e64739f2 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -54,6 +54,7 @@ DBusMessage *__connman_error_operation_aborted(DBusMessage
*msg);
DBusMessage *__connman_error_operation_timeout(DBusMessage *msg);
DBusMessage *__connman_error_invalid_service(DBusMessage *msg);
DBusMessage *__connman_error_invalid_property(DBusMessage *msg);
+DBusMessage *__connman_error_operation_canceled(DBusMessage *msg);
int __connman_manager_init(void);
void __connman_manager_cleanup(void);
diff --git a/src/error.c b/src/error.c
index 4f24ae25..660e57d3 100644
--- a/src/error.c
+++ b/src/error.c
@@ -67,6 +67,8 @@ DBusMessage *__connman_error_failed(DBusMessage *msg, int
errnum)
return __connman_error_in_progress(msg);
case ENOKEY:
return __connman_error_passphrase_required(msg);
+ case ECANCELED:
+ return __connman_error_operation_canceled(msg);
}
return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
@@ -185,3 +187,9 @@ DBusMessage *__connman_error_invalid_property(DBusMessage
*msg)
return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
".InvalidProperty", "Invalid property");
}
+
+DBusMessage *__connman_error_operation_canceled(DBusMessage *msg)
+{
+ return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
+ ".OperationCanceled", "Operation canceled");
+}
--
2.20.1
------------------------------
Message: 4
Date: Mon, 24 Jun 2019 17:37:53 +0300
From: Jussi Laakkonen <[email protected]>
To: [email protected]
Subject: [PATCH 10/10] vpn: Handle OperationCanceled D-Bus message
reply
Message-ID: <[email protected]>
OperationCanceled (ECANCELED) is returned by connman-vpnd if the VPN
agent used to input credentials for a VPN is canceled. This needs to be
handled in plugins/vpn.c:connect_reply() and with this error
autoconnect should be disabled for the VPN service.
---
plugins/vpn.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/plugins/vpn.c b/plugins/vpn.c
index 66d7661b..6157dffb 100644
--- a/plugins/vpn.c
+++ b/plugins/vpn.c
@@ -477,6 +477,9 @@ static int errorstr2val(const char *error) {
if (g_strcmp0(error, CONNMAN_ERROR_INTERFACE ".AlreadyConnected") == 0)
return -EISCONN;
+ if (g_strcmp0(error, CONNMAN_ERROR_INTERFACE ".OperationCanceled") == 0)
+ return -ECANCELED;
+
return -ECONNREFUSED;
}
@@ -499,7 +502,16 @@ static void connect_reply(DBusPendingCall *call, void
*user_data)
if (dbus_set_error_from_message(&error, reply)) {
int err = errorstr2val(error.name);
- if (err != -EINPROGRESS) {
+ /*
+ * ECANCELED means that user has canceled authentication
+ * dialog. That's not really an error, it's part of a normal
+ * workflow. We also take it as a request to turn autoconnect
+ * off, in case if it was on.
+ */
+ if (err == -ECANCELED) {
+ DBG("%s connect canceled", data->path);
+ connman_provider_set_autoconnect(data->provider, false);
+ } else if (err != -EINPROGRESS) {
connman_error("Connect reply: %s (%s)", error.message,
error.name);
DBG("data %p cb_data %p", data, cb_data);
--
2.20.1
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 44, Issue 8
**************************************