From a442de61311738e64009c6b1fd1884088333c18a Mon Sep 17 00:00:00 2001
From: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
Date: Thu, 25 Jun 2020 18:30:47 +0100
Subject: [PATCH] swmod: enhancement

---
 swmod.c      | 6 +++---
 swmod_opkg.c | 2 +-
 tools.c      | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/swmod.c b/swmod.c
index 4aa64b7..7fbc7ed 100644
--- a/swmod.c
+++ b/swmod.c
@@ -590,15 +590,15 @@ swmod_eu_list(struct ubus_context *ctx, struct ubus_object *obj,
 	return 0;
 }
 
-static struct ubus_method swmod_object_methods[] = {
+static const struct ubus_method swmod_object_methods[] = {
 	UBUS_METHOD_NOARG("environment", swmod_environment),
+	UBUS_METHOD_NOARG("du_list", swmod_du_list),
+	UBUS_METHOD_NOARG("eu_list", swmod_eu_list),
 	UBUS_METHOD("install", swmod_install, install_policy),
 	UBUS_METHOD("remove", swmod_remove, remove_policy),
 	UBUS_METHOD("du_install", swmod_du_install, du_install_policy),
 	UBUS_METHOD("du_update", swmod_du_update, du_update_policy),
 	UBUS_METHOD("du_uninstall", swmod_du_uninstall, du_uninstall_policy),
-	UBUS_METHOD_NOARG("du_list", swmod_du_list),
-	UBUS_METHOD_NOARG("eu_list", swmod_eu_list)
 };
 
 static struct ubus_object_type swmod_object_type = UBUS_OBJECT_TYPE("swmodules", swmod_object_methods);
diff --git a/swmod_opkg.c b/swmod_opkg.c
index f4a278b..66ccbbb 100644
--- a/swmod_opkg.c
+++ b/swmod_opkg.c
@@ -75,7 +75,7 @@ static int swmod_host_system_install_remove_package(const char *package_path, in
 
 int swmod_install_remove_package(const char *package_path, const char *environment, int action)
 {
-	if (environment && (strcmp(environment, HOST_SYSTEM) != 0))
+	if (environment && *environment != '\0' && (strcmp(environment, HOST_SYSTEM) != 0))
 		return swmod_lxc_install_remove_package(package_path, environment, action);
 
 	return swmod_host_system_install_remove_package(package_path, action);
diff --git a/tools.c b/tools.c
index 609598e..176d124 100644
--- a/tools.c
+++ b/tools.c
@@ -69,7 +69,7 @@ void swmod_strncpy(char *dst, const char *src, size_t n)
 
 char *generate_full_url(char *url, char *username, char *password)
 {
-	if (!username && !password)
+	if ((!username && !password) || *username == '\0' || *password == '\0')
 		return url;
 
 	static char buf[512]= {0};
-- 
GitLab