Import dpm-wifi plugin from tizen
authorSangwan Kwon <sangwan.kwon@samsung.com>
Mon, 22 Jul 2019 02:38:12 +0000 (11:38 +0900)
committerSangwan Kwon <sangwan.kwon@samsung.com>
Mon, 22 Jul 2019 02:41:01 +0000 (11:41 +0900)
Signed-off-by: Sangwan Kwon <sangwan.kwon@samsung.com>
osquery/CMakeLists.txt
osquery/tizen/CMakeLists.txt
osquery/tizen/device-policy/wifi/CMakeLists.txt [new file with mode: 0755]
osquery/tizen/device-policy/wifi/wifi-impl.cpp [new file with mode: 0644]
osquery/tizen/device-policy/wifi/wifi.cpp [new file with mode: 0644]
osquery/tizen/device-policy/wifi/wifi.h [new file with mode: 0644]
packaging/osquery.spec

index 8ef5ec0..66066df 100644 (file)
@@ -126,15 +126,15 @@ IF(DEFINED GBS_BUILD)
                                                   $<TARGET_OBJECTS:osquery_sqlite>
                                                   ${${TARGET_OSQUERY_LIB}_SRCS}
                                                   ${${TARGET_OSQUERY_LIB_ONLY_GBS}_SRCS})
-       TARGET_LINK_LIBRARIES(${TARGET_OSQUERY_LIB} ${${TARGET_OSQUERY_LIB}_DEPS})
+       TARGET_LINK_LIBRARIES(${TARGET_OSQUERY_LIB} ${${TARGET_OSQUERY_LIB}_DEPS}
+                                                                                               ${${TARGET_OSQUERY_LIB_ONLY_GBS}_DEPS})
 ELSE()
        ADD_LIBRARY(${TARGET_OSQUERY_LIB}
                                        STATIC main/lib.cpp
                                                   $<TARGET_OBJECTS:osquery_generated_tables>
                                                   $<TARGET_OBJECTS:osquery_sqlite>
                                                   ${${TARGET_OSQUERY_LIB}_SRCS})
-       TARGET_LINK_LIBRARIES(${TARGET_OSQUERY_LIB} ${${TARGET_OSQUERY_LIB}_DEPS}
-                                                                                               ${${TARGET_OSQUERY_LIB_ONLY_GBS}_DEPS})
+       TARGET_LINK_LIBRARIES(${TARGET_OSQUERY_LIB} ${${TARGET_OSQUERY_LIB}_DEPS})
 ENDIF()
 SET_TARGET_PROPERTIES(${TARGET_OSQUERY_LIB} PROPERTIES OUTPUT_NAME ${TARGET_OSQUERY_LIB})
 
index 68a5dfc..b87a065 100644 (file)
@@ -21,3 +21,19 @@ ADD_OSQUERY_LIBRARY(TRUE osquery_notification notification/notification.cpp)
 
 FILE(GLOB OSQUERY_TIZEN_TESTS "*/tests/*.cpp")
 ADD_OSQUERY_TEST(TRUE ${OSQUERY_TIZEN_TESTS})
