Ignore permission related exception on async scan 91/78291/2
authorKyungwook Tak <k.tak@samsung.com>
Tue, 5 Jul 2016 04:58:19 +0000 (13:58 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Tue, 5 Jul 2016 05:28:17 +0000 (14:28 +0900)
Change-Id: Ia2d1cbab672bf8d40b352a523bd902d4372a28ce
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
src/framework/service/cs-logic.cpp
test/test-api-content-screening-async.cpp

index efd0e10..040bee6 100644 (file)
@@ -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;
index 888efb1..5e9b99c 100644 (file)
@@ -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()