diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2024-02-20 08:44:55 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2024-02-20 09:19:54 +0900 |
commit | 563fced12f585c740c0222378d16bac4550ae269 (patch) | |
tree | 4d2ecbb568021d730676f2fba6688dbd5788e31e | |
parent | 55430e6a86571996f766dcb08f164736e0996bae (diff) | |
download | launchpad-563fced12f585c740c0222378d16bac4550ae269.tar.gz launchpad-563fced12f585c740c0222378d16bac4550ae269.tar.bz2 launchpad-563fced12f585c740c0222378d16bac4550ae269.zip |
Validate gadget resource paths
The gadget resource path will be changed to
"/<package root path>/res/allowed/<res-type>".
Before mounting the gadget paths, the launchpad checks whether the path exists
or not. If it does not exist, the gadget path will be modified to remove
the "<res-type>".
Change-Id: Ib7d28fb0df986e56269351c5a2f94446b82ab0f2
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r-- | src/lib/launchpad-glib/util.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lib/launchpad-glib/util.cc b/src/lib/launchpad-glib/util.cc index b5861f6..44cea5d 100644 --- a/src/lib/launchpad-glib/util.cc +++ b/src/lib/launchpad-glib/util.cc @@ -362,6 +362,19 @@ class AmdPacket : public tizen_base::Parcelable { int opt_ = 0; }; +std::vector<std::string> ValidateAndModifyGadgetPaths( + const std::vector<std::string> gadget_paths) { + std::vector<std::string> paths; + for (const auto& path : gadget_paths) { + if (access(path.c_str(), F_OK) == 0) + paths.push_back(path); + else + paths.push_back(fs::path(path).parent_path().string()); + } + + return paths; +} + } // namespace void Util::SetEnvironments(const AppInfo* app_info) { @@ -487,6 +500,7 @@ int Util::MountResourceDirectories(const AppInfo* app_info) { int Util::MountGadgetDirectories(const tizen_base::Bundle& b) { auto gadget_paths = b.GetStringArray(kAulMountGadgetPaths); if (!gadget_paths.empty()) { + gadget_paths = ValidateAndModifyGadgetPaths(gadget_paths); auto root_path = b.GetString(kAulRootPath); return MountDirectories(gadget_paths, root_path + "/bin"); } |