From: Szymon Jastrzebski Date: Wed, 31 Jan 2018 12:59:13 +0000 (+0100) Subject: [SystemSetting] Synchronously checking access to file X-Git-Tag: submit/tizen/20180427.125243~10^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5acc3a7d79155df2c11fa37959bd8aed498c7f8b;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [SystemSetting] Synchronously checking access to file [Verificaton] SystemSetting TCT 100% pass rate ACR: http://suprem.sec.samsung.net/jira/browse/TWDAPI-187 Change-Id: Ic7df53247ce575790f428d6338bfdb23ee00e997 Signed-off-by: Szymon Jastrzebski --- diff --git a/src/systemsetting/systemsetting_instance.cc b/src/systemsetting/systemsetting_instance.cc index 8b28ba7c..e791bc2c 100644 --- a/src/systemsetting/systemsetting_instance.cc +++ b/src/systemsetting/systemsetting_instance.cc @@ -21,6 +21,7 @@ #include "common/filesystem/filesystem_provider.h" #include "common/logger.h" #include "common/picojson.h" +#include "common/scope_exit.h" #include "common/task-queue.h" #include "common/tools.h" @@ -109,11 +110,15 @@ PlatformResult SystemSettingInstance::getPlatformPropertyValue(const std::string // other values (not specified in the documentation) are handled in JS switch (ret) { - case SYSTEM_SETTINGS_ERROR_NONE: + case SYSTEM_SETTINGS_ERROR_NONE: { + SCOPE_EXIT { + free(value); + }; LoggerD("ret == SYSTEM_SETTINGS_ERROR_NONE"); + CHECK_STORAGE_ACCESS_AND_RETURN(value); result_obj.insert(std::make_pair("value", picojson::value(value ? value : ""))); - free(value); return PlatformResult(ErrorCode::NO_ERROR); + } case SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED: return LogAndCreateResult( ErrorCode::NOT_SUPPORTED_ERR, "This property is not supported.", @@ -137,10 +142,12 @@ void SystemSettingInstance::setProperty(const picojson::value& args, picojson::o const std::string& value = args.get("value").get(); LoggerD("Value to set: %s ", value.c_str()); - auto get = [this, type, value, + std::string real_path = common::FilesystemProvider::Create().GetRealPath(value); + CHECK_STORAGE_ACCESS(real_path, &out); + + auto get = [this, type, real_path, callback_id](const std::shared_ptr& response) -> void { ScopeLogger("Entered into asynchronous function, get"); - std::string real_path = common::FilesystemProvider::Create().GetRealPath(value); PlatformResult status = setPlatformPropertyValue(type, real_path); picojson::object& obj = response->get(); if (status.IsSuccess()) {