From 1177e23a32736ff1bd302475778eb663ddd760fa Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Wed, 21 Dec 2016 15:37:25 +0900 Subject: [PATCH 01/16] Enable disable/enable function of global apps - For now, disable/enabling of global apps are prohibited. Remove some codes to enable it Change-Id: I2dd4c7873ce3432e0c3e10c5df18a1cab96a1d6e Signed-off-by: Junghyun Yeon --- src/pkgmgr-server.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/pkgmgr-server.c b/src/pkgmgr-server.c index c3d33d1..098b65c 100644 --- a/src/pkgmgr-server.c +++ b/src/pkgmgr-server.c @@ -588,14 +588,9 @@ static int __change_job_info(struct backend_job *job, uid_t uid, if (ret != PMINFO_R_OK) goto catch; - if ((job->req_type == REQUEST_TYPE_DISABLE_APP || - job->req_type == REQUEST_TYPE_ENABLE_APP) && - *is_global) { - ret = PMINFO_R_ERROR; - goto catch; - } else if ((job->req_type == REQUEST_TYPE_DISABLE_GLOBAL_APP_FOR_UID || - job->req_type == - REQUEST_TYPE_ENABLE_GLOBAL_APP_FOR_UID) && + if ((job->req_type == REQUEST_TYPE_DISABLE_GLOBAL_APP_FOR_UID || + job->req_type == + REQUEST_TYPE_ENABLE_GLOBAL_APP_FOR_UID) && !*is_global) { ret = PMINFO_R_ERROR; goto catch; -- 2.7.4 From 882d44fdc021c34c7f38e66ac2f9c311cf285128 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Mon, 19 Dec 2016 23:10:32 +0900 Subject: [PATCH 02/16] refactor getsize sync function Submit with: https://review.tizen.org/gerrit/#/c/105817/ https://review.tizen.org/gerrit/#/c/105823/ https://review.tizen.org/gerrit/#/c/105825/ Change-Id: I2b5a17199324a1f0ee6a2bac0f5adf8d077283f8 Signed-off-by: jongmyeongko --- include/pkgmgr-server.h | 1 + include/queue.h | 8 ++ org.tizen.pkgmgr.conf | 1 + src/pkgmgr-server.c | 193 +++++++++++++++++++++++++++++++++++++++--------- src/queue.c | 17 +++++ src/request.c | 48 ++++++++++++ 6 files changed, 235 insertions(+), 33 deletions(-) diff --git a/include/pkgmgr-server.h b/include/pkgmgr-server.h index 530ca0d..e22bfeb 100644 --- a/include/pkgmgr-server.h +++ b/include/pkgmgr-server.h @@ -65,6 +65,7 @@ enum request_type { REQUEST_TYPE_ENABLE_APP, REQUEST_TYPE_DISABLE_APP, REQUEST_TYPE_GETSIZE, + REQUEST_TYPE_GETSIZE_SYNC, REQUEST_TYPE_CLEARDATA, REQUEST_TYPE_CLEARCACHE, REQUEST_TYPE_ENABLE_GLOBAL_APP_FOR_UID, diff --git a/include/queue.h b/include/queue.h index 27fd907..d89d78c 100644 --- a/include/queue.h +++ b/include/queue.h @@ -20,6 +20,12 @@ #include +struct job_extra_info { + int getsize_fd; + char *getsize_fifo; + GIOChannel *getsize_io; +}; + struct backend_job { uid_t target_uid; uid_t caller_uid; @@ -31,6 +37,7 @@ struct backend_job { int backend_slot; char *backend_type; char *backend_path; + struct job_extra_info *extra; }; int _is_queue_empty(int pos); @@ -41,5 +48,6 @@ struct backend_job *_pop_queue(int pos); void _free_backend_job(struct backend_job *job); int _init_backend_queue(void); void _fini_backend_queue(void); +void __free_extra_info(struct backend_job *job); #endif // _QUEUE_H_ diff --git a/org.tizen.pkgmgr.conf b/org.tizen.pkgmgr.conf index e94bf6c..7ad7a4b 100644 --- a/org.tizen.pkgmgr.conf +++ b/org.tizen.pkgmgr.conf @@ -25,6 +25,7 @@ + diff --git a/src/pkgmgr-server.c b/src/pkgmgr-server.c index c3d33d1..d390f90 100644 --- a/src/pkgmgr-server.c +++ b/src/pkgmgr-server.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -59,6 +60,7 @@ #define EXT_STORAGE_APPDATA_GROUP 10002 #define MEDIA_STORAGE_GROUP 10502 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) +#define MAX_LONGLONG_LENGTH 32 typedef struct { char **env; @@ -89,7 +91,7 @@ static int pipe_sig[2]; static GIOChannel *pipe_io; static guint pipe_wid; static GHashTable *backend_info_table; -static GMainLoop *mainloop = NULL; +static GMainLoop *mainloop; static int __check_backend_status_for_exit(void); static int __check_queue_status_for_exit(void); @@ -116,6 +118,67 @@ static void __set_backend_free(int position) backend_busy = backend_busy & ~(1 << position); } +static gboolean getsize_io_handler(GIOChannel *io, GIOCondition cond, + gpointer data) +{ + GError *err = NULL; + GIOStatus s; + gsize len; + char buf[MAX_LONGLONG_LENGTH]; + long long result = 0; + struct backend_job *job = (struct backend_job *)data; + + s = g_io_channel_read_chars(io, (gchar *)buf, sizeof(buf), &len, &err); + if (s != G_IO_STATUS_NORMAL) { + ERR("getsize fd read failed: %s", err->message); + g_error_free(err); + result = -1; + } else { + if (strlen(buf) == 0) { + ERR("empty result"); + result = -1; + } else { + result = atoll(buf); + } + } + + _return_value_to_caller(job->req_id, g_variant_new("(ix)", + (result < 0) ? PKGMGR_R_ERROR : PKGMGR_R_OK, result)); + + unlink(job->extra->getsize_fifo); + free(job->extra->getsize_fifo); + job->extra->getsize_fifo = NULL; + + return FALSE; +} + +static int __setup_size_info_io(struct backend_job *job) +{ + guint getsize_wid; + + job->extra->getsize_fd = open(job->extra->getsize_fifo, + O_RDONLY | O_NONBLOCK); + if (job->extra->getsize_fd < 0) { + ERR("failed to open the fifo(%s), errno(%d)", + job->extra->getsize_fifo, errno); + return -1; + } + + job->extra->getsize_io = g_io_channel_unix_new(job->extra->getsize_fd); + if (!job->extra->getsize_io) + return -1; + g_io_channel_set_encoding(job->extra->getsize_io, NULL, NULL); + g_io_channel_set_buffered(job->extra->getsize_io, FALSE); + getsize_wid = g_io_add_watch(job->extra->getsize_io, + G_IO_IN, getsize_io_handler, job); + if (!getsize_wid) { + ERR("failed to add io watch"); + return -1; + } + + return 0; +} + static gboolean pipe_io_handler(GIOChannel *io, GIOCondition cond, gpointer data) { @@ -151,6 +214,14 @@ static gboolean pipe_io_handler(GIOChannel *io, GIOCondition cond, DBG("backend[%s] exit", job->backend_type); } + if (job->extra) { + if (job->extra->getsize_fifo) { + ERR("invalid backend close"); + _return_value_to_caller(job->req_id, + g_variant_new("(ix)", PKGMGR_R_ERROR, -1)); + } + } + g_hash_table_remove(backend_info_table, (gconstpointer)info.pid); g_idle_add(queue_job, NULL); @@ -356,7 +427,7 @@ static int __pkgcmd_app_cb(const pkgmgrinfo_appinfo_h handle, void *user_data) return 0; } -void free_user_context(user_ctx* ctx) +void free_user_context(user_ctx *ctx) { char **env = NULL; int i = 0; @@ -542,7 +613,7 @@ void __set_environment(gpointer user_data) static int __fork_and_exec_with_args(char **argv, uid_t uid) { - user_ctx* user_context; + user_ctx *user_context; GError *error = NULL; gboolean ret; int pid; @@ -559,6 +630,8 @@ static int __fork_and_exec_with_args(char **argv, uid_t uid) if (ret != TRUE) { ERR("Failed to excute backend: %s", error->message); g_error_free(error); + free_user_context(user_context); + return -1; } free_user_context(user_context); @@ -1033,6 +1106,59 @@ static int __process_getsize(struct backend_job *job) return pid; } +static int __process_getsize_sync(struct backend_job *job) +{ + static const char backend_cmd[] = "/usr/bin/pkg_getsize"; + char **argv; + char args[MAX_PKG_ARGS_LEN]; + char fifo_path[PATH_MAX]; + int pid; + + snprintf(fifo_path, sizeof(fifo_path), "/tmp/pkgmgr/%s", + job->req_id); + + job->extra = calloc(1, sizeof(struct job_extra_info)); + if (!job->extra) { + ERR("memory alloc failed"); + goto error; + } + + job->extra->getsize_fifo = strdup(fifo_path); + if (!job->extra->getsize_fifo) { + ERR("out of memory"); + goto error; + } + + if (mkfifo(job->extra->getsize_fifo, 0600) < 0) { + ERR("failed to mkfifo"); + goto error; + } + + snprintf(args, sizeof(args), "%s %s %s %d -k %s -u %d --sync", + backend_cmd, job->pkgid, job->args, job->caller_uid, + job->req_id, job->target_uid); + argv = __generate_argv(args); + pid = __fork_and_exec_with_args(argv, APPFW_UID); + + g_strfreev(argv); + + if (pid < 0) { + ERR("failed to execute backend"); + goto error; + } + if (__setup_size_info_io(job) < 0) { + ERR("failed to setup io handler"); + goto error; + } + + return pid; + +error: + _return_value_to_caller(job->req_id, + g_variant_new("(ix)", PKGMGR_R_ERROR, -1)); + return -1; +} + static int __process_cleardata(struct backend_job *job) { char *backend_cmd; @@ -1329,6 +1455,18 @@ static int __process_set_app_label(struct backend_job *job) return ret; } +static int __post_process(int ret, int x, struct backend_job *job) +{ + if (ret < 0) { + __set_backend_free(x); + _free_backend_job(job); + } else { + g_hash_table_insert(backend_info_table, (gpointer)ret, + (gpointer)job); + } + return 0; +} + gboolean queue_job(void *data) { struct backend_job *job = NULL; @@ -1372,56 +1510,41 @@ gboolean queue_job(void *data) case REQUEST_TYPE_INSTALL: __set_backend_busy(x); ret = __process_install(job); - g_hash_table_insert(backend_info_table, (gpointer)ret, - (gpointer)job); + __post_process(ret, x, job); break; case REQUEST_TYPE_MOUNT_INSTALL: __set_backend_busy(x); ret = __process_mount_install(job); - g_hash_table_insert(backend_info_table, (gpointer)ret, - (gpointer)job); + __post_process(ret, x, job); break; case REQUEST_TYPE_REINSTALL: __set_backend_busy(x); ret = __process_reinstall(job); - g_hash_table_insert(backend_info_table, (gpointer)ret, - (gpointer)job); + __post_process(ret, x, job); break; case REQUEST_TYPE_UNINSTALL: __set_backend_busy(x); ret = __process_uninstall(job); - g_hash_table_insert(backend_info_table, (gpointer)ret, - (gpointer)job); + __post_process(ret, x, job); break; case REQUEST_TYPE_MOVE: __set_backend_busy(x); ret = __process_move(job); - g_hash_table_insert(backend_info_table, (gpointer)ret, - (gpointer)job); + __post_process(ret, x, job); break; case REQUEST_TYPE_ENABLE_PKG: __set_backend_busy(x); ret = __process_enable_pkg(job); - if (ret == -1) { + if (ret < 0) _send_fail_signal(job); - __set_backend_free(x); - _free_backend_job(job); - } else { - g_hash_table_insert(backend_info_table, (gpointer)ret, - (gpointer)job); - } + __post_process(ret, x, job); break; case REQUEST_TYPE_DISABLE_PKG: __set_backend_busy(x); ret = __process_disable_pkg(job); - if (ret == -1) { + if (ret < 0) _send_fail_signal(job); - __set_backend_free(x); - _free_backend_job(job); - } else { - g_hash_table_insert(backend_info_table, (gpointer)ret, - (gpointer)job); - } + __post_process(ret, x, job); break; case REQUEST_TYPE_ENABLE_APP: ret = __process_enable_app(job); @@ -1434,20 +1557,24 @@ gboolean queue_job(void *data) case REQUEST_TYPE_GETSIZE: __set_backend_busy(x); ret = __process_getsize(job); - g_hash_table_insert(backend_info_table, (gpointer)ret, - (gpointer)job); + __post_process(ret, x, job); + break; + case REQUEST_TYPE_GETSIZE_SYNC: + __set_backend_busy(x); + ret = __process_getsize_sync(job); + if (ret < 0) + __free_extra_info(job); + __post_process(ret, x, job); break; case REQUEST_TYPE_CLEARDATA: __set_backend_busy(x); ret = __process_cleardata(job); - g_hash_table_insert(backend_info_table, (gpointer)ret, - (gpointer)job); + __post_process(ret, x, job); break; case REQUEST_TYPE_CLEARCACHE: __set_backend_busy(x); ret = __process_clearcache(job); - g_hash_table_insert(backend_info_table, (gpointer)ret, - (gpointer)job); + __post_process(ret, x, job); break; case REQUEST_TYPE_ENABLE_GLOBAL_APP_FOR_UID: ret = __process_enable_global_app_for_uid(job); diff --git a/src/queue.c b/src/queue.c index 11e6ace..68b0476 100644 --- a/src/queue.c +++ b/src/queue.c @@ -159,8 +159,25 @@ static gboolean __str_equal(gconstpointer v1, gconstpointer v2) return strcasecmp(str1, str2) == 0; } +void __free_extra_info(struct backend_job *job) +{ + if (job->extra) { + if (job->extra->getsize_io) + g_io_channel_unref(job->extra->getsize_io); + if (job->extra->getsize_fd) + close(job->extra->getsize_fd); + if (job->extra->getsize_fifo) { + unlink(job->extra->getsize_fifo); + free(job->extra->getsize_fifo); + } + free(job->extra); + job->extra = NULL; + } +} + void _free_backend_job(struct backend_job *job) { + __free_extra_info(job); free(job->req_id); free(job->pkgid); free(job->appid); diff --git a/src/request.c b/src/request.c index 4db0f6d..fce8210 100644 --- a/src/request.c +++ b/src/request.c @@ -97,6 +97,13 @@ static const char instropection_xml[] = " " " " " " + " " + " " + " " + " " + " " + " " + " " " " " " " " @@ -914,6 +921,45 @@ static int __handle_request_getsize(uid_t caller_uid, return 0; } +static int __handle_request_getsize_sync(uid_t caller_uid, + GDBusMethodInvocation *invocation, GVariant *parameters) +{ + uid_t target_uid = (uid_t)-1; + char *pkgid = NULL; + int get_type = -1; + char *reqkey; + char buf[4]; + + g_variant_get(parameters, "(u&si)", &target_uid, &pkgid, &get_type); + if (target_uid == (uid_t)-1 || pkgid == NULL || get_type == -1) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(is)", PKGMGR_R_ECOMM, "")); + return -1; + } + + reqkey = __generate_reqkey(pkgid); + if (reqkey == NULL) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(is)", PKGMGR_R_ENOMEM, "")); + return -1; + } + + snprintf(buf, sizeof(buf), "%d", get_type); + if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_GETSIZE_SYNC, + "pkgtool", pkgid, buf)) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(is)", PKGMGR_R_ESYSTEM, "")); + free(reqkey); + return -1; + } + + if (!g_hash_table_insert(req_table, (gpointer)reqkey, + (gpointer)invocation)) + ERR("reqkey already exists"); + + return 0; +} + static int __handle_request_cleardata(uid_t caller_uid, GDBusMethodInvocation *invocation, GVariant *parameters) { @@ -1442,6 +1488,8 @@ static void __handle_method_call(GDBusConnection *connection, ret = __handle_request_disable_pkgs(uid, invocation, parameters); else if (g_strcmp0(method_name, "getsize") == 0) ret = __handle_request_getsize(uid, invocation, parameters); + else if (g_strcmp0(method_name, "getsize_sync") == 0) + ret = __handle_request_getsize_sync(uid, invocation, parameters); else if (g_strcmp0(method_name, "clearcache") == 0) ret = __handle_request_clearcache(uid, invocation, parameters); else if (g_strcmp0(method_name, "enable_app") == 0) -- 2.7.4 From 74ee94ca22c75fa79c9ec7be630d4b7fb22c02ab Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Thu, 22 Dec 2016 10:26:10 +0900 Subject: [PATCH 03/16] Change bin file to be executed - pkg_clearcache is replced by pkg_cleardata so change code to use it - new pkg_cleardata will handle clear data of pkg Related changes: [pkgmgr-tool] : https://review.tizen.org/gerrit/106485 [app-installers] : https://review.tizen.org/gerrit/105691 [tpk-backend] : https://review.tizen.org/gerrit/106603 [wgt-backend] : https://review.tizen.org/gerrit/106601 Change-Id: Ifa296ecdaf00596261c7e676bbebe6a5b344a386 Signed-off-by: Junghyun Yeon --- src/pkgmgr-server.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/pkgmgr-server.c b/src/pkgmgr-server.c index d69728f..dc8e153 100644 --- a/src/pkgmgr-server.c +++ b/src/pkgmgr-server.c @@ -1156,40 +1156,37 @@ error: static int __process_cleardata(struct backend_job *job) { - char *backend_cmd; + static const char *backend_cmd = "/usr/bin/pkg_cleardata"; char **argv; char args[MAX_PKG_ARGS_LEN]; int pid; - backend_cmd = job->backend_path; - if (backend_cmd == NULL) + if ((int)job->target_uid < REGULAR_USER) return -1; - /* TODO: set movetype */ - snprintf(args, sizeof(args), "%s -k %s -c %s -u %d", backend_cmd, - job->req_id, job->pkgid, (int)job->target_uid); + snprintf(args, sizeof(args), "%s -d %s", backend_cmd, job->pkgid); argv = __generate_argv(args); - - pid = __fork_and_exec_with_args(argv, APPFW_UID); + pid = __fork_and_exec_with_args(argv, job->target_uid); g_strfreev(argv); - return pid; } static int __process_clearcache(struct backend_job *job) { - static const char *backend_cmd = "/usr/bin/pkg_clearcache"; + static const char *backend_cmd = "/usr/bin/pkg_cleardata"; char **argv; char args[MAX_PKG_ARGS_LEN]; int pid; - snprintf(args, sizeof(args), "%s %s", backend_cmd, job->pkgid); + if ((int)job->target_uid < REGULAR_USER) + return -1; + + snprintf(args, sizeof(args), "%s -c %s", backend_cmd, job->pkgid); argv = __generate_argv(args); pid = __fork_and_exec_with_args(argv, job->target_uid); g_strfreev(argv); - return pid; } -- 2.7.4 From 4b6f854383e05addb43658964d07370708de56cb Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Fri, 23 Dec 2016 11:53:22 +0900 Subject: [PATCH 04/16] Pass adjusted file path to backend Submit with: - https://review.tizen.org/gerrit/106774 Change-Id: Iff9755081a5d8031395c031bc684d07d7a288cbc Signed-off-by: Sangyoon Jang --- include/pkgmgr-server.h | 3 ++- src/request.c | 6 ++++-- src/util.c | 32 +++++++++++++++++++------------- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/include/pkgmgr-server.h b/include/pkgmgr-server.h index e22bfeb..0180fcb 100644 --- a/include/pkgmgr-server.h +++ b/include/pkgmgr-server.h @@ -94,7 +94,8 @@ void _send_fail_signal(struct backend_job *job); int _set_restriction_mode(uid_t uid, const char *pkgid, int mode); int _unset_restriction_mode(uid_t uid, const char *pkgid, int mode); int _get_restriction_mode(uid_t uid, const char *pkgid, int *mode); -const char *_get_pkgtype_from_file(const char *file_path, uid_t uid); +const char *_get_pkgtype_from_file(const char *file_path); char *_get_pkgtype_from_pkgid(const char *pkgid, uid_t uid); +const char *_get_adjusted_pkgpath(const char *org_file_path, uid_t caller_uid); #endif/* _PKGMGR_SERVER_H_ */ diff --git a/src/request.c b/src/request.c index fce8210..2e4fbc1 100644 --- a/src/request.c +++ b/src/request.c @@ -327,7 +327,8 @@ static int __handle_request_install(uid_t caller_uid, goto catch; } - pkgtype = _get_pkgtype_from_file(pkgpath, caller_uid); + pkgpath = _get_adjusted_pkgpath(pkgpath, caller_uid); + pkgtype = _get_pkgtype_from_file(pkgpath); if (!pkgtype && arg_pkgtype && strlen(arg_pkgtype)) pkgtype = (const char *)arg_pkgtype; if (pkgtype == NULL) { @@ -416,7 +417,8 @@ static int __handle_request_mount_install(uid_t caller_uid, goto catch; } - pkgtype = _get_pkgtype_from_file(pkgpath, caller_uid); + pkgpath = _get_adjusted_pkgpath(pkgpath, caller_uid); + pkgtype = _get_pkgtype_from_file(pkgpath); if (!pkgtype && arg_pkgtype && strlen(arg_pkgtype)) pkgtype = (const char *)arg_pkgtype; if (pkgtype == NULL) { diff --git a/src/util.c b/src/util.c index d64ccb7..97799ac 100644 --- a/src/util.c +++ b/src/util.c @@ -22,24 +22,12 @@ struct manifest_and_type type_map[] = { static const char legacy_content_path[] = "/opt/usr/media"; -const char *_get_pkgtype_from_file(const char *org_file_path, uid_t caller_uid) +const char *_get_pkgtype_from_file(const char *file_path) { const char *type = NULL; - const char *file_path = NULL; unzFile uf; int i; - if (caller_uid >= REGULAR_USER && - strstr(org_file_path, legacy_content_path) == org_file_path) { - DBG("legacy media path!"); - tzplatform_set_user(caller_uid); - file_path = tzplatform_mkpath(TZ_USER_CONTENT, - org_file_path + strlen(legacy_content_path)); - tzplatform_reset_user(); - } else { - file_path = org_file_path; - } - uf = unzOpen(file_path); if (uf == NULL) { ERR("failed to open zip file %s", file_path); @@ -83,3 +71,21 @@ char *_get_pkgtype_from_pkgid(const char *pkgid, uid_t uid) return type; } + +const char *_get_adjusted_pkgpath(const char *org_file_path, uid_t caller_uid) +{ + const char *file_path; + + if (caller_uid >= REGULAR_USER && + strstr(org_file_path, legacy_content_path) == org_file_path) { + DBG("legacy media path!"); + tzplatform_set_user(caller_uid); + file_path = tzplatform_mkpath(TZ_USER_CONTENT, + org_file_path + strlen(legacy_content_path)); + tzplatform_reset_user(); + } else { + file_path = org_file_path; + } + + return file_path; +} -- 2.7.4 From 3dd6c6b1a9944e8ce90ec3779239280afc5d4843 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 3 Jan 2017 15:24:29 +0900 Subject: [PATCH 05/16] Fix queue_job When multiple job queued and some job failed, the server cannot process next job because queue_job() never invoked. Return TRUE to continue invoking queue_job() until no job available. Change-Id: I207ced8359ea177233c6d637b94ac6277a0a175c Signed-off-by: Sangyoon Jang --- src/pkgmgr-server.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pkgmgr-server.c b/src/pkgmgr-server.c index dc8e153..47002d1 100644 --- a/src/pkgmgr-server.c +++ b/src/pkgmgr-server.c @@ -1477,7 +1477,7 @@ gboolean queue_job(void *data) /* all backend messages queue are empty or busy */ if (x == num_of_backends || job == NULL) { - DBG("no job left"); + DBG("no job available"); return FALSE; } @@ -1493,7 +1493,7 @@ gboolean queue_job(void *data) ret = -1; _send_fail_signal(job); _free_backend_job(job); - return FALSE; + return TRUE; } } #endif @@ -1625,7 +1625,7 @@ gboolean queue_job(void *data) break; } - return FALSE; + return TRUE; } int main(int argc, char *argv[]) -- 2.7.4 From 4fa9e329803529328c8a40da87c615c9b24677cd Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Wed, 4 Jan 2017 15:27:20 +0900 Subject: [PATCH 06/16] Adjust to change of pkg_cleardata interface Submit together: - https://review.tizen.org/gerrit/108352 Change-Id: Id20f7c3362a7d12c7f2f565b9533879a8f659174 Signed-off-by: Sangyoon Jang --- src/pkgmgr-server.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pkgmgr-server.c b/src/pkgmgr-server.c index 47002d1..f55c88d 100644 --- a/src/pkgmgr-server.c +++ b/src/pkgmgr-server.c @@ -1164,9 +1164,10 @@ static int __process_cleardata(struct backend_job *job) if ((int)job->target_uid < REGULAR_USER) return -1; - snprintf(args, sizeof(args), "%s -d %s", backend_cmd, job->pkgid); + snprintf(args, sizeof(args), "%s -d -n %s -u %d", + backend_cmd, job->pkgid, job->target_uid); argv = __generate_argv(args); - pid = __fork_and_exec_with_args(argv, job->target_uid); + pid = __fork_and_exec_with_args(argv, APPFW_UID); g_strfreev(argv); return pid; @@ -1182,9 +1183,10 @@ static int __process_clearcache(struct backend_job *job) if ((int)job->target_uid < REGULAR_USER) return -1; - snprintf(args, sizeof(args), "%s -c %s", backend_cmd, job->pkgid); + snprintf(args, sizeof(args), "%s -c -n %s -u %d", + backend_cmd, job->pkgid, job->target_uid); argv = __generate_argv(args); - pid = __fork_and_exec_with_args(argv, job->target_uid); + pid = __fork_and_exec_with_args(argv, APPFW_UID); g_strfreev(argv); return pid; -- 2.7.4 From 0f239346bc64b1aa61adb0675520019b9b8cd1c4 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Tue, 27 Dec 2016 17:53:08 +0900 Subject: [PATCH 07/16] Change signal type when disabling app for certain user - Server will send disable_app/enable_app when disable/enable global app for certain uid Related changes: [pkgmgr-info] : https://review.tizen.org/gerrit/107069 [pkgmgr-tool] : https://review.tizen.org/gerrit/107098 [slp-pkgmgr] : https://review.tizen.org/gerrit/107263 Change-Id: I9b00ebb7f943740287b123c398b67b573be8c7f7 Signed-off-by: Junghyun Yeon --- src/pkgmgr-server.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pkgmgr-server.c b/src/pkgmgr-server.c index f55c88d..e4653a2 100644 --- a/src/pkgmgr-server.c +++ b/src/pkgmgr-server.c @@ -1007,7 +1007,7 @@ static int __process_enable_global_app_for_uid(struct backend_job *job) if (ret != PMINFO_R_OK || strlen(job->appid) == 0) { _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->pkgid, PKGMGR_INSTALLER_START_KEY_STR, - PKGMGR_INSTALLER_GLOBAL_APP_ENABLE_FOR_UID, + PKGMGR_INSTALLER_APP_ENABLE_EVENT_STR, job->req_type); _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->pkgid, PKGMGR_INSTALLER_END_KEY_STR, @@ -1018,7 +1018,7 @@ static int __process_enable_global_app_for_uid(struct backend_job *job) _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->appid, PKGMGR_INSTALLER_START_KEY_STR, - PKGMGR_INSTALLER_GLOBAL_APP_ENABLE_FOR_UID, + PKGMGR_INSTALLER_APP_ENABLE_EVENT_STR, job->req_type); ret = pkgmgr_parser_update_global_app_disable_for_uid_info_in_db( @@ -1050,7 +1050,7 @@ static int __process_disable_global_app_for_uid(struct backend_job *job) _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->pkgid, PKGMGR_INSTALLER_START_KEY_STR, - PKGMGR_INSTALLER_GLOBAL_APP_DISABLE_FOR_UID, + PKGMGR_INSTALLER_APP_DISABLE_EVENT_STR, job->req_type); _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->pkgid, PKGMGR_INSTALLER_END_KEY_STR, @@ -1062,7 +1062,7 @@ static int __process_disable_global_app_for_uid(struct backend_job *job) _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->appid, PKGMGR_INSTALLER_START_KEY_STR, - PKGMGR_INSTALLER_GLOBAL_APP_DISABLE_FOR_UID, + PKGMGR_INSTALLER_APP_DISABLE_EVENT_STR, job->req_type); ret = __kill_app(job->appid, job->target_uid); -- 2.7.4 From 5b010288c2ea73bb4fdb4eb302833e89c0b76650 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Mon, 2 Jan 2017 09:08:52 +0900 Subject: [PATCH 08/16] Fix possible memory leak Change-Id: I63fddbec9b75149b1b65ab9f8ad6993e52bde472 Signed-off-by: Junghyun Yeon --- src/request.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/request.c b/src/request.c index 2e4fbc1..073be8e 100644 --- a/src/request.c +++ b/src/request.c @@ -1450,6 +1450,7 @@ static uid_t __get_caller_uid(GDBusConnection *connection, const char *name) } g_variant_get(result, "(u)", &uid); + g_variant_unref(result); return uid; } -- 2.7.4 From 377140fd7524b797ac330bf833d81245af758e5f Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 5 Jan 2017 15:34:24 +0900 Subject: [PATCH 09/16] Append null byte when readlink on backend path readlink() does not append a null byte to buf. Change-Id: I28034db705afd0ad1b1a5275f7896a6f9f0c3399 Signed-off-by: Sangyoon Jang --- src/queue.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/queue.c b/src/queue.c index 68b0476..13617ab 100644 --- a/src/queue.c +++ b/src/queue.c @@ -121,6 +121,7 @@ int _push_queue(uid_t target_uid, uid_t caller_uid, const char *req_id, static int __init_backends(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) { + int r; struct backend_queue *queue; if (typeflag != FTW_F && typeflag != FTW_SL) @@ -131,12 +132,14 @@ static int __init_backends(const char *fpath, const struct stat *sb, queue->path = strdup(fpath); } else if (typeflag == FTW_SL) { queue->path = malloc(sb->st_size + 1); - if (readlink(fpath, queue->path, sb->st_size + 1) < 0) { + r = readlink(fpath, queue->path, sb->st_size + 1); + if (r < 0 || r > sb->st_size) { ERR("failed to readlink for %s", fpath); free(queue->path); free(queue); return -1; } + queue->path[r] = '\0'; } queue->type = strdup(fpath + ftwbuf->base); queue->slot = num_of_backends++; -- 2.7.4 From 3f73227a7c17638c8ed28441fdd09ce2aad8fcd7 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Wed, 4 Jan 2017 15:25:14 +0900 Subject: [PATCH 10/16] Support legacy image for backward-compatibility Refer to: https://review.tizen.org/gerrit/#/c/104823/ Change-Id: I79f4ae9e75e728f20e3d079b3d63f1ba1a8f3c6a Signed-off-by: jongmyeongko --- include/pkgmgr-server.h | 1 + org.tizen.pkgmgr.conf | 1 + src/pkgmgr-server.c | 28 ++++++++++++++++++++++++ src/request.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+) diff --git a/include/pkgmgr-server.h b/include/pkgmgr-server.h index 0180fcb..7b2fe5a 100644 --- a/include/pkgmgr-server.h +++ b/include/pkgmgr-server.h @@ -81,6 +81,7 @@ enum request_type { REQUEST_TYPE_UNSET_RESTRICTION_MODE, REQUEST_TYPE_GET_RESTRICTION_MODE, REQUEST_TYPE_SET_APP_LABEL, + REQUEST_TYPE_MIGRATE_EXTERNAL_IMAGE, }; gboolean queue_job(void *data); diff --git a/org.tizen.pkgmgr.conf b/org.tizen.pkgmgr.conf index 7ad7a4b..306f578 100644 --- a/org.tizen.pkgmgr.conf +++ b/org.tizen.pkgmgr.conf @@ -43,5 +43,6 @@ + diff --git a/src/pkgmgr-server.c b/src/pkgmgr-server.c index e4653a2..b0cf052 100644 --- a/src/pkgmgr-server.c +++ b/src/pkgmgr-server.c @@ -1449,6 +1449,29 @@ static int __process_set_app_label(struct backend_job *job) return ret; } +static int __process_migrate_external_image(struct backend_job *job) +{ + char *backend_cmd; + char **argv; + char args[MAX_PKG_ARGS_LEN]; + int pid; + + backend_cmd = job->backend_path; + if (backend_cmd == NULL) + return -1; + + snprintf(args, sizeof(args), "%s -k %s --migrate-extimg %s -u %d %s", + backend_cmd, job->req_id, job->pkgid, + (int)job->target_uid, job->args); + + argv = __generate_argv(args); + + pid = __fork_and_exec_with_args(argv, APPFW_UID); + g_strfreev(argv); + + return pid; +} + static int __post_process(int ret, int x, struct backend_job *job) { if (ret < 0) { @@ -1622,6 +1645,11 @@ gboolean queue_job(void *data) ret = __process_set_app_label(job); _free_backend_job(job); break; + case REQUEST_TYPE_MIGRATE_EXTERNAL_IMAGE: + __set_backend_busy(x); + ret = __process_migrate_external_image(job); + __post_process(ret, x, job); + break; default: ret = -1; break; diff --git a/src/request.c b/src/request.c index 073be8e..8e3793e 100644 --- a/src/request.c +++ b/src/request.c @@ -175,6 +175,11 @@ static const char instropection_xml[] = " " " " " " + " " + " " + " " + " " + " " " " ""; static GDBusNodeInfo *instropection_data; @@ -1432,6 +1437,55 @@ static int __handle_request_set_app_label(uid_t uid, return 0; } +static int __handle_request_migrate_external_image(uid_t uid, + GDBusMethodInvocation *invocation, GVariant *parameters) +{ + uid_t target_uid = (uid_t)-1; + char *pkgid = NULL; + char *pkgtype; + char *reqkey; + + g_variant_get(parameters, "(us)", &target_uid, &pkgid); + if (target_uid == (uid_t)-1 || pkgid == NULL) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(i)", PKGMGR_R_ECOMM)); + return -1; + } + + pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid); + if (pkgtype == NULL) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(i)", PKGMGR_R_ENOPKG)); + return -1; + } + + reqkey = __generate_reqkey(pkgid); + if (reqkey == NULL) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(i)", PKGMGR_R_ENOMEM)); + free(pkgtype); + return -1; + } + + if (_push_queue(target_uid, uid, reqkey, + REQUEST_TYPE_MIGRATE_EXTERNAL_IMAGE, + pkgtype, pkgid, NULL)) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(i)", PKGMGR_R_ESYSTEM)); + free(reqkey); + free(pkgtype); + return -1; + } + + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(i)", PKGMGR_R_OK)); + + free(reqkey); + free(pkgtype); + + return 0; +} + static uid_t __get_caller_uid(GDBusConnection *connection, const char *name) { GError *err = NULL; @@ -1535,6 +1589,9 @@ static void __handle_method_call(GDBusConnection *connection, parameters); else if (g_strcmp0(method_name, "set_app_label") == 0) ret = __handle_request_set_app_label(uid, invocation, parameters); + else if (g_strcmp0(method_name, "migrate_external_image") == 0) + ret = __handle_request_migrate_external_image(uid, invocation, + parameters); else ret = -1; -- 2.7.4 From b35a4bbe91659f589a3ced79257477662ca11cdd Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 12 Jan 2017 18:42:42 +0900 Subject: [PATCH 11/16] Add double quote at argument to parsing properly Change-Id: I93d346baec22916600c3586fe05a3b434e28c7ee Signed-off-by: Sangyoon Jang --- src/pkgmgr-server.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pkgmgr-server.c b/src/pkgmgr-server.c index b0cf052..4dd532e 100644 --- a/src/pkgmgr-server.c +++ b/src/pkgmgr-server.c @@ -695,7 +695,7 @@ static int __process_install(struct backend_job *job) if (backend_cmd == NULL) return -1; - snprintf(args, sizeof(args), "%s -k %s -i %s -u %d %s", backend_cmd, + snprintf(args, sizeof(args), "%s -k \"%s\" -i \"%s\" -u %d %s", backend_cmd, job->req_id, job->pkgid, (int)job->target_uid, job->args); argv = __generate_argv(args); @@ -717,7 +717,7 @@ static int __process_mount_install(struct backend_job *job) if (backend_cmd == NULL) return -1; - snprintf(args, sizeof(args), "%s -k %s -w %s -u %d %s", backend_cmd, + snprintf(args, sizeof(args), "%s -k \"%s\" -w \"%s\" -u %d %s", backend_cmd, job->req_id, job->pkgid, (int)job->target_uid, job->args); argv = __generate_argv(args); @@ -739,7 +739,7 @@ static int __process_reinstall(struct backend_job *job) if (backend_cmd == NULL) return -1; - snprintf(args, sizeof(args), "%s -k %s -r %s -u %d", backend_cmd, + snprintf(args, sizeof(args), "%s -k \"%s\" -r \"%s\" -u %d", backend_cmd, job->req_id, job->pkgid, (int)job->target_uid); argv = __generate_argv(args); -- 2.7.4 From 7f1cc068964e3b94394fccb1579248c59e6991c2 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Thu, 12 Jan 2017 20:00:59 +0900 Subject: [PATCH 12/16] Change to add quote using g_shell_quote in some parameter - Inserting double quote will not cover if filepath contains double quote - using g_shell_quote handles this correctly Change-Id: Ib519c4c40536b3bcc78e2287e72542b822715c84 Signed-off-by: Junghyun Yeon --- src/pkgmgr-server.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/pkgmgr-server.c b/src/pkgmgr-server.c index 4dd532e..cf55a28 100644 --- a/src/pkgmgr-server.c +++ b/src/pkgmgr-server.c @@ -689,19 +689,28 @@ static int __process_install(struct backend_job *job) char *backend_cmd; char **argv; char args[MAX_PKG_ARGS_LEN]; + gchar *req_id; + gchar *pkgid; int pid; backend_cmd = job->backend_path; if (backend_cmd == NULL) return -1; - snprintf(args, sizeof(args), "%s -k \"%s\" -i \"%s\" -u %d %s", backend_cmd, - job->req_id, job->pkgid, (int)job->target_uid, job->args); + req_id = g_shell_quote(job->req_id); + pkgid = g_shell_quote(job->pkgid); + if (!req_id || !pkgid) + return -1; + + snprintf(args, sizeof(args), "%s -k %s -i %s -u %d %s", backend_cmd, + req_id, pkgid, (int)job->target_uid, job->args); argv = __generate_argv(args); pid = __fork_and_exec_with_args(argv, APPFW_UID); g_strfreev(argv); + g_free(req_id); + g_free(pkgid); return pid; } @@ -711,19 +720,28 @@ static int __process_mount_install(struct backend_job *job) char *backend_cmd; char **argv; char args[MAX_PKG_ARGS_LEN]; + gchar *req_id; + gchar *pkgid; int pid; backend_cmd = job->backend_path; if (backend_cmd == NULL) return -1; - snprintf(args, sizeof(args), "%s -k \"%s\" -w \"%s\" -u %d %s", backend_cmd, - job->req_id, job->pkgid, (int)job->target_uid, job->args); + req_id = g_shell_quote(job->req_id); + pkgid = g_shell_quote(job->pkgid); + if (!req_id || !pkgid) + return -1; + + snprintf(args, sizeof(args), "%s -k %s -w %s -u %d %s", backend_cmd, + req_id, pkgid, (int)job->target_uid, job->args); argv = __generate_argv(args); pid = __fork_and_exec_with_args(argv, APPFW_UID); g_strfreev(argv); + g_free(req_id); + g_free(pkgid); return pid; } @@ -733,19 +751,28 @@ static int __process_reinstall(struct backend_job *job) char *backend_cmd; char **argv; char args[MAX_PKG_ARGS_LEN]; + gchar *req_id; + gchar *pkgid; int pid; backend_cmd = job->backend_path; if (backend_cmd == NULL) return -1; - snprintf(args, sizeof(args), "%s -k \"%s\" -r \"%s\" -u %d", backend_cmd, - job->req_id, job->pkgid, (int)job->target_uid); + req_id = g_shell_quote(job->req_id); + pkgid = g_shell_quote(job->pkgid); + if (!req_id || !pkgid) + return -1; + + snprintf(args, sizeof(args), "%s -k %s -r %s -u %d", backend_cmd, + req_id, pkgid, (int)job->target_uid); argv = __generate_argv(args); pid = __fork_and_exec_with_args(argv, APPFW_UID); g_strfreev(argv); + g_free(req_id); + g_free(pkgid); return pid; } -- 2.7.4 From 09082fbbd5b749c4f4fc70018546c3c693f625f0 Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Wed, 16 Nov 2016 17:36:07 +0900 Subject: [PATCH 13/16] Remove Profile Build Dependency: Do it at runtime - This is for Tizen 4.0. : Tizen 4.0 Configurability and Build Blocks require to remove all profile-depending build options in spec files. (No More profile macros!) - It is recommended to distinguish features/profiles at runtime. unless it incurs too much overhead, which requires you to create multiple binaries and subpackages. (csr is included in Tizen:TV; thus we can keep BuildRequires on csr for TV while not using csr in TV at runtime) patchset5: updated coding style Change-Id: Ibc2e335a4f88918c37d703f8e9379a07d94a7fdc Signed-off-by: MyungJoo Ham Signed-off-by: jongmyeongko --- CMakeLists.txt | 9 +----- packaging/pkgmgr-server.spec | 12 ++------ src/pkgmgr-server.c | 72 +++++++++++++++++++++++++++++++++++--------- 3 files changed, 60 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b7bf90d..f6f0c64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,10 +27,7 @@ INCLUDE(FindPkgConfig) SET(PKGMGR_SERVER "pkgmgr-server") AUX_SOURCE_DIRECTORY(src SRCS) -SET(SERVER_CHECK_MODULES gio-2.0 glib-2.0 dlog pkgmgr-parser pkgmgr-info libtzplatform-config drm-service-core-tizen libgum sqlite3 pkgmgr pkgmgr-installer libsystemd aul minizip) -IF(TIZEN_FEATURE_CSR) - SET(SERVER_CHECK_MODULES "${SERVER_CHECK_MODULES} csr") -ENDIF(TIZEN_FEATURE_CSR) +SET(SERVER_CHECK_MODULES gio-2.0 glib-2.0 dlog pkgmgr-parser pkgmgr-info libtzplatform-config drm-service-core-tizen libgum sqlite3 pkgmgr pkgmgr-installer libsystemd aul minizip csr capi-system-info) pkg_check_modules(SERVER_DEPS REQUIRED ${SERVER_CHECK_MODULES}) @@ -38,10 +35,6 @@ FOREACH(SERVER_FLAGS ${SERVER_DEPS_CFLAGS}) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SERVER_FLAGS}") ENDFOREACH(SERVER_FLAGS) -IF(TIZEN_FEATURE_CSR) - ADD_DEFINITIONS("-DTIZEN_FEATURE_CSR") -ENDIF(TIZEN_FEATURE_CSR) - ADD_EXECUTABLE(${PKGMGR_SERVER} ${SRCS}) TARGET_LINK_LIBRARIES(${PKGMGR_SERVER} pkgmgr_installer) TARGET_LINK_LIBRARIES(${PKGMGR_SERVER} ${SERVER_DEPS_LDFLAGS}) diff --git a/packaging/pkgmgr-server.spec b/packaging/pkgmgr-server.spec index b27c953..98ac770 100644 --- a/packaging/pkgmgr-server.spec +++ b/packaging/pkgmgr-server.spec @@ -27,9 +27,8 @@ BuildRequires: pkgconfig(libsystemd) BuildRequires: pkgconfig(minizip) BuildRequires: fdupes -%if "%{?profile}" != "tv" BuildRequires: pkgconfig(csr) -%endif +BuildRequires: pkgconfig(capi-system-info) %description Packager Manager server package for packaging @@ -45,17 +44,10 @@ cp %{SOURCE1001} . %build sqlite3 restriction.db < ./restriction.sql -%if "%{?profile}" != "tv" -_TIZEN_FEATURE_CSR=ON -%else -_TIZEN_FEATURE_CSR=OFF -%endif - %cmake . -DRUN_DIR=%{run_dir} \ -DDB_DIR=%{db_dir} \ -DBACKEND_DIR=%{backend_dir} \ - -DUNITDIR=%{_unitdir} \ - -DTIZEN_FEATURE_CSR:BOOL=${_TIZEN_FEATURE_CSR} + -DUNITDIR=%{_unitdir} %__make %{?_smp_mflags} diff --git a/src/pkgmgr-server.c b/src/pkgmgr-server.c index cf55a28..638e89a 100644 --- a/src/pkgmgr-server.c +++ b/src/pkgmgr-server.c @@ -42,15 +42,15 @@ #include #include #include -#ifdef TIZEN_FEATURE_CSR #include -#endif #include "pkgmgr_installer.h" #include "pkgmgr-server.h" #include "queue.h" #include "package-manager.h" +#include + #define OWNER_ROOT 0 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) #define APPFW_UID 301 @@ -102,6 +102,50 @@ static void sighandler(int signo); gboolean exit_server(void *data); +typedef enum { + TIZEN_PROFILE_UNKNOWN = 0, + TIZEN_PROFILE_MOBILE = 0x1, + TIZEN_PROFILE_WEARABLE = 0x2, + TIZEN_PROFILE_TV = 0x4, + TIZEN_PROFILE_IVI = 0x8, + TIZEN_PROFILE_COMMON = 0x10, +} tizen_profile_t; + +static tizen_profile_t _get_tizen_profile() +{ + static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN; + char *profileName; + + if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1)) + return profile; + + system_info_get_platform_string("http://tizen.org/feature/profile", &profileName); + switch (*profileName) { + case 'm': + case 'M': + profile = TIZEN_PROFILE_MOBILE; + break; + case 'w': + case 'W': + profile = TIZEN_PROFILE_WEARABLE; + break; + case 't': + case 'T': + profile = TIZEN_PROFILE_TV; + break; + case 'i': + case 'I': + profile = TIZEN_PROFILE_IVI; + break; + default: // common or unknown ==> ALL ARE COMMON. + profile = TIZEN_PROFILE_COMMON; + } + free(profileName); + + return profile; +} +#define TIZEN_FEATURE_CSR (_get_tizen_profile() != TIZEN_PROFILE_TV) + /* To check whether a particular backend is free/busy */ static int __is_backend_busy(int position) { @@ -322,7 +366,6 @@ gboolean exit_server(void *data) return TRUE; } -#ifdef TIZEN_FEATURE_CSR static int __check_csr(const char *path) { csr_cs_context_h context = NULL; @@ -348,7 +391,6 @@ static int __check_csr(const char *path) return 0; } -#endif static int __kill_app(char *appid, uid_t uid) { @@ -1536,19 +1578,19 @@ gboolean queue_job(void *data) /* set current backend job */ DBG("handle request type [%d]", job->req_type); -#ifdef TIZEN_FEATURE_CSR - if (job->req_type == REQUEST_TYPE_INSTALL || - job->req_type == REQUEST_TYPE_MOUNT_INSTALL || - job->req_type == REQUEST_TYPE_REINSTALL) { - ret = __check_csr(job->pkgid); - if (ret != 0) { - ret = -1; - _send_fail_signal(job); - _free_backend_job(job); - return TRUE; + if (TIZEN_FEATURE_CSR) { + if (job->req_type == REQUEST_TYPE_INSTALL || + job->req_type == REQUEST_TYPE_MOUNT_INSTALL || + job->req_type == REQUEST_TYPE_REINSTALL) { + ret = __check_csr(job->pkgid); + if (ret != 0) { + ret = -1; + _send_fail_signal(job); + _free_backend_job(job); + return TRUE; + } } } -#endif switch (job->req_type) { case REQUEST_TYPE_INSTALL: -- 2.7.4 From c1c177befd157befc0dd73b26a5da90feed86dde Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Thu, 19 Jan 2017 15:29:15 +0900 Subject: [PATCH 14/16] Remove unused versioning macro Change-Id: I43386a2b4c6f1506ee5327c2367f9d04318fda5b Signed-off-by: jongmyeongko --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6f0c64..5d9bf55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,8 +3,6 @@ SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) SET(CMAKE_SKIP_BUILD_RPATH true) PROJECT(pkgmgr-server C) -SET(VERSION_MAJOR 0) -SET(VERSION ${VERSION_MAJOR}.1.68) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "\${prefix}") -- 2.7.4 From d599819298201ce1471fdc76758ec545e5894475 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Thu, 19 Jan 2017 15:31:01 +0900 Subject: [PATCH 15/16] Release Version 0.4.0 Changes: - Remove Profile Build Dependency: Do it at runtime Change-Id: If6988a96083060192f4d8753d975811f92824355 Signed-off-by: jongmyeongko --- packaging/pkgmgr-server.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/pkgmgr-server.spec b/packaging/pkgmgr-server.spec index 98ac770..abf54d9 100644 --- a/packaging/pkgmgr-server.spec +++ b/packaging/pkgmgr-server.spec @@ -1,6 +1,6 @@ Name: pkgmgr-server Summary: Packager Manager server package -Version: 0.3.37 +Version: 0.4.0 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From ffda75a93105b140c97e3c09c9a70e4dcaf5f653 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Fri, 3 Feb 2017 16:06:18 +0900 Subject: [PATCH 16/16] Change queue of cleardata - Cleardata is performed by pkgmgr-server itself so change queue into pkgtool - reqkey is no longer required when calling cleardata so it was removed Change-Id: Iee3ece77bc22111c2bc590f5a4d4f1400792c3c8 Signed-off-by: Junghyun Yeon --- src/request.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/request.c b/src/request.c index 8e3793e..b3f9164 100644 --- a/src/request.c +++ b/src/request.c @@ -971,9 +971,7 @@ static int __handle_request_cleardata(uid_t caller_uid, GDBusMethodInvocation *invocation, GVariant *parameters) { uid_t target_uid = (uid_t)-1; - char *pkgtype; char *pkgid = NULL; - char *reqkey = NULL; g_variant_get(parameters, "(u&s)", &target_uid, &pkgid); if (target_uid == (uid_t)-1 || pkgid == NULL) { @@ -982,36 +980,16 @@ static int __handle_request_cleardata(uid_t caller_uid, return -1; } - pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid); - if (pkgtype == NULL) { - g_dbus_method_invocation_return_value(invocation, - g_variant_new("(i)", PKGMGR_R_ENOPKG)); - return -1; - } - - reqkey = __generate_reqkey(pkgid); - if (reqkey == NULL) { - g_dbus_method_invocation_return_value(invocation, - g_variant_new("(i)", PKGMGR_R_ENOMEM)); - free(pkgtype); - return -1; - } - - if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_CLEARDATA, - pkgtype, pkgid, NULL)) { + if (_push_queue(target_uid, caller_uid, NULL, REQUEST_TYPE_CLEARDATA, + "pkgtool", pkgid, NULL)) { g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", PKGMGR_R_ESYSTEM)); - free(reqkey); - free(pkgtype); return -1; } g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", PKGMGR_R_OK)); - free(reqkey); - free(pkgtype); - return 0; } -- 2.7.4