+
+IF(DEFINED GBS_BUILD)
+       SET(GBS_ONLY_PACKAGES klay
+                                                 dpm-pil
+                                                 capi-base-common
+                                                 capi-system-info
+                                                 capi-network-wifi-manager)
+
+       INCLUDE(FindPkgConfig)
+       PKG_CHECK_MODULES(GBS_DEPS REQUIRED ${GBS_ONLY_PACKAGES})
+       INCLUDE_DIRECTORIES(SYSTEM ${GBS_DEPS_INCLUDE_DIRS})
+
+       ADD_OSQUERY_LINK(FALSE ${GBS_DEPS_LIBRARIES})
+       ADD_OSQUERY_LIBRARY(FALSE tizen-dpm-wifi device-policy/wifi/wifi.cpp
+                                                                                        device-policy/wifi/wifi-impl.cpp)
+ENDIF(DEFINED GBS_BUILD)
diff --git a/osquery/tizen/device-policy/wifi/CMakeLists.txt b/osquery/tizen/device-policy/wifi/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..cf1cc4d
--- /dev/null
@@ -0,0 +1,48 @@
+#
+# Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+SET(TARGET ${PROJECT_NAME})
+SET(PC_FILE "${TARGET}.pc")
+
+SET(LIB_VERSION "${VERSION}")
+SET(LIB_SOVERSION "0")
+
+SET(API_SOURCES "wifi.cpp")
+SET(API_HEADERS "wifi.h")
+
+SET(DEPENDENCY      klay
+                                       dpm-pil
+                    capi-base-common
+                    capi-system-info
+)
+
+PKG_CHECK_MODULES(API_DEPS REQUIRED ${DEPENDENCY})
+
+SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack")
+
+ADD_LIBRARY(${TARGET} SHARED ${API_SOURCES})
+
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS "-fvisibility=default")
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES SOVERSION ${LIB_SOVERSION})
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES VERSION   ${LIB_VERSION})
+
+INCLUDE_DIRECTORIES(SYSTEM ${API_DEPS_INCLUDE_DIRS})
+TARGET_LINK_LIBRARIES(${TARGET} ${API_DEPS_LIBRARIES} pthread)
+
+CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_BINARY_DIR}/${PC_FILE} @ONLY)
+
+INSTALL(FILES ${CMAKE_BINARY_DIR}/${PC_FILE} DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(TARGETS ${TARGET} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+INSTALL(FILES ${API_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/dpm)
diff --git a/osquery/tizen/device-policy/wifi/wifi-impl.cpp b/osquery/tizen/device-policy/wifi/wifi-impl.cpp
new file mode 100644 (file)
index 0000000..e62e6d0
--- /dev/null
@@ -0,0 +1,236 @@
+/*
+ *  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+#include <arpa/inet.h>
+
+#include <cstdlib>
+#include <functional>
+#include <unordered_set>
+
+#include <wifi-manager.h>
+
+#include <klay/dbus/connection.h>
+
+#include <dpm/pil/policy-context.h>
+#include <dpm/pil/policy-model.h>
+#include <dpm/pil/policy-storage.h>
+#include <dpm/pil/policy-event.h>
+
+#define NETCONFIG_INTERFACE            \
+       "net.netconfig",                        \
+       "/net/netconfig/network",       \
+       "net.netconfig.network"
+
+class ModeChange : public GlobalPolicy<DataSetInt> {
+public:
+       ModeChange() : GlobalPolicy("wifi")
+       {
+               PolicyEventNotifier::create("wifi");
+       }
+
+       bool apply(const DataType& value)
+       {
+               int enable = value;
+               try {
+                       dbus::Connection &systemDBus = dbus::Connection::getSystem();
+                       systemDBus.methodcall(NETCONFIG_INTERFACE,
+                                                                 "DevicePolicySetWifi",
+                                                                 -1,
+                                                                 "",
+                                                                 "(i)",
+                                                                 enable);
+               } catch (runtime::Exception& e) {
+                       ERROR("Failed to chaneg Wi-Fi state");
+                       return false;
+               }
+
+               PolicyEventNotifier::emit("wifi", enable ? "allowed" : "disallowed");
+               return true;
+       }
+};
+
+class ProfileChange : public GlobalPolicy<DataSetInt> {
+public:
+       ProfileChange() : GlobalPolicy("wifi-profile-change")
+       {
+               PolicyEventNotifier::create("wifi_profile_change");
+       }
+
+       bool apply(const DataType& value)
+       {
+               int enable = value;
+               try {
+                       dbus::Connection &systemDBus = dbus::Connection::getSystem();
+                       systemDBus.methodcall(NETCONFIG_INTERFACE,
+                                                                 "DevicePolicySetWifiProfile",
+                                                                 -1,
+                                                                 "",
+                                                                 "(i)",
+                                                                 enable);
+               } catch (runtime::Exception& e) {
+                       ERROR("Failed to set Wi-Fi profile change restriction");
+                       return false;
+               }
+               PolicyEventNotifier::emit("wifi_profile_change", enable ? "allowed" : "disallowed");
+               return true;
+       }
+};
+
+class Hotspot : public GlobalPolicy<DataSetInt> {
+public:
+       Hotspot() : GlobalPolicy("wifi-hotspot")
+       {
+               PolicyEventNotifier::create("wifi_hotspot");
+       }
+
+       bool apply(const DataType& value)
+       {
+               int enable = value;
+               PolicyEventNotifier::emit("wifi_hotspot", enable ? "allowed" : "disallowed");
+               return true;
+       }
+};
+
+class Wifi : public AbstractPolicyProvider {
+public:
+       Wifi();
+       ~Wifi();
+
+       int setState(bool enable);
+       bool getState();
+       int setHotspotState(bool enable);
+       bool getHotspotState();
+       int setProfileChangeRestriction(bool enable);
+       bool isProfileChangeRestricted();
+
+       static void onConnectionStateChanged(wifi_manager_connection_state_e state,
+                                                                                wifi_manager_ap_h ap, void *user_data);
+
+private:
+       wifi_manager_h handle;
+
+       ModeChange modeChange;
+       ProfileChange profileChange;
+       Hotspot hotspot;
+};
+
+
+Wifi::Wifi() : handle(nullptr)
+{
+       int ret = 0;
+
+       ret = ::wifi_manager_initialize(&handle);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               if (ret == WIFI_MANAGER_ERROR_NOT_SUPPORTED) {
+                       return;
+               }
+               throw runtime::Exception("WiFi Manager initialization failed");
+       }
+
+       ret = ::wifi_manager_set_connection_state_changed_cb(handle, &onConnectionStateChanged, this);
+       if (ret != WIFI_MANAGER_ERROR_NONE) {
+               throw runtime::Exception("WiFi Manager set connection state changed callback failed");
+       }
+}
+
+Wifi::~Wifi()
+{
+       if (handle) {
+               ::wifi_manager_unset_connection_state_changed_cb(handle);
+               ::wifi_manager_deinitialize(handle);
+       }
+}
+
+void Wifi::onConnectionStateChanged(wifi_manager_connection_state_e state,
+                                                                       wifi_manager_ap_h ap, void *user_data)
+{
+       if (state == WIFI_MANAGER_CONNECTION_STATE_FAILURE ||
+               state == WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED) {
+               return;
+       }
+}
+
+int Wifi::setState(bool enable)
+{
+       try {
+               modeChange.set(enable);
+       } catch (runtime::Exception& e) {
+               ERROR(e.what());
+               return -1;
+       }
+
+       return 0;
+}
+
+bool Wifi::getState()
+{
+       return modeChange.get();
+}
+
+int Wifi::setHotspotState(bool enable)
+{
+       try {
+               hotspot.set(enable);
+       } catch (runtime::Exception& e) {
+               ERROR(e.what());
+               return -1;
+       }
+
+       return 0;
+}
+
+bool Wifi::getHotspotState()
+{
+       return hotspot.get();
+}
+
+int Wifi::setProfileChangeRestriction(bool enable)
+{
+       try {
+               profileChange.set(enable);
+       } catch (runtime::Exception& e) {
+               ERROR(e.what());
+               return -1;
+       }
+
+       return 0;
+}
+
+bool Wifi::isProfileChangeRestricted()
+{
+       return profileChange.get();
+}
+
+extern "C" {
+
+#define PRIVILEGE "http://tizen.org/privilege/dpm.wifi"
+
+AbstractPolicyProvider *PolicyFactory(PolicyControlContext& context)
+{
+       Wifi *policy = new Wifi();
+
+       context.expose(policy, PRIVILEGE, (int)(Wifi::setState)(bool));
+       context.expose(policy, PRIVILEGE, (int)(Wifi::setHotspotState)(bool));
+       context.expose(policy, PRIVILEGE, (int)(Wifi::setProfileChangeRestriction)(bool));
+
+       context.expose(policy, "", (bool)(Wifi::getState)());
+       context.expose(policy, "", (bool)(Wifi::getHotspotState)());
+       context.expose(policy, "", (bool)(Wifi::isProfileChangeRestricted)());
+
+       return policy;
+}
+
+} // extern "C"
diff --git a/osquery/tizen/device-policy/wifi/wifi.cpp b/osquery/tizen/device-policy/wifi/wifi.cpp
new file mode 100644 (file)
index 0000000..90b843c
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+#include <tizen.h>
+#include <tizen_type.h>
+
+#include <dpm/pil/policy-client.h>
+
+#include "wifi.h"
+
+#define RET_ON_FAILURE(cond, ret) \
+{                                 \
+       if (!(cond))                  \
+               return (ret);             \
+}
+
+EXPORT_API int dpm_wifi_set_state(device_policy_manager_h handle, bool allow)
+{
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
+
+       try {
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Wifi::setState", allow);
+               return status.get();
+       } catch (...) {
+               return -1;
+       }
+}
+
+EXPORT_API int dpm_wifi_get_state(device_policy_manager_h handle, bool *is_allowed)
+{
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
+
+    try {
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Wifi::getState");
+               *is_allowed = status.get();
+       } catch (...) {
+               return -1;
+       }
+
+       return DPM_ERROR_NONE;
+}
+
+EXPORT_API int dpm_wifi_set_hotspot_state(device_policy_manager_h handle, bool allow)
+{
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
+
+       try {
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Wifi::setHotspotState", allow);
+               return status.get();
+       } catch (...) {
+               return -1;
+       }
+}
+
+EXPORT_API int dpm_wifi_get_wifi_hotspot_state(device_policy_manager_h handle, bool *is_allowed)
+{
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
+
+       try {
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Wifi::getHotspotState");
+               *is_allowed = status.get();
+       } catch (...) {
+               return -1;
+       }
+
+       return DPM_ERROR_NONE;
+}
+
+EXPORT_API int dpm_wifi_set_profile_change_restriction(device_policy_manager_h handle, bool enable)
+{
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
+
+       try {
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Wifi::setProfileChangeRestriction", enable);
+               return status.get();
+       } catch (...) {
+               return -1;
+       }
+}
+
+EXPORT_API int dpm_wifi_is_profile_change_restricted(device_policy_manager_h handle, bool *enable)
+{
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
+
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
+
+       try {
+               Status<bool> status { false };
+               status = client.methodCall<bool>("Wifi::isProfileChangeRestricted");
+               *enable = status.get();
+       } catch (...) {
+               return -1;
+       }
+
+       return DPM_ERROR_NONE;
+}
diff --git a/osquery/tizen/device-policy/wifi/wifi.h b/osquery/tizen/device-policy/wifi/wifi.h
new file mode 100644 (file)
index 0000000..b62aaf3
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+#ifndef __CAPI_DPM_WIFI_POLICY_H__
+#define __CAPI_DPM_WIFI_POLICY_H__
+
+#include <stdbool.h>
+
+#include <dpm/device-policy-manager.h>
+
+/**
+ * @file wifi.h
+ * @brief This file provides APIs to control wifi policy
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup  CAPI_DPM_WIFI_POLICY_MODULE
+ * @{
+ */
+
+/**
+ * @partner
+ * @brief       Allows or disallows user to change the Wi-Fi state.
+ * @details     An administrator can use this API to allow or disallow user to
+ *              change the Wi-Fi state. If it is disallowed, user does not have UI
+ *              access to change the state.
+ * @since_tizen 3.0
+ * @privlevel   partner
+ * @privilege   %http://tizen.org/privilege/dpm.wifi
+ * @param[in]   handle Device policy manager handle
+ * @param[in]   allow If true, allow user to change Wi-Fi state,
+ *              if false, disallow user to change Wi-Fi state.
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
+ *              the privilege to call this API
+ * @pre         The handle must be created by dpm_manager_create().
+ * @see         dpm_manager_create()
+ * @see         dpm_wifi_get_state()
+ */
+int dpm_wifi_set_state(device_policy_manager_h handle, bool allow);
+
+/**
+ * @brief       Checks whether the Wi-Fi state change is allowed or not.
+ * @details     An administrator can use this API to check whether user is
+ *              allowed to change Wi-Fi state or not.
+ * @since_tizen 3.0
+ * @param[in]   handle Device policy manager handle
+ * @param[out]  is_allowed true if the change is allowed, false otherwise.
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre         The handle must be created by dpm_manager_create().
+ * @see         dpm_manager_create()
+ * @see         dpm_wifi_set_state()
+ */
+int dpm_wifi_get_state(device_policy_manager_h handle, bool *is_allowed);
+
+/**
+ * @partner
+ * @brief       Allows or disallows user to change Wi-Fi hotspot state change.
+ * @details     An administrator can use this API to allow or disallow user to change Wi-Fi
+ *              hotspot state. When it is disallowed, the UI is grayed out so user cannot
+ *              change Wi-Fi hotspot state.
+ * @since_tizen 3.0
+ * @privlevel   partner
+ * @privilege   %http://tizen.org/privilege/dpm.wifi
+ * @param[in]   handle Device policy manager handle
+ * @param[in]   allow If true, allow user to change Wi-Fi hostspot state,
+ *              if false, disallow user to change Wi-Fi hotspot state.
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
+ *              the privilege to call this API
+ * @pre         The handle must be created by dpm_manager_create().
+ * @see         dpm_manager_create()
+ * @see         dpm_wifi_get_hotspot_state()
+ */
+int dpm_wifi_set_hotspot_state(device_policy_manager_h handle, bool allow);
+
+/**
+ * @brief       Checks whether the the Wi-Fi hotspot state change is allowed or not.
+ * @details     An administrator can use this API to check whether user is allowed to change
+ *              Wi-Fi hotspot state or not.
+ *              If the Wi-Fi hotspot state change is disallowed, the UI is grayed out so user can not
+ *              change its state.
+ * @since_tizen 3.0
+ * @param[in]   handle Device policy manager handle
+ * @param[out]  is_allowed true if the state change is allowed, false otherwise.
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre         The handle must be created by dpm_manager_create().
+ * @see         dpm_manager_create()
+ * @see         dpm_wifi_set_hotspot_state()
+ */
+int dpm_wifi_get_hotspot_state(device_policy_manager_h handle, bool *is_allowed);
+
+/**
+ * @brief       Allows or disallows user to modify some Wi-Fi profiles of network settings.
+ * @details     An administrator can use this API to allow or disallow users to modify selected
+ *              Wi-Fi profiles like static ip configuration, proxy settings, security type
+ *              and others. When this policy is in effect the user is only allowed to
+ *              modify only the username, password, anonymous identity, and wep key.
+ *              In addition, the user cannot remove the network. When false, the user can
+ *              modify all Wi-fi network profiles normally and also remove it.
+ * @since_tizen 3.0
+ * @param[in]   handle The device policy manager handle
+ * @param[in]   enable true to enable restriction mode for wifi profile changes, else false
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
+ *              the privilege to call this API
+ * @pre         handle must be created by dpm_context_acquire_wifi_policy()
+ * @see         dpm_manager_create()
+ * @see         dpm_wifi_is_profile_change_restricted()
+ */
+int dpm_wifi_set_profile_change_restriction(device_policy_manager_h handle, bool enable);
+
+/**
+ * @brief       Checks if the user is allowed to modify certain Wi-Fi profiles.
+ * @details     An administrator can use this API to check whether the user is
+ *              allowed to modify Wi-Fi profiles. The user is restricted in modifying
+ *              Wi-Fi profiles if at least one administrator has set the value to TRUE.
+ * @since_tizen 3.0
+ * @param[in]   handle The device policy manager handle
+ * @param[out]  is_enabled true if one or more administrators enabled restriction
+ *              false if user can change all Wi-Fi profiles
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre         handle must be created by dpm_context_acquire_wifi_policy()
+ * @see         dpm_manager_create()
+ * @see         dpm_wifi_set_profile_change_restriction()
+ */
+int dpm_wifi_is_profile_change_restricted(device_policy_manager_h handle, bool *is_enabled);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //! __CAPI_DPM_WIFI_POLICY_H__
index 7f3827c..d471bb8 100644 (file)
@@ -7,6 +7,7 @@ Url: https://github.com/facebook/osquery
 Group: Security/Libraries
 Source0: file://%{name}-%{version}.tar.gz
 Source1: %name.manifest
+### Core dependencies
 BuildRequires: gcc-c++
 BuildRequires: make
 BuildRequires: cmake
@@ -40,6 +41,14 @@ Requires: libreadline
 Requires: procps-ng
 Requires: libsystemd
 Requires: iptables
+### Tizen dependencies
+BuildRequires: pkgconfig(buxton2)
+BuildRequires: pkgconfig(klay)
+BuildRequires: pkgconfig(dpm-pil)
+BuildRequires: pkgconfig(capi-network-wifi-manager)
+BuildRequires: pkgconfig(capi-network-connection)
+BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(capi-base-common)
 
 %description
 Osquery exposes an operating system as a high-performance relational database.