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
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(
%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
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)
#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
%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}
%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
#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();
}
/* 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;
}
__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;
#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;
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()
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);
_I("Release Policy Manager");
delete __policyMgr;
-#ifdef TRIGGER_SUPPORT
_I("Release Context Trigger");
if (__contextTrigger)
__contextTrigger->release();
-#endif
_I("Release Context Manager");
if (__contextMgr)
g_main_loop_unref(mainloop);
-#ifdef TRIGGER_SUPPORT
delete __contextTrigger;
-#endif
delete __contextMgr;
delete __dbusHandle;
}
return;
}
-#ifdef TRIGGER_SUPPORT
if (__contextTrigger->assignRequest(request))
return;
-#endif
__contextMgr->assignRequest(request);
}
* 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),
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");
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);
*/
#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
return (ret == CYNARA_API_ACCESS_ALLOWED);
}
};
-#endif
bool ctx::privilege_manager::isAllowed(const ctx::Credentials *creds, const char *privilege)
{
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
}
__subscribe(SUBJ_SENSOR_HEART_RATE);
#endif
-#ifdef TRIGGER_SUPPORT
__subscribe(SUBJ_CUSTOM);
-#endif
}
PolicyManager::~PolicyManager()