diff options
author | Sabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org> | 2015-01-09 18:08:30 +0100 |
---|---|---|
committer | Baptiste DURAND <baptiste.durand@open.eurogiciel.org> | 2015-01-12 00:22:21 -0800 |
commit | fff394dc3b5b452a59fc54d3bfe84b2766c471a5 (patch) | |
tree | 4eb0fc11ff6659fbb5da0aa3c9d1dbb7f04f8d30 | |
parent | 7d5da70551f5bd2733f137986bbb6591debd29a2 (diff) | |
download | smartcard-service-tizen_3.0_ivi.tar.gz smartcard-service-tizen_3.0_ivi.tar.bz2 smartcard-service-tizen_3.0_ivi.zip |
add uid in parametertizen_3.0_ivi_releasesubmit/tizen_wearable/20150121.020025submit/tizen_tv/20150121.020041submit/tizen_mobile/20150121.020049submit/tizen_ivi/20150115.222222submit/tizen_common/20150112.154626submit/tizen_common/20150112.103909accepted/tizen/wearable/20150121.044754accepted/tizen/tv/20150121.044521accepted/tizen/mobile/20150121.045021accepted/tizen/ivi/20150115.062914accepted/tizen/common/20150113.085923tizen_3.0_ivitizen_3.0.2015.q1_commontizen_3.0.2014.q4_common
This permits to align the CAPI usage with the multi user changes for pkgmgr-info API (ie. pkgmgr_pkginfo_create_certinfo)
Bug-Tizen: TC-2222
Change-Id: I0ed4f14c19534967ea7b2a9df7e9610471e782a6
Signed-off-by: Sabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
-rw-r--r-- | common/SignatureHelper.cpp | 34 | ||||
-rw-r--r-- | common/include/SignatureHelper.h | 6 |
2 files changed, 30 insertions, 10 deletions
diff --git a/common/SignatureHelper.cpp b/common/SignatureHelper.cpp index a4491b6..d0c97ba 100644 --- a/common/SignatureHelper.cpp +++ b/common/SignatureHelper.cpp @@ -22,6 +22,7 @@ #include <list> #include <string> #include <vector> +#include <sys/stat.h> /* SLP library header */ #include "package-manager.h" @@ -39,12 +40,27 @@ namespace smartcard_service_api { + uid_t ProcGetUsrBypid(int pid) + { + char buf[255]; + int ret; + uid_t uid; + struct stat dir_stats; + snprintf(buf, sizeof(buf), "/proc/%d", pid); + ret = stat(buf, &dir_stats); + if (ret < 0) + uid = (uid_t) - 1; + else + uid = dir_stats.st_uid; + return uid; + } + int SignatureHelper::getPackageName(int pid, char *package, size_t length) { return aul_app_get_pkgname_bypid(pid, package, length); } - const ByteArray SignatureHelper::getCertificationHash(const char *packageName) + const ByteArray SignatureHelper::getCertificationHash(const char *packageName, uid_t uid) { ByteArray result; int ret = 0; @@ -68,7 +84,7 @@ namespace smartcard_service_api if ((ret = pkgmgr_pkginfo_create_certinfo(&handle)) == 0) { - if ((ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle)) == 0) + if ((ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle, uid)) == 0) { int type; @@ -110,10 +126,11 @@ namespace smartcard_service_api ByteArray result; int error = 0; char pkgName[256] = { 0, }; + uid_t uid = ProcGetUsrBypid(pid); if ((error = aul_app_get_pkgname_bypid(pid, pkgName, sizeof(pkgName))) == 0) { - result = getCertificationHash(pkgName); + result = getCertificationHash(pkgName, uid); } else { @@ -128,10 +145,11 @@ namespace smartcard_service_api bool result = false; int error = 0; char pkgName[256] = { 0, }; + uid_t uid = ProcGetUsrBypid(pid); if ((error = aul_app_get_pkgname_bypid(pid, pkgName, sizeof(pkgName))) == 0) { - result = getCertificationHashes(pkgName, certHashes); + result = getCertificationHashes(pkgName, certHashes, uid); } else { @@ -141,7 +159,7 @@ namespace smartcard_service_api return result; } - bool SignatureHelper::getCertificationHashes(const char *packageName, vector<ByteArray> &certHashes) + bool SignatureHelper::getCertificationHashes(const char *packageName, vector<ByteArray> &certHashes, uid_t uid) { bool result = false; int ret = 0; @@ -164,7 +182,7 @@ namespace smartcard_service_api if ((ret = pkgmgr_pkginfo_create_certinfo(&handle)) == 0) { - if ((ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle)) == 0) + if ((ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle, uid)) == 0) { int type; @@ -265,7 +283,7 @@ ERROR : return NULL; } -EXTERN_API int signature_helper_get_certificate_hashes(const char *packageName, certiHash **hash) +EXTERN_API int signature_helper_get_certificate_hashes(const char *packageName, uid_t uid, certiHash **hash) { int ret = -1; vector<ByteArray> hashes; @@ -273,7 +291,7 @@ EXTERN_API int signature_helper_get_certificate_hashes(const char *packageName, if (packageName == NULL) return ret; - if (SignatureHelper::getCertificationHashes(packageName, hashes) == true) + if (SignatureHelper::getCertificationHashes(packageName, hashes, uid) == true) { *hash = __signature_helper_vector_to_linked_list(hashes); ret = 0; diff --git a/common/include/SignatureHelper.h b/common/include/SignatureHelper.h index 1da4078..65e9b26 100644 --- a/common/include/SignatureHelper.h +++ b/common/include/SignatureHelper.h @@ -22,6 +22,8 @@ #include "ByteArray.h" #endif /* __cplusplus */ +#include <sys/types.h> + #include "Debug.h" #include "smartcard-types.h" @@ -34,10 +36,10 @@ namespace smartcard_service_api { public: static int getPackageName(int pid, char *package, size_t length); - static const ByteArray getCertificationHash(const char *packageName); + static const ByteArray getCertificationHash(const char *packageName, uid_t uid); static const ByteArray getCertificationHash(int pid); static bool getCertificationHashes(int pid, vector<ByteArray> &certHashes); - static bool getCertificationHashes(const char *packageName, vector<ByteArray> &certHashes); + static bool getCertificationHashes(const char *packageName, vector<ByteArray> &certHashes, uid_t uid); }; } /* namespace smartcard_service_api */ |