diff options
author | Kyungwook Tak <k.tak@samsung.com> | 2016-07-05 13:58:19 +0900 |
---|---|---|
committer | Kyungwook Tak <k.tak@samsung.com> | 2016-07-05 14:28:17 +0900 |
commit | 759e0ddc95f143c0166c050989ff200e8c477a92 (patch) | |
tree | f3f5185f74ae7de246f5ad45325a18a4882211de | |
parent | d82e4542803159badd94982198f397b28ae417e4 (diff) | |
download | csr-framework-759e0ddc95f143c0166c050989ff200e8c477a92.tar.gz csr-framework-759e0ddc95f143c0166c050989ff200e8c477a92.tar.bz2 csr-framework-759e0ddc95f143c0166c050989ff200e8c477a92.zip |
Ignore permission related exception on async scan
Change-Id: Ia2d1cbab672bf8d40b352a523bd902d4372a28ce
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
-rw-r--r-- | src/framework/service/cs-logic.cpp | 12 | ||||
-rw-r--r-- | test/test-api-content-screening-async.cpp | 29 |
2 files changed, 36 insertions, 5 deletions
diff --git a/src/framework/service/cs-logic.cpp b/src/framework/service/cs-logic.cpp index efd0e10..040bee6 100644 --- a/src/framework/service/cs-logic.cpp +++ b/src/framework/service/cs-logic.cpp @@ -514,8 +514,9 @@ RawBuffer CsLogic::scanFilesAsync(const ConnShPtr &conn, const CsContext &contex canonicalized.insert(target->getName()); } catch (const Exception &e) { if (e.error() == CSR_ERROR_FILE_DO_NOT_EXIST || - e.error() == CSR_ERROR_FILE_SYSTEM) { - WARN("File-system related exception occured while getting " + e.error() == CSR_ERROR_FILE_SYSTEM || + e.error() == CSR_ERROR_PERMISSION_DENIED) { + WARN("File-system & permission related exception occured while getting " "canonicalize path of path: " << path << " " << e.what() << ". Ignore this exception."); continue; @@ -562,7 +563,7 @@ RawBuffer CsLogic::scanDirsAsync(const ConnShPtr &conn, const CsContext &context for (const auto &path : paths) { try { - auto target = canonicalizePath(File::getPkgPath(path), true); + auto target = canonicalizePath(path, true); if (dirs.find(target) == dirs.end()) { INFO("Insert to canonicalized list: " << target); @@ -570,8 +571,9 @@ RawBuffer CsLogic::scanDirsAsync(const ConnShPtr &conn, const CsContext &context } } catch (const Exception &e) { if (e.error() == CSR_ERROR_FILE_DO_NOT_EXIST || - e.error() == CSR_ERROR_FILE_SYSTEM) { - WARN("File-system related exception occured while getting " + e.error() == CSR_ERROR_FILE_SYSTEM || + e.error() == CSR_ERROR_PERMISSION_DENIED) { + WARN("File-system & permission related exception occured while getting " "canonicalize path of path: " << path << " " << e.what() << ". Ignore this exception."); continue; diff --git a/test/test-api-content-screening-async.cpp b/test/test-api-content-screening-async.cpp index 888efb1..5e9b99c 100644 --- a/test/test-api-content-screening-async.cpp +++ b/test/test-api-content-screening-async.cpp @@ -1173,4 +1173,33 @@ BOOST_AUTO_TEST_CASE(scan_async_multiple) EXCEPTION_GUARD_END } +BOOST_AUTO_TEST_CASE(scan_async_no_perm_dirs) +{ + EXCEPTION_GUARD_START + + std::string tmp_no_perm_media = std::string() + TEST_DIR_MEDIA() + "/tak"; + BOOST_MESSAGE("This TC needs special directory(" << tmp_no_perm_media << ") " + "which should be created manualy with special smack label to occur " + "smack-deny to open."); + + auto c = Test::Context<csr_cs_context_h>(); + auto context = c.get(); + + const char *dirs[3] = { + "/tmp", + tmp_no_perm_media.c_str(), + TEST_DIR_APPS() + }; + + set_default_callback(context); + + AsyncTestContext testCtx; + + ASSERT_SUCCESS(csr_cs_scan_dirs_async(context, dirs, 3, &testCtx)); + + ASSERT_CALLBACK(testCtx, -1, -1, 1, 0, 0); + + EXCEPTION_GUARD_END +} + BOOST_AUTO_TEST_SUITE_END() |