diff options
author | Nishant Chaprana <n.chaprana@samsung.com> | 2021-07-15 11:34:16 +0530 |
---|---|---|
committer | Nishant Chaprana <n.chaprana@samsung.com> | 2021-07-15 11:34:16 +0530 |
commit | cef237e5250062e3943724b36c06f585cafee10b (patch) | |
tree | 2eb3abdc95845099a6eb42b947d59b41882c6680 | |
parent | a4047324d2ce8e10e74a8a9ca6c0d5062b6ecc5d (diff) | |
download | connman-cef237e5250062e3943724b36c06f585cafee10b.tar.gz connman-cef237e5250062e3943724b36c06f585cafee10b.tar.bz2 connman-cef237e5250062e3943724b36c06f585cafee10b.zip |
vpn: Make domain parameter optional
There is no technical requirement to provide the domain name. Thus,
make the domain paremeter optional.
Reported by Christian Hewitt
Upstream Patch: https://git.kernel.org/pub/scm/network/connman/connman.git/patch/?id=82699007fa89e26206771047d8cbb7c160fd2990
Change-Id: Iac21532e3e310d67c633874a95566413beb4b3a4
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
-rw-r--r-- | doc/vpn-config-format.txt | 2 | ||||
-rwxr-xr-x | vpn/vpn-config.c | 4 | ||||
-rwxr-xr-x | vpn/vpn-provider.c | 16 |
3 files changed, 13 insertions, 9 deletions
diff --git a/doc/vpn-config-format.txt b/doc/vpn-config-format.txt index 91e2a636..f2adf299 100644 --- a/doc/vpn-config-format.txt +++ b/doc/vpn-config-format.txt @@ -38,7 +38,7 @@ Allowed fields: VPN related parameters (M = mandatory, O = optional): - Name: A user defined name for the VPN (M) - Host: VPN server IP address (M) -- Domain: Domain name for the VPN service (M) +- Domain: Domain name for the VPN service (O) - Networks: The networks behind the VPN link can be defined here. This can be missing if all traffic should go via VPN tunnel. If there are more than one network, then separate them by comma. Format of the entry diff --git a/vpn/vpn-config.c b/vpn/vpn-config.c index 2fe03077..97e072c6 100755 --- a/vpn/vpn-config.c +++ b/vpn/vpn-config.c @@ -234,11 +234,11 @@ static int load_provider(GKeyFile *keyfile, const char *group, host = get_string(config_provider, "Host"); domain = get_string(config_provider, "Domain"); #if !defined TIZEN_EXT - if (host && domain) { + if (host) { char *id = __vpn_provider_create_identifier(host, domain); #else name = get_string(config_provider, "Name"); - if (host && domain && name) { + if (host && name) { char *id = __vpn_provider_create_identifier(host, domain, name); #endif diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c index 8d2836ef..d29b0186 100755 --- a/vpn/vpn-provider.c +++ b/vpn/vpn-provider.c @@ -2167,9 +2167,10 @@ char *__vpn_provider_create_identifier(const char *host, const char *domain) { char *ident; - ident = g_strdup_printf("%s_%s", host, domain); - if (!ident) - return NULL; + if (domain) + ident = g_strdup_printf("%s_%s", host, domain); + else + ident = g_strdup_printf("%s", host); provider_dbus_ident(ident); @@ -2180,7 +2181,10 @@ char *__vpn_provider_create_identifier(const char *host, const char *domain, con { char *ident; - ident = g_strdup_printf("%s_%s_%s", host, domain, name); + if (domain) + ident = g_strdup_printf("%s_%s_%s", host, domain, name); + else + ident = g_strdup_printf("%s_%s", host, name); if (!ident) return NULL; @@ -2234,7 +2238,7 @@ int __vpn_provider_create(DBusMessage *msg) dbus_message_iter_next(&array); } - if (!host || !domain) + if (!host) return -EINVAL; DBG("Type %s name %s networks %p", type, name, networks); @@ -2423,7 +2427,7 @@ int __vpn_provider_create_from_config(GHashTable *settings, networks_str = get_string(settings, "Networks"); networks = parse_user_networks(networks_str); - if (!host || !domain) { + if (!host) { err = -EINVAL; goto fail; } |