Add multi-user support 46/16446/2 accepted/tizen/generic accepted/tizen_generic accepted/tizen_ivi_panda accepted/tizen_ivi_release tizen_3.0.m14.2_ivi tizen_ivi_release accepted/tizen/generic/20140221.200649 accepted/tizen/generic/20140312.095935 accepted/tizen/ivi/20140221.215707 accepted/tizen/ivi/panda/20140312.090845 accepted/tizen/ivi/release/20140312.114550 accepted/tizen/mobile/20140227.071820 submit/tizen/20140221.200534 submit/tizen/20140312.070742 submit/tizen_ivi_release/20140312.071216 tizen_3.0.m14.2_ivi_release
authorKévin THIERRY <kevin.thierry@open.eurogiciel.org>
Tue, 28 Jan 2014 14:00:08 +0000 (15:00 +0100)
committerKévin THIERRY <kevin.thierry@open.eurogiciel.org>
Mon, 17 Feb 2014 14:11:28 +0000 (15:11 +0100)
Bug-Tizen: PTREL-384
Change-Id: If6c8577398bb484f86793bd4edbb6123d22829fa
Signed-off-by: Kévin THIERRY <kevin.thierry@open.eurogiciel.org>
Makefile
framework/TCSImpl.c
framework/TWPImpl.c
framework/TWPImpl.h
packaging/csr-framework.spec
test/TCSTest.c
test/TCSTest.h
test/TCSTestUtils.c
test/TWPTestUtils.c

index 3db2f5b..87041dc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -33,7 +33,7 @@ OUTDIR = lib
 TARGET = $(OUTDIR)/libsecfw.so
 SRCDIR = framework
 INCLUDE = -I. $(TCS_INC) -I../plugin
-LD_FLAGS := $(LD_FLAGS) -ldl
+LD_FLAGS := $(LD_FLAGS) -ldl -ltzplatform-config-1.0
 
 ifeq ($(TCS_CC), )
        CC = gcc
index 1cea1b3..2d8f08e 100644 (file)
@@ -34,6 +34,9 @@
 #include <dlfcn.h>
 #include <malloc.h>
 
+/* For multi-user support */
+#include <tzplatform_config.h>
+
 #include "TCSImpl.h"
 #include "TCSErrorCodes.h"
 
@@ -49,7 +52,7 @@
 #endif
 
 
-#define PLUGIN_PATH "/opt/usr/share/sec_plugin/libengine.so"
+#define PLUGIN_PATH tzplatform_mkpath(TZ_USER_SHARE, "sec_plugin/libengine.so")
 
 
 typedef TCSLIB_HANDLE (*FuncLibraryOpen)(void);
index 82b7062..4291e49 100644 (file)
 #include <dlfcn.h>
 #include <malloc.h>
 
+/* For multi-user support */
+#include <tzplatform_config.h>
+
 #include "TWPImpl.h"
 
 
-#define SITE_PLUGIN_PATH "/opt/usr/share/sec_plugin/libwpengine.so"
+#define SITE_PLUGIN_PATH tzplatform_mkpath(TZ_USER_SHARE, "sec_plugin/libwpengine.so")
 
 #if defined(DEBUG)
 #define DEBUG_LOG(_fmt_, _param_...)    { \
index 7eaf9c0..4a62f13 100644 (file)
@@ -50,13 +50,13 @@ struct TWPLibHandle_struct {int iDummy;};
 typedef struct TWPLibHandle_struct *TWPLIB_HANDLE;
 
 #define TWPAPI_VERSION 1 /* SDK version */
-       
+
 #define TWPCONFIG_VERSION 1 /* Configure version */
-       
+
 #define TWPREQUEST_VERSION 1 /* Request version */
 
 #define INVALID_TWPLIB_HANDLE ((TWPLIB_HANDLE) 0) /* Invalid web protection library interface handle. */
-       
+
 /**
  * Result code used by TWP_RESULT
  */
index 8d4c180..b4d2e74 100644 (file)
@@ -1,13 +1,14 @@
 
-Summary: Content Security Framework
-Name: csr-framework
-Version: 1.0.0
-Release: 1
-License: BSD-3-Clause
-Group: Security/Libraries
-URL: http://tizen.org
-Source: %{name}-%{version}.tar.gz
-Source1001:    csr-framework.manifest
+Summary:       Content Security Framework
+Name:          csr-framework
+Version:       1.0.0
+Release:       0
+License:       BSD-3-Clause
+Group:         Security/Libraries
+URL:           http://tizen.org
+Source:        %{name}-%{version}.tar.gz
+Source1001:    csr-framework.manifest
+BuildRequires: pkgconfig(libtzplatform-config)
 
 %description
 A general purpose content screening and reputation solution. 
@@ -17,7 +18,6 @@ A general purpose content screening and reputation solution.
 cp %{SOURCE1001} .
 
 %build 
-
 make all
 
 %install
index 68ea190..d4fd730 100644 (file)
@@ -259,6 +259,16 @@ static void TestCases(void)
 }
 
 
