connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Set regdom to follow timezone setting as optional feature
@ 2022-04-05 14:31 Jussi Laakkonen
  2022-04-05 14:31 ` [PATCH 1/4] main: Add path to localtime to config options Jussi Laakkonen
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Jussi Laakkonen @ 2022-04-05 14:31 UTC (permalink / raw)
  To: connman

This patchset adds an optional feature to make regdom follow the timezone set
on the system. This feature is useful on systems where no cellular is available
or there is no SIM present, as the regdom on WLAN would stay on default (US)
and some channels would be unreachable. Enabling the "RegdomFollowsTimezone"
config option makes Ofono plugin not to change regdom when the cellular network
has indicated a change on country. By following the timezone, which can be
also updated by the cellular stack if set to automatic configuration (might
need a external service to do this), would then eventually propagate to ConnMan.

In order to fully faciliate this on different configurations also the watching
of the localtime is improved. This is done by allowing to configure it as on
some systems there may be an external service controlling localtime setting,
e.g, by defining /etc/localtime a permanent symlink to the service's own
changeable symlink. Furthermore, inotify then needed to react also to IN_CREATE
event in timezone.c in order to detect changes on symlink.

Regdom is read from /usr/share/zoneinfo/zone1970.tab and the first ISO3166
country code set for the current timezone is used. This is done both on startup
and when the content/link of the localtime set has changed.

Jussi Laakkonen (4):
  main: Add path to localtime to config options.
  main: Add RegdomFollowsTimezone option for regdom changes
  timezone: Change regdom along timezone, use localtime config
  ofono: Do not change regdom when it follows timezone

 doc/connman.conf.5.in |   9 ++++
 plugins/ofono.c       |   5 +++
 src/main.c            |  32 ++++++++++++++
 src/timezone.c        | 100 +++++++++++++++++++++++++++++++++++++++---
 4 files changed, 141 insertions(+), 5 deletions(-)

-- 
2.30.2


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

* [PATCH 1/4] main: Add path to localtime to config options.
  2022-04-05 14:31 [PATCH 0/4] Set regdom to follow timezone setting as optional feature Jussi Laakkonen
@ 2022-04-05 14:31 ` Jussi Laakkonen
  2022-04-05 14:31 ` [PATCH 2/4] main: Add RegdomFollowsTimezone option for regdom changes Jussi Laakkonen
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Jussi Laakkonen @ 2022-04-05 14:31 UTC (permalink / raw)
  To: connman

The path to localtime is kept as default /etc/localtime but in some
cases external daemon manages the localtime by changing its own symlink
to which /etc/localtime points to. Thus, ConnMan would not see any
change in the localtime changes.
---
 doc/connman.conf.5.in |  3 +++
 src/main.c            | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/doc/connman.conf.5.in b/doc/connman.conf.5.in
index 82cceb72..a64b8c6d 100644
--- a/doc/connman.conf.5.in
+++ b/doc/connman.conf.5.in
@@ -205,6 +205,9 @@ address will be chosen instead (according to RFC3927). If an address conflict
 occurs for an address offered via DHCP, ConnMan send a DHCP DECLINE once and
 for the second conflict resort to finding an IPv4LL address.
 Default value is false.
+.TP
+.BI Localtime= string
+Path to localtime file. Defaults to /etc/localtime.
 .SH "EXAMPLE"
 The following example configuration disables hostname updates and enables
 ethernet tethering.
diff --git a/src/main.c b/src/main.c
index bf6ccad5..13b7e4bc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -54,6 +54,7 @@
  */
 #define DEFAULT_ONLINE_CHECK_INITIAL_INTERVAL 1
 #define DEFAULT_ONLINE_CHECK_MAX_INTERVAL 12
+#define DEFAULT_LOCALTIME "/etc/localtime"
 
 #define MAINFILE "main.conf"
 #define CONFIGMAINFILE CONFIGDIR "/" MAINFILE
@@ -107,6 +108,7 @@ static struct {
 	bool auto_connect_roaming_services;
 	bool acd;
 	bool use_gateways_as_timeservers;
+	char *localtime;
 } connman_settings  = {
 	.bg_scan = true,
 	.pref_timeservers = NULL,
@@ -134,6 +136,7 @@ static struct {
 	.auto_connect_roaming_services = false,
 	.acd = false,
 	.use_gateways_as_timeservers = false,
+	.localtime = NULL,
 };
 
 #define CONF_BG_SCAN                    "BackgroundScanning"
@@ -162,6 +165,7 @@ static struct {
 #define CONF_AUTO_CONNECT_ROAMING_SERVICES "AutoConnectRoamingServices"
 #define CONF_ACD                        "AddressConflictDetection"
 #define CONF_USE_GATEWAYS_AS_TIMESERVERS "UseGatewaysAsTimeservers"
+#define CONF_LOCALTIME                  "Localtime"
 
 static const char *supported_options[] = {
 	CONF_BG_SCAN,
@@ -190,6 +194,7 @@ static const char *supported_options[] = {
 	CONF_AUTO_CONNECT_ROAMING_SERVICES,
 	CONF_ACD,
 	CONF_USE_GATEWAYS_AS_TIMESERVERS,
+	CONF_LOCALTIME,
 	NULL
 };
 
@@ -569,6 +574,15 @@ static void parse_config(GKeyFile *config)
 				CONF_USE_GATEWAYS_AS_TIMESERVERS, &error);
 	if (!error)
 		connman_settings.use_gateways_as_timeservers = boolean;
+
+	g_clear_error(&error);
+
+	string = __connman_config_get_string(config, "General",
+				CONF_LOCALTIME, &error);
+	if (!error)
+		connman_settings.localtime = string;
+	else
+		g_free(string);
 
 	g_clear_error(&error);
 }
@@ -761,6 +775,10 @@ char *connman_setting_get_string(const char *key)
 			return option_wifi;
 	}
 
+	if (g_str_equal(key, CONF_LOCALTIME))
+		return connman_settings.localtime ?
+			connman_settings.localtime : DEFAULT_LOCALTIME;
+
 	return NULL;
 }
 
@@ -1037,6 +1055,7 @@ int main(int argc, char *argv[])
 	g_free(connman_settings.vendor_class_id);
 	g_free(connman_settings.online_check_ipv4_url);
 	g_free(connman_settings.online_check_ipv6_url);
+	g_free(connman_settings.localtime);
 
 	g_free(option_debug);
 	g_free(option_wifi);
-- 
2.30.2


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

* [PATCH 2/4] main: Add RegdomFollowsTimezone option for regdom changes
  2022-04-05 14:31 [PATCH 0/4] Set regdom to follow timezone setting as optional feature Jussi Laakkonen
  2022-04-05 14:31 ` [PATCH 1/4] main: Add path to localtime to config options Jussi Laakkonen
