diff options
author | Rafal Krypa <r.krypa@samsung.com> | 2016-03-14 14:17:18 +0100 |
---|---|---|
committer | Rafal Krypa <r.krypa@samsung.com> | 2016-03-14 14:21:43 +0100 |
commit | cc059948b58bdfebf7e084bc64a97b617164c1df (patch) | |
tree | edf2a523478f32af454962696ed285674cb1adb1 | |
parent | 2a9b7604632310069a140fc11ff0950111c31cd0 (diff) | |
download | security-manager-cc059948b58bdfebf7e084bc64a97b617164c1df.tar.gz security-manager-cc059948b58bdfebf7e084bc64a97b617164c1df.tar.bz2 security-manager-cc059948b58bdfebf7e084bc64a97b617164c1df.zip |
Resolve symlinks in TZ_SYS_RW_APP/TZ_USER_APP before validating app pathssubmit/tizen/20160315.072217accepted/tizen/wearable/20160315.122929accepted/tizen/tv/20160315.122909accepted/tizen/mobile/20160315.122847accepted/tizen/ivi/20160315.122946accepted/tizen/common/20160316.155924
Change-Id: Iefa723380df60af802e33bbeb95d4d0ebe543444
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
-rw-r--r-- | src/common/service_impl.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/common/service_impl.cpp b/src/common/service_impl.cpp index a9a624e4..2c09ec1f 100644 --- a/src/common/service_impl.cpp +++ b/src/common/service_impl.cpp @@ -214,25 +214,23 @@ bool ServiceImpl::getUserAppDir(const uid_t &uid, std::string &userAppDir) if (tzplatform_context_create(&tz_ctx)) return false; - if (tzplatform_context_set_user(tz_ctx, uid)) { - tzplatform_context_destroy(tz_ctx); - tz_ctx = nullptr; + std::unique_ptr<struct tzplatform_context, decltype(tzplatform_context_destroy)*> tz_ctxPtr( + tz_ctx, &tzplatform_context_destroy); + + if (tzplatform_context_set_user(tz_ctxPtr.get(), uid)) return false; - } enum tzplatform_variable id = (uid == getGlobalUserId()) ? TZ_SYS_RW_APP : TZ_USER_APP; - const char *appDir = tzplatform_context_getenv(tz_ctx, id); - if (!appDir) { - tzplatform_context_destroy(tz_ctx); - tz_ctx = nullptr; + const char *appDir = tzplatform_context_getenv(tz_ctxPtr.get(), id); + if (!appDir) return false; - } - userAppDir = appDir; + std::unique_ptr<char, decltype(free)*> real_pathPtr(realpath(appDir, NULL), free); + if (!real_pathPtr.get()) + return false; - tzplatform_context_destroy(tz_ctx); - tz_ctx = nullptr; + userAppDir.assign(real_pathPtr.get()); return true; } |