Replace security-server with cynara 33/37633/7 submit/tizen/20150414.040508
authorSangyoon Jang <s89.jang@samsung.com>
Wed, 1 Apr 2015 11:50:11 +0000 (20:50 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Thu, 9 Apr 2015 04:32:30 +0000 (13:32 +0900)
TODO:
use asynchronous api

remove unused files
this is temporary fix that using synchronous api
security-server will be removed from Tizen 3
security-manager and cynara are newly introduced into Tizen 3

Change-Id: I706d16c949d57a1a2eb80f163e7b8241b7f198f7
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
22 files changed:
client/CMakeLists.txt
client/pkgmgr.pc.in
client/src/pkgmgr.c
comm/CMakeLists.txt
comm/SLP_package_manager_frontend_backend_PG.h [deleted file]
comm/comm_client.c [deleted file]
comm/comm_client.h
comm/comm_client_gdbus.c
comm/comm_pkg_mgr.xml
comm/comm_pkg_mgr_server.c
comm/comm_pkg_mgr_server.h
comm/comm_status_broadcast_server.c [deleted file]
comm/comm_status_broadcast_signal_marshaller.list [deleted file]
comm/test/test_comm_client.c
comm/test/test_comm_pkg_mgr_server.c
packaging/pkgmgr.spec
server/CMakeLists.txt
server/include/pkgmgr-server.h
server/org.tizen.slp.pkgmgr.conf.in
server/src/pkgmgr-server.c
server/src/pm-queue.c
tool/CMakeLists.txt

index fe92867..46123c7 100644 (file)
@@ -9,8 +9,7 @@ pkg_check_modules(CLIENT_DEPS REQUIRED
                pkgmgr-parser
                pkgmgr-info
                iniparser
-               libtzplatform-config
-               security-server)
+               libtzplatform-config)
 FOREACH(CLIENT_FLAGS ${CLIENT_DEPS_CFLAGS})
        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CLIENT_FLAGS}")
 ENDFOREACH(CLIENT_FLAGS)
index c9157b6..940b3f8 100644 (file)
@@ -11,6 +11,6 @@ includedir=@INCLUDEDIR@
 Name: package manager 
 Description: SLP Package Manager Package
 Version: @VERSION@
-Requires: security-server dlog pkgmgr-types pkgmgr-installer-client pkgmgr-installer-status-broadcast-server
+Requires: dlog pkgmgr-types pkgmgr-installer-client pkgmgr-installer-status-broadcast-server
 Libs: -L${libdir} -L${libdir}/pkgmgr -lpkgmgr-client
 Cflags: -I${includedir}
index ae1f5d1..6bb322f 100644 (file)
@@ -36,7 +36,6 @@
 #include <db-util.h>
 #include <pkgmgr-info.h>
 #include <iniparser.h>
-#include <security-server.h>
 
 /* For multi-user support */
 #include <tzplatform_config.h>
@@ -101,29 +100,6 @@ typedef struct _iter_data {
        void *data;
 } iter_data;
 
-static char *__get_cookie_from_security_server(void)
-{
-       int ret = 0;
-       size_t cookie_size = 0;
-       char *e_cookie = NULL;
-
-       //calculage cookie size
-       cookie_size = security_server_get_cookie_size();
-       retvm_if(cookie_size <= 0, NULL, "security_server_get_cookie_size : cookie_size is %d", cookie_size);
-
-       //get cookie from security server
-       char cookie[cookie_size];
-       cookie[0] = '\0';
-       ret = security_server_request_cookie(cookie, cookie_size);
-       retvm_if(ret < 0, NULL, "security_server_request_cookie fail (%d)", ret);
-
-       //encode cookie
-       e_cookie = g_base64_encode((const guchar *)cookie, cookie_size);
-       retvm_if(e_cookie == NULL, NULL, "g_base64_encode e_cookie is NULL");
-
-       return e_cookie;
-}
-
 static int __xsystem(const char *argv[])
 {
        int status = 0;
@@ -831,7 +807,6 @@ static int __get_size_process(pkgmgr_client * pc, const char *pkgid, uid_t uid,
        char *temp = NULL;
        int i = 0;
        char buf[128] = {'\0'};
-       char *cookie = NULL;
 
        pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
        retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
@@ -862,12 +837,8 @@ static int __get_size_process(pkgmgr_client * pc, const char *pkgid, uid_t uid,
        }
        DBG("[args] %s [len] %d\n", args, len);
 
-       /* get cookie from security-server */
-       cookie = __get_cookie_from_security_server();
-       tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
-
        /* request */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, cookie, uid, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, uid, 1);
        if (ret < 0)
                ERR("comm_client_request failed, ret=%d\n", ret);
 
@@ -881,8 +852,6 @@ catch:
 
        if(args)
                free(args);
-       if (cookie)
-               free(cookie);
 
        return ret;
 }
@@ -903,7 +872,6 @@ static int __move_pkg_process(pkgmgr_client * pc, const char *pkgid, uid_t uid,
        int i = 0;
        char buf[128] = {'\0'};
        char info_file[PKG_STRING_LEN_MAX] = {'\0', };
-       char *cookie = NULL;
 
        pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
        retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
@@ -960,12 +928,8 @@ static int __move_pkg_process(pkgmgr_client * pc, const char *pkgid, uid_t uid,
        }
        DBG("[args] %s [len] %d\n", args, len);
 
-       /* get cookie from security-server */
-       cookie = __get_cookie_from_security_server();
-       tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
-
        /* 6. request */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_MOVER, pkgtype, pkgid, args, cookie,uid, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_MOVER, pkgtype, pkgid, args, uid, 1);
        if (ret < 0)
                ERR("comm_client_request failed, ret=%d\n", ret);
 
@@ -980,8 +944,6 @@ catch:
 
        if(args)
                free(args);
-       if (cookie)
-               free(cookie);
 
        pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
        return ret;
@@ -1013,9 +975,9 @@ static int __check_app_process(pkgmgr_request_service_type service_type, pkgmgr_
 
        /* 3. request activate */
        if (service_type == PM_REQUEST_KILL_APP)
-               ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_KILL_APP, pkgtype, pkgid, NULL, NULL, uid, 1);
+               ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_KILL_APP, pkgtype, pkgid, NULL, uid, 1);
        else if (service_type == PM_REQUEST_CHECK_APP)
-               ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_CHECK_APP, pkgtype, pkgid, NULL, NULL, uid, 1);
+               ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_CHECK_APP, pkgtype, pkgid, NULL, uid, 1);
 
        if (ret < 0)
                ERR("request failed, ret=%d\n", ret);
@@ -1046,7 +1008,6 @@ static int __request_size_info(pkgmgr_client *pc, uid_t uid)
        char *temp = NULL;
        int i = 0;
        char buf[128] = {'\0'};
-       char *cookie = NULL;
 
        pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
        retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
@@ -1078,12 +1039,8 @@ static int __request_size_info(pkgmgr_client *pc, uid_t uid)
        }
        DBG("[args] %s [len] %d\n", args, len);
 
-       /* get cookie from security-server */
-       cookie = __get_cookie_from_security_server();
-       tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
-
        /* request */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, cookie, uid, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, uid, 1);
        if (ret < 0) {
                ERR("COMM_REQ_GET_SIZE failed, ret=%d\n", ret);
        }
@@ -1094,8 +1051,6 @@ catch:
 
        if(args)
                free(args);
-       if (cookie)
-               free(cookie);
 
        return ret;
 }
@@ -1142,7 +1097,6 @@ static int __get_package_size_info(pkgmgr_client_t *mpc, char *req_key, const ch
        char *pkgtype = "getsize"; //unused
        char buf[128] = { 0, };
        int len = 0;
-       char *cookie = NULL;
        char *temp = NULL;
        int i = 0;
        int ret = 0;
@@ -1173,12 +1127,8 @@ static int __get_package_size_info(pkgmgr_client_t *mpc, char *req_key, const ch
        }
        DBG("[args] %s [len] %d\n", args, len);
 
-       /* get cookie from security-server */
-       cookie = __get_cookie_from_security_server();
-       tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
-
        /* request */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, cookie, uid, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, uid, 1);
        if (ret < 0)
                ERR("COMM_REQ_GET_SIZE failed, ret=%d\n", ret);
 
@@ -1188,8 +1138,6 @@ catch:
 
        if(args)
                free(args);
-       if (cookie)
-               free(cookie);
 
        return ret;
 }
@@ -1351,7 +1299,6 @@ API int pkgmgr_client_usr_install(pkgmgr_client * pc, const char *pkg_type,
        int len = 0;
        char *temp = NULL;
        int ret = 0;
-       char *cookie = NULL;
        char *caller_pkgid = NULL;
 
        caller_pkgid = __get_caller_pkgid(uid);
@@ -1449,13 +1396,10 @@ API int pkgmgr_client_usr_install(pkgmgr_client * pc, const char *pkg_type,
        }
        DBG("[args] %s [len] %d\n", args, len);
 
-       /* get cookie from security-server */
-       cookie = __get_cookie_from_security_server();
-       tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
        /******************* end of quote ************************/
 
        /* 6. request install */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkg_path, args, cookie, uid, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkg_path, args, uid, 1);
        tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
 
        ret = req_id;
@@ -1468,8 +1412,6 @@ catch:
                free(args);
        if (pkgtype)
                free(pkgtype);
-       if (cookie)
-               free(cookie);
 
        return ret;
 }
@@ -1509,7 +1451,6 @@ API int pkgmgr_client_usr_reinstall(pkgmgr_client * pc, const char *pkg_type, co
        int len = 0;
        char *temp = NULL;
        int ret = 0;
-       char *cookie = NULL;
 
        /* Check for NULL value of pc */
        retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
@@ -1582,13 +1523,10 @@ API int pkgmgr_client_usr_reinstall(pkgmgr_client * pc, const char *pkg_type, co
        }
        DBG("[args] %s [len] %d\n", args, len);
 
-       /* get cookie from security-server */
-       cookie = __get_cookie_from_security_server();
-       tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
        /******************* end of quote ************************/
 
        /* 6. request install */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, cookie, uid, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, uid, 1);
        tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed");
 
        ret = req_id;