@ 2022-04-05 14:31 ` Jussi Laakkonen
  2022-04-05 14:31 ` [PATCH 3/4] timezone: Change regdom along timezone, use localtime config Jussi Laakkonen
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Jussi Laakkonen @ 2022-04-05 14:31 UTC (permalink / raw)
  To: connman

This boolean option toggles whether the regdom is being changed along
timezone changes or not. By default the feature is off.
---
 doc/connman.conf.5.in |  6 ++++++
 src/main.c            | 13 +++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/doc/connman.conf.5.in b/doc/connman.conf.5.in
index a64b8c6d..cb36e9fb 100644
--- a/doc/connman.conf.5.in
+++ b/doc/connman.conf.5.in
@@ -208,6 +208,12 @@ Default value is false.
 .TP
 .BI Localtime= string
 Path to localtime file. Defaults to /etc/localtime.
+.TP
+.BI RegdomFollowsTimezone= true\ \fR|\fB\ false
+Enable regdomain to be changed along timezone changes. With this option set to
+true each time the timezone changes the first present ISO3166 country code is
+being read from /usr/share/zoneinfo/zone1970.tab and set as regdom value.
+Default value is false.
 .SH "EXAMPLE"
 The following example configuration disables hostname updates and enables
 ethernet tethering.
diff --git a/src/main.c b/src/main.c
index 13b7e4bc..7b68a930 100644
--- a/src/main.c
+++ b/src/main.c
@@ -109,6 +109,7 @@ static struct {
 	bool acd;
 	bool use_gateways_as_timeservers;
 	char *localtime;
+	bool regdom_follows_timezone;
 } connman_settings  = {
 	.bg_scan = true,
 	.pref_timeservers = NULL,
@@ -166,6 +167,7 @@ static struct {
 #define CONF_ACD                        "AddressConflictDetection"
 #define CONF_USE_GATEWAYS_AS_TIMESERVERS "UseGatewaysAsTimeservers"
 #define CONF_LOCALTIME                  "Localtime"
+#define CONF_REGDOM_FOLLOWS_TIMEZONE    "RegdomFollowsTimezone"
 
 static const char *supported_options[] = {
 	CONF_BG_SCAN,
@@ -195,6 +197,7 @@ static const char *supported_options[] = {
 	CONF_ACD,
 	CONF_USE_GATEWAYS_AS_TIMESERVERS,
 	CONF_LOCALTIME,
+	CONF_REGDOM_FOLLOWS_TIMEZONE,
 	NULL
 };
 
@@ -585,6 +588,13 @@ static void parse_config(GKeyFile *config)
 		g_free(string);
 
 	g_clear_error(&error);
+
+	boolean = __connman_config_get_bool(config, "General",
+				CONF_REGDOM_FOLLOWS_TIMEZONE, &error);
+	if (!error)
+		connman_settings.regdom_follows_timezone = boolean;
+
+	g_clear_error(&error);
 }
 
 static int config_init(const char *file)
@@ -817,6 +827,9 @@ bool connman_setting_get_bool(const char *key)
 	if (g_str_equal(key, CONF_USE_GATEWAYS_AS_TIMESERVERS))
 		return connman_settings.use_gateways_as_timeservers;
 
+	if (g_str_equal(key, CONF_REGDOM_FOLLOWS_TIMEZONE))
+		return connman_settings.regdom_follows_timezone;
+
 	return false;
 }
 
-- 
2.30.2


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

* [PATCH 3/4] timezone: Change regdom along timezone, use localtime config
  2022-04-05 14:31 [PATCH 0/4] Set regdom to follow timezone setting as optional feature Jussi Laakkonen
  2022-04-05 14:31 ` [PATCH 1/4] main: Add path to localtime to config options Jussi Laakkonen
  2022-04-05 14:31 ` [PATCH 2/4] main: Add RegdomFollowsTimezone option for regdom changes Jussi Laakkonen
@ 2022-04-05 14:31 ` Jussi Laakkonen
  2022-04-07  9:27   ` [PATCH v2 " Jussi Laakkonen
  2022-04-05 14:31 ` [PATCH 4/4] ofono: Do not change regdom when it follows timezone Jussi Laakkonen
  2022-04-08  7:20 ` [PATCH 0/4] Set regdom to follow timezone setting as optional feature Daniel Wagner
  4 siblings, 1 reply; 7+ messages in thread
From: Jussi Laakkonen @ 2022-04-05 14:31 UTC (permalink / raw)
  To: connman

This is an optional feature and when enabled with RegdomFollowsTimezone
config option the regdom is changed when the timezone changes. This
feature is useful in cases when the devices without a cellular
functionality or a SIM card to set the regdom for WiFi via regdom
changes indicated by Ofono plugin are remaining the default setting (US).
As a result some region specific channels cannot be utilized with WiFi.

The ISO3166 country code is read from /usr/share/zoneinfo/zone1970.tab
using the set timezone. This is done at startup and when there is an
inotify event for the localtime. The first ISO3166 country code set on
the line is used.

Timezone.c now uses localtime configured in main.conf. It may be a
symlink as external service can manage localtime so IN_CREATE event
is added for inotify watch.
---
 src/timezone.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 95 insertions(+), 5 deletions(-)

diff --git a/src/timezone.c b/src/timezone.c
index cc499097..484d3ecb 100644
--- a/src/timezone.c
+++ b/src/timezone.c
@@ -38,9 +38,9 @@
 
 #include "connman.h"
 
-#define ETC_LOCALTIME		"/etc/localtime"
 #define ETC_SYSCONFIG_CLOCK	"/etc/sysconfig/clock"
 #define USR_SHARE_ZONEINFO	"/usr/share/zoneinfo"
+#define USR_SHARE_ZONEINFO_MAP	USR_SHARE_ZONEINFO "/zone1970.tab"
 
 static char *read_key_file(const char *pathname, const char *key)
 {
@@ -228,18 +228,99 @@ static char *find_origin(void *src_map, struct stat *src_st,
 	return NULL;
 }
 
+static char *get_timezone_alpha2(const char *zone)
+{
+	GIOChannel *channel;
+	struct stat st;
+	char **tokens;
+	char *line;
+	char *alpha2 = NULL;
+	gsize len;
+	int fd;
+
+	if (!zone)
+		return NULL;
+
+	fd = open(USR_SHARE_ZONEINFO_MAP, O_RDONLY | O_CLOEXEC);
+	if (fd < 0) {
+		connman_warn("failed to open zoneinfo map %s",
+							USR_SHARE_ZONEINFO_MAP);
+		return NULL;
+	}
+
+	if (fstat(fd, &st) < 0) {
+		connman_warn("zoneinfo map does not exist");
+		close(fd);
+		return NULL;
+	}
+
+	channel = g_io_channel_unix_new(fd);
+	if (!channel) {
+		connman_warn("failed to create io channel for %s",
+							USR_SHARE_ZONEINFO_MAP);
+		close(fd);
+		return NULL;
+	}
+
+	DBG("read %s for %s", USR_SHARE_ZONEINFO_MAP, zone);
+	g_io_channel_set_encoding(channel, "UTF-8", NULL);
+
+	while (g_io_channel_read_line(channel, &line, &len, NULL, NULL) ==
+							G_IO_STATUS_NORMAL) {
+		if (!line || !*line || *line == '#' || *line == '\n')
+			continue;
+
+		/* File format: Countrycodes Coordinates TZ Comments */
+		tokens = g_strsplit_set(line, " \t", 4);
+		if (!tokens) {
+			connman_warn("line %s failed to parse", line);
+			continue;
+		}
+
+		if (g_strv_length(tokens) >= 3 && !g_strcmp0(
+						g_strstrip(tokens[2]), zone)) {
+			/*
+			 * Multiple country codes can be listed, use the first
+			 * 2 chars.
+			 */
+			alpha2 = g_strndup(g_strstrip(tokens[0]), 2);
+			if (strlen(alpha2) != 2) {
+				connman_warn("Invalid ISO3166 code %s", alpha2);
+				g_free(alpha2);
+				alpha2 = NULL;
+				break;
+			}
+
+			DBG("Zone %s ISO3166 country code %s", zone, alpha2);
+		}
+
+		g_strfreev(tokens);
+		g_free(line);
+
+		if (alpha2)
+			break;
+	}
+
+	g_io_channel_shutdown(channel, FALSE, NULL);
+	close(fd);
+
+	return alpha2;
+}
+
 char *__connman_timezone_lookup(void)
 {
 	struct stat st;
 	void *map;
 	int fd;
 	char *zone;
+	char *alpha2;
 
 	zone = read_key_file(ETC_SYSCONFIG_CLOCK, "ZONE");
 
 	DBG("sysconfig zone %s", zone);
 
-	fd = open(ETC_LOCALTIME, O_RDONLY | O_CLOEXEC);
+	fd = open(connman_setting_get_string("Localtime"),
+							O_RDONLY | O_CLOEXEC);
 	if (fd < 0) {
 		g_free(zone);
 		return NULL;
@@ -283,6 +364,15 @@ done:
 
 	DBG("localtime zone %s", zone);
 
+	if (connman_setting_get_bool("RegdomFollowsTimezone")) {
+		alpha2 = get_timezone_alpha2(zone);
+		if (alpha2) {
+			DBG("change regdom to %s", alpha2);
+			connman_technology_set_regdom(alpha2);
+			g_free(alpha2);
+		}
+	}
+
 	return zone;
 }
 
@@ -338,7 +428,7 @@ int __connman_timezone_change(const char *zone)
 		return -EIO;
 	}
 
-	err = write_file(map, &st, ETC_LOCALTIME);
+	err = write_file(map, &st, connman_setting_get_string("Localtime"));
 
 	munmap(map, st.st_size);
 
@@ -432,9 +522,9 @@ int __connman_timezone_init(void)
 
 	g_io_channel_unref(channel);
 
-	dirname = g_path_get_dirname(ETC_LOCALTIME);
+	dirname = g_path_get_dirname(connman_setting_get_string("Localtime"));
 
-	wd = inotify_add_watch(fd, dirname, IN_DONT_FOLLOW |
+	wd = inotify_add_watch(fd, dirname, IN_CREATE | IN_DONT_FOLLOW |
 						IN_CLOSE_WRITE | IN_MOVED_TO);
 
 	g_free(dirname);
-- 
2.30.2


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

* [PATCH 4/4] ofono: Do not change regdom when it follows timezone
  2022-04-05 14:31 [PATCH 0/4] Set regdom to follow timezone setting as optional feature Jussi Laakkonen
                   ` (2 preceding siblings ...)
  2022-04-05 14:31 ` [PATCH 3/4] timezone: Change regdom along timezone, use localtime config Jussi Laakkonen
@ 2022-04-05 14:31 ` Jussi Laakkonen
  2022-04-08  7:20 ` [PATCH 0/4] Set regdom to follow timezone setting as optional feature Daniel Wagner
  4 siblings, 0 replies; 7+ messages in thread
From: Jussi Laakkonen @ 2022-04-05 14:31 UTC (permalink / raw)
  To: connman

---
 plugins/ofono.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/plugins/ofono.c b/plugins/ofono.c
index f0bd3c5d..8bb53949 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -40,6 +40,7 @@
 #include <connman/dbus.h>
 #include <connman/log.h>
 #include <connman/technology.h>
+#include <connman/setting.h>
 
 #include "mcc.h"
 
@@ -1710,6 +1711,10 @@ static void netreg_update_regdom(struct modem_data *modem,
 	char *alpha2;
 	int mcc;
 
+	/* Do not change regdom here if it is set to follow timezone. */
+	if (connman_setting_get_bool("RegdomFollowsTimezone"))
+		return;
+
 	dbus_message_iter_get_basic(value, &mobile_country_code);
 
 	DBG("%s MobileContryCode %s", modem->path, mobile_country_code);
-- 
2.30.2


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

* [PATCH v2 3/4] timezone: Change regdom along timezone, use localtime config
  2022-04-05 14:31 ` [PATCH 3/4] timezone: Change regdom along timezone, use localtime config Jussi Laakkonen
@ 2022-04-07  9:27   ` Jussi Laakkonen
  0 siblings, 0 replies; 7+ messages in thread
From: Jussi Laakkonen @ 2022-04-07  9:27 UTC (permalink / raw)
  To: connman

This is an optional feature and when enabled with RegdomFollowsTimezone
config option the regdom is changed when the timezone changes. This
feature is useful in cases when the devices without a cellular
functionality or a SIM card to set the regdom for WiFi via regdom
changes indicated by Ofono plugin are remaining the default setting (US).
As a result some region specific channels cannot be utilized with WiFi.

The ISO3166 country code is read from /usr/share/zoneinfo/zone1970.tab
using the set timezone. This is done at startup and when there is an
inotify event for the localtime. The first ISO3166 country code set on
the line is used.

Timezone.c now uses localtime configured in main.conf. It may be a
symlink as external service can manage localtime so IN_CREATE event
is added for inotify watch.
---
Changes since v2:
 - Fix memory leaks and restructure
 - Check that zone1970.tab is a regular file
 - Forgot the "-v1" when sending original, my bad, sorry.

 src/timezone.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 100 insertions(+), 5 deletions(-)

diff --git a/src/timezone.c b/src/timezone.c
index cc499097..f8d192df 100644
--- a/src/timezone.c
+++ b/src/timezone.c
@@ -38,9 +38,9 @@
 
 #include "connman.h"
 
-#define ETC_LOCALTIME		"/etc/localtime"
 #define ETC_SYSCONFIG_CLOCK	"/etc/sysconfig/clock"
 #define USR_SHARE_ZONEINFO	"/usr/share/zoneinfo"
+#define USR_SHARE_ZONEINFO_MAP	USR_SHARE_ZONEINFO "/zone1970.tab"
 
 static char *read_key_file(const char *pathname, const char *key)
 {
@@ -228,18 +228,104 @@ static char *find_origin(void *src_map, struct stat *src_st,
 	return NULL;
 }
 
+static char *get_timezone_alpha2(const char *zone)
+{
+	GIOChannel *channel;
+	struct stat st;
+	char **tokens;
+	char *line;
+	char *alpha2 = NULL;
+	gsize len;
+	int fd;
+
+	if (!zone)
+		return NULL;
+
+	fd = open(USR_SHARE_ZONEINFO_MAP, O_RDONLY | O_CLOEXEC);
+	if (fd < 0) {
+		connman_warn("failed to open zoneinfo map %s",
+							USR_SHARE_ZONEINFO_MAP);
+		return NULL;
+	}
+
+	if (fstat(fd, &st) < 0 || !S_ISREG(st.st_mode)) {
+		connman_warn("zoneinfo map does not exist/not regular file");
+		close(fd);
+		return NULL;
+	}
+
+	channel = g_io_channel_unix_new(fd);
+	if (!channel) {
+		connman_warn("failed to create io channel for %s",
+							USR_SHARE_ZONEINFO_MAP);
+		close(fd);
+		return NULL;
+	}
+
+	DBG("read %s for %s", USR_SHARE_ZONEINFO_MAP, zone);
+	g_io_channel_set_encoding(channel, "UTF-8", NULL);
+
+	while (g_io_channel_read_line(channel, &line, &len, NULL, NULL) ==
+							G_IO_STATUS_NORMAL) {
+		if (!line || !*line || *line == '#' || *line == '\n') {
+			g_free(line);
+			continue;
+		}
+
+		/* File format: Countrycodes Coordinates TZ Comments */
+		tokens = g_strsplit_set(line, " \t", 4);
+		if (!tokens) {
+			connman_warn("line %s failed to parse", line);
+			g_free(line);
+			continue;
+		}
+
+		if (g_strv_length(tokens) >= 3 && !g_strcmp0(
+						g_strstrip(tokens[2]), zone)) {
+			/*
+			 * Multiple country codes can be listed, use the first
+			 * 2 chars.
+			 */
+			alpha2 = g_strndup(g_strstrip(tokens[0]), 2);
+		}
+
+		g_strfreev(tokens);
+		g_free(line);
+
+		if (alpha2) {
+			if (strlen(alpha2) != 2) {
+				connman_warn("Invalid ISO3166 code %s", alpha2);
+				g_free(alpha2);
+				alpha2 = NULL;
+			} else {
+				DBG("Zone %s ISO3166 country code %s", zone,
+									alpha2);
+			}
+
+			break;
+		}
+	}
+
+	g_io_channel_unref(channel);
+	close(fd);
+
+	return alpha2;
+}
+
 char *__connman_timezone_lookup(void)
 {
 	struct stat st;
 	void *map;
 	int fd;
 	char *zone;
+	char *alpha2;
 
 	zone = read_key_file(ETC_SYSCONFIG_CLOCK, "ZONE");
 
 	DBG("sysconfig zone %s", zone);
 
-	fd = open(ETC_LOCALTIME, O_RDONLY | O_CLOEXEC);
+	fd = open(connman_setting_get_string("Localtime"),
+							O_RDONLY | O_CLOEXEC);
 	if (fd < 0) {
 		g_free(zone);
 		return NULL;
@@ -283,6 +369,15 @@ done:
 
 	DBG("localtime zone %s", zone);
 
+	if (connman_setting_get_bool("RegdomFollowsTimezone")) {
+		alpha2 = get_timezone_alpha2(zone);
+		if (alpha2) {
+			DBG("change regdom to %s", alpha2);
+			connman_technology_set_regdom(alpha2);
+			g_free(alpha2);
+		}
+	}
+
 	return zone;
 }
 
@@ -338,7 +433,7 @@ int __connman_timezone_change(const char *zone)
 		return -EIO;
 	}
 
-	err = write_file(map, &st, ETC_LOCALTIME);
+	err = write_file(map, &st, connman_setting_get_string("Localtime"));
 
 	munmap(map, st.st_size);
 
@@ -432,9 +527,9 @@ int __connman_timezone_init(void)
 
 	g_io_channel_unref(channel);
 
-	dirname = g_path_get_dirname(ETC_LOCALTIME);
+	dirname = g_path_get_dirname(connman_setting_get_string("Localtime"));
 
-	wd = inotify_add_watch(fd, dirname, IN_DONT_FOLLOW |
+	wd = inotify_add_watch(fd, dirname, IN_CREATE | IN_DONT_FOLLOW |
 						IN_CLOSE_WRITE | IN_MOVED_TO);
 
 	g_free(dirname);
-- 
2.30.2


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

* Re: [PATCH 0/4] Set regdom to follow timezone setting as optional feature
  2022-04-05 14:31 [PATCH 0/4] Set regdom to follow timezone setting as optional feature Jussi Laakkonen
                   ` (3 preceding siblings ...)
  2022-04-05 14:31 ` [PATCH 4/4] ofono: Do not change regdom when it follows timezone Jussi Laakkonen
@ 2022-04-08  7:20 ` Daniel Wagner
  4 siblings, 0 replies; 7+ messages in thread
From: Daniel Wagner @ 2022-04-08  7:20 UTC (permalink / raw)
  To: Jussi Laakkonen, connman; +Cc: Daniel Wagner

On Tue, 5 Apr 2022 17:31:12 +0300, Jussi Laakkonen wrote:
> This patchset adds an optional feature to make regdom follow the timezone set
> on the system. This feature is useful on systems where no cellular is available
> or there is no SIM present, as the regdom on WLAN would stay on default (US)
> and some channels would be unreachable. Enabling the "RegdomFollowsTimezone"
> config option makes Ofono plugin not to change regdom when the cellular network
> has indicated a change on country. By following the timezone, which can be
> also updated by the cellular stack if set to automatic configuration (might
> need a external service to do this), would then eventually propagate to ConnMan.
> 
> [...]

Applied, thanks!

[1/4] main: Add path to localtime to config options.
      commit: f035539d46ac23ccb8916ed7ae8d38ab553d32b1
[2/4] main: Add RegdomFollowsTimezone option for regdom changes
      commit: aaab2161b247588bbee32fefe775ef55acc69c4d
[3/4] timezone: Change regdom along timezone, use localtime config
      commit: bce73f1bdbf1aa6fc28d2f75b7780f4f1d8b0e3a
[4/4] ofono: Do not change regdom when it follows timezone
      commit: cb87ddd2f5905782b45c0e46277fcf7f32de16af

Best regards,
-- 
Daniel Wagner <wagi@monom.org>

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

end of thread, other threads:[~2022-04-08  7:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-05 14:31 [PATCH 0/4] Set regdom to follow timezone setting as optional feature Jussi Laakkonen
2022-04-05 14:31 ` [PATCH 1/4] main: Add path to localtime to config options Jussi Laakkonen
2022-04-05 14:31 ` [PATCH 2/4] main: Add RegdomFollowsTimezone option for regdom changes Jussi Laakkonen
2022-04-05 14:31 ` [PATCH 3/4] timezone: Change regdom along timezone, use localtime config Jussi Laakkonen
2022-04-07  9:27   ` [PATCH v2 " Jussi Laakkonen
2022-04-05 14:31 ` [PATCH 4/4] ofono: Do not change regdom when it follows timezone Jussi Laakkonen
2022-04-08  7:20 ` [PATCH 0/4] Set regdom to follow timezone setting as optional feature Daniel Wagner

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