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 08:44:55 +0900 |
commit | b2f22b8a5a4e68b712d2aeacbd65cda67c423869 (patch) | |
tree | 5c0154271b0298185501635d4274e85e7e2c7a6d | |
parent | 3fc962179245997996f764a41eaa7c8c03c11214 (diff) | |
download | launchpad-b2f22b8a5a4e68b712d2aeacbd65cda67c423869.tar.gz launchpad-b2f22b8a5a4e68b712d2aeacbd65cda67c423869.tar.bz2 launchpad-b2f22b8a5a4e68b712d2aeacbd65cda67c423869.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 99d5724..01cb31d 100644 --- a/src/lib/launchpad-glib/util.cc +++ b/src/lib/launchpad-glib/util.cc @@ -363,6 +363,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) { @@ -485,6 +498,7 @@ int Util::MountLibraryDirectories(const tizen_base::Bundle& b) { 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"); } |