summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunwook Bae <sunwook45.bae@samsung.com>2013-08-28 11:10:14 +0900
committerSunwook Bae <sunwook45.bae@samsung.com>2013-08-28 11:17:22 +0900
commitd68a3ad8d9c02097484054857d0f9876ece5a2ac (patch)
tree9daf55048b7550cb4919b90fb429beb90da40094
parentf577e376a1c53a0d18f127f6419e2de45b13cbc0 (diff)
parent671f859a012dfdd77b45a17c3fb72fede131db21 (diff)
downloadenv-config-d68a3ad8d9c02097484054857d0f9876ece5a2ac.tar.gz
env-config-d68a3ad8d9c02097484054857d0f9876ece5a2ac.tar.bz2
env-config-d68a3ad8d9c02097484054857d0f9876ece5a2ac.zip
Change-Id: Ic7a88df8ef2ddfbed46ef9392b1bcc5e959c60cc
-rw-r--r--CMakeLists.txt18
-rw-r--r--appinfo/CMakeLists.txt54
-rw-r--r--appinfo/appinfo.c371
-rw-r--r--appinfo/appinfo.h152
-rw-r--r--appinfo/appinfo.pc.in13
-rw-r--r--osp-env-config.c867
-rw-r--r--[-rwxr-xr-x]packaging/osp-env-config.spec28
-rw-r--r--usr/etc/app-storage-exclude-dirs.list23
8 files changed, 1122 insertions, 404 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 315d1cf..01516e6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,8 @@ SET (${this_target}_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/osp-env-config.c
)
+ADD_SUBDIRECTORY(appinfo)
+
ADD_LIBRARY(${this_target} SHARED ${${this_target}_SOURCE_FILES})
SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
@@ -21,14 +23,14 @@ SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -
TARGET_LINK_LIBRARIES(${this_target} "-lvconf -ldlog")
SET_TARGET_PROPERTIES(${this_target}
- PROPERTIES
- VERSION ${FULLVER}
- SOVERSION ${MAJORVER}
- CLEAN_DIRECT_OUTPUT 1
+ PROPERTIES
+ VERSION ${FULLVER}
+ SOVERSION ${MAJORVER}
+ CLEAN_DIRECT_OUTPUT 1
)
INSTALL(TARGETS ${this_target} DESTINATION ${LIB_INSTALL_DIR}
- PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
- GROUP_EXECUTE GROUP_READ
- WORLD_EXECUTE WORLD_READ)
-
+ PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
+ GROUP_EXECUTE GROUP_READ
+ WORLD_EXECUTE WORLD_READ)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/usr/etc/app-storage-exclude-dirs.list DESTINATION ../usr/etc)
diff --git a/appinfo/CMakeLists.txt b/appinfo/CMakeLists.txt
new file mode 100644
index 0000000..9718a86
--- /dev/null
+++ b/appinfo/CMakeLists.txt
@@ -0,0 +1,54 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(this_target appinfo)
+
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.1.1")
+
+#INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+ dlog
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+
+SET (${this_target}_SOURCE_FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/appinfo.c
+)
+
+ADD_LIBRARY(${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed")
+
+SET_TARGET_PROPERTIES(${this_target}
+ PROPERTIES
+ VERSION ${FULLVER}
+ SOVERSION ${MAJORVER}
+ CLEAN_DIRECT_OUTPUT 1
+ )
+
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+
+
+SET(PC_NAME ${this_target})
+SET(PC_REQUIRED ${pc_requires})
+SET(PC_LDFLAGS -l${this_target})
+
+CONFIGURE_FILE(appinfo.pc.in appinfo.pc @ONLY)
+
+INSTALL(TARGETS ${this_target} DESTINATION ${LIB_INSTALL_DIR}/osp
+ PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
+ GROUP_EXECUTE GROUP_READ
+ WORLD_EXECUTE WORLD_READ)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/appinfo.h DESTINATION include/osp)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/appinfo.pc DESTINATION lib/pkgconfig)
+
diff --git a/appinfo/appinfo.c b/appinfo/appinfo.c
new file mode 100644
index 0000000..5078f24
--- /dev/null
+++ b/appinfo/appinfo.c
@@ -0,0 +1,371 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include <dlog.h>
+
+#include "appinfo.h"
+
+#undef LOG_TAG
+#define LOG_TAG "APPINFO"
+
+#ifdef _SECURE_LOG
+#define _SECURE_LOGI LOGI
+#define _SECURE_LOGE LOGE
+#else
+#define _SECURE_LOGI(...)
+#define _SECURE_LOGE(...)
+#endif
+
+#ifndef likely
+#define likely(x) __builtin_expect(!!(x), 1)
+#endif
+#ifndef unlikely
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static const char INVALID_EXEC_NAME[] = "";
+static app_info_version_e _current_api_ver = APP_INFO_VERSION_2_2;
+static int _compat_mode = 0;
+static int _app_info_init = 0;
+
+static int _argc = 0;
+static char** _argv = NULL;
+
+#define MAX_OSP_PKGID 10
+#define MAX_APPID 256
+
+static char __pkgid[MAX_OSP_PKGID+1]={'\0',};
+static char __appid[MAX_APPID]={'\0',};
+static const char* _pkgid = NULL;
+static const char* _appid = NULL;
+static const char* _execname = &INVALID_EXEC_NAME;
+
+
+/**
+ * @brief Initializes the appinfo structure
+ *
+ * @param[in] appid The application id to initialize
+ * @param[in] is_invalid_appid @c 1 for invalid appid compatibility mode, @c 0 otherwise
+ * @return 0 on success, otherwise a negative error value
+ * @retval APP_INFO_ERROR_NONE Succesful
+ * @retval APP_INFO_ERROR_INVALID_ARG The appid is invalid
+ * @remarks It initialize the platform API version to APP_INFO_VERSION_3_0 and compat mode 0.
+ */
+int
+appinfo_init(const char* appid, int is_invalid_appid)
+{
+ if (!appid || (appid && strlen(appid) >= sizeof(__appid)))
+ {
+ return APP_INFO_ERROR_INVALID_ARG;
+ }
+
+ strncpy(__appid, appid, strlen(appid));
+ if (is_invalid_appid)
+ {
+ // SLP-style old appid
+ _pkgid = __appid;
+ _appid = __appid;
+ _execname = __appid;
+ }
+ else
+ {
+ if (strlen(appid) < sizeof(MAX_OSP_PKGID))
+ {
+ return APP_INFO_ERROR_INVALID_ARG;
+ }
+ // proper OSP or Web appid
+ strncpy(__pkgid, appid, MAX_OSP_PKGID);
+ _appid = __appid;
+ _pkgid = __pkgid;
+ _execname = __appid+(MAX_OSP_PKGID+1);
+ }
+
+ _current_api_ver = APP_INFO_VERSION_2_2;
+ _compat_mode = 0;
+ _app_info_init = 1;
+
+ return APP_INFO_ERROR_NONE;
+}
+
+/**
+ * @brief Returns the API version
+ *
+ * @return app_info_version_e value
+ */
+int
+appinfo_get_api_version(void)
+{
+ return _current_api_ver;
+}
+
+/**
+ * @brief Sets the API version for the current process
+ *
+ * @param[in] ver Given API version
+ * @return 0 on success, otherwise a negative error value
+ * @retval APP_INFO_ERROR_NONE Succesful
+ */
+
+int
+appinfo_set_api_version(app_info_version_e ver)
+{
+ if (ver < 0)
+ {
+ return APP_INFO_ERROR_INVALID_ARG;
+ }
+
+ _current_api_ver = ver;
+
+ return 0;
+}
+
+/*
+int
+appinfo_set_api_version(int ver)
+{
+ app_info_version_e temp_ver;
+ temp_ver = __get_api_version_from_str(appinfo_get_api_str_by_version(ver));
+
+ if ( temp_ver == APP_INFO_VERSION_INVALID)
+ {
+ return APP_INFO_ERROR_INVALID_ARG;
+ }
+ else
+ {
+ _current_api_ver = temp_ver;
+ return APP_INFO_ERROR_NONE;
+ }
+}
+*/
+
+/**
+ * @brief Returns the API version string by given API version
+ *
+ * @param[in] ver Given API version
+ * @return the API version string by the given version
+ * @remakr If wrong API version, return NULL
+ */
+const char*
+appinfo_get_api_str_by_version(int ver)
+{
+ switch (ver) {
+ case APP_INFO_VERSION_1_0 :
+ return "1.0";
+ case APP_INFO_VERSION_1_0_2 :
+ return "1.0.2";
+ case APP_INFO_VERSION_1_1 :
+ return "1.1";
+ case APP_INFO_VERSION_1_2 :
+ return "1.2";
+ case APP_INFO_VERSION_2_0 :
+ return "2.0";
+ case APP_INFO_VERSION_2_1 :
+ return "2.1";
+ case APP_INFO_VERSION_2_2 :
+ return "2.2";
+ case APP_INFO_VERSION_3_0 :
+ return "3.0";
+ default :
+ return NULL;
+ }
+}
+
+app_info_version_e appinfo_get_api_version_from_str(const char * ver_str)
+{
+ if (ver_str == NULL)
+ {
+ return APP_INFO_VERSION_INVALID;
+ }
+
+ if (!strcmp(ver_str,"3.0"))
+ {
+ return APP_INFO_VERSION_3_0;
+ }
+ else if (!strcmp(ver_str,"2.2"))
+ {
+ return APP_INFO_VERSION_2_2;
+ }
+ else if (!strcmp(ver_str,"2.1"))
+ {
+ return APP_INFO_VERSION_2_1;
+ }
+ else if (!strcmp(ver_str,"2.0"))
+ {
+ return APP_INFO_VERSION_2_0;
+ }
+ else if (!strcmp(ver_str,"1.2"))
+ {
+ return APP_INFO_VERSION_1_2;
+ }
+ else if (!strcmp(ver_str,"1.1"))
+ {
+ return APP_INFO_VERSION_1_1;
+ }
+ else if (!strcmp(ver_str,"1.0.2"))
+ {
+ return APP_INFO_VERSION_1_0_2;
+ }
+ else if (!strcmp(ver_str,"1.0"))
+ {
+ return APP_INFO_VERSION_1_0;
+ }
+ else
+ {
+ return APP_INFO_VERSION_INVALID;
+ }
+}
+
+/**
+ * @brief Returns whether the application is compat mode or not
+ *
+ * @return @c 1 for compat mode, @c 0 otherwise
+ */
+int
+appinfo_is_compat(void)
+{
+ return _compat_mode;
+}
+
+/**
+ * @brief Sets the application compat mode
+ *
+ * @param[in] the compatibility mode
+ * @return 0 on success, otherwise a negative error value
+ * @retval APP_INFO_ERROR_NONE Succesful
+ * @retval APP_INFO_ERROR_INVALID_ARG compat should be either @c 0 or @c 1.
+ */
+int
+appinfo_set_compat(int compat)
+{
+ if (compat == 0 || compat == 1)
+ {
+ _compat_mode = compat;
+ return APP_INFO_ERROR_NONE;
+ }
+ return APP_INFO_ERROR_INVALID_ARG;
+
+}
+
+/**
+ * @brief Returns the appid for the application
+ *
+ * @retval application ID if valid, @c NULL otherwise
+ */
+const char*
+appinfo_get_appid(void)
+{
+ if (likely(_app_info_init))
+ {
+ return _appid;
+ }
+
+ return NULL;
+}
+
+/**
+ * @brief Returns the exec name for the application
+ *
+ * @retval application exec name if valid, empty string otherwise
+ */
+const char*
+appinfo_get_execname(void)
+{
+ return _execname;
+}
+
+
+/**
+ * @brief Returns the packageid for the application
+ *
+ * @retval package ID if valid, @c NULL otherwise
+ */
+const char*
+appinfo_get_packageid(void)
+{
+ if (likely(_app_info_init))
+ {
+ return _pkgid;
+ }
+
+ return NULL;
+}
+
+/**
+ * @brief Returns whether the appinfo is initialized or not
+ *
+ * @return @c 1 if initialized, @c 0 otherwise
+ */
+int
+appinfo_is_initialized(void)
+{
+ return _app_info_init;
+}
+
+int
+appinfo_set_argv(int argc, char** argv)
+{
+ if (argc > 0 && argv)
+ {
+ _argc = argc;
+ _argv = argv;
+ return 1;
+ }
+ return 0;
+}
+
+int appinfo_get_argv(int* argc, char*** argv)
+{
+ if (_app_info_init && argc && argv)
+ {
+ *argc = _argc;
+ *argv = _argv;
+
+ return 1;
+ }
+ return 0;
+}
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+
+int appinfo_update_submode_execname_and_appid(const char* execname)
+{
+ if (execname == NULL)
+ {
+ return 0;
+ }
+
+ const size_t max_len = MAX_APPID - MAX_OSP_PKGID - 1;
+ const size_t size = MIN(strlen(execname), max_len - 1);
+ strncpy(__appid + MAX_OSP_PKGID + 1, execname, size);
+ __appid[size + MAX_OSP_PKGID + 1] = '\0';
+
+ return 1;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/appinfo/appinfo.h b/appinfo/appinfo.h
new file mode 100644
index 0000000..ea7963d
--- /dev/null
+++ b/appinfo/appinfo.h
@@ -0,0 +1,152 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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 _APP_INFO_H_
+#define _APP_INFO_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Enumeration of API version
+ */
+typedef enum
+{
+ APP_INFO_VERSION_INVALID = -1,
+ APP_INFO_VERSION_1_0 = 100,
+ APP_INFO_VERSION_1_0_2 = 102,
+ APP_INFO_VERSION_1_1 = 110,
+ APP_INFO_VERSION_1_2 = 120,
+ APP_INFO_VERSION_2_0 = 200,
+ APP_INFO_VERSION_2_1 = 210,
+ APP_INFO_VERSION_2_2 = 220,
+ APP_INFO_VERSION_3_0 = 300,
+ APP_INFO_VERSION_MAX = 65535,
+} app_info_version_e;
+
+
+/**
+ * @brief Enumerations of error code
+ */
+typedef enum
+{
+ APP_INFO_ERROR_NONE = 0, /**< Successful */
+ APP_INFO_ERROR_INVALID_ARG = -1, /**< Invalid argument */
+} app_info_error_e;
+
+/**
+ * @brief Initializes the appinfo structure
+ *
+ * @param[in] appid The application id to initialize
+ * @param[in] is_invalid_appid @c 1 for invalid appid compatibility mode, @c 0 otherwise
+ * @return 0 on success, otherwise a negative error value
+ * @retval APP_INFO_ERROR_NONE Succesful
+ * @retval APP_INFO_ERROR_INVALID_ARG The appid is invalid
+ * @remarks It initialize the platform API version to APP_INFO_VERSION_3_0 and compat mode 0.
+ */
+int appinfo_init(const char* appid, int is_invalid_appid);
+
+/**
+ * @brief Returns the API version
+ *
+ * @return app_info_version_e value
+ */
+int appinfo_get_api_version(void);
+
+/**
+ * @brief Sets the API version for the current process
+ *
+ * @param[in] ver Given API version
+ * @return 0 on success, otherwise a negative error value
+ * @retval APP_INFO_ERROR_NONE Succesful
+ */
+//int appinfo_set_api_version(int ver);
+int appinfo_set_api_version(app_info_version_e ver);
+
+/**
+ * @brief Returns the API version string by given API version
+ *
+ * @param[in] ver Given API version
+ * @return the API version string by the given version
+ */
+const char* appinfo_get_api_str_by_version(int ver);
+
+/**
+ * @brief Returns the API version by given version string
+ *
+ * @param[in] ver_str Given version string
+ * @return the API version
+ */
+app_info_version_e appinfo_get_api_version_from_str(const char* ver_str);
+
+/**
+ * @brief Returns whether the application is compat mode or not
+ *
+ * @return @c 1 for compat mode, @c 0 otherwise
+ */
+int appinfo_is_compat(void);
+
+/**
+ * @brief Sets the application compat mode
+ *
+ * @param[in] the compatibility mode
+ * @return 0 on success, otherwise a negative error value
+ * @retval APP_INFO_ERROR_NONE Succesful
+ * @retval APP_INFO_ERROR_INVALID_ARG compat should be either @c 0 or @c 1.
+ */
+int appinfo_set_compat(int compat);
+
+/**
+ * @brief Returns the appid for the application
+ *
+ * @retval application ID if valid, @c NULL otherwise
+ */
+const char* appinfo_get_appid(void);
+
+/**
+ * @brief Returns the exec name for the application
+ *
+ * @retval application exec name if valid, empty string otherwise
+ */
+const char* appinfo_get_execname(void);
+
+/**
+ * @brief Returns the packageid for the application
+ *
+ * @retval package ID if valid, @c NULL otherwise
+ */
+const char* appinfo_get_packageid(void);
+
+/**
+ * @brief Returns whether the appinfo is initialized or not
+ *
+ * @return @c 1 if initialized, @c 0 otherwise
+ */
+int appinfo_is_initialized(void);
+
+int appinfo_set_argv(int argc, char** argv);
+
+int appinfo_get_argv(int* argc, char*** argv);
+
+int appinfo_update_submode_execname_and_appid(const char* execname);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //_APP_INFO_H_
+
diff --git a/appinfo/appinfo.pc.in b/appinfo/appinfo.pc.in
new file mode 100644
index 0000000..d83c28c
--- /dev/null
+++ b/appinfo/appinfo.pc.in
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib/osp
+includedir=/usr/include/osp
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
diff --git a/osp-env-config.c b/osp-env-config.c
index d39d551..f259cdf 100644
--- a/osp-env-config.c
+++ b/osp-env-config.c
@@ -30,6 +30,7 @@
#include <limits.h>
#include <sys/prctl.h>
#include <sys/vfs.h>
+#include <fcntl.h>
#include <dlog.h>
#include <vconf.h>
@@ -40,14 +41,21 @@
#define _MAX_PACKAGEID_LENGTH 10
#define _MAX_APIVERSION_LENGTH 3
-static const char* _OSP_HOME_PATH = "/opt/osp/\0"; // /opt/apps/com.samsung.osp
+#ifdef _SECURE_LOG
+#define _SECURE_LOGI LOGI
+#define _SECURE_LOGE LOGE
+#else
+#define _SECURE_LOGI(...)
+#define _SECURE_LOGE(...)
+#endif
+
static const char* _OSP_COMPAT_SHARED_PATH = "/opt/usr/share/.osp-compat/\0";
static const char* _EXT_OSP_HOME_PATH = "/opt/storage/sdcard/osp/\0";
struct _path_info
{
- char src_path[PATH_MAX];
- char dest_path[PATH_MAX];
+ char src_path[PATH_MAX];
+ char dest_path[PATH_MAX];
};
struct _dir_info
@@ -76,7 +84,7 @@ get_app_rootpath_from_path(const char* bin_path)
memset(app_rootpath, '\0', length + 1);
strncpy(app_rootpath, bin_path, length);
- LOGI("input bin_path: %s", app_rootpath);
+ _SECURE_LOGI("input bin_path: %s", app_rootpath);
delimiter = strrchr(app_rootpath, '/');
*delimiter = '\0';
@@ -93,38 +101,39 @@ get_package_id_from_app_rootpath(const char* app_rootpath, char* package_id)
const char* p = NULL;
if (strncmp(app_rootpath, "/opt/apps/org.tizen.", 19) == 0)
{
- p = strrchr(app_rootpath, '.') + 1;
+ p = strrchr(app_rootpath, '.') + 1;
}
else
{
- p = strrchr(app_rootpath, '/') + 1;
+ p = strrchr(app_rootpath, '/') + 1;
}
strncpy(package_id, p, _MAX_PACKAGEID_LENGTH);
- package_id[_MAX_PACKAGEID_LENGTH] = '\0';
- LOGI("package id: %s", package_id);
+ package_id[_MAX_PACKAGEID_LENGTH] = '\0';
+ _SECURE_LOGI("package id: %s", package_id);
}
+#if 0
static void
get_package_id_from_package_name(const char* package_name, char* package_id)
{
- char* tmpbuf = NULL;
-
- if (strncmp(package_name, "com", 3) == 0)
- { // in case of com.samsung.#osp#[package_id]#[serviceid]
- tmpbuf = strstr(package_name, "#osp#");
- if (tmpbuf != NULL)
- {
- strncpy(package_id, tmpbuf + 5, _MAX_PACKAGEID_LENGTH);
- }
- }
- else if (strncmp(package_name, "osp", 3) == 0)
- { // in case of osp.[package_id].#osp#[serviceid]
- tmpbuf = strstr(package_name, "osp.");
- if (tmpbuf != NULL)
- {
- strncpy(package_id, tmpbuf + 4, _MAX_PACKAGEID_LENGTH);
- }
- }
+ char* tmpbuf = NULL;
+
+ if (strncmp(package_name, "com", 3) == 0)
+ { // in case of com.samsung.#osp#[package_id]#[serviceid]
+ tmpbuf = strstr(package_name, "#osp#");
+ if (tmpbuf != NULL)
+ {
+ strncpy(package_id, tmpbuf + 5, _MAX_PACKAGEID_LENGTH);
+ }
+ }
+ else if (strncmp(package_name, "osp", 3) == 0)
+ { // in case of osp.[package_id].#osp#[serviceid]
+ tmpbuf = strstr(package_name, "osp.");
+ if (tmpbuf != NULL)
+ {
+ strncpy(package_id, tmpbuf + 4, _MAX_PACKAGEID_LENGTH);
+ }
+ }
else if (strncmp(package_name, "org.tizen", 9) == 0)
{
// in case of org.tizen.[package_id]#[serviceid]
@@ -134,18 +143,19 @@ get_package_id_from_package_name(const char* package_name, char* package_id)
strncpy(package_id, tmpbuf + 10, _MAX_PACKAGEID_LENGTH);
}
}
- else if (strlen(package_name) == 10)
- {
+ else if (strlen(package_name) == 10)
+ {
strncpy(package_id, package_name, _MAX_PACKAGEID_LENGTH);
- }
- else
- {
- LOGE("package name is invalid (%s)", package_name);
- }
-
- package_id[_MAX_PACKAGEID_LENGTH] = '\0';
- LOGI("package_id: %s", package_id);
+ }
+ else
+ {
+ LOGE("package name is invalid (%s)", package_name);
+ }
+
+ package_id[_MAX_PACKAGEID_LENGTH] = '\0';
+ _SECURE_LOGI("package_id: %s", package_id);
}
+#endif
static int
internal_is_mounted(const char* pkgid)
@@ -246,351 +256,366 @@ external_is_mounted(const char* pkgid)
}
static int
-mount_slp_paths(const char* app_rootpath)
+mount_native_paths(const char* app_rootpath)
{
- int i = 0;
- static const struct _path_info mount_info[] = {
- //{ "/bin", "./bin" },
- //{ "/boot", "./boot" },
- //{ "/cache", "./cache" },
- { "/csa", "./csa" },
- { "/dev", "./dev" },
- { "/dev/pts", "./dev/pts" },
- { "/dev/shm", "./dev/shm" },
- { "/etc", "./etc" },
- { "/lib", "./lib" },
- //{ "/lost+found", "./lost+found" },
- { "/media", "./media" },
- { "/mnt", "./mnt" },
- { "/opt", "./opt" },
- { "/opt/usr", "./opt/usr" },
- { "/opt/var/kdb/db", "./opt/var/kdb/db" },
- { "/opt/storage/sdcard","./opt/storage/sdcard" },
- //{ "/packaging", "./packaging" },
- { "/proc", "./proc" },
- { "/sbin", "./sbin" },
- { "/smack", "./smack" },
- { "/srv", "./srv" },
- { "/sys", "./sys" },
- { "/sys/kernel/debug", "./sys/kernel/debug" },
- { "/tmp", "./tmp" },
- { "/usr", "./usr" },
- { "/var", "./var" },
- { "/var/run", "./var/run" }
- };
-
- if (chdir(app_rootpath) != 0)
- {
- LOGE("chdir() failed path: %s, errno: %d (%s)", app_rootpath, errno, strerror(errno));
- return -1;
- }
-
- for (i = 0; i < sizeof(mount_info)/sizeof(struct _path_info); ++i)
- {
- if (mount(mount_info[i].src_path, mount_info[i].dest_path, NULL, MS_BIND, NULL) != 0)
- {
- LOGE("mount() failed, src path: %s, dest path: %s, errno: %d (%s)",
- mount_info[i].src_path, mount_info[i].dest_path, errno, strerror(errno));
-
- int j = 0;
- for (j = i; j > 0; --j)
- {
- umount2(mount_info[j-1].dest_path, MNT_DETACH);
- }
- return -1;
- }
- }
-
- return 0;
+ int i = 0;
+ static const struct _path_info mount_info[] =
+ {
+ //{ "/bin", "./bin" },
+ { "/csa", "./csa" },
+ { "/dev", "./dev" },
+ { "/dev/pts", "./dev/pts" },
+ { "/dev/shm", "./dev/shm" },
+ { "/etc", "./etc" },
+ { "/lib", "./lib" },
+ { "/mnt", "./mnt" },
+ { "/proc", "./proc" },
+ { "/sbin", "./sbin" },
+ { "/smack", "./smack" },
+ { "/srv", "./srv" },
+ { "/sys", "./sys" },
+ { "/sys/kernel/debug", "./sys/kernel/debug" },
+ { "/tmp", "./tmp" },
+ { "/usr", "./usr" },
+ { "/var", "./var" },
+ { "/var/run", "./var/run" },
+ { "/opt", "./opt" },
+ { "/opt/usr", "./opt/usr" },
+ { "/opt/var/kdb/db", "./opt/var/kdb/db" },
+ //{ "/opt/storage/sdcard","./opt/storage/sdcard" }
+ };
+
+ if (chdir(app_rootpath) != 0)
+ {
+ LOGE("chdir() failed path: %s, errno: %d (%s)", app_rootpath, errno, strerror(errno));
+ return -1;
+ }
+
+ for (i = 0; i < sizeof(mount_info)/sizeof(struct _path_info); ++i)
+ {
+ if (mount(mount_info[i].src_path, mount_info[i].dest_path, NULL, MS_BIND, NULL) != 0)
+ {
+ LOGE("mount() failed, src path: %s, dest path: %s, errno: %d (%s)",
+ mount_info[i].src_path, mount_info[i].dest_path, errno, strerror(errno));
+
+ int j = 0;
+ for (j = i; j > 0; --j)
+ {
+ umount2(mount_info[j-1].dest_path, MNT_DETACH);
+ }
+ return -1;
+ }
+ }
+
+ return 0;
}
static int
mount_osp_internal_paths(const char* app_rootpath, const char* pkgid)
{
- int i = 0;
- char osp_share_pkgid_path[PATH_MAX] = {0, };
- char osp_share2_pkgid_path[PATH_MAX] = {0, };
- struct _path_info mount_info[] = {
- { "\0", "./data/Share" },
- { "\0", "./data/Share2" },
- { "/opt/usr/share/.osp-compat/share", "./Share" },
- { "/opt/usr/share/.osp-compat/share2", "./Share2" },
- //{ "/opt/osp/clipboard", "./Clipboard" },
- //{ "/opt/osp/partner/npki", "./NPKI" },
- //{ "/opt/osp/system", "./System" },
- //{ "/opt/osp/Tmp", "./Tmp" },
- { "/opt/usr/media", "./Media" }
- };
-
- strncpy(osp_share_pkgid_path, _OSP_COMPAT_SHARED_PATH, strlen(_OSP_COMPAT_SHARED_PATH));
- strncat(osp_share_pkgid_path, "share/", 6);
- strncat(osp_share_pkgid_path, pkgid, strlen(pkgid));
-
- strncpy(osp_share2_pkgid_path, _OSP_COMPAT_SHARED_PATH, strlen(_OSP_COMPAT_SHARED_PATH));
- strncat(osp_share2_pkgid_path, "share2/", 7);
- strncat(osp_share2_pkgid_path, pkgid, strlen(pkgid));
-
- strncpy(mount_info[0].src_path, osp_share_pkgid_path, strlen(osp_share_pkgid_path));
- strncpy(mount_info[1].src_path, osp_share2_pkgid_path, strlen(osp_share2_pkgid_path));
-
- if (chdir(app_rootpath) != 0)
- {
- LOGE("chdir() failed, path: %s, errno: %d (%s)", app_rootpath, errno, strerror(errno));
- return -1;
- }
-
- for (i = 0; i < sizeof(mount_info)/sizeof(struct _path_info); ++i)
- {
- if (mount(mount_info[i].src_path, mount_info[i].dest_path, NULL, MS_BIND, NULL) != 0)
- {
- LOGE("mount() failed, src path: %s, dest path: %s, errno: %d (%s)",
- mount_info[i].src_path, mount_info[i].dest_path, errno, strerror(errno));
-
- int j = 0;
- for (j = i; j > 0; --j)
- {
- umount2(mount_info[j-1].dest_path, MNT_DETACH);
- }
- return -1;
- }
- }
-
- return 0;
+ int i = 0;
+ char osp_share_pkgid_path[PATH_MAX] = {0, };
+ char osp_share2_pkgid_path[PATH_MAX] = {0, };
+ struct _path_info mount_info[] =
+ {
+ { "\0", "./data/Share" },
+ { "\0", "./data/Share2" },
+ { "/opt/usr/share/.osp-compat/share", "./Share" },
+ { "/opt/usr/share/.osp-compat/share2", "./Share2" },
+ { "/opt/usr/media", "./Media" }
+ };
+
+ strncpy(osp_share_pkgid_path, _OSP_COMPAT_SHARED_PATH, strlen(_OSP_COMPAT_SHARED_PATH));
+ strncat(osp_share_pkgid_path, "share/", 6);
+ strncat(osp_share_pkgid_path, pkgid, strlen(pkgid));
+
+ strncpy(osp_share2_pkgid_path, _OSP_COMPAT_SHARED_PATH, strlen(_OSP_COMPAT_SHARED_PATH));
+ strncat(osp_share2_pkgid_path, "share2/", 7);
+ strncat(osp_share2_pkgid_path, pkgid, strlen(pkgid));
+
+ strncpy(mount_info[0].src_path, osp_share_pkgid_path, strlen(osp_share_pkgid_path));
+ strncpy(mount_info[1].src_path, osp_share2_pkgid_path, strlen(osp_share2_pkgid_path));
+
+ if (chdir(app_rootpath) != 0)
+ {
+ LOGE("chdir() failed, path: %s, errno: %d (%s)", app_rootpath, errno, strerror(errno));
+ return -1;
+ }
+
+ for (i = 0; i < sizeof(mount_info)/sizeof(struct _path_info); ++i)
+ {
+ if (mount(mount_info[i].src_path, mount_info[i].dest_path, NULL, MS_BIND, NULL) != 0)
+ {
+ LOGE("mount() failed, src path: %s, dest path: %s, errno: %d (%s)",
+ mount_info[i].src_path, mount_info[i].dest_path, errno, strerror(errno));
+
+ int j = 0;
+ for (j = i; j > 0; --j)
+ {
+ umount2(mount_info[j-1].dest_path, MNT_DETACH);
+ }
+ return -1;
+ }
+ }
+
+ return 0;
}
static int
-link_osp_share_path(const char* app_rootpath, const char* pkgid)
+mount_linux_paths(const char* app_rootpath)
{
- char osp_app_share_path[PATH_MAX] = { 0, };
- char osp_app_share2_path[PATH_MAX] = { 0, };
- char osp_share_pkgid_path[PATH_MAX] = { 0, };
- char osp_share2_pkgid_path[PATH_MAX] = { 0, };
-
- strncpy(osp_app_share_path, app_rootpath, strlen(app_rootpath));
- strncat(osp_app_share_path, "/shared/data", 12);
-
- strncpy(osp_share_pkgid_path, _OSP_COMPAT_SHARED_PATH, strlen(_OSP_COMPAT_SHARED_PATH));
- strncat(osp_share_pkgid_path, "share/", 6);
- strncat(osp_share_pkgid_path, pkgid, strlen(pkgid));
-
- strncpy(osp_app_share2_path, app_rootpath, strlen(app_rootpath));
- strncat(osp_app_share2_path, "/shared/trusted", 15);
-
- strncpy(osp_share2_pkgid_path, _OSP_COMPAT_SHARED_PATH, strlen(_OSP_COMPAT_SHARED_PATH));
- strncat(osp_share2_pkgid_path, "share2/", 7);
- strncat(osp_share2_pkgid_path, pkgid, strlen(pkgid));
-
- unlink(osp_share_pkgid_path);
- unlink(osp_share2_pkgid_path);
-
- int ret = symlink(osp_app_share_path, osp_share_pkgid_path);
- if (ret == -1 && errno != EEXIST)
- {
- LOGE("symlink() failed, src path: %s, dest path: %s, errno: %d (%s)",
- osp_app_share_path, osp_share_pkgid_path, errno, strerror(errno));
- return -1;
- }
-
- ret = symlink(osp_app_share2_path, osp_share2_pkgid_path);
- if (ret == -1 && errno != EEXIST)
- {
- LOGE("symlink() failed, src path: %s, dest path: %s, errno: %d (%s)",
- osp_app_share2_path, osp_share2_pkgid_path, errno, strerror(errno));
- return -1;
- }
-
- return 0;
+ int i = 0;
+ static const struct _path_info mount_info[] =
+ {
+ { "/bin", "./bin" },
+ { "/cache", "./cache" },
+ { "/csa", "./csa" },
+ { "/data", "./data" },
+ { "/dev", "./dev" },
+ { "/dev/pts", "./dev/pts" },
+ { "/dev/shm", "./dev/shm" },
+ { "/etc", "./etc" },
+ { "/lib", "./lib" },
+ { "/lib/modules", "./lib/modules" },
+ { "/media", "./media" },
+ { "/mnt", "./mnt" },
+ { "/proc", "./proc" },
+ { "/run", "./run" },
+ { "/sbin", "./sbin" },
+ { "/smack", "./smack" },
+ { "/srv", "./srv" },
+ { "/sys", "./sys" },
+ { "/sys/fs/cgroup", "./sys/fs/cgroup" },
+ { "/sys/fs/cgroup/systemd", "./sys/fs/cgroup/systemd" },
+ { "/system", "./system" },
+ { "/tmp", "./tmp" },
+ { "/usr", "./usr" },
+ { "/var", "./var" },
+ { "/var/run", "./var/run" },
+ { "/opt", "./opt" },
+ { "/opt/usr", "./opt/usr" },
+ //{ "/opt/var/run", "./opt/var/run" },
+ { "/opt/storage/sdcard","./opt/storage/sdcard" },
+ };
+
+ if (chdir(app_rootpath) != 0)
+ {
+ LOGE("chdir() failed path: %s, errno: %d (%s)", app_rootpath, errno, strerror(errno));
+ return -1;
+ }
+
+ for (i = 0; i < sizeof(mount_info)/sizeof(struct _path_info); ++i)
+ {
+ if (i == 27) // /opt/storage/sdcard
+ {
+ int mmc_mounted = 0;
+ int ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &mmc_mounted);
+ if (ret < 0)
+ {
+ LOGE("vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS) failed.");
+ }
+ if (mmc_mounted == 0)
+ {
+ continue;
+ }
+ }
+
+ LOGI("src path: %s, dest path: %s", mount_info[i].src_path, mount_info[i].dest_path);
+ if (mount(mount_info[i].src_path, mount_info[i].dest_path, NULL, MS_BIND, NULL) != 0)
+ {
+ LOGE("mount() failed, src path: %s, dest path: %s, errno: %d (%s)",
+ mount_info[i].src_path, mount_info[i].dest_path, errno, strerror(errno));
+
+ int j = 0;
+ for (j = i; j > 0; --j)
+ {
+ umount2(mount_info[j-1].dest_path, MNT_DETACH);
+ }
+ return -1;
+ }
+ }
+
+ return 0;
}
static int
create_osp_external_paths(const char* app_rootpath, const char* pkgid)
{
- char osp_ext_apps_pkgid_path[PATH_MAX] = {0, };
- char osp_ext_apps_pkgid_share_path[PATH_MAX] = {0, };
- char osp_ext_apps_pkgid_share2_path[PATH_MAX] = {0, };
- char osp_ext_share_pkgid_path[PATH_MAX] = {0, };
- char osp_ext_share2_pkgid_path[PATH_MAX] = {0, };
- struct _dir_info external_dirs[] = {
- { "./HomeExt", 0000, 0},
- { "./ShareExt", 0000, 0},
- { "./Share2Ext", 0000, 0},
- { "/opt/storage/sdcard/osp", 0777, 0 },
- { "/opt/storage/sdcard/osp/apps", 0777, 0 },
- { "/opt/storage/sdcard/osp/share", 0777, 0 },
- { "/opt/storage/sdcard/osp/share2", 0777, 0 },
- { "\0", 0777, 0},
- { "\0", 0777, 0},
- { "\0", 0777, 0},
- { "\0", 0777, 0},
- { "\0", 0777, 0},
- { "/opt/storage/sdcard/Images", 0777, 0 },
- { "/opt/storage/sdcard/Sounds", 0777, 0 },
- { "/opt/storage/sdcard/Videos", 0777, 0 },
- //{ "/opt/storage/sdcard/Themes", 0777, 0 },
- { "/opt/storage/sdcard/Others", 0777, 0 }
+ char osp_ext_apps_pkgid_path[PATH_MAX] = {0, };
+ char osp_ext_apps_pkgid_share_path[PATH_MAX] = {0, };
+ char osp_ext_apps_pkgid_share2_path[PATH_MAX] = {0, };
+ char osp_ext_share_pkgid_path[PATH_MAX] = {0, };
+ char osp_ext_share2_pkgid_path[PATH_MAX] = {0, };
+ struct _dir_info external_dirs[] =
+ {
+ { "./HomeExt", 0000, 0 },
+ { "./ShareExt", 0000, 0 },
+ { "./Share2Ext", 0000, 0 },
+ { "/opt/storage/sdcard/osp", 0777, 0 },
+ { "/opt/storage/sdcard/osp/apps", 0777, 0 },
+ { "/opt/storage/sdcard/osp/share", 0777, 0 },
+ { "/opt/storage/sdcard/osp/share2", 0777, 0 },
+ { "\0", 0777, 0},
+ { "\0", 0777, 0},
+ { "\0", 0777, 0},
+ { "\0", 0777, 0},
+ { "\0", 0777, 0},
+ { "/opt/storage/sdcard/Images", 0777, 0 },
+ { "/opt/storage/sdcard/Sounds", 0777, 0 },
+ { "/opt/storage/sdcard/Videos", 0777, 0 },
+ { "/opt/storage/sdcard/Others", 0777, 0 }
};
- int i = 0;
-
- strncpy(osp_ext_apps_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
- strncat(osp_ext_apps_pkgid_path, "apps/", 5);
- strncat(osp_ext_apps_pkgid_path, pkgid, strlen(pkgid));
-
- strncpy(osp_ext_apps_pkgid_share_path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
- strncat(osp_ext_apps_pkgid_share_path, "/Share", 6);
-
- strncpy(osp_ext_apps_pkgid_share2_path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
- strncat(osp_ext_apps_pkgid_share2_path, "/Share2", 7);
-
- strncpy(osp_ext_share_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
- strncat(osp_ext_share_pkgid_path, "share/", 6);
- strncat(osp_ext_share_pkgid_path, pkgid, strlen(pkgid));
-
- strncpy(osp_ext_share2_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
- strncat(osp_ext_share2_pkgid_path, "share2/", 7);
- strncat(osp_ext_share2_pkgid_path, pkgid, strlen(pkgid));
-
- strncpy(external_dirs[7].path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
- strncpy(external_dirs[8].path, osp_ext_apps_pkgid_share_path, strlen(osp_ext_apps_pkgid_share_path));
- strncpy(external_dirs[9].path, osp_ext_apps_pkgid_share2_path, strlen(osp_ext_apps_pkgid_share2_path));
- strncpy(external_dirs[10].path, osp_ext_share_pkgid_path, strlen(osp_ext_share_pkgid_path));
- strncpy(external_dirs[11].path, osp_ext_share2_pkgid_path, strlen(osp_ext_share2_pkgid_path));
-
- if (chdir(app_rootpath) != 0)
- {
- LOGE("chdir() failed (%s), path: %s", strerror(errno), app_rootpath);
- return -1;
- }
-
- for (i = 0; i < sizeof(external_dirs)/sizeof(struct _dir_info); i++)
- {
- int ret = mkdir(external_dirs[i].path, external_dirs[i].mode);
- if (ret == -1 && errno != 17) // EEXIST
- {
- LOGE("mkdir() failed, path: %s, errno: %d (%s)", external_dirs[i].path, errno, strerror(errno));
- return -1;
- }
- }
-
- return 0;
+ int i = 0;
+
+ strncpy(osp_ext_apps_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
+ strncat(osp_ext_apps_pkgid_path, "apps/", 5);
+ strncat(osp_ext_apps_pkgid_path, pkgid, strlen(pkgid));
+
+ strncpy(osp_ext_apps_pkgid_share_path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
+ strncat(osp_ext_apps_pkgid_share_path, "/Share", 6);
+
+ strncpy(osp_ext_apps_pkgid_share2_path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
+ strncat(osp_ext_apps_pkgid_share2_path, "/Share2", 7);
+
+ strncpy(osp_ext_share_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
+ strncat(osp_ext_share_pkgid_path, "share/", 6);
+ strncat(osp_ext_share_pkgid_path, pkgid, strlen(pkgid));
+
+ strncpy(osp_ext_share2_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
+ strncat(osp_ext_share2_pkgid_path, "share2/", 7);
+ strncat(osp_ext_share2_pkgid_path, pkgid, strlen(pkgid));
+
+ strncpy(external_dirs[7].path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
+ strncpy(external_dirs[8].path, osp_ext_apps_pkgid_share_path, strlen(osp_ext_apps_pkgid_share_path));
+ strncpy(external_dirs[9].path, osp_ext_apps_pkgid_share2_path, strlen(osp_ext_apps_pkgid_share2_path));
+ strncpy(external_dirs[10].path, osp_ext_share_pkgid_path, strlen(osp_ext_share_pkgid_path));
+ strncpy(external_dirs[11].path, osp_ext_share2_pkgid_path, strlen(osp_ext_share2_pkgid_path));
+
+ if (chdir(app_rootpath) != 0)
+ {
+ LOGE("chdir() failed (%s), path: %s", strerror(errno), app_rootpath);
+ return -1;
+ }
+
+ for (i = 0; i < sizeof(external_dirs)/sizeof(struct _dir_info); i++)
+ {
+ int ret = mkdir(external_dirs[i].path, external_dirs[i].mode);
+ if (ret == -1 && errno != 17) // EEXIST
+ {
+ LOGE("mkdir() failed, path: %s, errno: %d (%s)", external_dirs[i].path, errno, strerror(errno));
+ return -1;
+ }
+ }
+
+ return 0;
}
static int
mount_osp_external_paths(const char* app_rootpath, const char* pkgid)
{
- char osp_ext_apps_pkgid_path[PATH_MAX] = {0, };
- char osp_ext_share_pkgid_path[PATH_MAX] = {0, };
- char osp_ext_share2_pkgid_path[PATH_MAX] = {0, };
- struct _path_info mount_info[] = {
- { "/opt/storage/sdcard", "./Storagecard/Media" },
- { "/opt/storage/sdcard/osp/share", "./ShareExt" },
- { "/opt/storage/sdcard/osp/share2", "./Share2Ext" },
- { "\0", "./HomeExt" },
- { "\0", "./HomeExt/Share" },
- { "\0", "./HomeExt/Share2" },
- };
- int i = 0;
-
- strncpy(osp_ext_apps_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
- strncat(osp_ext_apps_pkgid_path, "apps/", 5);
- strncat(osp_ext_apps_pkgid_path, pkgid, strlen(pkgid));
-
- strncpy(osp_ext_share_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
- strncat(osp_ext_share_pkgid_path, "share/", 6);
- strncat(osp_ext_share_pkgid_path, pkgid, strlen(pkgid));
-
- strncpy(osp_ext_share2_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
- strncat(osp_ext_share2_pkgid_path, "share2/", 7);
- strncat(osp_ext_share2_pkgid_path, pkgid, strlen(pkgid));
-
- strncpy(mount_info[3].src_path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
- strncpy(mount_info[4].src_path, osp_ext_share_pkgid_path, strlen(osp_ext_share_pkgid_path));
- strncpy(mount_info[5].src_path, osp_ext_share2_pkgid_path, strlen(osp_ext_share2_pkgid_path));
-
- if (chdir(app_rootpath) != 0)
- {
- LOGE("chdir() failed, path: %s, errno: %d (%s)", app_rootpath, errno, strerror(errno));
- return -1;
- }
- LOGI("app_rootpath: %s", app_rootpath);
-
- for (i = 0; i < sizeof(mount_info)/sizeof(struct _path_info); i++)
- {
- if (mount(mount_info[i].src_path, mount_info[i].dest_path, NULL, MS_BIND, NULL) != 0)
- {
- LOGE("mount() failed, src path: %s, dest path: %s, errno: %d (%s)",
- mount_info[i].src_path, mount_info[i].dest_path, errno, strerror(errno));
-
- int j = 0;
- for (j = i; j > 0; --j)
- {
- umount2(mount_info[j-1].dest_path, MNT_DETACH);
- }
- return -1;
- }
- }
-
- return 0;
+ char osp_ext_apps_pkgid_path[PATH_MAX] = {0, };
+ char osp_ext_share_pkgid_path[PATH_MAX] = {0, };
+ char osp_ext_share2_pkgid_path[PATH_MAX] = {0, };
+ struct _path_info mount_info[] =
+ {
+ { "/opt/storage/sdcard", "./Storagecard/Media" },
+ { "/opt/storage/sdcard/osp/share", "./ShareExt" },
+ { "/opt/storage/sdcard/osp/share2", "./Share2Ext" },
+ { "\0", "./HomeExt" },
+ { "\0", "./HomeExt/Share" },
+ { "\0", "./HomeExt/Share2" }
+ };
+ int i = 0;
+
+ strncpy(osp_ext_apps_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
+ strncat(osp_ext_apps_pkgid_path, "apps/", 5);
+ strncat(osp_ext_apps_pkgid_path, pkgid, strlen(pkgid));
+
+ strncpy(osp_ext_share_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
+ strncat(osp_ext_share_pkgid_path, "share/", 6);
+ strncat(osp_ext_share_pkgid_path, pkgid, strlen(pkgid));
+
+ strncpy(osp_ext_share2_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
+ strncat(osp_ext_share2_pkgid_path, "share2/", 7);
+ strncat(osp_ext_share2_pkgid_path, pkgid, strlen(pkgid));
+
+ strncpy(mount_info[3].src_path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
+ strncpy(mount_info[4].src_path, osp_ext_share_pkgid_path, strlen(osp_ext_share_pkgid_path));
+ strncpy(mount_info[5].src_path, osp_ext_share2_pkgid_path, strlen(osp_ext_share2_pkgid_path));
+
+ if (chdir(app_rootpath) != 0)
+ {
+ LOGE("chdir() failed, path: %s, errno: %d (%s)", app_rootpath, errno, strerror(errno));
+ return -1;
+ }
+ LOGI("app_rootpath: %s", app_rootpath);
+
+ for (i = 0; i < sizeof(mount_info)/sizeof(struct _path_info); i++)
+ {
+ if (mount(mount_info[i].src_path, mount_info[i].dest_path, NULL, MS_BIND, NULL) != 0)
+ {
+ LOGE("mount() failed, src path: %s, dest path: %s, errno: %d (%s)",
+ mount_info[i].src_path, mount_info[i].dest_path, errno, strerror(errno));
+
+ int j = 0;
+ for (j = i; j > 0; --j)
+ {
+ umount2(mount_info[j-1].dest_path, MNT_DETACH);
+ }
+ return -1;
+ }
+ }
+
+ return 0;
}
int
do_pre_exe(const char* package_name, const char* bin_path, const char* package_id)
{
char* app_rootpath = NULL;
- char osp_app_data_path[PATH_MAX] = {0, };
- //char internal_installed = 1; // true
int mmc_mounted = 0;
- struct statfs fs;
- /* e.g., app_rootdir is "/opt/apps/com.samsung.basicapp or /opt/osp/applications/[appId] */
+ /* e.g., app_rootdir is "/opt/usr/apps/[pkgId] */
app_rootpath = get_app_rootpath_from_path(bin_path);
- LOGI("[data_caging] do_pre_exe() was called, package name: %s, \
- binary path: %s, application root(home) path: %s, package id: %s",
- package_name, bin_path, app_rootpath, package_id);
+ _SECURE_LOGI("[data_caging] do_pre_exe() was called, package name: %s, package id: %s, binary: %s, app root: %s",
+ package_name, package_id, bin_path, app_rootpath);
umask(0000);
- // TODO: Check whether the application is installed in internal or external storage.
- // Check installation position using the input path.
- //if (internal_installed)
- //{
-
- if (!internal_is_mounted(package_id))
- {
- if (mount_slp_paths(app_rootpath) != 0)
- goto ERROR;
-
- if (mount_osp_internal_paths(app_rootpath, package_id) != 0)
- goto ERROR;
- }
-
- int ret = 0;
- ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &mmc_mounted);
- if (ret < 0)
- {
- LOGE("vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS) failed.");
- }
- if (mmc_mounted == 1)
- {
- LOGI("MMC is mounted.");
- if (create_osp_external_paths(app_rootpath, package_id) != 0)
- {
- goto ERROR;
- }
-
- if (!external_is_mounted(package_id))
- {
- if (mount_osp_external_paths(app_rootpath, package_id) != 0)
- {
- goto ERROR;
- }
- }
- }
- /*}
- else
+ if (!internal_is_mounted(package_id))
+ {
+ if (mount_native_paths(app_rootpath) != 0)
+ {
+ goto ERROR;
+ }
+ if (mount_osp_internal_paths(app_rootpath, package_id) != 0)
+ {
+ goto ERROR;
+ }
+ }
+
+ int ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &mmc_mounted);
+ if (ret < 0)
{
- // TODO mount_external_paths(app_rootpath);
- }*/
+ LOGE("vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS) failed.");
+ }
+ if (mmc_mounted == 1)
+ {
+ LOGI("MMC is mounted.");
+ if (create_osp_external_paths(app_rootpath, package_id) != 0)
+ {
+ goto ERROR;
+ }
+
+ if (!external_is_mounted(package_id))
+ {
+ if (mount_osp_external_paths(app_rootpath, package_id) != 0)
+ {
+ goto ERROR;
+ }
+ }
+ }
LOGI("mount() succeeded.");
if (chroot(app_rootpath) != 0)
@@ -598,19 +623,13 @@ do_pre_exe(const char* package_name, const char* bin_path, const char* package_i
LOGE("chroot() failed, path: %s, errno: %d (%s)", app_rootpath, errno, strerror(errno));
goto ERROR;
}
- if (chdir("/") != 0)
+ if (chdir("/") != 0)
{
LOGE("chdir() failed, path: /, errno: %d (%s)", errno, strerror(errno));
goto ERROR;
}
LOGI("chroot() succeeded.");
- // set current working dir to "/opt/apps/{packageId}/data"
-#if 0
- strncpy(osp_app_data_path, app_rootpath, strlen(app_rootpath));
- strncat(osp_app_data_path, "/data", strlen("/data"));
-#endif
-
if (chdir("/data") != 0)
{
LOGE("chdir() failed, path: /data, errno: %d (%s)", errno, strerror(errno));
@@ -618,69 +637,140 @@ do_pre_exe(const char* package_name, const char* bin_path, const char* package_i
}
free(app_rootpath);
- umask(0022);
+ umask(0022);
LOGI("[data_caging] do_pre_exec() succeeded.");
return 0;
ERROR:
- free(app_rootpath);
- umask(0022);
+ free(app_rootpath);
+ umask(0022);
LOGI("[data_caging] do_pre_exec() failed.");
- return -1;
+ return -1;
+}
+
+static int
+do_virtual_root(const char* virtual_root_path, const char* package_id)
+{
+ _SECURE_LOGI("[virtual_root] do_virtual_root() was called, virtual root path: %s, package id: %s",
+ virtual_root_path, package_id);
+
+ umask(0000);
+
+ if (!internal_is_mounted(package_id))
+ {
+ if (mount_linux_paths(virtual_root_path) != 0)
+ {
+ goto ERROR;
+ }
+ }
+ LOGI("mount() succeeded.");
+
+ if (chroot(virtual_root_path) != 0)
+ {
+ LOGE("chroot() failed. path: %s, errno: %d (%s)", virtual_root_path, errno, strerror(errno));
+ goto ERROR;
+ }
+ if (chdir("/") != 0)
+ {
+ LOGE("chdir() failed. path: /data, errno: %d (%s)", errno, strerror(errno));
+ goto ERROR;
+ }
+ LOGI("chroot() succeeded.");
+
+ umask(0022);
+
+ LOGI("[virtual_root] do_virtual_root() succeeded.");
+ return 0;
+
+ERROR:
+ umask(0022);
+
+ LOGI("[virtual_root] do_virtual_root() failed.");
+ return -1;
}
int
do_pre_exec(const char* package_name, const char* bin_path)
{
char* app_rootpath = NULL;
- char app_compat_path[PATH_MAX] = { 0, };
- const char app_compat_file[] = "/info/compat.info\0";
- int pathlen = 0;
- char package_id[_MAX_PACKAGEID_LENGTH + 1] = { 0, };
- char osp_app_data_path[PATH_MAX] = { 0, };
- int osp_compat = 0;
+ char app_compat_path[PATH_MAX] = { 0, };
+ const char app_compat_file[] = "/info/compat.info\0";
+ char package_id[_MAX_PACKAGEID_LENGTH + 1] = { 0, };
+ char osp_app_data_path[PATH_MAX] = { 0, };
+ int osp_compat = 0;
- LOGI("do_pre_exec() is called, package_name: %s, bin_path: %s", package_name, bin_path);
+ _SECURE_LOGI("do_pre_exec() is called, package name: %s, binary path: %s", package_name, bin_path);
app_rootpath = get_app_rootpath_from_path(bin_path);
strncpy(app_compat_path, app_rootpath, strlen(app_rootpath));
strncat(app_compat_path, app_compat_file, strlen(app_compat_file));
- if (access(app_compat_path, F_OK) == 0)
- {
- osp_compat = 1;
- }
-
- // XXX: temp code
- //if (package_name == NULL)
- {
- //LOGI("The package name is empty.");
- get_package_id_from_app_rootpath(app_rootpath, package_id);
- }
+ if (access(app_compat_path, F_OK) == 0)
+ {
+ osp_compat = 1;
+ }
+
+ // XXX: temp code
+ //if (package_name == NULL)
+ {
+ //LOGI("The package name is empty.");
+ get_package_id_from_app_rootpath(app_rootpath, package_id);
+ }
#if 0
- else
- {
- get_package_id_from_package_name(package_name, package_id);
- }
+ else
+ {
+ get_package_id_from_package_name(package_name, package_id);
+ }
#endif
- // XXX-end
+ // XXX-end
- LOGI("package name: %s, binary path: %s, package id: %s, OSP compatibility: %d",
- package_name, bin_path, package_id, osp_compat);
+ _SECURE_LOGI("package: %s (%s), binary: %s, OSP compat: %d", package_name, package_id, bin_path, osp_compat);
// FIXME: Temporary code with security risk
prctl(PR_SET_KEEPCAPS, 1);
- if (osp_compat == 1)
- {
+ if (osp_compat == 1)
+ {
free(app_rootpath);
//unshare(CLONE_NEWNS);
return do_pre_exe(package_name, bin_path, package_id);
- }
+ }
+
+ char virtual_root_file[PATH_MAX] = { 0, };
+ const char virtual_root_info[] = "/info/virtualroot.info";
+ strncpy(virtual_root_file, app_rootpath, strlen(app_rootpath));
+ strncat(virtual_root_file, virtual_root_info, strlen(virtual_root_info));
+ if (access(virtual_root_file, F_OK) == 0)
+ {
+ LOGI("This is virtual root application.");
+ int fd = open(virtual_root_file, O_RDONLY);
+ if (fd < 0)
+ {
+ LOGE("failed to open %s, errno: %d (%s)", virtual_root_file, errno, strerror(errno));
+ goto ERROR;
+ }
- // API version is equal to or greater than Tizen 2.0
+ char user_path[PATH_MAX] = { 0, };
+ int read_bytes = read(fd, user_path, PATH_MAX);
+ if (read_bytes < 0)
+ {
+ LOGE("failed to read %s, errno: %d (%s)", virtual_root_file, errno, strerror(errno));
+ close(fd);
+ goto ERROR;
+ }
+ close(fd);
+
+ char virtual_root_path[PATH_MAX] = { 0, };
+ sprintf(virtual_root_path, "%s/data/%s", app_rootpath, user_path);
+
+ int res = do_virtual_root(virtual_root_path, package_id);
+ free(app_rootpath);
+ return res;
+ }
+
+ // API version is equal to or greater than Tizen 2.0
// Set current working dir to "/opt/apps/{pkgId}/data"
strncpy(osp_app_data_path, app_rootpath, strlen(app_rootpath));
strncat(osp_app_data_path, "/data", strlen("/data"));
@@ -691,11 +781,6 @@ do_pre_exec(const char* package_name, const char* bin_path)
goto ERROR;
}
- if (link_osp_share_path(app_rootpath, package_id) != 0)
- {
- goto ERROR;
- }
-
LOGI("[data_caging] do_pre_exec() succeeded.");
free(app_rootpath);
return 0;
diff --git a/packaging/osp-env-config.spec b/packaging/osp-env-config.spec
index 8148f29..007b62d 100755..100644
--- a/packaging/osp-env-config.spec
+++ b/packaging/osp-env-config.spec
@@ -1,9 +1,9 @@
Name: osp-env-config
Summary: osp application environment cofiguration serivce
-Version: 1.2.1.0
+Version: 1.2.2.1
Release: 2
Group: System/Libraries
-License: Apache-2.0 or Flora
+License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
Source1001: osp-env-config.manifest
BuildRequires: cmake
@@ -11,20 +11,33 @@ BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(vconf)
Requires(post): coreutils
+Requires(post): /sbin/ldconfig
%description
osp application environment cofiguration serivce
+%package devel
+Summary: osp application environment cofiguration serivce (devel)
+Group: System/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+osp application environment cofiguration serivce (devel)
+
%prep
%setup -q
cp %{SOURCE1001} .
-%build
+%build
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
%ifarch %{ix86} x86_64
-CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_ -D_SECURE_LOG" %cmake .
+%if 0%{?simulator}
+CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_ -D_SECURE_LOG" %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%else
+CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_SECURE_LOG" %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%endif
%else
-CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_ -D_SECURE_LOG" %cmake .
+CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_ -D_SECURE_LOG" %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
%endif
# Call make instruction with smp support
@@ -46,4 +59,9 @@ cp %{_builddir}/%{name}-%{version}/LICENSE.APLv2 %{buildroot}/usr/share/license
%manifest %{name}.manifest
/usr/share/license/%{name}
%{_libdir}/*.so*
+%{_libdir}/osp/libappinfo.so*
+/usr/etc/app-storage-exclude-dirs.list
+%files devel
+%{_includedir}/osp/*.h
+%{_libdir}/pkgconfig/appinfo.pc
diff --git a/usr/etc/app-storage-exclude-dirs.list b/usr/etc/app-storage-exclude-dirs.list
new file mode 100644
index 0000000..199a06f
--- /dev/null
+++ b/usr/etc/app-storage-exclude-dirs.list
@@ -0,0 +1,23 @@
+csa
+dev
+etc
+lib
+mnt
+proc
+sbin
+smack
+srv
+sys
+tmp
+usr
+var
+opt
+data/Share
+data/Share2
+Share
+Share2
+Media
+HomeExt
+ShareExt
+Share2Ext
+Storagecard/Media