summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsaerome.kim <saerome.kim@samsung.com>2018-10-01 15:17:38 +0900
committersaerome.kim <saerome.kim@samsung.com>2018-10-01 15:17:38 +0900
commit4de53f3e66193d10e0e6da6d6194335641450855 (patch)
tree30edbe6562236f657d2791990b9a704ab3f741a9
parent0c5db75e7cac1bd45f6642208d9f6d3f68074d2d (diff)
downloadwifi-mesh-4de53f3e66193d10e0e6da6d6194335641450855.tar.gz
wifi-mesh-4de53f3e66193d10e0e6da6d6194335641450855.tar.bz2
wifi-mesh-4de53f3e66193d10e0e6da6d6194335641450855.zip
Change-Id: Ib0e613109507cf2f0d7c9691bfd27bf4a92bf3e5 Signed-off-by: saerome.kim <saerome.kim@samsung.com>
-rw-r--r--include/wifi-mesh_dbus.h1
-rw-r--r--include/wifi-mesh_private.h19
-rw-r--r--src/wifi-mesh-dbus.c198
-rw-r--r--src/wifi-mesh.c2
4 files changed, 188 insertions, 32 deletions
diff --git a/include/wifi-mesh_dbus.h b/include/wifi-mesh_dbus.h
index 580d19b..97159cd 100644
--- a/include/wifi-mesh_dbus.h
+++ b/include/wifi-mesh_dbus.h
@@ -75,6 +75,7 @@ int _wifi_mesh_get_mpath_info(wifi_mesh_h handle, mesh_found_mpath_cb cb, void *
int _wifi_mesh_set_interfaces(wifi_mesh_h handle, const char *mesh, const char *gate, const char *softap);
int _wifi_mesh_get_meshconf_info(wifi_mesh_h handle,
wifi_mesh_meshconf_info_h *meshconf);
+int wifi_mesh_check_privilege();
#ifdef __cplusplus
}
diff --git a/include/wifi-mesh_private.h b/include/wifi-mesh_private.h
index bf05428..6363d84 100644
--- a/include/wifi-mesh_private.h
+++ b/include/wifi-mesh_private.h
@@ -32,7 +32,7 @@
return WIFI_MESH_ERROR_INVALID_PARAMETER; \
}
-#if 0
+#ifdef CHECK_WIFI_MESH_FEATURE
#define CHECK_FEATURE_SUPPORTED(feature_name) { \
bool mesh_supported = FALSE; \
if (!system_info_get_platform_bool(feature_name, &mesh_supported)) { \
@@ -47,8 +47,21 @@
}
#else
#define CHECK_FEATURE_SUPPORTED(feature_name) { \
- LOGE("[Feature] Should be check !"); \
- }
+ LOGE("[Feature] Should be check !"); \
+}
+#endif
+
+#ifdef CHECK_WIFI_MESH_PRIVILEGE
+#define CHECK_PRIVILEGE() { \
+ int wifi_mesh_check_priv = wifi_mesh_check_privilege(); \
+ if (wifi_mesh_check_priv != WIFI_MESH_ERROR_NONE) { \
+ return wifi_mesh_check_priv; \
+ } \
+}
+#else
+#define CHECK_PRIVILEGE() { \
+ LOGE("[Privilege] Should be check !"); \
+}
#endif
typedef struct mesh_handle {
diff --git a/src/wifi-mesh-dbus.c b/src/wifi-mesh-dbus.c
index c3ed396..f294e14 100644
--- a/src/wifi-mesh-dbus.c
+++ b/src/wifi-mesh-dbus.c
@@ -247,8 +247,12 @@ int _wifi_mesh_get_scan_result(wifi_mesh_h handle)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -315,8 +319,12 @@ int _wifi_mesh_find_peers(wifi_mesh_h handle)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -639,8 +647,12 @@ int _wifi_mesh_enable(wifi_mesh_h handle)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -687,8 +699,12 @@ int _wifi_mesh_disable(wifi_mesh_h handle)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
h->event_handler = NULL;
@@ -729,8 +745,12 @@ int _wifi_mesh_scan(wifi_mesh_h handle)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -770,8 +790,12 @@ int _wifi_mesh_specific_scan(wifi_mesh_h handle, const char* ssid, int channel)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -811,8 +835,12 @@ int _wifi_mesh_cancel_scan(wifi_mesh_h handle)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -959,8 +987,12 @@ int _wifi_mesh_enable_mesh(wifi_mesh_h handle)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1000,8 +1032,12 @@ int _wifi_mesh_disable_mesh(wifi_mesh_h handle)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1010,6 +1046,7 @@ int _wifi_mesh_disable_mesh(wifi_mesh_h handle)
int _wifi_mesh_is_started(wifi_mesh_h handle, bool* is_started)
{
+ int result = WIFI_MESH_ERROR_NONE;
GVariant *variant = NULL;
GError *error = NULL;
gboolean state;
@@ -1040,8 +1077,12 @@ int _wifi_mesh_is_started(wifi_mesh_h handle, bool* is_started)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1084,8 +1125,12 @@ int _wifi_mesh_is_joined(wifi_mesh_h handle, bool* is_joined)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1193,8 +1238,12 @@ int _mesh_get_joined_mesh_network(wifi_mesh_h handle, wifi_mesh_network_h* _netw
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1234,8 +1283,12 @@ int _wifi_mesh_set_gate(wifi_mesh_h handle, bool gate_announce, int hwmp_root_mo
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1275,8 +1328,12 @@ int _wifi_mesh_unset_gate(wifi_mesh_h handle)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1320,8 +1377,12 @@ int _wifi_mesh_set_softap(wifi_mesh_h handle, const char* ssid,
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1373,8 +1434,12 @@ int _wifi_mesh_get_softap(wifi_mesh_h handle, char **ssid, int *channel,
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1414,8 +1479,12 @@ int _wifi_mesh_enable_softap(wifi_mesh_h handle)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1455,16 +1524,21 @@ int _wifi_mesh_disable_softap(wifi_mesh_h handle)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
return result;
}
-int _wifi_mesh_is_softap_started(wifi_mesh_h handle, bool *result)
+int _wifi_mesh_is_softap_started(wifi_mesh_h handle, bool *ret)
{
+ int result = WIFI_MESH_ERROR_NONE;
GVariant *variant = NULL;
GError *error = NULL;
struct mesh_handle *h = handle;
@@ -1487,13 +1561,17 @@ int _wifi_mesh_is_softap_started(wifi_mesh_h handle, bool *result)
"is_softap_enabled", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL,
&error);
if (variant) {
- g_variant_get(variant, "(b)", result);
- LOGD("check_softap_status status %d", *result);
+ g_variant_get(variant, "(b)", ret);
+ LOGD("check_softap_status status %d", *ret);
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1534,8 +1612,12 @@ int _mesh_create_network(wifi_mesh_h handle, wifi_mesh_network_h _network)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1576,8 +1658,12 @@ int _mesh_connect_network(wifi_mesh_h handle, wifi_mesh_network_h _network)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1618,8 +1704,12 @@ int _mesh_disconnect_network(wifi_mesh_h handle, wifi_mesh_network_h _network)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1662,8 +1752,12 @@ int _mesh_forget_network(wifi_mesh_h handle, wifi_mesh_network_h _network)
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1824,8 +1918,12 @@ int _wifi_mesh_get_stations_info(wifi_mesh_h handle,
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -1926,8 +2024,12 @@ int _wifi_mesh_get_mpath_info(wifi_mesh_h handle, mesh_found_mpath_cb cb, void *
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -2026,8 +2128,12 @@ int _wifi_mesh_get_meshconf_info(wifi_mesh_h handle,
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
- return WIFI_MESH_ERROR_IO_ERROR;
+ return result ;
/* LCOV_EXCL_STOP */
}
@@ -2067,11 +2173,45 @@ int _wifi_mesh_set_interfaces(wifi_mesh_h handle, const char *mesh, const char *
} else if (error) {
/* LCOV_EXCL_START */
LOGE("Failed DBus call [%s]", error->message);
+ if (strstr(error->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
g_error_free(error);
+ return result ;
+ /* LCOV_EXCL_STOP */
+ }
+
+ return result;
+}
+
+int wifi_mesh_check_privilege()
+{
+ int result = WIFI_MESH_ERROR_NONE;
+ GVariant *variant = NULL;
+ GError *dbus_err = NULL;
+
+ if (NULL == _gproxy_mesh_service) {
+ /* LCOV_EXCL_START */
+ LOGE("I/O error");
return WIFI_MESH_ERROR_IO_ERROR;
/* LCOV_EXCL_STOP */
}
+ variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "check_privilege",
+ NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err);
+ if (variant) {
+ g_variant_unref(variant);
+ } else if (dbus_err) {
+ LOGE("Failed to check wifi-mesh privilege [%s]", dbus_err->message);
+ if (strstr(dbus_err->message, "AccessDenied"))
+ result = WIFI_MESH_ERROR_PERMISSION_DENIED;
+ else
+ result = WIFI_MESH_ERROR_IO_ERROR;
+
+ g_error_free(dbus_err);
+ }
+
return result;
}
diff --git a/src/wifi-mesh.c b/src/wifi-mesh.c
index eeb2ec3..8a1dcc7 100644
--- a/src/wifi-mesh.c
+++ b/src/wifi-mesh.c
@@ -31,6 +31,7 @@ EXPORT_API int wifi_mesh_network_new(wifi_mesh_network_h* network)
struct mesh_network_s *net;
CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+ CHECK_PRIVILEGE();
if (NULL == network) {
/* LCOV_EXCL_START */
@@ -94,6 +95,7 @@ EXPORT_API int wifi_mesh_network_new_with(wifi_mesh_network_h* network, const ch
struct mesh_network_s *net;
CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+ CHECK_PRIVILEGE();
if (NULL == network) {
/* LCOV_EXCL_START */