Skip to contentSkip to conversation

resolver: FIX path to resolv.conf config option

PATCH In review Nicolas Gariepy 3 participants 4 messages Sep 29, 2023 – Nov 7, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 resolver: FIX path to resolv.conf config option

There are two problems with how the "ResolvConf" option was implemented.

1. The "ResolvConf" is used in src/resolver.c using the function connman_setting_get_string(const char *key) but the connman_settings.resolv_conf option could only be accessed using the connman_setting_get_bool(const char *key) function at the moment.
2. The Gerror is not cleared before trying to read the "ResolvConf" parameter of the config.

This patch fixes the two issues above.

---
 src/main.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
src/main.c +5 -3
index ae4a450d..61881442 100644
@@ -599,6 +599,8 @@ static void parse_config(GKeyFile *config)
 	if (!error)
 		connman_settings.regdom_follows_timezone = boolean;
 
+	g_clear_error(&error);
+
 	string = __connman_config_get_string(config, "General",
 				CONF_RESOLV_CONF, &error);
 	if (!error)
@@ -801,6 +803,9 @@ char *connman_setting_get_string(const char *key)
 		return connman_settings.localtime ?
 			connman_settings.localtime : DEFAULT_LOCALTIME;
 
+	if (g_str_equal(key, CONF_RESOLV_CONF))
+		return connman_settings.resolv_conf;
+
 	return NULL;
 }
 
@@ -842,9 +847,6 @@ bool connman_setting_get_bool(const char *key)
 	if (g_str_equal(key, CONF_REGDOM_FOLLOWS_TIMEZONE))
 		return connman_settings.regdom_follows_timezone;
 
-	if (g_str_equal(key, CONF_RESOLV_CONF))
-		return connman_settings.resolv_conf;
-
 	return false;
 }
 
Signature · 1 line
2.40.1
Reviewed-by on v1 1/1
#1 lore raw

Nicolas:

This looks good to me and seems to address the issues I was having with this configuration option.

Best,

Grant

Quoted 47 lines · Nicolas Gariepy

There are two problems with how the "ResolvConf" option was implemented.

1. The "ResolvConf" is used in src/resolver.c using the function connman_setting_get_string(const char *key) but the connman_settings.resolv_conf option could only be accessed using the connman_setting_get_bool(const char *key) function at the moment.
2. The Gerror is not cleared before trying to read the "ResolvConf" parameter of the config.

This patch fixes the two issues above.
---
src/main.c | 8 +++++---

1 file changed, 5 insertions(+), 3 deletions(-)
src/main.c +5 -3
index ae4a450d..61881442 100644
@@ -599,6 +599,8 @@ static void parse_config(GKeyFile *config)
 	if (!error)
 		connman_settings.regdom_follows_timezone = boolean;
 
+	g_clear_error(&error);
+
 	string = __connman_config_get_string(config, "General",
 				CONF_RESOLV_CONF, &error);
 	if (!error)
@@ -801,6 +803,9 @@ char *connman_setting_get_string(const char *key)
 		return connman_settings.localtime ?
 			connman_settings.localtime : DEFAULT_LOCALTIME;
 
+	if (g_str_equal(key, CONF_RESOLV_CONF))
+		return connman_settings.resolv_conf;
+
 	return NULL;
 }
 
@@ -842,9 +847,6 @@ bool connman_setting_get_bool(const char *key)
 	if (g_str_equal(key, CONF_REGDOM_FOLLOWS_TIMEZONE))
 		return connman_settings.regdom_follows_timezone;
 
-	if (g_str_equal(key, CONF_RESOLV_CONF))
-		return connman_settings.resolv_conf;
-
 	return false;
 }
 
Signature · 1 line
2.40.1
Signature · 5 lines
Principal
Nuovations

[email protected]
http://www.nuovations.com/
#2 lore raw
In reply to Nicolas Gariepy

Nicolas,

Thank you again for this. I’ve submitted a pull request at my clone / fork:

https://github.com/Nuovations/connman/pull/19

and it has been merged to the primary branch there.

Best,

Grant

Signature · 5 lines
Principal
Nuovations

[email protected]
http://www.nuovations.com/
Quoted 7 lines · Nicolas Gariepy

There are two problems with how the "ResolvConf" option was implemented.

1. The "ResolvConf" is used in src/resolver.c using the function connman_setting_get_string(const char *key) but the connman_settings.resolv_conf option could only be accessed using the connman_setting_get_bool(const char *key) function at the moment.
2. The Gerror is not cleared before trying to read the "ResolvConf" parameter of the config.

This patch fixes the two issues above.

#3 lore raw
In reply to Nicolas Gariepy

Hi Nicolas,

Quoted 9 lines

There are two problems with how the "ResolvConf" option was implemented.

1. The "ResolvConf" is used in src/resolver.c using the function connman_setting_get_string(const char *key) but the connman_settings.resolv_conf option could only be accessed using the connman_setting_get_bool(const char *key) function at the moment.
2. The Gerror is not cleared before trying to read the "ResolvConf" parameter of the config.

This patch fixes the two issues above.
---
src/main.c | 8 +++++---

1 file changed, 5 insertions(+), 3 deletions(-)

patch has been applied.

Regards

Marcel