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;
}
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)
BuildRequires: pkgconfig(libprivilege-control)
# runtime requires
-Requires: osp-env-config
+Requires: osp-env-config
%description
osp application loader