Do not fail NS worker action if mount point doesn't exist 00/215100/2
authorTomasz Swierczek <t.swierczek@samsung.com>
Tue, 1 Oct 2019 11:05:53 +0000 (13:05 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Wed, 9 Oct 2019 08:27:30 +0000 (08:27 +0000)
This mimics actions taken at app launch, where privileges
defined for nonexisting mount points are not causing
the launch to be failed.

Change-Id: I4e8f14452d379ee86efc31412aa940a4aa67b463

src/common/worker.cpp

index 64b80f3f02f24c4cae5ddbe19841dc7284557a2c..466f50dac01ccab63611ab89229324da312217e6 100644 (file)
@@ -1,7 +1,7 @@
 /*
- *  Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2017 - 2019 Samsung Electronics Co., Ltd All Rights Reserved
  *
- *  Contact: Rafal Krypa <r.krypa@samsung.com>
+ *  Contact: Tomasz Swierczek <t.swierczek@samsung.com>
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -71,9 +71,15 @@ int Worker::doWork(const NSMountLogic::EntryVector &entries)
                 if (mapIter == storagePrivilegePathMap.end())
                     continue;
 
-                for (auto &privilegePath : mapIter->second)
+                for (auto &privilegePath : mapIter->second) {
+                    if (FS::directoryStatus(privilegePath.dstPath) == 0) {
+                        LogWarning("Not enforcing privilege " << privName << " for application " << entry.smackLabel << " : " <<
+                                   "directory " << privilegePath.dstPath << " doesn't exist");
+                        continue;
+                    }
                     if (SECURITY_MANAGER_SUCCESS != applyPrivilegePath(allowed, privilegePath))
                         status = -1;
+                }
             }
         } catch (...) {
             status = -1;