fix system service loader to remove path dependency
authorYoung Ik Cho <youngik.cho@samsung.com>
Tue, 9 Apr 2013 12:36:06 +0000 (21:36 +0900)
committerYoung Ik Cho <youngik.cho@samsung.com>
Tue, 9 Apr 2013 12:41:30 +0000 (21:41 +0900)
Change-Id: Iad87145f72304a5da9e32411e7137eb24acd3eda
Signed-off-by: Young Ik Cho <youngik.cho@samsung.com>
osp-service-app-loader/CMakeLists.txt [changed mode: 0755->0644]
osp-system-service-loader/CMakeLists.txt [changed mode: 0755->0644]
osp-system-service-loader/systemservice_loader.c
osp-ui-app-loader/uiapp_loader.c
packaging/osp-loader.spec

old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index d94a187..7dfb9d5 100644 (file)
@@ -92,51 +92,37 @@ osp_do_pre_exe(const char* bin_path)
 static int
 get_appid_executable_name_from_path(const char path[], char appid[], char executable_name[])
 {
-       const char* begin = NULL;
-       const char* end = NULL;
-       const int path_len = strlen(path);
-
-       // path is "/opt/apps/[appid]/bin/[executable_name]"
+       // path is ".../[appid]/bin/[executable_name]"
 
        // Calculate the header
-       const char* p = strstr(path, "/opt/apps/");
+       const char* p = strrchr(path, '/');
        if (p == NULL)
        {
                LOGI("Improper path %s", path);
                return -1;
        }
 
-       LOGI("Proper appId format");
-
-       begin = p + 9;
-
-       end = strchr(begin + 1, '/');
-       if (end == NULL)
-       {
+       const int path_len = strlen(path);
+       const int exec_len = strlen(p);
+       if (exec_len <= 0 || exec_len > PATH_MAX || path_len <= 0 || path_len > PATH_MAX)   
+       {   
                LOGI("Improper path %s", path);
                return -1;
        }
 
-       const int len = end - begin - 1;
+       strncpy(executable_name, p + 1, exec_len);
 
-       if (len > MAX_APPID)
+       LOGI("ExeName is %s", executable_name);
+
+       if (path_len < /* '/' */ 1 + 10 + strlen("/bin/") + exec_len)
        {
-               LOGI("Improper path %s with length %d", path, len);
+               LOGI("Improper path %s", path);
                return -1;
        }
 
-       strncpy(appid, begin + 1, len);
-       LOGI("appId is %s", appid);
-
-       int exe_len = 0;
-
-       if (path_len > len + 15)
-       {
-               exe_len = MIN(MAX_APP_EXECUTABLE_NAME - 1, path_len - len - 15);
-               strncpy(executable_name, end + 5, exe_len);
-       }
+       strncpy(appid, p - strlen("bin/") - 10, 10);
 
-       LOGI("exeName is %s", executable_name);
+       LOGI("PackageId is %s", appid);
 
        return 1;
 }
index ab327e6..9a7895f 100644 (file)
@@ -194,7 +194,7 @@ osp_do_pre_exe(const char* bin_path)
 static int
 get_appid_executable_name_from_path(const char path[], char appid[], char executable_name[])
 {
-       // path is "/opt/apps/[appid]/bin/[executable_name]"
+       // path is ".../[appid]/bin/[executable_name]"
 
        const char* p = strrchr(path, '/');
        if (p == NULL)
index 452029b..68f62fe 100755 (executable)
@@ -1,9 +1,9 @@
 Name:          osp-loader
 Summary:       osp application loader
 Version:       1.2.1.0
-Release:       1
+Release:       2
 Group:         TO_BE/FILLED_IN
-License:       Apache-2.0 or Flora
+License:       Apache-2.0
 Source0:       %{name}-%{version}.tar.gz
 BuildRequires: cmake
 BuildRequires: pkgconfig(aul)
@@ -11,7 +11,7 @@ BuildRequires:        pkgconfig(dlog)
 BuildRequires: pkgconfig(libprivilege-control)
 
 # runtime requires
-Requires: osp-env-config
+Requires:      osp-env-config
 
 %description
 osp application loader