/*
########### Internal APIs ##################
*/
+enum path_type {
+ PATH_PRIVATE,
+ PATH_GROUP_RW,
+ PATH_PUBLIC_RO,
+ PATH_SETTINGS_RW,
+ PATH_ANY_LABEL
+};
+
+static int _app2sd_apply_app_smack(const char *pkgid, GList* dir_list, const char *groupid)
+{
+ int ret = APP2EXT_SUCCESS;
+ GList *list = NULL;
+ app2ext_dir_details* dir_detail = NULL;
+ char path[FILENAME_MAX] = { 0, };
+
+ list = g_list_first(dir_list);
+ while (list) {
+ dir_detail = (app2ext_dir_details *)list->data;
+ if (dir_detail && dir_detail->name
+ && dir_detail->type == APP2EXT_DIR_RO) {
+ snprintf(path, FILENAME_MAX, "%s%s/%s",APP_INSTALLATION_PATH, pkgid, dir_detail->name);
+ ret = _app2sd_setup_path(pkgid, path, PATH_ANY_LABEL, groupid);
+ if (ret) {
+ app2ext_print ("App2Sd Error : unable to smack %s\n", path);
+ return APP2EXT_ERROR_MOVE;
+ }
+ }
+ list = g_list_next(list);
+ }
+
+ return APP2EXT_SUCCESS;
+}
+
+static int _app2sd_apply_mmc_smack(const char *pkgid, GList* dir_list, const char *groupid)
+{
+ int ret = APP2EXT_SUCCESS;
+ GList *list = NULL;
+ app2ext_dir_details* dir_detail = NULL;
+ char path[FILENAME_MAX] = { 0, };
+
+ list = g_list_first(dir_list);
+ while (list) {
+ dir_detail = (app2ext_dir_details *)list->data;
+ if (dir_detail && dir_detail->name
+ && dir_detail->type == APP2EXT_DIR_RO) {
+ snprintf(path, FILENAME_MAX, "%s%s/.mmc/%s",APP_INSTALLATION_PATH, pkgid, dir_detail->name);
+
+ ret = _app2sd_setup_path(pkgid, path, PATH_ANY_LABEL, groupid);
+ if (ret) {
+ app2ext_print ("App2Sd Error : unable to smack %s\n", path);
+ return APP2EXT_ERROR_MOVE;
+ }
+ }
+ list = g_list_next(list);
+ }
+
+ return APP2EXT_SUCCESS;
+}
char *_app2sd_find_associated_device_node(const char *pkgid)
{
}
}
+ ret = _app2sd_setup_path(pkgid, app_dir_path, PATH_ANY_LABEL, pkgid);
+ if (ret) {
+ app2ext_print ("App2Sd Error : unable to smack %s\n", app_dir_mmc_path);
+ return APP2EXT_ERROR_MOVE;
+ }
+
return ret;
}
app_archive_path);
return APP2EXT_ERROR_DELETE_DIRECTORY;
}
+
+ ret = _app2sd_apply_mmc_smack(pkgid, dir_list, pkgid);
+ if (ret) {
+ app2ext_print("App2Sd Error : unable to apply app smack\n");
+ return APP2EXT_ERROR_MOVE;
+ }
+
/*Restore archive ends */
/*Re-mount the loopback encrypted pseudo device on application installation path as with Read Only permission */
ret = _app2sd_unmount_app_content(pkgid);
app_archive_path);
return APP2EXT_ERROR_DELETE_DIRECTORY;
}
+
+ ret = _app2sd_apply_app_smack(pkgid, dir_list, pkgid);
+ if (ret) {
+ app2ext_print("App2Sd Error : unable to apply app smack\n");
+ return APP2EXT_ERROR_MOVE;
+ }
+
return APP2EXT_SUCCESS;
}
#include <dlog.h>
#include <sys/statvfs.h>
#include <errno.h>
+#include <dlfcn.h>
#define PASSWD_LEN 8
#define ASCII_PASSWD_CHAR 93
+#define LIB_PRIVILEGE_CONTROL "libprivilege-control.so.0"
/*
########### Internal APIs ##################
memcpy(ret_result, passwd, PASSWD_LEN+1);
return ret_result;
}
+
+/*@_app2sd_setup_path
+* change smack label given groupid
+* return: On success, it will return the password, else NULL.
+*/
+int _app2sd_setup_path(const char *pkgid, const char *dirpath,
+ int apppathtype, const char *groupid)
+{
+ int ret = 0;
+ void *handle = NULL;
+ char *errmsg = NULL;
+ int (*app_setup_path)(const char*, const char*, int, ...) = NULL;
+
+ if (pkgid == NULL || dirpath == NULL)
+ return -1;
+
+ handle = dlopen(LIB_PRIVILEGE_CONTROL, RTLD_LAZY | RTLD_GLOBAL);
+ if (!handle) {
+ app2ext_print( "setup path: dlopen() failed. [%s]", dlerror());
+ return -1;
+ }
+
+ app_setup_path = dlsym(handle, "app_setup_path");
+ errmsg = dlerror();
+ if ((errmsg != NULL) || (app_setup_path == NULL)) {
+ app2ext_print( "setup path: dlsym() failed. [%s]", errmsg);
+ dlclose(handle);
+ return -1;
+ }
+
+ if (groupid == NULL) {
+ app2ext_print( "[smack] app_setup_path(%s, %s, %d)", pkgid, dirpath, apppathtype);
+ ret = app_setup_path(pkgid, dirpath, apppathtype);
+ app2ext_print( "[smack] app_setup_path(), result = [%d]", ret);
+ } else {
+ app2ext_print( "[smack] app_setup_path(%s, %s, %d, %s)", pkgid, dirpath, apppathtype, groupid);
+ ret = app_setup_path(pkgid, dirpath, apppathtype, groupid);
+ app2ext_print( "[smack] app_setup_path(), result = [%d]", ret);
+ }
+
+ dlclose(handle);
+ return ret;
+}
+