Add to check privilege for setting ap information 51/65051/1
authorhyunuktak <hyunuk.tak@samsung.com>
Thu, 7 Apr 2016 05:30:28 +0000 (14:30 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Thu, 7 Apr 2016 05:32:40 +0000 (14:32 +0900)
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
Change-Id: I3525c9d8a6d0ddae9025ce32bb6a3758e904f35d

include/net_wifi_private.h
packaging/capi-network-wifi.spec
src/libnetwork.c
src/net_wifi_ap.c

index 210af6b..946f224 100755 (executable)
@@ -124,6 +124,9 @@ wifi_connection_state_e _wifi_convert_to_ap_state(net_state_type_t state);
 guint _wifi_callback_add(GSourceFunc func, gpointer user_data);
 void _wifi_callback_cleanup(void);
 
+int _wifi_libnet_check_get_privilege();
+int _wifi_libnet_check_profile_privilege();
+
 bool __libnet_check_feature_supported(const char *key, wifi_supported_feature_e feature);
 int _wifi_check_feature_supported(const char *feature_name, ...);
 
index 71849a8..0b3d734 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          capi-network-wifi
 Summary:       Network Wi-Fi library in TIZEN C API
-Version:       1.0.71
+Version:       1.0.72
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
index a326b55..5070e2d 100755 (executable)
@@ -1347,6 +1347,32 @@ void _wifi_callback_cleanup(void)
        managed_idler_list = NULL;
 }
 
+int _wifi_libnet_check_get_privilege()
+{
+       int rv;
+
+       rv = net_check_get_privilege();
+       if (rv == NET_ERR_ACCESS_DENIED) {
+               WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+       } else if (rv != NET_ERR_NONE)
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+       return WIFI_ERROR_NONE;
+}
+
+int _wifi_libnet_check_profile_privilege()
+{
+       int rv = net_check_profile_privilege();
+       if (rv == NET_ERR_ACCESS_DENIED) {
+               WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+       } else if (rv != NET_ERR_NONE)
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+       return WIFI_ERROR_NONE;
+}
+
 bool __libnet_check_feature_supported(const char *key, wifi_supported_feature_e feature)
 {
        if (!wifi_is_feature_checked[feature]) {
index 52dfb38..dd78185 100755 (executable)
@@ -512,6 +512,22 @@ EXPORT_API int wifi_ap_set_ip_config_type(wifi_ap_h ap, wifi_address_family_e ad
                return WIFI_ERROR_INVALID_PARAMETER;
        }
 
+       int rv = _wifi_libnet_check_get_privilege();
+       if (rv == WIFI_ERROR_PERMISSION_DENIED)
+               return rv;
+       else if (rv != WIFI_ERROR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
+       rv = _wifi_libnet_check_profile_privilege();
+       if (rv == WIFI_ERROR_PERMISSION_DENIED)
+               return rv;
+       else if (rv != WIFI_ERROR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
        net_profile_info_t *profile_info = ap;
 
        if (address_family == WIFI_ADDRESS_FAMILY_IPV4)
@@ -615,6 +631,22 @@ EXPORT_API int wifi_ap_set_ip_address(wifi_ap_h ap, wifi_address_family_e addres
                return WIFI_ERROR_INVALID_PARAMETER;
        }
 
+       int rv = _wifi_libnet_check_get_privilege();
+       if (rv == WIFI_ERROR_PERMISSION_DENIED)
+               return rv;
+       else if (rv != WIFI_ERROR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
+       rv = _wifi_libnet_check_profile_privilege();
+       if (rv == WIFI_ERROR_PERMISSION_DENIED)
+               return rv;
+       else if (rv != WIFI_ERROR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
        net_profile_info_t *profile_info = ap;
 
        if (address_family == WIFI_ADDRESS_FAMILY_IPV4) {
@@ -687,6 +719,22 @@ EXPORT_API int wifi_ap_set_subnet_mask(wifi_ap_h ap, wifi_address_family_e addre
                return WIFI_ERROR_INVALID_PARAMETER;
        }
 
+       int rv = _wifi_libnet_check_get_privilege();
+       if (rv == WIFI_ERROR_PERMISSION_DENIED)
+               return rv;
+       else if (rv != WIFI_ERROR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
+       rv = _wifi_libnet_check_profile_privilege();
+       if (rv == WIFI_ERROR_PERMISSION_DENIED)
+               return rv;
+       else if (rv != WIFI_ERROR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
        net_profile_info_t *profile_info = ap;
 
        /* Based on the family of address provided subnet mask should be set.
@@ -764,6 +812,22 @@ EXPORT_API int wifi_ap_set_gateway_address(wifi_ap_h ap, wifi_address_family_e a
                return WIFI_ERROR_INVALID_PARAMETER;
        }
 
+       int rv = _wifi_libnet_check_get_privilege();
+       if (rv == WIFI_ERROR_PERMISSION_DENIED)
+               return rv;
+       else if (rv != WIFI_ERROR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
+       rv = _wifi_libnet_check_profile_privilege();
+       if (rv == WIFI_ERROR_PERMISSION_DENIED)
+               return rv;
+       else if (rv != WIFI_ERROR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
        net_profile_info_t *profile_info = ap;
        if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
                //LCOV_EXCL_START
@@ -819,6 +883,22 @@ EXPORT_API int wifi_ap_set_proxy_address(wifi_ap_h ap, wifi_address_family_e add
                return WIFI_ERROR_INVALID_PARAMETER;
        }
 
+       int rv = _wifi_libnet_check_get_privilege();
+       if (rv == WIFI_ERROR_PERMISSION_DENIED)
+               return rv;
+       else if (rv != WIFI_ERROR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
+       rv = _wifi_libnet_check_profile_privilege();
+       if (rv == WIFI_ERROR_PERMISSION_DENIED)
+               return rv;
+       else if (rv != WIFI_ERROR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
        net_profile_info_t *profile_info = ap;
 
        if (proxy_address == NULL)
@@ -875,8 +955,23 @@ EXPORT_API int wifi_ap_set_proxy_type(wifi_ap_h ap, wifi_proxy_type_e proxy_type
                return WIFI_ERROR_INVALID_PARAMETER;
        }
 
+       int rv = _wifi_libnet_check_get_privilege();
+       if (rv == WIFI_ERROR_PERMISSION_DENIED)
+               return rv;
+       else if (rv != WIFI_ERROR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
+       rv = _wifi_libnet_check_profile_privilege();
+       if (rv == WIFI_ERROR_PERMISSION_DENIED)
+               return rv;
+       else if (rv != WIFI_ERROR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
        net_profile_info_t *profile_info = ap;
-       int rv;
 
        switch (proxy_type) {
        //LCOV_EXCL_START
@@ -952,6 +1047,22 @@ EXPORT_API int wifi_ap_set_dns_address(wifi_ap_h ap, int order, wifi_address_fam
                return WIFI_ERROR_INVALID_PARAMETER;
        }
 
+       int rv = _wifi_libnet_check_get_privilege();
+       if (rv == WIFI_ERROR_PERMISSION_DENIED)
+               return rv;
+       else if (rv != WIFI_ERROR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
+       rv = _wifi_libnet_check_profile_privilege();
+       if (rv == WIFI_ERROR_PERMISSION_DENIED)
+               return rv;
+       else if (rv != WIFI_ERROR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE
+               return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
        net_profile_info_t *profile_info = ap;
 
        if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {