Remove legacy code for supporting Tizen 2.x 01/89901/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Tue, 27 Sep 2016 10:24:34 +0000 (19:24 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Tue, 27 Sep 2016 10:24:34 +0000 (19:24 +0900)
Change-Id: Iee2b92329714a519b71ba0298a9aa75d53ded0ec
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
CMakeLists.txt
packaging/context-service.spec
src/ContextManager.cpp
src/DBusServer.cpp
src/Server.cpp
src/access_control/PeerCreds.cpp
src/access_control/Privilege.cpp
src/policy/PolicyManager.cpp

index 959bd13..565a232 100644 (file)
@@ -6,17 +6,16 @@ INCLUDE(GNUInstallDirs)
 SET(target "contextd")
 
 # Source Lists
-FILE(GLOB SRCS src/*.cpp src/access_control/*.cpp src/policy/*.cpp)
-IF(${TRIGGER_SUPPORT})
-       FILE(GLOB SRCS ${SRCS} src/trigger/*.cpp)
-       ADD_DEFINITIONS(-DTRIGGER_SUPPORT)
-ENDIF(${TRIGGER_SUPPORT})
+FILE(GLOB_RECURSE SRCS src/*.cpp)
 MESSAGE("Sources: ${SRCS}")
 
 # Dependencies
 SET(DEPS
        gmodule-2.0
        vconf
+       cynara-creds-gdbus
+       cynara-client
+       cynara-session
        capi-system-device
        capi-appfw-app-manager
        capi-appfw-package-manager
@@ -33,17 +32,6 @@ IF("${PROFILE}" STREQUAL "wearable")
        ADD_DEFINITIONS("-D_WEARABLE_")
 ENDIF("${PROFILE}" STREQUAL "wearable")
 
-IF(${LEGACY_SECURITY})
-       SET(DEPS ${DEPS} security-server)
-       ADD_DEFINITIONS(-DLEGACY_SECURITY)
-ELSE(${LEGACY_SECURITY})
-       SET(DEPS ${DEPS} cynara-creds-gdbus cynara-client cynara-session)
-ENDIF(${LEGACY_SECURITY})
-
-IF(${SYSTEM_SERVICE})
-       ADD_DEFINITIONS(-DSYSTEM_SERVICE)
-ENDIF(${SYSTEM_SERVICE})
-
 # Common Options
 INCLUDE(FindPkgConfig)
 INCLUDE_DIRECTORIES(
index 278219c..6621ff1 100644 (file)
@@ -9,20 +9,11 @@ Source1:      context-service.service
 
 %define BUILD_PROFILE %{?profile}%{!?profile:%{?tizen_profile_name}}
 
-%define SYSTEM_SERVICE 0
-%define LEGACY_SECURITY        0
-%define TRIGGER_SUPPORT        1
-
 %if "%{?BUILD_PROFILE}" == "tv"
 ExcludeArch: %{arm} aarch64 %ix86 x86_64
 %endif
 
-%if %{SYSTEM_SERVICE}
-%define SERVICE_UNIT_DIR %{_unitdir}
-%else
 %define SERVICE_UNIT_DIR %{_unitdir_user}
-%endif
-
 %define upgrade_script_path /usr/share/upgrade/scripts
 
 BuildRequires: cmake
@@ -33,13 +24,9 @@ BuildRequires: pkgconfig(capi-appfw-app-manager)
 BuildRequires: pkgconfig(capi-appfw-package-manager)
 BuildRequires: pkgconfig(notification)
 
-%if %{LEGACY_SECURITY}
-BuildRequires: pkgconfig(security-server)
-%else
 BuildRequires: pkgconfig(cynara-creds-gdbus)
 BuildRequires: pkgconfig(cynara-client)
 BuildRequires: pkgconfig(cynara-session)
-%endif
 
 BuildRequires: pkgconfig(context-common)
 BuildRequires: pkgconfig(context)
@@ -75,14 +62,7 @@ export CXXFLAGS+=" -std=c++0x"
 #export   CFLAGS+=" -Wcast-qual"
 #export CXXFLAGS+=" -Wcast-qual"
 
-#export   CFLAGS+=" -DTIZEN_ENGINEER_MODE"
-#export CXXFLAGS+=" -DTIZEN_ENGINEER_MODE"
-#export   FFLAGS+=" -DTIZEN_ENGINEER_MODE"
-
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DPROFILE=%{?BUILD_PROFILE} \
-                                                          -DSYSTEM_SERVICE=%{SYSTEM_SERVICE} \
-                                                          -DLEGACY_SECURITY=%{LEGACY_SECURITY} \
-                                                          -DTRIGGER_SUPPORT=%{TRIGGER_SUPPORT}
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DPROFILE=%{?BUILD_PROFILE}
 make %{?jobs:-j%jobs}
 
 %install
@@ -90,15 +70,11 @@ rm -rf %{buildroot}
 %make_install
 
 mkdir -p %{buildroot}%{SERVICE_UNIT_DIR}
-mkdir -p %{buildroot}%{_datadir}/license
 mkdir -p %{buildroot}%{_datadir}/packages
 mkdir -p %{buildroot}/opt/data/context-service
 install -m 0644 %{SOURCE1} %{buildroot}%{SERVICE_UNIT_DIR}
-cp LICENSE %{buildroot}%{_datadir}/license/%{name}
-%if ! %{LEGACY_SECURITY}
 mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/session.d
 install -m 0644 packaging/org.tizen.context.conf %{buildroot}%{_sysconfdir}/dbus-1/session.d/
-%endif
 mkdir -p %{buildroot}%{upgrade_script_path}
 cp -f scripts/context-service_upgrade.sh %{buildroot}%{upgrade_script_path}
 
@@ -120,11 +96,8 @@ rm -f %{SERVICE_UNIT_DIR}/default.target.wants/context-service.service
 
 %files
 %manifest packaging/%{name}.manifest
-%if ! %{LEGACY_SECURITY}
 %config %{_sysconfdir}/dbus-1/session.d/*
-%endif
 %{_bindir}/*
 %{SERVICE_UNIT_DIR}/context-service.service
-%{_datadir}/license/%{name}
-
 %{upgrade_script_path}/context-service_upgrade.sh
+%license LICENSE
index 0ad7413..c3c548c 100644 (file)
 #include <DBusTypes.h>
 #include <Json.h>
 #include <ContextProvider.h>
+#include <CustomRegister.h>
 
 #include "access_control/Privilege.h"
+#include "trigger/TemplateManager.h"
 #include "Server.h"
 #include "Request.h"
 #include "ProviderHandler.h"
 #include "ProviderLoader.h"
 #include "ContextManager.h"
 
-#ifdef TRIGGER_SUPPORT
-#include <CustomRegister.h>
-#include "trigger/TemplateManager.h"
 using namespace ctx::trigger;
-#endif
-
 using namespace ctx;
 
 ContextManager::ContextManager()
 {
        ContextProvider::__setContextManager(this);
-#ifdef TRIGGER_SUPPORT
        CustomRegister::__setCustomRegister(this);
-#endif
        ProviderLoader::init();
 }
 
@@ -212,25 +207,23 @@ bool ContextManager::popTriggerTemplate(std::string &subject, int &operation, Js
 /* Only for explicit request of custom provider */
 bool ContextManager::registerCustomProvider(const char* subject, int operation, ctx::Json &attribute, ctx::Json &option, const char* owner)
 {
-#ifdef TRIGGER_SUPPORT
        IF_FAIL_RETURN_TAG(ProviderHandler::getInstance(subject, true), false, _E, "Register provider failed");
 
        TemplateManager* tmplMgr = TemplateManager::getInstance();
        IF_FAIL_RETURN_TAG(tmplMgr, false, _E, "Memory allocation failed");
        tmplMgr->registerTemplate(subject, operation, attribute, option, owner);
-#endif
+
        return true;
 }
 
 bool ContextManager::unregisterCustomProvider(const char* subject)
 {
-#ifdef TRIGGER_SUPPORT
        TemplateManager* tmplMgr = TemplateManager::getInstance();
        IF_FAIL_RETURN_TAG(tmplMgr, false, _E, "Memory allocation failed");
        tmplMgr->unregisterTemplate(subject);
 
        int error = ProviderHandler::unregisterCustomProvider(subject);
        IF_FAIL_RETURN_TAG(error == ERR_NONE, false, _E, "Unregister provider failed");
-#endif
+
        return true;
 }
index 959fd33..ff43612 100644 (file)
@@ -163,13 +163,8 @@ bool DBusServer::__init()
        __nodeInfo = g_dbus_node_info_new_for_xml(__introspection_xml, NULL);
        IF_FAIL_RETURN_TAG(__nodeInfo != NULL, false, _E, "Initialization failed");
 
-#ifdef SYSTEM_SERVICE
-       __owner = g_bus_own_name(G_BUS_TYPE_SYSTEM, DBUS_DEST, G_BUS_NAME_OWNER_FLAGS_NONE,
-                       __onBusAcquired, __onNameAcquired, __onNameLost, NULL, NULL);
-#else
        __owner = g_bus_own_name(G_BUS_TYPE_SESSION, DBUS_DEST, G_BUS_NAME_OWNER_FLAGS_NONE,
                        __onBusAcquired, __onNameAcquired, __onNameLost, NULL, NULL);
-#endif
 
        __theInstance = this;
        return true;
index 35e6866..8c2afe9 100644 (file)
 #include "DBusServer.h"
 #include "ContextManager.h"
 #include "policy/PolicyManager.h"
+#include "trigger/Trigger.h"
 #include "Server.h"
 
-#ifdef TRIGGER_SUPPORT
-#include "trigger/Trigger.h"
-#endif
 
 static GMainLoop *mainloop = NULL;
 static bool started = false;
@@ -35,10 +33,7 @@ static bool started = false;
 static ctx::ContextManager *__contextMgr = NULL;
 static ctx::DBusServer *__dbusHandle = NULL;
 static ctx::PolicyManager *__policyMgr = NULL;
-
-#ifdef TRIGGER_SUPPORT
 static ctx::trigger::Trigger *__contextTrigger = NULL;
-#endif
 
 /* TODO: re-organize activation & deactivation processes */
 void ctx::Server::initialize()
@@ -68,13 +63,11 @@ void ctx::Server::activate()
        result = __contextMgr->init();
        IF_FAIL_CATCH_TAG(result, _E, "Initialization Failed");
 
-#ifdef TRIGGER_SUPPORT
        _I("Init Context Trigger");
        __contextTrigger = new(std::nothrow) ctx::trigger::Trigger();
        IF_FAIL_CATCH_TAG(__contextTrigger, _E, "Memory allocation failed");
        result = __contextTrigger->init(__contextMgr);
        IF_FAIL_CATCH_TAG(result, _E, "Initialization Failed");
-#endif
 
        _I("Init Policy Manager");
        __policyMgr = new(std::nothrow) ctx::PolicyManager(__contextMgr);
@@ -98,11 +91,9 @@ void ctx::Server::release()
        _I("Release Policy Manager");
        delete __policyMgr;
 
-#ifdef TRIGGER_SUPPORT
        _I("Release Context Trigger");
        if (__contextTrigger)
                __contextTrigger->release();
-#endif
 
        _I("Release Context Manager");
        if (__contextMgr)
@@ -114,9 +105,7 @@ void ctx::Server::release()
 
        g_main_loop_unref(mainloop);
 
-#ifdef TRIGGER_SUPPORT
        delete __contextTrigger;
-#endif
        delete __contextMgr;
        delete __dbusHandle;
 }
@@ -135,10 +124,8 @@ void ctx::Server::sendRequest(ctx::RequestInfo* request)
                return;
        }
 