@@ -1601,8 +1539,6 @@ catch:
                free(args);
        if (pkgtype)
                free(pkgtype);
-       if (cookie)
-               free(cookie);
 
        return ret;
 }
@@ -1628,7 +1564,6 @@ API int pkgmgr_client_usr_uninstall(pkgmgr_client *pc, const char *pkg_type,
        int len = 0;
        char *temp = NULL;
        int ret = -1;
-       char *cookie = NULL;
        bool removable = false;
        char *caller_pkgid = NULL;
 
@@ -1736,13 +1671,10 @@ API int pkgmgr_client_usr_uninstall(pkgmgr_client *pc, const char *pkg_type,
        }
        DBG("[args] %s [len] %d\n", args, len);
 
-       /* get cookie from security-server */
-       cookie = __get_cookie_from_security_server();
-       tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
        /******************* end of quote ************************/
 
        /* 6. request install */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, cookie, uid, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, uid, 1);
        tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "calloc failed");
 
        ret = req_id;
@@ -1753,8 +1685,6 @@ catch:
 
        if(args)
                free(args);
-       if (cookie)
-               free(cookie);
 
        pkgmgr_pkginfo_destroy_pkginfo(handle);
        return ret;
@@ -1779,7 +1709,6 @@ API int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type,
        char *temp = NULL;
        int ret = 0;
        int req_id = 0;
-       char *cookie = NULL;
        char buf[128] = {'\0'};
 
        /* Check for NULL value of pc */
@@ -1868,7 +1797,7 @@ API int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type,
        /* 6. request install */
        ret = comm_client_request(mpc->info.request.cc, req_key,
                                  COMM_REQ_TO_MOVER, pkgtype, pkgid,
-                                 args, cookie, uid, 1);
+                                 args, uid, 1);
        if (ret < 0) {
                ERR("request failed, ret=%d\n", ret);
 
@@ -1910,7 +1839,6 @@ API int pkgmgr_client_move_usr_pkg(pkgmgr_client *pc, const char *pkg_type,
        int len = 0;
        char *temp = NULL;
        int ret = -1;
-       char *cookie = NULL;
        char buf[128] = {'\0'};
 
        /* Check for NULL value of pc */
@@ -2013,13 +1941,10 @@ API int pkgmgr_client_move_usr_pkg(pkgmgr_client *pc, const char *pkg_type,
        }
        DBG("[args] %s [len] %d\n", args, len);
 
-       /* get cookie from security-server */
-       cookie = __get_cookie_from_security_server();
-       tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
        /******************* end of quote ************************/
 
        /* 6. request install */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_MOVER, pkgtype, pkgid, args, cookie, uid, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_MOVER, pkgtype, pkgid, args, uid, 1);
        tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "calloc failed");
 
        ret = req_id;
@@ -2030,8 +1955,6 @@ catch:
 
        if(args)
                free(args);
-       if (cookie)
-               free(cookie);
 
        pkgmgr_pkginfo_destroy_pkginfo(handle);
        return ret;
