|| move_type < APP2EXT_MOVE_TO_EXT
|| move_type > APP2EXT_MOVE_TO_PHONE) {
_E("invalid function arguments");
- ret = APP2EXT_ERROR_INVALID_ARGUMENTS;
- goto END;
+ return APP2EXT_ERROR_INVALID_ARGUMENTS;
}
pkgmgrinfo_pkginfo_h info_handle = NULL;
if (pkgmgr_ret < 0) {
_E("failed to get pkginfo for pkg(%s), uid(%d), pkgmgr_ret(%d)",
pkgid, uid, pkgmgr_ret);
+ return APP2EXT_ERROR_PKGMGR_ERROR;
}
pkgmgr_ret = pkgmgrinfo_pkginfo_get_installed_storage(info_handle, &storage);
if (pkgmgr_ret < 0) {
_E("failed to get installed storage for pkg(%s) of uid(%d), pkgmgr_ret(%d)",
pkgid, uid, pkgmgr_ret);
pkgmgrinfo_pkginfo_destroy_pkginfo(info_handle);
- goto END;
+ return APP2EXT_ERROR_PKGMGR_ERROR;
}
if ((move_type == APP2EXT_MOVE_TO_EXT && storage == PMINFO_EXTERNAL_STORAGE)
|| (move_type == APP2EXT_MOVE_TO_PHONE && storage == PMINFO_INTERNAL_STORAGE)) {
- ret = APP2EXT_ERROR_PKG_EXISTS;
_E("PKG_EXISTS in [%d] STORAGE", storage);
pkgmgrinfo_pkginfo_destroy_pkginfo(info_handle);
- goto END;
+ return APP2EXT_ERROR_PKG_EXISTS;
} else {
_D("pkgid[%s] move to STORAGE [%d]", pkgid, storage);
}
ret = _app2sd_usr_move_app(pkgid, move_type, dir_list, uid);
if (ret) {
_D("unable to move application");
- goto END;
+ return ret;
}
/* if move is completed, then update installed storage to pkgmgr_parser db */
}
}
-END:
- _app2sd_make_result_info_file((char*)pkgid, ret, uid);
-
- return ret;
+ return APP2EXT_SUCCESS;
}
int app2sd_usr_pre_app_upgrade(const char *pkgid, GList* dir_list,
struct passwd pwd;
struct passwd *pwd_result;
char buf[1024] = { 0, };
+ int fd;
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0) {
+ _E("can't open path(%s)", path);
+ return APP2EXT_ERROR_OPEN_DIR;
+ }
+ ret = fchmod(fd, 0755);
+ if (ret < 0) {
+ _E("change file permission error");
+ close(fd);
+ return APP2EXT_ERROR_ACCESS_FILE;
+ }
+ close(fd);
ret = lsetxattr(path, "security.SMACK64TRANSMUTE", "TRUE", 4, 0);
if (ret < 0) {
_E("set label(%s) error", label);
return APP2EXT_ERROR_ACCESS_FILE;
}
- ret = chmod(path, 0755);
- if (ret < 0) {
- _E("change file permission error");
- return APP2EXT_ERROR_ACCESS_FILE;
- }
ret = getpwuid_r(uid, &pwd, buf, sizeof(buf), &pwd_result);
if (ret != 0 || pwd_result == NULL) {
return err_res;
}
-
-void _app2sd_make_result_info_file(char *pkgid, int size, uid_t uid)
-{
- int ret = 0;
- FILE* file = NULL;
- int fd = 0;
- char buf[FILENAME_MAX] = {0};
- const char* app_info_label = "*";
- char info_file[FILENAME_MAX] = {'\0', };
- struct passwd pwd;
- struct passwd *pwd_result;
-
- if(pkgid == NULL)
- return;
-
- snprintf(info_file, FILENAME_MAX - 1, "/tmp/%s", pkgid);
- _D("file path = %s", info_file);
-
- file = fopen(info_file, "w");
- if (file == NULL) {
- _E("couldn't open the file (%s)", info_file);
- return;
- }
-
- snprintf(buf, FILENAME_MAX - 1, "%d\n", size);
- fwrite(buf, 1, strlen(buf), file);
-
- fflush(file);
- fd = fileno(file);
- fsync(fd);
- fclose(file);
-
- if(lsetxattr(info_file, "security.SMACK64", app_info_label, strlen(app_info_label), 0)) {
- _E("error(%d) in setting smack label", errno);
- }
-
- ret = chmod(info_file, 0755);
- if (ret == -1) {
- return;
- }
-
- memset(buf, '\0', FILENAME_MAX);
- ret = getpwuid_r(uid, &pwd, buf, FILENAME_MAX, &pwd_result);
- if (ret != 0 || pwd_result == NULL) {
- _E("get uid failed(%d)", ret);
- }
-
- ret = chown(info_file, uid, pwd.pw_gid);
- if (ret == -1) {
- return;
- }
-}