Name: app2sd
Summary: Application installation on external memory
-Version: 0.5.34
+Version: 0.5.36
Release: 1
Group: Application Framework/Application Installer
License: Apache-2.0
### Required packages
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED libssl dlog openssl db-util pkgmgr-info vconf)
+pkg_check_modules(pkgs REQUIRED libssl dlog openssl db-util pkgmgr-info vconf libprivilege-control)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-pkg_check_modules(libpkgs REQUIRED libssl dlog openssl db-util pkgmgr-info vconf)
+pkg_check_modules(libpkgs REQUIRED libssl dlog openssl db-util pkgmgr-info vconf libprivilege-control)
FOREACH(flag ${libpkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
int _app2sd_set_password_in_db(const char *pkgid,
const char *passwd);
-/* This functions setup path for smack */
-int _app2sd_setup_path(const char *pkgid, const char *dirpath,
- int apppathtype, const char *groupid);
-
/* This functions make result file */
void _app2sd_make_result_info_file(char *pkgid, int size);
} else {
/*If the status is success, then update installed storage to pkgmgr_parser db*/
int rt = 0;
- pkgmgrinfo_pkgdbinfo_h handle = NULL;
- rt = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
- if (rt < 0) {
- app2ext_print("pkgmgrinfo_create_pkgdbinfo[%s] fail.. \n", pkgid);
- }
- rt = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, INSTALL_EXTERNAL);
+ rt = pkgmgrinfo_pkginfo_set_installed_storage(pkgid, INSTALL_EXTERNAL);
if (rt < 0) {
app2ext_print("fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_EXTERNAL);
}
- rt =pkgmgrinfo_save_pkgdbinfo(handle);
- if (rt < 0) {
- app2ext_print("pkgmgrinfo_save_pkgdbinfo[%s] failed\n", pkgid);
- }
- rt =pkgmgrinfo_destroy_pkgdbinfo(handle);
- if (rt < 0) {
- app2ext_print("pkgmgrinfo_destroy_pkgdbinfo[%s] failed\n", pkgid);
- }
}
return ret;
}
END:
if (ret != APP2EXT_SUCCESS)
app2ext_print("App2Sd Error : app2sd has [%d]error, but return success for uninstallation\n", ret);
- return APP2EXT_SUCCESS;
+ return ret;
}
/*
END:
if (ret != APP2EXT_SUCCESS)
app2ext_print("App2Sd Error : app2sd has [%d]error, but return success for uninstallation\n", ret);
- return APP2EXT_SUCCESS;
+ return ret;
}
int app2sd_move_installed_app(const char *pkgid, GList* dir_list,
}
/*If move is completed, then update installed storage to pkgmgr_parser db*/
- pkgmgrinfo_pkgdbinfo_h handle = NULL;
- pkgmgrinfo_ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
- if (pkgmgrinfo_ret < 0) {
- app2ext_print("App2Sd Error : pkgmgrinfo_create_pkgdbinfo[%s] fail.. \n", pkgid);
- }
-
if (move_type == APP2EXT_MOVE_TO_EXT) {
- pkgmgrinfo_ret = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, INSTALL_EXTERNAL);
+ pkgmgrinfo_ret = pkgmgrinfo_pkginfo_set_installed_storage(pkgid, INSTALL_EXTERNAL);
if (pkgmgrinfo_ret < 0) {
app2ext_print("App2Sd Error : fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_EXTERNAL);
}
} else {
- pkgmgrinfo_ret = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, INSTALL_INTERNAL);
+ pkgmgrinfo_ret = pkgmgrinfo_pkginfo_set_installed_storage(pkgid, INSTALL_INTERNAL);
if (pkgmgrinfo_ret < 0) {
app2ext_print("App2Sd Error : fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_INTERNAL);
}
}
- pkgmgrinfo_ret =pkgmgrinfo_save_pkgdbinfo(handle);
- if (pkgmgrinfo_ret < 0) {
- app2ext_print("pkgmgrinfo_save_pkgdbinfo[%s] failed\n", pkgid);
- }
- pkgmgrinfo_ret =pkgmgrinfo_destroy_pkgdbinfo(handle);
- if (pkgmgrinfo_ret < 0) {
- app2ext_print("pkgmgrinfo_destroy_pkgdbinfo failed\n");
- }
-
END:
// vconf_set_int(VCONFKEY_PKGMGR_STATUS, ret);
#include <fcntl.h>
#include <time.h>
#include <dlog.h>
+#include <privilege-control.h>
/*
########### Internal APIs ##################
*/
-enum path_type {
- PATH_PRIVATE,
- PATH_GROUP_RW,
- PATH_PUBLIC_RO,
- PATH_SETTINGS_RW,
- PATH_ANY_LABEL
-};
+static int _app2sd_setup_path(const char *pkgid, const char *dirpath,
+ int apppathtype, const char *groupid)
+{
+ int ret = 0;
+
+ if (groupid == NULL) {
+ ret = perm_app_setup_path(pkgid, dirpath, apppathtype);
+ app2ext_print( "[smack] app_setup_path(), result = [%d]", ret);
+ } else {
+ ret = perm_app_setup_path(pkgid, dirpath, apppathtype, groupid);
+ app2ext_print( "[smack] app_setup_path(), result = [%d]", ret);
+ }
+
+ return ret;
+}
static int _app2sd_apply_app_smack(const char *pkgid, GList* dir_list, const char *groupid)
{
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);
+ ret = _app2sd_setup_path(pkgid, path, PERM_APP_PATH_ANY_LABEL, groupid);
if (ret) {
app2ext_print ("App2Sd Error : unable to smack %s\n", path);
return APP2EXT_ERROR_MOVE;
&& 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);
+ ret = _app2sd_setup_path(pkgid, path, PERM_APP_PATH_ANY_LABEL, groupid);
if (ret) {
app2ext_print ("App2Sd Error : unable to smack %s\n", path);
return APP2EXT_ERROR_MOVE;
}
}
- ret = _app2sd_setup_path(pkgid, app_dir_path, PATH_ANY_LABEL, pkgid);
+ ret = _app2sd_setup_path(pkgid, app_dir_path, PERM_APP_PATH_ANY_LABEL, pkgid);
+ if (ret) {
+ app2ext_print ("App2Sd Error : unable to smack %s\n", app_dir_path);
+ return APP2EXT_ERROR_MOVE;
+ }
+
+ ret = _app2sd_setup_path(pkgid, app_dir_mmc_path, PERM_APP_PATH_ANY_LABEL, pkgid);
if (ret) {
app2ext_print ("App2Sd Error : unable to smack %s\n", app_dir_mmc_path);
return APP2EXT_ERROR_MOVE;
#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 ##################
return -1;
case 0:
/* child */
- execvp(argv[0], (char *const *)argv);
+ if (execvp(argv[0], (char *const *)argv) < 0) {
+ fprintf(stderr, "execvp failed %d....%s\n", errno, strerror(errno)); /*Don't use d_msg_app2sd */
+ }
_exit(-1);
default:
/* parent */
result = dup(my_pipe[1]);
if (result < 0) {
fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+ close(result);
_exit(-1);
}
result = dup(my_pipe[1]);
if (result < 0) {
fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+ close(result);
_exit(-1);
}
if (execvp(argv[0], (char *const *)argv) < 0) {
result = dup(my_pipe[1]);
if (result < 0) {
fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+ close(result);
_exit(-1);
}
result = dup(my_pipe[1]);
if (result < 0) {
fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+ close(result);
_exit(-1);
}
if (execvp(argv[0], (char *const *)argv) < 0) {
result = dup(my_pipe[1]);
if (result < 0) {
fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+ close(result);
_exit(-1);
}
result = dup(my_pipe[1]);
if (result < 0) {
fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+ close(result);
_exit(-1);
}
if (execvp(argv[0], (char *const *)argv) < 0) {
result = dup(my_pipe[1]);
if (result < 0) {
fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+ close(result);
_exit(-1);
}
result = dup(my_pipe[1]);
if (result < 0) {
fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno));
+ close(result);
_exit(-1);
}
if (execvp(argv[0], (char *const *)argv) < 0) {
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;
-}
-