@@ -2048,7 +1971,6 @@ API int pkgmgr_client_usr_activate(pkgmgr_client * pc, const char *pkg_type,
 {
        const char *pkgtype;
        char *req_key;
-       char *cookie = NULL;
        int ret;
        /* Check for NULL value of pc */
        retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
@@ -2073,7 +1995,7 @@ API int pkgmgr_client_usr_activate(pkgmgr_client * pc, const char *pkg_type,
        retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
 
        /* 3. request activate */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, pkgid, "1 PKG", cookie, uid, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, pkgid, "1 PKG", uid, 1);
        tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
 
        ret = PKGMGR_R_OK;
@@ -2094,7 +2016,6 @@ API int pkgmgr_client_usr_deactivate(pkgmgr_client *pc, const char *pkg_type,
 {
        const char *pkgtype;
        char *req_key;
-       char *cookie = NULL;
        int ret;
        /* Check for NULL value of pc */
        retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
@@ -2120,7 +2041,7 @@ API int pkgmgr_client_usr_deactivate(pkgmgr_client *pc, const char *pkg_type,
        retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
 
        /* 3. request activate */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, pkgid, "0 PKG", cookie, uid, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, pkgid, "0 PKG", uid, 1);
        tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
 
        ret = PKGMGR_R_OK;
@@ -2139,7 +2060,6 @@ API int pkgmgr_client_usr_activate_app(pkgmgr_client * pc, const char *appid, ui
 {
        const char *pkgtype;
        char *req_key;
-       char *cookie = NULL;
        int ret;
        /* Check for NULL value of pc */
        retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
@@ -2161,7 +2081,7 @@ API int pkgmgr_client_usr_activate_app(pkgmgr_client * pc, const char *appid, ui
        retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
 
        /* 3. request activate */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, appid, "1 APP", cookie, uid, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, appid, "1 APP", uid, 1);
        tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
 
        ret = PKGMGR_R_OK;
@@ -2180,7 +2100,6 @@ API int pkgmgr_client_usr_activate_appv(pkgmgr_client * pc, const char *appid, c
 {
        const char *pkgtype;
        char *req_key;
-       char *cookie = NULL;
        int ret;
        int i = 0;
        char *temp = NULL;
@@ -2243,7 +2162,7 @@ API int pkgmgr_client_usr_activate_appv(pkgmgr_client * pc, const char *appid, c
        /******************* end of quote ************************/
 
        /* 3. request activate */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, appid, argsr, cookie, uid, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, appid, argsr, uid, 1);
        tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
 
        ret = PKGMGR_R_OK;
@@ -2267,7 +2186,6 @@ API int pkgmgr_client_usr_deactivate_app(pkgmgr_client *pc, const char *appid, u
 {
        const char *pkgtype;
        char *req_key;
-       char *cookie = NULL;
        int ret;
        /* Check for NULL value of pc */
        retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
@@ -2289,7 +2207,7 @@ API int pkgmgr_client_usr_deactivate_app(pkgmgr_client *pc, const char *appid, u
        retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
 
        /* 3. request activate */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, appid, "0 APP", cookie, uid, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, appid, "0 APP", uid, 1);
        tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
 
        ret = PKGMGR_R_OK;
@@ -2317,7 +2235,6 @@ API int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc, const char *pkg_typ
        int len = 0;
        char *temp = NULL;
        int ret;
-       char *cookie = NULL;
 
        /* Check for NULL value of pc */
        if (pc == NULL) {
@@ -2399,7 +2316,7 @@ API int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc, const char *pkg_typ
        /* 6. request clear */
        ret = comm_client_request(mpc->info.request.cc, req_key,
                                  COMM_REQ_TO_CLEARER, pkgtype, appid,
-                                 args, cookie, uid, 1);
+                                 args, uid, 1);
        if (ret < 0) {
                ERR("request failed, ret=%d\n", ret);
 
@@ -2645,7 +2562,6 @@ API int pkgmgr_client_usr_clear_cache_dir(const char *pkgid, uid_t uid)
        int ret = 0;
        pkgmgr_client_t *pc = NULL;
        char *pkg_type = NULL;
-       char *cookie = NULL;
        int is_type_malloced = 0;
 
        pkgmgrinfo_pkginfo_h handle = NULL;
@@ -2668,17 +2584,11 @@ API int pkgmgr_client_usr_clear_cache_dir(const char *pkgid, uid_t uid)
                is_type_malloced = 1;
        }
 
-       cookie = __get_cookie_from_security_server();
-       tryvm_if(cookie == NULL, ret = PKGMGR_R_ESYSTEM, "__get_cookie_from_security_server is NULL");
-
-       ret = comm_client_request(pc->info.request.cc, NULL, COMM_REQ_CLEAR_CACHE_DIR, pkg_type, pkgid, NULL, cookie, uid, 0);
+       ret = comm_client_request(pc->info.request.cc, NULL, COMM_REQ_CLEAR_CACHE_DIR, pkg_type, pkgid, NULL, uid, 0);
        tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "COMM_REQ_CLEAR_CACHE_DIR failed, ret=%d\n", ret);
 
        ret = PKGMGR_R_OK;
 catch:
-       if (cookie)
-               free(cookie);
-
        if (pc)
                pkgmgr_client_free(pc);
 
@@ -2724,7 +2634,6 @@ API int pkgmgr_client_usr_get_size(pkgmgr_client * pc, const char *pkgid, pkgmgr
        char *temp = NULL;
        int i = 0;
        char buf[128] = {'\0'};
-       char *cookie = NULL;
        int req_id = 0;
 
        pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
@@ -2764,12 +2673,8 @@ API int pkgmgr_client_usr_get_size(pkgmgr_client * pc, const char *pkgid, pkgmgr
        }
        DBG("[args] %s [len] %d\n", args, len);
 
-       /* get cookie from security-server */
-       cookie = __get_cookie_from_security_server();
-       tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
-
        /* request */
-       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, cookie, uid, 1);
+       ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, uid, 1);
        if (ret < 0)
                ERR("comm_client_request failed, ret=%d\n", ret);
 
@@ -2779,8 +2684,6 @@ catch:
 
        if(args)
                free(args);
-       if (cookie)
-               free(cookie);
 
        return ret;
 }
index f4841c3..40a319e 100644 (file)
@@ -25,7 +25,7 @@ message(STATUS "version/major : ${VERSION} / ${VERSION_MAJOR}")
 ### Get required CFLAGS, LDFLAGS from pkg-config
 
 include(FindPkgConfig)
-pkg_check_modules(comm_pkgs REQUIRED dbus-1 glib-2.0 dbus-glib-1 gio-2.0 gio-unix-2.0 dlog pkgmgr-info db-util)
+pkg_check_modules(comm_pkgs REQUIRED dbus-1 glib-2.0 dbus-glib-1 gio-2.0 gio-unix-2.0 dlog pkgmgr-info db-util cynara-client cynara-creds-dbus cynara-session)
 
 foreach(flag ${comm_pkgs_CFLAGS})
        set(comm_pkgs_CFLAGS_str "${comm_pkgs_CFLAGS_str} ${flag}")
@@ -38,11 +38,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
 ### Create dbus-glib bindings headers (client/server) from xml by dbus-binding-tool
 
 # comm_pkg_mgr : package manger interface (client - package manager process)
-add_custom_target(comm_pkg_mgr_client_dbus_bindings.h
-       COMMAND dbus-binding-tool --prefix=pkgmgr --mode=glib-client 
-                       ${CMAKE_CURRENT_SOURCE_DIR}/comm_pkg_mgr.xml 
-                       --output=${CMAKE_CURRENT_BINARY_DIR}/comm_pkg_mgr_client_dbus_bindings.h
-       )
 add_custom_target(comm_pkg_mgr_server_dbus_bindings.h
        COMMAND dbus-binding-tool --prefix=pkgmgr --mode=glib-server
                        ${CMAKE_CURRENT_SOURCE_DIR}/comm_pkg_mgr.xml 
@@ -55,30 +50,12 @@ add_custom_command(OUTPUT comm_pkg_mgr_client_gdbus_generated.c comm_pkg_mgr_cli
                        --interface-prefix pkgmgr ${CMAKE_CURRENT_SOURCE_DIR}/comm_pkg_mgr.xml
        )
 
-# comm_status_broadcast : status broadcast interface (client - backend process)
-add_custom_target(comm_status_broadcast_client_dbus_bindings.h
-       COMMAND dbus-binding-tool --prefix=status_broadcast --mode=glib-client 
-                       ${CMAKE_CURRENT_SOURCE_DIR}/comm_status_broadcast.xml 
-                       --output=${CMAKE_CURRENT_BINARY_DIR}/comm_status_broadcast_client_dbus_bindings.h
-       )
 add_custom_target(comm_status_broadcast_server_dbus_bindings.h
        COMMAND dbus-binding-tool --prefix=status_broadcast --mode=glib-server
                        ${CMAKE_CURRENT_SOURCE_DIR}/comm_status_broadcast.xml 
                        --output=${CMAKE_CURRENT_BINARY_DIR}/comm_status_broadcast_server_dbus_bindings.h
        )
 
-### Create marshaller header/source for signal (client must use this)
-add_custom_target(comm_status_broadcast_signal_marshaller.h
-               COMMAND glib-genmarshal --header ${CMAKE_CURRENT_SOURCE_DIR}/comm_status_broadcast_signal_marshaller.list > ${CMAKE_CURRENT_BINARY_DIR}/comm_status_broadcast_signal_marshaller.h
-               )
-add_custom_target(comm_status_broadcast_signal_marshaller.c
-               COMMAND glib-genmarshal --body ${CMAKE_CURRENT_SOURCE_DIR}/comm_status_broadcast_signal_marshaller.list > ${CMAKE_CURRENT_BINARY_DIR}/comm_status_broadcast_signal_marshaller.c
-               )
-set_source_files_properties(comm_status_broadcast_signal_marshaller.c PROPERTIES GENERATED true)  # This source is generated during build time, so this property must be set
-
-
-
-
 
 ### Build modules
 
@@ -87,13 +64,11 @@ set_source_files_properties(comm_status_broadcast_signal_marshaller.c PROPERTIES
 add_library(pkgmgr_installer_client SHARED
                comm_client_gdbus.c
                comm_pkg_mgr_client_gdbus_generated.c
-               #${CMAKE_CURRENT_BINARY_DIR}/comm_status_broadcast_signal_marshaller.c
                )
 set_target_properties(pkgmgr_installer_client PROPERTIES SOVERSION ${VERSION_MAJOR})
 set_target_properties(pkgmgr_installer_client PROPERTIES VERSION ${VERSION})
 set_target_properties(pkgmgr_installer_client PROPERTIES COMPILE_FLAGS "${comm_pkgs_CFLAGS_str}")
 target_link_libraries(pkgmgr_installer_client ${comm_pkgs_LDFLAGS})
-#add_dependencies(pkgmgr_installer_client comm_pkg_mgr_client_dbus_bindings.h comm_status_broadcast_client_dbus_bindings.h comm_status_broadcast_signal_marshaller.h comm_status_broadcast_signal_marshaller.c)
 add_dependencies(pkgmgr_installer_client comm_pkg_mgr_client_gdbus_generated.h comm_pkg_mgr_client_gdbus_generated.c)
 
 ## pkg-mgr server for PMS
diff --git a/comm/SLP_package_manager_frontend_backend_PG.h b/comm/SLP_package_manager_frontend_backend_PG.h
deleted file mode 100644 (file)
index bc072b8..0000000
+++ /dev/null
@@ -1,470 +0,0 @@
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-
-/**
- * @ingroup SLP_PG
- * @defgroup pacakge_manager_PG PackageManagerStructure
- * @brief A programming guide for deelopers who want to make a frontend/backend pair for a package type.
- * @{
-
-<h1 class="pg">Introduction</h1>
-       <h2 class="pg">Terms of use</h2>
-       <ul>
-               <li><b>frontend</b> an installer frontend process</li>
-               <li><b>backend</b> an installer backend process</li>
-               <li><b>backendlib</b> a library of backend plugin</li>
-               <li><b>PMS</b> Package manager server</li>
-       </ul>
-
-       <h2 class="pg">Structure overview</h2>
-
- When a command to install/update/delete a package to package-manager system, a frontend process receives request, and pass it to the package manager server. Package manager server will queue all requests, and runs backend one by one.<br>
-For example, <br>
-  <center>SamsungApps --(install foo.deb)--> frontend --(install foo.deb)--> PMS --(Run dpkg backend to install foo.deb)--> backend</center><br>
-
-When 'install' command is given, the package file to be installed is already downloaded by user's application (SamsungApps, ...), and these frontend/PMS/backend are only responsible for installing it.<br>
-Requests between frontend and PMS, and signal broadcasting between backend and frontend/apps are implemented by dbus.<br>
-<h2></h2><br>
-
- To get the package information, backend plugin library is used. Each backend library provides the predefined functions, and package manager client library uses it.<br>
-  <center>SamsungApps ~~> package-manager client library ~~> backend end plugin library </center>
-  <center>(link and API call)                     (dynamic loading and symbol binding)  </center><br>
-
-Detailed informations for each process are explained below.
-
-       <h2 class="pg">Frontend</h2>
-
-  A frontend is a program which shows UI to users(if needed), requests install/update/delete/recover to PMS, and shows installing status(if needed). frontend/backend programs must be exist per one package type. Again, each package type must have one frontend/backend pair.<br>
-
-  A frontend process runs with <b>user provilege</b>, executed by package-manager client API, in include/package-manager.h;
-<ul>
-       <li>package_manager_install_application()</li>
-       <li>package_manager_uninstall_application()</li>
-</ul>
-
-  Frontend process does following things;
-<ul>
-       <li>Gets arguments from argv, with one of following options;
-               <ul>
-                       <li>-i <filepath> : Install package</li>
-                       <li>-u <filepath> : Update package</li>
-                       <li>-r : Recover package system</li>
-                       <li>-d <package_name> : Delete package</li>
-               </ul>
-       </li>
-       <li>Gets cookie from security server.</li>
-       <li>Sends request to PMS, with various arguments and cookie.</li>
-       <li>Waits backend's status signals.</li>
-       <li>Updates UI accroding to backend's status signal, if necessary.</li>
-       <li>Finishes process when 'end' signal from backend comes.</li>
-</ul>
-
-A frontend has UI, so it runs in event-loop (usually ecore_loop, sometimes g_main_loop). We provide an object 'comm_client', which is integrated with g_main_loop. So, you have to program event-loop based code. Luckily the ecore_loop in SLP is integrated with g_main_loop, so you don't need to worry about using comm_client API in ecore_loop.
-
-               <h3 class="pg">Rules</h3>
-A frontend must have following features;
-<ul>
-       <li>Must be able to parse -i, -u, -r, -d, -q options.</li>
-       <li>Must be able to parse -k <req_id> option. This string is passed to backend, as a request id.
-       <li>Must have UI(at least a OK/Cancel dialog), which can be ignored by -q option.</li>
-       <li>Must be able to use g_main_loop based functions.</li>
-</ul>
-
-
-
-       <h2 class="pg">Package manager server</h2>
-Package Manager Server(PMS) is a <b>root</b> privilege process, which queues all requests from lots of frontends, and runs backends accrding to each requests. <br>
-PMS has a queue internally, which stores each request and runs one by one. <br>
-When no PMS is running yet, first frontend's request will execute PMS.
-
-  PMS process does following things;
-<ul>
-       <li>Receives requests from a frontend via dbus.</li>
-       <li>If the request has a wrong cookie, discard it.</li>
-       <li>Puts the request into the queue.</li>
-       <li>Pops a request from the queue, and sends it to corresponding backend.</li>
-       <li>When the backend finishes, run next request in the queue.</li>
-</ul>
-
-PMS is already made and installed in your system.
-
-       <h2 class="pg">Backend</h2>
-
-for a certain package type, a backend is a <b>root</b> privilege process invoked by PMS, which is doing following things;
-<ul>
-       <li>Parses input values</li>
-       <li>Checks signing of the package file, and verifies its validity (if necessary)
-       <li>Does install/update/delete a pacakge, or recovers package system, or </li>
-       <li>activate/deactivate a package</li>
-       <li>Broadcasts current status</li>
-</ul>
-
-               <h3 class="pg">Rules</h3>
-A backend must have following features;
-<ul>
-       <li>Must parse args string from frontend.</li>
-       <li>Must install/update/delete a package.</li>
-       <li>Must be able to recover package system, when it is corrupted.</li>
-       <li>Must broadcast current install/status</li>
-</ul>
-
-       <h2 class="pg">Backend library</h2>
-
-for a certain package type, a backend library  is just a <b>library</b> client process uses this library.
-Backend library does following things;
-<ul>
-       <li>Checks whether package is installed or not</li>
-       <li>Gets the list of installed package</li>
-       <li>Gets the information of installed package</li>
-       <li>Gets the information from package file</li>
-</ul>
-
-               <h3 class="pg">Rules</h3>
-A backend must have following features;
-<ul>
-       <li>Must check whether package is installed or not.</li>
-       <li>Must get the list of installed package.</li>
-       <li>Must get the information of installed package.</li>
-       <li>Must gets the information from package file</li>
-</ul>
-
-
-<h1 class="pg">Programming guide</h1>
-
-       <h2 class="pg">Requied dev package</h2>
-libpkgmgr-installer-dev package is provided to develop installer frontend/backend. <br>
-@code
-$ apt-get install libpkgmgr-installer-dev
-@endcode
-
-libpkgmgr-types-dev package is provided to develop installer backendlib. <br>
-@code
-$ apt-get install libpkgmgr-types-dev
-@endcode
-
-Three package-config files are installed; pkgmgr-installer-client.pc and pkgmgr-installer-status-broadcast-server.pc and pkgmgr-types.pc 
-The first one is for frontend, the second one is for backend, and last one if for backendlib <br>
-
-
-       <h2 class="pg">Installer frontend's programming guide</h2>
-
-comm_client module is provided for frontend programming, which can do comminucations with PMS and backend process.<br>
-
-Example code is in packages/test/frontend.c. <br>
-
-<B>NOTE:</b> This example code uses g_main_loop. If you use ecore_loop, you don't need to run g_main_loop_*() functions. <br>
-
-Every installer frontend's command arguments are like this; <br>
-@code
-$ <frontend> <cmd_opt> [<opt_val>] -k <req_id>
-@endcode
-<ul>
-       <li>frontend : An installer frontend executable file.  </li>
-       <li>cmd_opt : One of -i(install package), -u(update package), -d(delete package), -r(recover package system), -a(activate package)</li>
-       <li>opt_val : Means package file path (with -i/-u), package name (with -d, -a). When cmd_opt is -r, no opt_val is required.  </li>
-       <li>req_id : A request id, which is passed from frontend (with -k option) to backend. </li>
-</ul>
-
-
-
-               <h3 class="pg">Get a cookie from security-server</h3>
-To authenticate this frontend process, firstly you have to get a cookie from security server.<br>
-security-server.h from security-server package has cookie APIs. For more information, see security-server.h file.<br>
-@code
-
-#include <security-server.h>
-
-/* ...... */
-
-char *cookie;
-int cookie_size;
-int cookie_ret;
-
-cookie_size = security_server_get_cookie_size();
-/* If security server is down or some other error occured, raise failure */
-if(0 >= cookie_size) {
-       /* TODO: raise error */
-} else {
-       cookie = calloc(cookie_size, sizeof(char));
-       cookie_ret = security_server_request_cookie(cookie, cookie_size);
-       /* TODO: Check cookie_ret... (See security-server.h to check return code) */
-}
-
-@endcode
-This cookie string will be passed to PMS later.
-
-               <h3 class="pg">Parse argv options</h3>
-All frontends must support at least 5 options; -i, -u, -d, -r, -k, and -q. Parse each options, and do requested job. <br>
-Only one of following options must be taken. <br>
-               <ul>
-                       <li>-i <filepath> : Install package</li>
-                       <li>-u <filepath> : Update package</li>
-                       <li>-r : Recover package system</li>
-                       <li>-d <package_name> : Delete package</li>
-               </ul>
-Following options must be able to taken. <br>
-               <ul>
-                       <li>-k <request_id> : An <b>unique string</b> to identify this request. This key will be included in status broadcast signals from backend.</li>
-                       <li>-q : Quiet option. Do now show UI.</li>
-               </ul>
-
-
-The sample code uses getopt() function in unistd.h to parse argv options.<br>
-
-@code
-#include <unistd.h>
-#define BUFSIZE 256
-
-/* ...... */
-
-const char *opts_str = "i:u:d:rqk:";   
-int s = 0;
-int quite = 0;
-int mode = 0;
-char buf[BUFSIZE];
-char req_id[BUFSIZE];
-
-
-while(-1 != (s = getopt(argc, argv, opts_str))) {
-       switch(s) {
-               case 'i':
-                       if(mode) break;
-                       mode = MODE_INSTALL;
-                       strncpy(buf, optarg, BUFSIZE);
-                       break;
-               case 'u':
-                       if(mode) break;
-                       mode = MODE_UPDATE;
-                       strncpy(buf, optarg, BUFSIZE);
-                       break;
-               case 'd':
-                       if(mode) break;
-                       mode = MODE_DELETE;
-                       strncpy(buf, optarg, BUFSIZE);
-                       break;
-               case 'r':
-                       if(mode) break;
-                       mode = MODE_RECOVER;
-                       break;
-               case 'q':
-                       quite = 1;
-                       break;
-               case 'k':
-                       strncpy(req_id, optarg, BUFSIZE);
-
-               default:
-                       usage();        /* Show usage, and exit */
-       }
-}
-
-@endcode
-
-               <h3 class="pg">Do send a request to install,update,delete or recover</h3>
-After parsing argv options, now your frontend knows what command will be request to your backend. For this work, we provide APIs.
-
-               <h3 class="pg"></h3>
-               <h3 class="pg"></h3>
-               <h3 class="pg"></h3>
-
-       <h2 class="pg">Installer backend's programming guide</h2>
-
-Example code is in packages/test/backend.c. <br>
-
-       <h3 class="pg">Parse command args</h3>
-Every installer backend's command arguments are like this; <br>
-@code
-$ <backend> <req_id> <pkgid> [<arg1> <arg2> <arg3> ...]
-@endcode
-<ul>
-       <li>backend : An installer backend executable file.  </li>
-       <li>req_id : A request id, which is passed from frontend (with -k option). This is broadcasted with all signals from this backend. </li>
-       <li>pkgid : package name</li>
-       <li>arg1, arg2, ... : Separated arguments from frontend. You can use anything. This is a rule just between frontend and backend. </li>
-</ul>
-
-Those options must be parsed and processed properly. <br>
-
-       <h3 class="pg">Broadcast installing status</h3>
-Backend must broadcast its installing status. You can broadcast your status by using following API.
-@code
-#include "comm_status_broadcast_server.h"
-
-/* ... */
-
-DBusConnection *conn;
-conn = comm_status_broadcast_server_connect(COMM_STATUS_BROADCAST_ALL);
-
-comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, conn, req_id, pkg_type, pkgid, "start", "0");
-/* ... */
-comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL,conn,  req_id, pkg_type, pkgid, "install_percent", "60");
-/* ... */
-comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, conn, req_id, pkg_type, pkgid, "end", "0");
-
-/* ... */
-@endcode
-
-Last two values are key/value pair. Following values are mandatory;
-<table>
-       <tr>
-               <th>key</th>
-               <th>value</th>
-               <th>Comment</th>
-       </tr>
-       <tr>
-               <td>start</td>
-               <td>download|install|uninstall|update|recover</td>
-               <td>Start backend process. <br>NOTE: 'download' is used only by downloader.</td>
-       </tr>
-       <tr>
-               <td>install_percent</td>
-               <td>[number between 0~100]</td>
-               <td>Install progress</td>
-       </tr>
-       <tr>
-               <td>error</td>
-               <td>[string]</td>
-               <td>Error message</td>
-       </tr>
-       <tr>
-               <td>end</td>
-               <td>ok|fail</td>
-               <td>End backend (Process termination)</td>
-       </tr>
-</table>
-
-Following values are required also. If you need any of them in downloader or installer backend, send it. <br>
-<table>
-       <tr>
-               <th>key</th>
-               <th>value</th>
-               <th>Comment</th>
-       </tr>
-       <tr>
-               <td>icon_path</td>
-               <td>path of icon file</td>
-               <td>Before icon and *.desktop files are installed, menu-screen must have temporary icon file. This option indicates temporary icon file's path.<br>If no icon_path is provided, menu-screen will use general temporary icon.</td>
-       </tr>
-       <tr>
-               <td>download_percent</td>
-               <td>[number between 0~100]</td>
-               <td>Download progress<br>NOTE: This key is used by downloader only. Installer backends don't use this.</td>
-</table>
-
-You can send any other key/val pair by this API, to send any information to your frontend or donwloader app. Any keys except above will be ignored by PMS.<br>
-
-
-
-       <h2 class="pg">Installer backendlib's programming guide</h2>
-Example code is in packages/installers/sample/sample_backendlib.c. <br>
-
-       <h3 class="pg">Plugin implementation</h3>
-Backendlib should implemented according to following Rule.
-<ul>
-       <li>Exported API : pkg_plugin_onload() is a exported symbol. This symbol is found when after loading the library. </li>
-       <li>function pointer : _pkg_plugin_set defines the structor of function pointer. Each functions are implemented. </li>
-       <li>function mapping : defined each functions are connected to function pointer when pkg_plugin_onload() is called. </li>
-</ul>
-
-@code
-#include "package-manager-plugin.h"
-
-
-static void pkg_native_plugin_unload (void)
-{
-       //ToDo
-}
-
-static int pkg_plugin_app_is_installed(const char *pkgid)
-{
-       //ToDo
-       
-       return 0;
-}
-
-static int pkg_plugin_get_installed_apps_list(package_manager_pkg_info_t **list, int *count)
-{
-       //ToDo
-       
-       return 0;
-}
-
-static int pkg_plugin_get_app_detail_info(const char *pkgid, package_manager_pkg_detail_info_t* pkg_detail_info)
-{
-       //ToDo
-       
-       return 0;
-}
-
-static int pkg_plugin_get_app_detail_info_from_package(const char *pkg_path, package_manager_pkg_detail_info_t* pkg_detail_info)
-{
-       //ToDo
-       
-       return 0;
-}
-
-
-int pkg_plugin_onload (pkg_plugin_set * set)
-{
-       if(set == NULL)
-       {
-               return -1;
-       }
-       
-       memset(set, 0x00, sizeof(pkg_plugin_set));
-
-       set->plugin_unload = pkg_native_plugin_unload;
-       set->pkg_is_installed = pkg_plugin_app_is_installed;
-       set->get_installed_pkg_list = pkg_plugin_get_installed_apps_list;
-       set->get_pkg_detail_info = pkg_plugin_get_app_detail_info;
-       set->get_pkg_detail_info_from_package = pkg_plugin_get_app_detail_info_from_package;
-
-       return 0;
-}
-@endcode
-
-
-
-       <h2 class="pg">Install frontend/backend</h2>
-Your frontend/backend binary executables have to be installed. Usually they are installed into @PREFIX@/bin/. <br>
-
-One thing you must do is that your backend binary's owner must be <b>root</b>, permission must be <b>700</b>.
-In case of backendlib, it's permission is <b>644</b>.
-
-
-       <h2 class="pg">Create symlinks for your frontend/backend binaries and backendlib library</h2>
-After installing your frontend/backend, You have to create symlinks pointing your frontend/backend binaries. <br>
-Those symlinks must be installed as following paths;
-<ul>
-       <li>frontend : @PREFIX@/etc/package-manager/frontend/<your package file's extension></li>
-       <li>backend : @PREFIX@/etc/package-manager/backend/<your package file's extension></li>
-       <li>backendlib : @PREFIX@/etc/package-manager/backendlib/lib[<your package file's extension>].so</li>
-</ul>
-For example, the debian package (*.deb) must have symlink @PREFIX@/etc/package-manager/frontend/deb, which is pointing actual frontend binary.<br>
-Client API and PMS will find actual frontend/backend binaries from those paths. <br>
-
- * @}
- */
diff --git a/comm/comm_client.c b/comm/comm_client.c
deleted file mode 100644 (file)
index b5cce80..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-
-#include "comm_config.h"
-#include "comm_client.h"
-#include "comm_pkg_mgr_client_dbus_bindings.h"
-#include "comm_status_broadcast_client_dbus_bindings.h"
-#include "comm_status_broadcast_signal_marshaller.h"
-#include "comm_debug.h"
-#include <stdlib.h>
-#include <string.h>
-
-struct comm_client {
-       /* Resources to be freed */
-       DBusGConnection *conn;
-       GError *err;
-       DBusGProxy *request_proxy;
-       DBusGProxy *signal_proxy;
-       char *pkgid;
-
-       status_cb signal_cb;
-       void *signal_cb_data;
-};
-
-comm_client *comm_client_new(void)
-{
-       comm_client *cc = NULL;
-
-       cc = calloc(1, sizeof(comm_client));
-       if (NULL == cc)
-               return NULL;
-
-       cc->conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &(cc->err));
-       if (NULL == cc->conn) {
-               g_printerr("Failed to open connection to dbus: %s\n",
-                          cc->err->message);
-               g_error_free(cc->err);
-               cc->err = NULL;
-               comm_client_free(cc);
-               return NULL;
-       }
-
-       cc->request_proxy = dbus_g_proxy_new_for_name(cc->conn,
-                                               COMM_PKG_MGR_DBUS_SERVICE,
-                               /* name : written in service file */
-                                               COMM_PKG_MGR_DBUS_PATH,
-                               /* path : written as a node in xml */
-                                               COMM_PKG_MGR_DBUS_INTERFACE
-                       /* interface : written as an interface in xml */
-           );
-
-       return cc;
-}
-
-int comm_client_free(comm_client *cc)
-{
-       if (NULL == cc)
-               return -1;
-
-       if (cc->err)
-               g_error_free(cc->err);
-       if (cc->conn)
-               dbus_g_connection_unref(cc->conn);
-       if (cc->request_proxy)
-               g_object_unref(cc->request_proxy);
-       if (cc->signal_proxy)
-               g_object_unref(cc->signal_proxy);
-       if (cc->pkgid)
-               free(cc->pkgid);
-
-       free(cc);
-
-       return 0;
-}
-
-static void
-status_signal_handler(DBusGProxy *proxy,
-                     const char *req_id,
-                     const char *pkg_type,
-                     const char *pkgid,
-                     const char *key, const char *val, gpointer data)
-{
-       comm_client *cc = (comm_client *) data;
-
-       DBG("Got signal: %s/%s/%s/%s/%s", req_id, pkg_type,
-                                pkgid, key, val);
-       if (cc->signal_cb) {
-               if (cc->pkgid && pkgid &&
-                       0 == strncmp(cc->pkgid, pkgid,
-                                    strlen(cc->pkgid))) {
-                       DBG("Run signal handler");
-                       cc->signal_cb(cc->signal_cb_data, req_id, pkg_type,
-                                     pkgid, key, val);
-               } else {
-                       DBG("pkgid is different. (My pkgid:%s)"
-                       " Though pass signal to user callback.", cc->pkgid);
-                       cc->signal_cb(cc->signal_cb_data, req_id, pkg_type,
-                                     pkgid, key, val);
-               }
-       } else {
-               DBG("No signal handler is set. Do nothing.");
-       }
-}
-
-int
-comm_client_request(comm_client *cc, const char *req_id, const int req_type,
-                   const char *pkg_type, const char *pkgid,
-                   const char *args, const char *cookie)
-{
-       gboolean r;
-       gint ret = COMM_RET_ERROR;
-
-       DBG("got request:%s/%d/%s/%s/%s/%s\n", req_id, req_type, pkg_type,
-           pkgid, args, cookie);
-
-       if (!pkgid)
-               pkgid = "";     /* NULL check */
-
-       r = org_tizen_slp_pkgmgr_request(cc->request_proxy, req_id, req_type,
-                                          pkg_type, pkgid, args, cookie,
-                                          &ret, &(cc->err));
-       if (TRUE == r) {
-               ret = COMM_RET_OK;
-       } else {
-               g_printerr("Failed to send request via dbus: %s\n",
-                          cc->err->message);
-               if (cc->err) {
-                       g_error_free(cc->err);
-                       cc->err = NULL;
-               }
-               return ret;
-       }
-       DBG("request sent");
-
-       if (cc->pkgid) {
-               DBG("freeing pkgid");
-               free(cc->pkgid);
-               DBG("freed pkgid");
-       }
-       cc->pkgid = strdup(pkgid);
-
-       DBG("ret:%d", ret);
-
-       return ret;
-}
-
-int
-comm_client_set_status_callback(comm_client *cc, status_cb cb, void *cb_data)
-{
-       /* set callback */
-       if (!cc->signal_proxy) {
-               DBG("signal_proxy is NULL. Try to create a proxy for signal.");
-               cc->signal_proxy = dbus_g_proxy_new_for_name(cc->conn,
-                                    COMM_STATUS_BROADCAST_DBUS_SERVICE_PREFIX,
-                                    COMM_STATUS_BROADCAST_DBUS_PATH,
-                                    COMM_STATUS_BROADCAST_DBUS_INTERFACE);
-               if (NULL == cc->signal_proxy) {
-                       g_printerr("Failed to create proxy for signal\n", NULL);
-                       return COMM_RET_ERROR;
-               } else {
-               }
-       } else {
-               /* Proxy is existing. Do nothing. */
-       }
-
-       cc->signal_cb = cb;
-       cc->signal_cb_data = cb_data;
-
-       DBG("Register signal-type marshaller.");
-       dbus_g_object_register_marshaller(
-       g_cclosure_user_marshal_VOID__STRING_STRING_STRING_STRING_STRING,
-               /* marshaller */
-       G_TYPE_NONE, /* return type */
-       G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
-       G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);  /* termination flag */
-
-       DBG("Add signal to proxy.");
-       dbus_g_proxy_add_signal(cc->signal_proxy,
-                               COMM_STATUS_BROADCAST_SIGNAL_STATUS,
-                               G_TYPE_STRING,
-                               G_TYPE_STRING,
-                               G_TYPE_STRING,
-                               G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
-
-       DBG("Connect signal to proxy.");
-
-       dbus_g_proxy_connect_signal(cc->signal_proxy,
-                                   COMM_STATUS_BROADCAST_SIGNAL_STATUS,
-                                   G_CALLBACK(status_signal_handler),
-                                   cc, NULL);
-
-       return 0;
-}
-
index af6a65b..5cce5e3 100644 (file)
@@ -46,7 +46,7 @@ API int comm_client_free(comm_client *cc);
 API int comm_client_request(comm_client *cc, const char *req_id,
                            const int req_type, const char *pkg_type,
                            const char *pkgid, const char *args,
-                           const char *cookie, uid_t uid, int is_block);
+                           uid_t uid, int is_block);
 
 API int comm_client_set_status_callback(int comm_status_type, comm_client *cc, status_cb cb, void *cb_data);
 #endif                         /* __COMM_CLIENT_H__ */
index 3633950..01f38c8 100644 (file)
@@ -61,7 +61,6 @@ static int __retry_request(comm_client *cc,
        const gchar *pkg_type,
        const gchar *pkgid,
        const gchar *args,
-       const gchar *cookie,
        uid_t uid,
        gint *ret)
 {      
@@ -79,7 +78,7 @@ static int __retry_request(comm_client *cc,
        }
 
        rc = org_tizen_slp_pkgmgr_call_request_sync(proxy,
-                       req_id, req_type, pkg_type, pkgid, args, cookie, uid, &ret, NULL, &error);
+                       req_id, req_type, pkg_type, pkgid, args, uid, &ret, NULL, &error);
        if (!rc) {
                ERR("Failed to send request[rc=%d, err=%s]\n", rc, error->message);
                return FALSE;
@@ -276,7 +275,6 @@ comm_client_request(
                const char *pkg_type,
                const char *pkgid,
                const char *args,
-               const char *cookie,
                uid_t uid,
                int is_block)
 {
@@ -308,11 +306,9 @@ comm_client_request(
                pkgid = "";
        if (args == NULL)
                args = "";
-       if (cookie == NULL)
-               cookie = "";
 
        rc = org_tizen_slp_pkgmgr_call_request_sync(proxy,
-                       req_id, req_type, pkg_type, pkgid, args, cookie, uid, &ret, NULL, &error);
+                       req_id, req_type, pkg_type, pkgid, args, uid, &ret, NULL, &error);
 
        while ((rc == FALSE) && (retry_cnt < COMM_CLIENT_RETRY_MAX)) {
                ERR("Failed to send request, sleep and retry[rc=%d, err=%s]\n", rc, error->message);
@@ -320,7 +316,7 @@ comm_client_request(
 
                retry_cnt++;
 
-               rc = __retry_request(cc, req_id, req_type, pkg_type, pkgid, args, cookie, uid, &ret);
+               rc = __retry_request(cc, req_id, req_type, pkg_type, pkgid, args, uid, &ret);
                if(rc == TRUE) {
                        ERR("__retry_request is success[retry_cnt=%d]\n", retry_cnt);
                }
index 28ec17c..765c995 100644 (file)
@@ -4,12 +4,12 @@
        <interface name="org.tizen.slp.pkgmgr">
                <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="pkgmgr" />
                <method name="Request">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value="yes" />
                        <arg type="s" name="req_id" direction="in" />
                        <arg type="i" name="req_type" direction="in" />
                        <arg type="s" name="pkg_type" direction="in" />
                        <arg type="s" name="pkgid" direction="in" />
                        <arg type="s" name="args" direction="in" />
-                       <arg type="s" name="cookie" direction="in" />
                        <arg type="i" name="uid" direction="in" />
                        <arg type="i" name="ret" direction="out" />
                </method>
index 8359f4b..1422f72 100644 (file)
 #include <stdlib.h>
 #include <unistd.h>
 
+#include <cynara-client.h>
+#include <cynara-creds-dbus.h>
+#include <cynara-session.h>
+
 #include "comm_pkg_mgr_server.h"
 #include "comm_debug.h"
 
+#define BUFMAX 128
+
 /* object class def: do nothing on this */
 struct PkgMgrObjectClass {
        GObjectClass parent_class;
@@ -73,10 +79,10 @@ G_DEFINE_TYPE(PkgMgrObject, pkg_mgr_object, G_TYPE_OBJECT);
 /* Method declarations
  * Used for binding stub.
  */
-GCallback pkgmgr_request(PkgMgrObject *obj, const gchar *req_id,
+static gboolean pkgmgr_request(PkgMgrObject *obj, const gchar *req_id,
                         const gint req_type, const gchar *pkg_type,
                         const gchar *pkgid, const gchar *args,
-                        const gchar *cookie, uid_t uid, gint *ret, GError *err);
+                        uid_t uid, DBusGMethodInvocation *invocation);
 
 /* Include stub header */
 #include "comm_pkg_mgr_server_dbus_bindings.h"
@@ -159,27 +165,79 @@ static void pkg_mgr_object_finalize(GObject *self)
 
 /* dbus-glib methods */
 
-GCallback
+static gboolean
 pkgmgr_request(PkgMgrObject *obj,
               const gchar *req_id,
               const gint req_type,
               const gchar *pkg_type,
               const gchar *pkgid,
               const gchar *args,
-              const gchar *cookie, uid_t uid, gint *ret, GError *err)
+              uid_t uid,
+              DBusGMethodInvocation *invocation)
 {
+       DBusConnection *con;
+       gchar *sender = NULL;
+       char *client = NULL;
+       char *session = NULL;
+       char *user = NULL;
+       pid_t pid;
+       int ret;
+       char buf[BUFMAX] = {0, };
+       int r;
+
        DBG("Called");
-       *ret = COMM_RET_OK;     /* TODO: fix this! */
+       ret = COMM_RET_OK;      /* TODO: fix this! */
 
        /* TODO: Add business logic 
         * - add to queue, or remove from queue
         * */
-
-       if (obj->req_cb) {
-               DBG("Call request callback(obj, %lu, %s, %d, %s, %s, %s, *ret)",
+       do {
+               con = dbus_g_connection_get_connection(obj->bus);
+               sender = dbus_g_method_get_sender(invocation);
+               if (sender == NULL) {
+                       ERR("get sender failed");
+                       ret = COMM_RET_ERROR;
+                       break;
+               }
+
+               r = cynara_creds_dbus_get_client(con, sender,
+                               CLIENT_METHOD_SMACK, &client);
+               if (r != CYNARA_API_SUCCESS) {
+                       cynara_strerror(r, buf, BUFMAX);
+                       ERR("cynara_creds_dbus_get_client failed: %s", buf);
+                       ret = COMM_RET_ERROR;
+                       break;
+               }
+
+               r = cynara_creds_dbus_get_user(con, sender, USER_METHOD_UID, &user);
+               if (r != CYNARA_API_SUCCESS) {
+                       cynara_strerror(r, buf, BUFMAX);
+                       ERR("cynara_creds_dbus_get_user failed: %s", buf);
+                       ret = COMM_RET_ERROR;
+                       break;
+               }
+
+               r = cynara_creds_dbus_get_pid(con, sender, &pid);
+               if (r != CYNARA_API_SUCCESS) {
+                       cynara_strerror(r, buf, BUFMAX);
+                       ERR("cynara_creds_dbus_get_pid failed: %s", buf);
+                       ret = COMM_RET_ERROR;
+                       break;
+               }
+
+               session = cynara_session_from_pid(pid);
+               if (session == NULL) {
+                       ERR("cynara_session_from_pid failed");
+                       ret = COMM_RET_ERROR;
+                       break;
+               }
+       } while (0);
+
+       if (obj->req_cb && ret != COMM_RET_ERROR) {
+               DBG("Call request callback(obj, %lu, %s, %d, %s, %s, %s)",
                    uid, req_id, req_type, pkg_type, pkgid, args);
                obj->req_cb(obj->req_cb_data, uid, req_id, req_type, pkg_type,
-                           pkgid, args, cookie, ret);
+                           pkgid, args, client, session, user, &ret);
        } else {
                DBG("Attempt to call request callback,"
                " but request callback is not set. Do nothing.\n"
@@ -187,7 +245,18 @@ pkgmgr_request(PkgMgrObject *obj,
                " to register your callback.");
        }
 
-       return (GCallback) TRUE;
+       if (sender)
+               g_free(sender);
+       if (client)
+               free(client);
+       if (session)
+               free(session);
+       if (user)
+               free(user);
+
+       dbus_g_method_return(invocation, ret);
+
+       return TRUE;
 }
 
 /* Other APIs
index 0e45b8c..6d98b81 100644 (file)
@@ -41,7 +41,8 @@ API GType pkg_mgr_object_get_type(void);
 typedef void (*request_callback) (void *cb_data, uid_t uid, const char *req_id,
                                  const int req_type, const char *pkg_type,
                                  const char *pkgid, const char *args,
-                                 const char *cookie, int *ret);
+                                 const char *client, const char *session,
+                                 const char *user, int *ret);
 
 API void pkg_mgr_set_request_callback(PkgMgrObject *obj,
                                      request_callback req_cb, void *cb_data);
diff --git a/comm/comm_status_broadcast_server.c b/comm/comm_status_broadcast_server.c
deleted file mode 100644 (file)
index 7e1acab..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-
-#include "comm_config.h"
-#include <stdlib.h>
-#include <unistd.h>
-#include <dbus/dbus.h>
-
-#include "comm_status_broadcast_server.h"
-#include "comm_debug.h"
-
-/***************************
- * dbus-glib API for server
- ***************************/
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
-
-/* object class def: do nothing on this */
-struct StatusBroadcastObjectClass {
-       GObjectClass parent_class;
-
-       guint signal;
-};
-
-/* object def: has connection */
-struct StatusBroadcastObject {
-       GObject parent;
-
-       DBusGConnection *bus;
-       char *dbus_service_name;
-};
-
-#define STATUS_BROADCAST_OBJECT(object) \
-(G_TYPE_CHECK_INSTANCE_CAST((object), \
-       STATUS_BROADCAST_TYPE_OBJECT, StatusBroadcastObject))
-#define STATUS_BROADCAST_OBJECT_CLASS(klass) \
-       (G_TYPE_CHECK_CLASS_CAST((klass), \
-        STATUS_BROADCAST_TYPE_OBJECT, StatusBroadcastObjectClass))
-#define STATUS_BROADCAST_IS_OBJECT(object) \
-       (G_TYPE_CHECK_INSTANCE_TYPE((object), \
-       STATUS_BROADCAST_TYPE_OBJECT))
-#define STATUS_BROADCAST_IS_OBJECT_CLASS(klass) \
-       (G_TYPE_CHECK_CLASS_TYPE((klass), \
-        STATUS_BROADCAST_TYPE_OBJECT))
-#define STATUS_BROADCAST_OBJECT_GET_CLASS(obj) \
-       (G_TYPE_INSTANCE_GET_CLASS((obj), \
-       STATUS_BROADCAST_TYPE_OBJECT, StatusBroadcastObjectClass))
-
-/* Macro that creates follwoing functions automatically;
- *   - status_broadcast_object_get_type()
- *   - status_broadcast_object_parent_class
- */
-G_DEFINE_TYPE(StatusBroadcastObject, status_broadcast_object, G_TYPE_OBJECT);
-
-/* method/signal declarations
- * Used for binding stub.
- */
-
-/* Include stub header */
-#include "comm_status_broadcast_server_dbus_bindings.h"
-
-static void
-__status_broadcast_object_class_init(StatusBroadcastObjectClass *klass);
-static void __status_broadcast_object_init(StatusBroadcastObject *obj);
-static void __status_broadcast_object_finalize(GObject *self);
-
-static void
-__status_broadcast_object_class_init(StatusBroadcastObjectClass *klass)
-{
-       DBG("called");
-
-       g_assert(NULL != klass);
-
-       klass->signal = g_signal_new(COMM_STATUS_BROADCAST_SIGNAL_STATUS,
-                                    G_OBJECT_CLASS_TYPE(klass),
-                                    G_SIGNAL_RUN_LAST,
-                                    0,
-                                    NULL,
-                                    NULL,
-                                    g_cclosure_marshal_VOID__STRING,
-                                    G_TYPE_NONE,
-                                    3,
-                                    G_TYPE_STRING,
-                                    G_TYPE_STRING, G_TYPE_STRING);
-
-       dbus_g_object_type_install_info(STATUS_BROADCAST_TYPE_OBJECT,
-                               &dbus_glib_status_broadcast_object_info);
-
-       DBG("done");
-}
-
-static void __status_broadcast_object_init(StatusBroadcastObject *obj)
-{
-       DBG("called");
-       g_assert(NULL != obj);
-
-       GError *err = NULL;
-
-       /* Establish dbus session  */
-       obj->bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
-       if (NULL == obj->bus) {
-               DBG("Failed to open connection to dbus: %s", err->message);
-               return;
-       }
-
-       /* Create a proxy to resgister, connecting dbus daemon */
-       DBusGProxy *proxy = NULL;
-       proxy = dbus_g_proxy_new_for_name(obj->bus,
-                                         DBUS_SERVICE_DBUS,
-                                         DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
-       if (NULL == proxy) {
-               DBG("Failed to get a proxy");
-               return;
-       }
-       /* Register service name
-        * NOTE: refer to 
-       http://dbus.freedesktop.org/doc/dbus-specification.html 
-        */
-
-       guint result;
-       if (!dbus_g_proxy_call(proxy, "RequestName", &err,
-               /* input vars */
-               G_TYPE_STRING, COMM_STATUS_BROADCAST_DBUS_SERVICE_PREFIX,
-               /* service name */
-               G_TYPE_UINT, 0, /* default flag */
-               G_TYPE_INVALID,
-               /* output vars */
-               G_TYPE_UINT, &result, G_TYPE_INVALID)) {
-               g_printerr("dbus RequestName RPC failed", err->message, TRUE);
-               return;
-       }
-       DBG("RequestName returns: %d", result);
-
-       dbus_g_connection_register_g_object(obj->bus,
-                                           COMM_STATUS_BROADCAST_DBUS_PATH,
-                                           G_OBJECT(obj));
-       DBG("Ready to serve requests");
-
-       g_object_unref(proxy);
-
-       DBG("done");
-}
-
-static void __status_broadcast_object_finalize(GObject *self)
-{
-       StatusBroadcastObjectClass *klass =
-           (StatusBroadcastObjectClass *) G_OBJECT_CLASS(self);
-
-       /* Call parent's finalize function
-        * 'server_object_parent_class' comes from G_DEFINE_TYPE() macro. 
-        */
-       G_OBJECT_CLASS(status_broadcast_object_parent_class)->finalize(self);
-}
-
-/* dbus-glib methods/signals */
-
-void
-status_broadcast_emit_status(StatusBroadcastObject *obj,
-                            const char *pkg, const char *key, const char *val)
-{
-       StatusBroadcastObjectClass *klass;
-       klass = STATUS_BROADCAST_OBJECT_GET_CLASS(obj);
-
-       DBG("Send signal: %s/%s/%s", pkg, key, val);
-       g_signal_emit(obj, klass->signal, 0, pkg, key, val);
-
-}
-
diff --git a/comm/comm_status_broadcast_signal_marshaller.list b/comm/comm_status_broadcast_signal_marshaller.list
deleted file mode 100644 (file)
index 1c50753..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-VOID:STRING,STRING,STRING,STRING,STRING
-
index d3bf0d5..0f86670 100644 (file)
@@ -47,7 +47,7 @@ int main(int argc, char **argv)
        gint ret;
        ret = comm_client_request(cc, "__test__req_key", COMM_REQ_TO_INSTALLER,
                                  "dpkg", "test_pkg", "arg1 arg2 arg3",
-                                 "this_is_a_cookie", getuid(), 0);
+                                 getuid(), 0);
 
        printf("client: waiting signal...\n");
        comm_client_set_status_callback(COMM_STATUS_BROADCAST_ALL,
index b20636f..00eb462 100644 (file)
 #include <stdio.h>
 
 void
-req_cb(void *cb_data, const char *req_id, const int req_type,
+req_cb(void *cb_data, uid_t uid, const char *req_id, const int req_type,
        const char *pkg_type, const char *pkgid, const char *args,
-       const char *cookie, int *ret)
+       const char *client, const char *session, const char *user, int *ret)
 {
        /* TODO: Do your job here */
-       printf(">> in callback >> Got request: %s %d %s %s %s (cookie:%s)\n",
-              req_id, req_type, pkg_type, pkgid, args, cookie);
+       printf(">> in callback >> Got request: %s %d %s %s %s\n",
+              req_id, req_type, pkg_type, pkgid, args);
 }
 
 gboolean queue_job(void *data)
index c842469..3a5a1e9 100644 (file)
@@ -19,7 +19,9 @@ BuildRequires:  cmake
 BuildRequires:  unzip
 BuildRequires:  gettext-tools
 BuildRequires:  pkgconfig(ecore)
-BuildRequires:  pkgconfig(security-server)
+BuildRequires:  pkgconfig(cynara-client)
+BuildRequires:  pkgconfig(cynara-creds-dbus)
+BuildRequires:  pkgconfig(cynara-session)
 BuildRequires:  pkgconfig(dbus-1)
 BuildRequires:  pkgconfig(dbus-glib-1)
 BuildRequires:  pkgconfig(dlog)
index a1cc82a..1917b47 100644 (file)
@@ -4,7 +4,7 @@ SET(PKGMGR_SERVER "pkgmgr-server")
 SET(SRCS src/pkgmgr-server.c src/pm-queue.c)
 
 pkg_check_modules(SERVER_DEPS REQUIRED
-               security-server
+               cynara-client
                dlog
                ail
                pkgmgr-parser
index 234ae80..45a0e0b 100644 (file)
@@ -39,7 +39,6 @@
 #define MAX_PKG_TYPE_LEN 128
 #define MAX_PKG_NAME_LEN 256
 #define MAX_PKG_ARGS_LEN 4096
-#define MAX_COOKIE_LEN  32
 #define DESKTOP_FILE_DIRS_NUM 1024
 
 typedef struct {
@@ -49,7 +48,6 @@ typedef struct {
        char pkg_type[MAX_PKG_TYPE_LEN];
        char pkgid[MAX_PKG_NAME_LEN];
        char args[MAX_PKG_ARGS_LEN];
-       char cookie[MAX_COOKIE_LEN];
 } pm_dbus_msg;
 
 typedef struct backend_info_t {
index e5f4c7f..a1cfc7f 100644 (file)
@@ -3,8 +3,10 @@
         "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
 
 <busconfig>
-        <policy context="default">
-                <allow own="org.tizen.slp.pkgmgr"/>
+        <policy user="root">
+               <allow own="org.tizen.slp.pkgmgr"/>
+       </policy>
+       <policy context="default">
                 <allow own="org.tizen.slp.pkgmgr_status"/>
                 <allow receive_sender="org.tizen.slp.pkgmgr"/>
                 <allow send_destination="org.tizen.slp.pkgmgr"/>
index d587c25..85a3fee 100644 (file)
@@ -38,7 +38,7 @@
 #include <pkgmgr-info.h>
 #include <pkgmgr/pkgmgr_parser.h>
 
-#include <security-server.h>
+#include <cynara-client.h>
 
 #include <vconf.h>
 
@@ -55,6 +55,7 @@
 #include "comm_config.h"
 #include "package-manager.h"
 
+#define BUFMAX 128
 #define PACKAGE_RECOVERY_DIR tzplatform_mkpath(TZ_SYS_RW_PACKAGES, ".recovery/pkgmgr")
 #define NO_MATCHING_FILE 11
 
@@ -101,6 +102,7 @@ static guint pipe_wid;
 backend_info *begin;
 extern queue_info_map *start;
 extern int entries;
+static cynara *p_cynara;
 
 GMainLoop *mainloop = NULL;
 
@@ -240,53 +242,52 @@ static void __unset_recovery_mode(char *pkgid, char *pkg_type)
                DBG("remove recovery_file[%s] fail\n", recovery_file);
 }
 
-static int __check_privilege_by_cookie(const char *e_cookie, int req_type)
-{
-       guchar *cookie = NULL;
-       gsize size;
-       int ret = PMINFO_R_OK;  //temp to success , it should be PMINFO_R_ERROR
-
-       if (e_cookie == NULL)   {
-               DBG("e_cookie is NULL!!!\n");
-               return PMINFO_R_ERROR;
-       }
-
-       cookie = g_base64_decode(e_cookie, &size);
-       if (cookie == NULL)     {
-               DBG("Unable to decode cookie!!!\n");
-               return PMINFO_R_ERROR;
-       }
+#define PRIVILEGE_PACKAGEMANAGER_ADMIN "http://tizen.org/privilege/packagemanager.admin"
+#define PRIVILEGE_PACKAGEMANAGER_INFO  "http://tizen.org/privilege/packagemanager.info"
+#define PRIVILEGE_PACKAGEMANAGER_NONE  "NONE"
 
+static const char *__convert_req_type_to_privilege(int req_type)
+{
        switch (req_type) {
-               case COMM_REQ_TO_INSTALLER:
-                       if (SECURITY_SERVER_API_SUCCESS == security_server_check_privilege_by_cookie(cookie, "pkgmgr::svc", "r"))
-                               ret = PMINFO_R_OK;
-
-                       break;
-
-               case COMM_REQ_TO_MOVER:
-                       if (SECURITY_SERVER_API_SUCCESS == security_server_check_privilege_by_cookie(cookie, "pkgmgr::svc", "x"))
-                               ret = PMINFO_R_OK;
-                       break;
-
-               case COMM_REQ_GET_SIZE:
-                       if (SECURITY_SERVER_API_SUCCESS == security_server_check_privilege_by_cookie(cookie, "pkgmgr::info", "r"))
-                               ret = PMINFO_R_OK;
-                       break;
-
-               default:
-                       DBG("Check your request[%d]..\n", req_type);
-                       break;
+       case COMM_REQ_TO_INSTALLER:
+       case COMM_REQ_TO_ACTIVATOR:
+       case COMM_REQ_TO_CLEARER:
+       case COMM_REQ_TO_MOVER:
+       case COMM_REQ_KILL_APP:
+       case COMM_REQ_CLEAR_CACHE_DIR:
+               return PRIVILEGE_PACKAGEMANAGER_ADMIN;
+       case COMM_REQ_GET_SIZE:
+       case COMM_REQ_CHECK_APP:
+               return PRIVILEGE_PACKAGEMANAGER_INFO;
+       case COMM_REQ_CANCEL:
+       default:
+               return PRIVILEGE_PACKAGEMANAGER_NONE;
        }
+}
 
-       DBG("security_server[req-type:%d] check cookie result = %d, \n", req_type, ret);
+static int __check_privilege_by_cynara(const char *client, const char *session, const char *user, int req_type)
+{
+       int ret;
+       const char *privilege;
+       char buf[BUFMAX] = {0, };
 
-       if (cookie){
-               g_free(cookie);
-               cookie = NULL;
-       }
+       privilege = __convert_req_type_to_privilege(req_type);
+       if (!strcmp(privilege, PRIVILEGE_PACKAGEMANAGER_NONE))
+               return 0;
 
-       return ret;
+       ret = cynara_check(p_cynara, client, session, user, privilege);
+       switch (ret) {
+       case CYNARA_API_ACCESS_ALLOWED:
+               DBG("%s(%s) from user %s privilege %s allowed", client, session, user, privilege);
+               return 0;
+       case CYNARA_API_ACCESS_DENIED:
+               ERR("%s(%s) from user %s privilege %s denied", client, session, user, privilege);
+               return -1;
+       default:
+               cynara_strerror(ret, buf, BUFMAX);
+               ERR("cynara_check failed: %s", buf);
+               return -1;
+       }
 }
 
 static int __get_position_from_pkg_type(char *pkgtype)
@@ -826,13 +827,12 @@ static int __register_signal_handler(void)
 
 void req_cb(void *cb_data, uid_t uid, const char *req_id, const int req_type,
            const char *pkg_type, const char *pkgid, const char *args,
-           const char *cookie, int *ret)
+           const char *client, const char *session, const char *user, int *ret)
 {
        int p;
-       int cookie_result;
 
-       DBG(">> in callback >> Got request: [%s] [%d] [%s] [%s] [%s] [%s]",
-           req_id, req_type, pkg_type, pkgid, args, cookie);
+       DBG(">> in callback >> Got request: [%s] [%d] [%s] [%s] [%s] [%s] [%s] [%s]",
+           req_id, req_type, pkg_type, pkgid, args, client, session, user);
 
        struct appdata *ad = (struct appdata *)cb_data;
 
@@ -844,7 +844,6 @@ void req_cb(void *cb_data, uid_t uid, const char *req_id, const int req_type,
        strncpy(item->pkg_type, pkg_type, sizeof(item->pkg_type) - 1);
        strncpy(item->pkgid, pkgid, sizeof(item->pkgid) - 1);
        strncpy(item->args, args, sizeof(item->args) - 1);
-       strncpy(item->cookie, cookie, sizeof(item->cookie) - 1);
        item->uid = uid;
        /* uid equals to GLOBALUSER means that the installation or action is made at Global level.
         * At this time, we are not able to check the credentials of this dbus message (due to gdbus API to implement the pkgmgr-server)
@@ -875,16 +874,13 @@ void req_cb(void *cb_data, uid_t uid, const char *req_id, const int req_type,
 
        char *quiet = NULL;
 
+       if (__check_privilege_by_cynara(client, session, user, item->req_type)) {
+               *ret = PKGMGR_R_EPRIV;
+               goto err;
+       }
+
        switch (item->req_type) {
        case COMM_REQ_TO_INSTALLER:
-               /* check caller privilege */
-               cookie_result = __check_privilege_by_cookie(cookie, item->req_type);
-               if (cookie_result < 0){
-                       DBG("__check_privilege_by_cookie result fail[%d]\n", cookie_result);
-                       *ret = COMM_RET_ERROR;
-                       goto err;
-               }
-
                /* -q option should be located at the end of command !! */
                if (((quiet = strstr(args, " -q")) &&
                     (quiet[strlen(quiet)] == '\0')) ||
@@ -969,14 +965,6 @@ void req_cb(void *cb_data, uid_t uid, const char *req_id, const int req_type,
                *ret = COMM_RET_OK;
                break;
        case COMM_REQ_TO_MOVER:
-               /* check caller privilege */
-               cookie_result = __check_privilege_by_cookie(cookie, item->req_type);
-               if (cookie_result < 0){
-                       DBG("__check_privilege_by_cookie result fail[%d]\n", cookie_result);
-                       *ret = COMM_RET_ERROR;
-                       goto err;
-               }
-
                /* In case of mover, there is no popup */
                if (_pm_queue_push(item)) {
                        ERR("failed to push queue item");
@@ -1000,14 +988,6 @@ void req_cb(void *cb_data, uid_t uid, const char *req_id, const int req_type,
                *ret = COMM_RET_OK;
                break;
        case COMM_REQ_GET_SIZE:
-               /* check caller privilege */
-               cookie_result = __check_privilege_by_cookie(cookie, item->req_type);
-               if (cookie_result < 0){
-                       DBG("__check_privilege_by_cookie result fail[%d]\n", cookie_result);
-                       *ret = COMM_RET_ERROR;
-                       goto err;
-               }
-
                if (_pm_queue_push(item)) {
                        ERR("failed to push queue item");
                        *ret = COMM_RET_ERROR;
@@ -1036,14 +1016,6 @@ void req_cb(void *cb_data, uid_t uid, const char *req_id, const int req_type,
                *ret = COMM_RET_OK;
                break;
        case COMM_REQ_CLEAR_CACHE_DIR:
-               /* check caller privilege */
-               cookie_result = __check_privilege_by_cookie(cookie, item->req_type);
-               if (cookie_result < 0){
-                       LOGE("__check_privilege_by_cookie result fail[%d]\n", cookie_result);
-                       *ret = PKGMGR_R_EPRIV;
-                       goto err;
-               }
-
                if (_pm_queue_push(item)) {
                        ERR("failed to push queue item");
                        *ret = COMM_RET_ERROR;
@@ -1061,7 +1033,7 @@ void req_cb(void *cb_data, uid_t uid, const char *req_id, const int req_type,
                break;
        }
 err:
-       if (*ret == COMM_RET_ERROR) {
+       if (*ret != COMM_RET_OK) {
                DBG("Failed to handle request %s %s\n",item->pkg_type, item->pkgid);
                pkgmgr_installer *pi;
                gboolean ret_parse;
@@ -1891,6 +1863,12 @@ int main(int argc, char *argv[])
                return -1;
        }
 
+       r = cynara_initialize(&p_cynara, NULL);
+       if (r != CYNARA_API_SUCCESS) {
+               ERR("cynara initialize failed with code=%d", r);
+               return -1;
+       }
+
        g_type_init();
        mainloop = g_main_loop_new(NULL, FALSE);
        if (!mainloop) {
@@ -1913,6 +1891,7 @@ int main(int argc, char *argv[])
        DBG("Quit main loop.");
        _pm_queue_final();
        __fini_backend_info();
+       cynara_finish(p_cynara);
 
        DBG("package manager server terminated.");
 
index c73c8ba..e862671 100644 (file)
@@ -282,7 +282,6 @@ int _pm_queue_push(pm_dbus_msg *item)
        strncpy(data->msg->pkg_type, item->pkg_type, strlen(item->pkg_type));
        strncpy(data->msg->pkgid, item->pkgid, strlen(item->pkgid));
        strncpy(data->msg->args, item->args, strlen(item->args));
-       strncpy(data->msg->cookie, item->cookie, strlen(item->cookie));
 
        data->next = NULL;
 
@@ -336,7 +335,6 @@ pm_dbus_msg *_pm_queue_pop(int position)
        strncpy(ret->pkg_type, cur->msg->pkg_type, strlen(cur->msg->pkg_type));
        strncpy(ret->pkgid, cur->msg->pkgid, strlen(cur->msg->pkgid));
        strncpy(ret->args, cur->msg->args, strlen(cur->msg->args));
-       strncpy(ret->cookie, cur->msg->cookie, strlen(cur->msg->cookie));
 
        ptr->head = cur->next;
        saveptr = ptr->head;
index 1d27cc9..435dfc5 100644 (file)
@@ -6,18 +6,18 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/client/include)
 
 INCLUDE(FindPkgConfig)
 
-pkg_check_modules(pkgs_initdb REQUIRED libsmack ecore dbus-1 ail libxml-2.0 bundle pkgmgr-parser vconf security-server pkgmgr-info libtzplatform-config)
+pkg_check_modules(pkgs_initdb REQUIRED libsmack ecore dbus-1 ail libxml-2.0 bundle pkgmgr-parser vconf pkgmgr-info libtzplatform-config)
 FOREACH(flag ${pkgs_initdb_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
 
-pkg_check_modules(pkgs_test REQUIRED ecore dbus-1 ail libxml-2.0 bundle pkgmgr-parser vconf security-server pkgmgr-info libtzplatform-config)
+pkg_check_modules(pkgs_test REQUIRED ecore dbus-1 ail libxml-2.0 bundle pkgmgr-parser vconf pkgmgr-info libtzplatform-config)
 FOREACH(flag ${pkgs_test_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-pkg_check_modules(toolpkgs REQUIRED appcore-efl dlog bundle glib-2.0 pkgmgr-parser vconf security-server pkgmgr-info libtzplatform-config)
+pkg_check_modules(toolpkgs REQUIRED appcore-efl dlog bundle glib-2.0 pkgmgr-parser vconf pkgmgr-info libtzplatform-config)
 FOREACH(flag ${toolpkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)