+static void TCSRemovePlugin(void)
+{
+    char *pszCommand;
+
+    asprintf(&pszCommand, "rm -f %s", PLUGIN_PATH);
+    CallSys(pszCommand);
+    free(pszCommand);
+}
+
+
 static void TCSLibraryOpen_0001(void)
 {
     TestCase TestCtx;
@@ -280,7 +290,7 @@ static void TCSLibraryOpen_0002(void)
     TESTCASECTOR(&TestCtx, __FUNCTION__, 0, 0, 0, NULL);
 
     BackupEngine();
-    system("rm -f /opt/usr/share/sec_plugin/libengine.so");
+    TCSRemovePlugin();
 
     TEST_ASSERT((hLib = TCSLibraryOpen()) == INVALID_TCSLIB_HANDLE);
     iErr = TCSGetLastError(hLib);
@@ -298,7 +308,7 @@ static void TCSGetLastError_0001(void)
     TestCase TestCtx;
 
     BackupEngine();
-    system("rm -f /opt/usr/share/sec_plugin/libengine.so");
+    TCSRemovePlugin();
 
     TESTCASECTOR(&TestCtx, __FUNCTION__, 0, 0, 0, NULL);
     iErr = TCSGetLastError(INVALID_TCSLIB_HANDLE);
@@ -317,7 +327,7 @@ static void TCSScanData_0052(void)
     TCSScanResult SR= {0};
 
     BackupEngine();
-    system("rm -f /opt/usr/share/sec_plugin/libengine.so");
+    TCSRemovePlugin();
 
     SP.iAction = TCS_SA_SCANONLY;
     SP.iDataType = TCS_DTYPE_UNKNOWN;
@@ -1059,7 +1069,7 @@ static void TCSLibraryOpen_0003(void)
     TESTCASECTOR(&TestCtx, __FUNCTION__, 0, 0, 0, NULL);
     /* pre-condition is stub library */
     BackupEngine();
-    system("rm -f /opt/usr/share/sec_plugin/libengine.so");
+    TCSRemovePlugin();
 
     TEST_ASSERT((hLib = TCSLibraryOpen()) == INVALID_TCSLIB_HANDLE);
     RestoreEngine();
@@ -1080,7 +1090,7 @@ static void TCSLibraryOpen_0004(void)
     TEST_ASSERT((hLib = TCSLibraryOpen()) != INVALID_TCSLIB_HANDLE);
 
     BackupEngine();
-    system("rm -f /opt/usr/share/sec_plugin/libengine.so");
+    TCSRemovePlugin();
     TCSLibraryClose(hLib);
 
     TEST_ASSERT((hLib = TCSLibraryOpen()) == INVALID_TCSLIB_HANDLE);
index fb925e8..983e1e8 100644 (file)
@@ -5,6 +5,9 @@
 #include <setjmp.h>
 
 
+/* For multi-user support */
+#include <tzplatform_config.h>
+
 #ifdef __cplusplus 
 extern "C" {
 #endif
@@ -68,6 +71,8 @@ extern "C" {
 
 #define TEST_CONSTRUCT_ERRCODE(m, e) (((m) << 24) | (e))
 
+#define PLUGIN_PATH tzplatform_mkpath(TZ_USER_SHARE, "sec_plugin/libengine.so")
+#define PLUGIN_DIR tzplatform_mkpath(TZ_USER_SHARE, "sec_plugin/")
 
 /* Test content file types */
 enum ENUM_MALWARE_TEST_TYPES
index c3af2fa..71f61e8 100644 (file)
@@ -2072,7 +2072,7 @@ void BackupEngine()
         CallSys(pszCommand);
         free(pszCommand);
 
-        asprintf(&pszCommand, "cp -f /opt/usr/share/sec_plugin/libengine.so %s/backup", pszRoot);
+        asprintf(&pszCommand, "cp -f %s %s/backup", PLUGIN_PATH, pszRoot);
         CallSys(pszCommand);
         free(pszCommand);
 
@@ -2087,7 +2087,7 @@ void RestoreEngine()
 
     if (pszRoot != NULL)
     {
-        asprintf(&pszCommand, "cp -f %s/backup/libengine.so /opt/usr/share/sec_plugin/", pszRoot);
+        asprintf(&pszCommand, "cp -f %s/backup/libengine.so %s", pszRoot, PLUGIN_DIR);
         CallSys(pszCommand);
         free(pszCommand);
 
index 46e9ac9..343de00 100644 (file)
 #include <sys/time.h>
 #include <sys/stat.h>
 #include <errno.h>
+
+/* For multi-user support */
+#include <tzplatform_config.h>
+
 #include "TWPImpl.h"
 #include "XMHttp.h"
 #include "TWPTest.h"
@@ -51,6 +55,8 @@
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 #endif
 
+#define PLUGIN_PATH tzplatform_mkpath(TZ_USER_SHARE, "sec_plugin/libengine.so")
+#define PLUGIN_DIR tzplatform_mkpath(TZ_USER_SHARE, "sec_plugin/")
 
 static void ReportTestCase(TestCase *pCtx);
 static void CallSys(const char *pszCmd);
@@ -130,7 +136,7 @@ void BackupEngine()
         CallSys(pszCommand);
         free(pszCommand);
 
-        asprintf(&pszCommand, "cp -f /opt/usr/share/sec_plugin/libwpengine.so %s/backup", pszRoot);
+        asprintf(&pszCommand, "cp -f %s %s/backup", PLUGIN_PATH, pszRoot);
         CallSys(pszCommand);
         free(pszCommand);
 
@@ -145,7 +151,7 @@ void RestoreEngine()
 
     if (pszRoot != NULL)
     {
-        asprintf(&pszCommand, "cp -f %s/backup/libwpengine.so /opt/usr/share/sec_plugin/", pszRoot);
+        asprintf(&pszCommand, "cp -f %s/backup/libwpengine.so %s", pszRoot, PLUGIN_DIR);
         CallSys(pszCommand);
         free(pszCommand);
 
@@ -161,7 +167,7 @@ void RemoveEngine()
     BackupEngine();
     if (pszRoot != NULL)
     {
-        asprintf(&pszCommand, "rm -f /opt/usr/share/sec_plugin/libwpengine.so");
+        asprintf(&pszCommand, "rm -f %s", PLUGIN_PATH);
         CallSys(pszCommand);
         free(pszCommand);
     }