tizen 2.3 release tizen_2.3 submit/tizen_2.3/20150202.061249 tizen_2.3_release
authorjk7744.park <jk7744.park@samsung.com>
Sun, 1 Feb 2015 04:33:44 +0000 (13:33 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Sun, 1 Feb 2015 04:33:44 +0000 (13:33 +0900)
packaging/app2sd.spec
plugin/app2sd/CMakeLists.txt
plugin/app2sd/inc/app2sd_internals.h
plugin/app2sd/src/app2sd_interface.c
plugin/app2sd/src/app2sd_internals.c
plugin/app2sd/src/app2sd_internals_utils.c

index a517556..1d4db72 100755 (executable)
@@ -1,6 +1,6 @@
 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
index f9e3ea3..920c369 100755 (executable)
@@ -3,13 +3,13 @@ PROJECT(app2sd C)
 
 ### 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}")
index 4992334..c422d8b 100755 (executable)
@@ -186,10 +186,6 @@ int _app2sd_remove_password_from_db(const char *pkgid);
 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);
 
index ef749f5..5961cb9 100755 (executable)
@@ -217,23 +217,10 @@ int app2sd_post_app_install(const char *pkgid,
        } 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;
 }
@@ -436,7 +423,7 @@ int app2sd_pre_app_uninstall(const char *pkgid)
 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;
 }
 
 /*
@@ -512,7 +499,7 @@ int app2sd_post_app_uninstall(const char *pkgid)
 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,
@@ -560,32 +547,17 @@ 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);
index 58809b5..72efc28 100755 (executable)
 #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)
 {
@@ -62,7 +71,7 @@ static int _app2sd_apply_app_smack(const char *pkgid, GList* dir_list, const cha
                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;
@@ -88,7 +97,7 @@ static int _app2sd_apply_mmc_smack(const char *pkgid, GList* dir_list, const cha
                        && 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;
@@ -520,7 +529,13 @@ static int _app2sd_create_dir_with_link(const char *pkgid,
                }
        }
 
-       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;
index 1c3d046..744f07b 100755 (executable)
 #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 ##################
@@ -58,7 +56,9 @@ int _xsystem(const char *argv[])
                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 */
@@ -329,11 +329,13 @@ char *_app2sd_encrypt_device(const char *device, const char *pkgid,
                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) {
@@ -384,11 +386,13 @@ char *_app2sd_detach_loop_device(const char *device)
                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) {
@@ -440,11 +444,13 @@ char *_app2sd_find_associated_device(const char *mmc_app_path)
                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) {
@@ -496,11 +502,13 @@ char *_app2sd_find_free_device(void)
                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) {
@@ -564,47 +572,3 @@ char *_app2sd_generate_password(const char *pkgid)
        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;
-}
-