-#ifdef TRIGGER_SUPPORT
        if (__contextTrigger->assignRequest(request))
                return;
-#endif
 
        __contextMgr->assignRequest(request);
 }
index 3806e21..336da5a 100644 (file)
  * limitations under the License.
  */
 
+#include <cynara-creds-gdbus.h>
+#include <cynara-session.h>
 #include <app_manager.h>
 #include <package_manager.h>
 #include <Types.h>
 #include "PeerCreds.h"
 
-#ifdef LEGACY_SECURITY
-#include <security-server.h>
-#else
-#include <cynara-creds-gdbus.h>
-#include <cynara-session.h>
-#endif
-
 ctx::Credentials::Credentials(char *pkgId, char *cli, char *sess, char *usr) :
        packageId(pkgId),
        client(cli),
@@ -51,21 +46,6 @@ bool ctx::peer_creds::get(GDBusConnection *connection, const char *uniqueName, c
        char *session = NULL;
        gchar *user = NULL;
 
-#ifdef LEGACY_SECURITY
-       gsize size;
-       char *decoded = reinterpret_cast<char*>(g_base64_decode(cookie, &size));
-       IF_FAIL_RETURN_TAG(decoded, false, _E, "Cookie decoding failed");
-
-       pid = security_server_get_cookie_pid(decoded);
-       if (pid <= 0) {
-               _E("security_server_get_cookie_pid() failed");
-               g_free(decoded);
-               return false;
-       }
-       client = security_server_get_smacklabel_cookie(decoded);
-       g_free(decoded);
-       IF_FAIL_RETURN_TAG(client, false, _E, "security_server_get_smacklabel_cookie() failed");
-#else
        int err = cynara_creds_gdbus_get_pid(connection, uniqueName, &pid);
        IF_FAIL_RETURN_TAG(err == CYNARA_API_SUCCESS, false, _E, "Peer credentialing failed");
 
@@ -77,7 +57,6 @@ bool ctx::peer_creds::get(GDBusConnection *connection, const char *uniqueName, c
 
        err = cynara_creds_gdbus_get_user(connection, uniqueName, USER_METHOD_DEFAULT, &user);
        IF_FAIL_CATCH_TAG(err == CYNARA_API_SUCCESS, _E, "Peer credentialing failed");
-#endif
 
        app_manager_get_app_id(pid, &app_id);
        package_manager_get_package_id_by_app_id(app_id, &packageId);
index 94a7629..da2bdae 100644 (file)
  */
 
 #include <string>
+#include <cynara-client.h>
 #include <Types.h>
 #include "PeerCreds.h"
 #include "Privilege.h"
 
-#ifdef LEGACY_SECURITY
-
-#include <sys/smack.h>
-#define PRIV_PREFIX "privilege::tizen::"
-
-#else
-
-#include <cynara-client.h>
 #define PRIV_PREFIX "http://tizen.org/privilege/"
 #define CACHE_SIZE 100
 
@@ -81,7 +74,6 @@ public:
                return (ret == CYNARA_API_ACCESS_ALLOWED);
        }
 };
-#endif
 
 bool ctx::privilege_manager::isAllowed(const ctx::Credentials *creds, const char *privilege)
 {
@@ -90,11 +82,5 @@ bool ctx::privilege_manager::isAllowed(const ctx::Credentials *creds, const char
        std::string priv = PRIV_PREFIX;
        priv += privilege;
 
-#ifdef LEGACY_SECURITY
-       int ret = smack_have_access(creds->client, priv.c_str(), "rw");
-       _SD("Client: %s, Priv: %s, Enabled: %d", creds->client, privilege, ret);
-       return (ret == 1);
-#else
        return PermissionChecker::getInstance().hasPermission(creds, priv.c_str());
-#endif
 }
index 827d040..33131ee 100644 (file)
@@ -44,9 +44,7 @@ PolicyManager::PolicyManager(ContextManager *contextMgr) :
        __subscribe(SUBJ_SENSOR_HEART_RATE);
 #endif
 
-#ifdef TRIGGER_SUPPORT
        __subscribe(SUBJ_CUSTOM);
-#endif
 }
 
 PolicyManager::~PolicyManager()