char *dbus_sender_name;
} target_app_info_s;
+static const char *__last_index_of(const char *path, const char *search);
static bool __make_sharing_dir(const char *dir)
{
GFile *noti_dir = NULL;
}
static char *__get_data_path_by_pkg_id(const char *pkg_id,
- const char *file_name, uid_t uid)
+ const char *file_path, uid_t uid)
{
const char *path;
- char dir[PATH_MAX];
+ char dir[PATH_MAX * 2];
+ char rel_file_path[PATH_MAX];
+ const char *pkg_path;
if (pkg_id == NULL)
return NULL;
if (path == NULL)
return NULL;
- snprintf(dir, sizeof(dir), "%s/%s/%s", path, pkg_id, NOTI_PRIV_DATA_DIR);
+ pkg_path = __last_index_of(file_path, pkg_id);
+ if (pkg_path == NULL) {
+ ERR("Wrong file path : cannot find pkgid");
+ return NULL;
+ }
+
+ snprintf(rel_file_path, sizeof(rel_file_path), "%s",
+ pkg_path + strlen(pkg_id));
+
+ for (int i = 0; i < strlen(rel_file_path); i++) {
+ if (rel_file_path[i] == '/')
+ rel_file_path[i] = '_';
+ }
+ snprintf(dir, sizeof(dir), "%s/%s/%s",
+ path, pkg_id, NOTI_PRIV_DATA_DIR);
if (__make_sharing_dir(dir) == false)
return NULL;
snprintf(dir, sizeof(dir), "%s/%s/%s/%s", path, pkg_id,
- NOTI_PRIV_DATA_DIR, file_name);
+ NOTI_PRIV_DATA_DIR, rel_file_path);
return strdup(dir);
}
}
if (__is_RO_file(smack_label))
- dst_path = __get_data_path_by_pkg_id(pkg_id,
- __last_index_of(file_path, "/") + 1, uid);
+ dst_path = __get_data_path_by_pkg_id(pkg_id, file_path, uid);
if (dst_path == NULL && __is_private_file(smack_label, pkg_id)) {
dst_path = strdup(file_path);