Fix to use pkgid for FacetId verification 23/88723/1 accepted/tizen/3.0/ivi/20161011.044109 accepted/tizen/3.0/mobile/20161015.033324 accepted/tizen/3.0/wearable/20161015.082801 accepted/tizen/common/20160921.161505 accepted/tizen/ivi/20160921.081138 accepted/tizen/mobile/20160921.081133 accepted/tizen/wearable/20160921.081128 submit/tizen/20160921.004200 submit/tizen_3.0_common/20161104.104000 submit/tizen_3.0_ivi/20161010.000002 submit/tizen_3.0_mobile/20161015.000002 submit/tizen_3.0_wearable/20161015.000002
authorManasij Sur Roy <manasij.r@samsung.com>
Tue, 20 Sep 2016 10:07:26 +0000 (15:37 +0530)
committerManasij Sur Roy <manasij.r@samsung.com>
Tue, 20 Sep 2016 10:07:26 +0000 (15:37 +0530)
Change-Id: Iffc7dfd1f6ffaaa7bae850c09c38fde37c633d7a
Signed-off-by: Manasij Sur Roy <manasij.r@samsung.com>
server/fido_app_id_handler.c

index ffd3bc0..c994d08 100644 (file)
@@ -444,6 +444,9 @@ __get_pub_key_from_cert(const char *cert_b64)
 
        OPENSSL_free(der_pubkey);
 
+       if (pub_key != NULL)
+               _INFO("%s", pub_key);
+
        return pub_key;
 }
 
@@ -458,12 +461,43 @@ __get_tz_facet_id_of_caller(const char *caller_app_id, GDBusMethodInvocation *in
        _INFO("Caller uid =[%d]", uid);
 #endif
 
+       _INFO("Caller app id = [%s]", caller_app_id);
+
        pkgmgrinfo_pkginfo_h handle = NULL;
 
+       char *caller_pkg_id = NULL;
+       pkgmgrinfo_appinfo_h pkg_app_info = NULL;
+
 #ifdef WITH_JSON_BUILDER
-       int ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(caller_app_id, uid, &handle);
+       int ret = pkgmgrinfo_appinfo_get_usr_appinfo(caller_app_id, uid, &pkg_app_info);
+       if (ret != PMINFO_R_OK) {
+               _ERR("pkgmgrinfo_appinfo_get_appinfo=[%d]", ret);
+
+               return NULL;
+       }
 #else
-       int ret = pkgmgrinfo_pkginfo_get_pkginfo(caller_app_id, &handle);
+       int ret = pkgmgrinfo_appinfo_get_appinfo(caller_app_id, &pkg_app_info);
+       if (ret != PMINFO_R_OK) {
+               _ERR("pkgmgrinfo_appinfo_get_appinfo=[%d]", ret);
+
+               return NULL;
+       }
+#endif
+
+       ret = pkgmgrinfo_appinfo_get_pkgid(pkg_app_info, &caller_pkg_id);
+       if (ret != PMINFO_R_OK) {
+               _ERR("pkgmgrinfo_appinfo_get_appinfo=[%d]", ret);
+               pkgmgrinfo_appinfo_destroy_appinfo(pkg_app_info);
+
+               return NULL;
+       }
+
+       _INFO("Caller package id = [%s]", caller_pkg_id);
+
+#ifdef WITH_JSON_BUILDER
+       ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(caller_pkg_id, uid, &handle);
+#else
+       ret = pkgmgrinfo_pkginfo_get_pkginfo(caller_pkg_id, &handle);
 #endif
 
        if (ret < 0) {
@@ -473,7 +507,7 @@ __get_tz_facet_id_of_caller(const char *caller_app_id, GDBusMethodInvocation *in
 
        _INFO("");
 
-       char *pkgid = NULL;
+       /*char *pkgid = NULL;
        ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
        if (ret != PMINFO_R_OK) {
 
@@ -482,9 +516,9 @@ __get_tz_facet_id_of_caller(const char *caller_app_id, GDBusMethodInvocation *in
                return NULL;
        }
 
-       _INFO("");
+       _INFO("");*/
 
-       pkgmgrinfo_certinfo_h cert_handle;
+       pkgmgrinfo_certinfo_h cert_handle = NULL;
        const char *author_cert = NULL;
        ret = pkgmgrinfo_pkginfo_create_certinfo(&cert_handle);
        if (ret != PMINFO_R_OK) {
@@ -496,11 +530,13 @@ __get_tz_facet_id_of_caller(const char *caller_app_id, GDBusMethodInvocation *in
        _INFO("");
 
 #ifdef WITH_JSON_BUILDER
-       ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, cert_handle, uid);
+       ret = pkgmgrinfo_pkginfo_load_certinfo(caller_pkg_id, cert_handle, uid);
 #else
-       ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, cert_handle);
+       ret = pkgmgrinfo_pkginfo_load_certinfo(caller_pkg_id, cert_handle);
 #endif
 
+       _INFO("pkgmgrinfo_pkginfo_load_certinfo = [%d]", ret);
+
        if (ret != PMINFO_R_OK) {
                _ERR("");
                pkgmgrinfo_pkginfo_destroy_certinfo(cert_handle);
@@ -511,6 +547,7 @@ __get_tz_facet_id_of_caller(const char *caller_app_id, GDBusMethodInvocation *in
        _INFO("");
 
        ret = pkgmgrinfo_pkginfo_get_cert_value(cert_handle, PMINFO_AUTHOR_SIGNER_CERT, &author_cert);
+       _INFO("pkgmgrinfo_pkginfo_get_cert_value = [%d]", ret);
        if (ret != PMINFO_R_OK) {
                pkgmgrinfo_pkginfo_destroy_certinfo(cert_handle);
                _ERR("");
@@ -518,7 +555,7 @@ __get_tz_facet_id_of_caller(const char *caller_app_id, GDBusMethodInvocation *in
                return NULL;
        }
 
-       /*_INFO("Author Root Cert=%s", author_cert);*/
+       _INFO("Author Signer Cert=%s", author_cert);
 
        _INFO("");
 
@@ -543,6 +580,7 @@ CATCH:
 
        pkgmgrinfo_pkginfo_destroy_certinfo(cert_handle);
        pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+       pkgmgrinfo_appinfo_destroy_appinfo(pkg_app_info);
        _INFO("");
        return tz_facet_id;
 }