Check request before access control 58/318758/1
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 8 Oct 2024 03:36:45 +0000 (12:36 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 8 Oct 2024 03:37:35 +0000 (12:37 +0900)
For access control, the application ID should be set if it's the launch request.
Before checking the permission of the caller, amd checks the request.
If it's the implicit launch request, amd sets the application ID to the request.

Change-Id: I548eb1ac9f9f8a41b6007fa7eacf887af9d8823d
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/request/request_manager.cc
src/lib/request/request_manager.hh

index f95296fb766bbb6993be88b4144b65fd1ca4b99e..02320ccaa6ad0a0e6ffa5905649bdb288a467e18 100644 (file)
@@ -364,20 +364,10 @@ Request::Status RequestManager::CheckStatus(const RequestPtr& req) {
     return Request::Status::Invalid;
   }
 
-  if (b->GetString(AUL_K_APPID).empty())
+  auto appid = b->GetString(AUL_K_APPID);
+  if (appid.empty())
     return Request::Status::Normal;
 
-  if (req->CanBeImplicitLaunch())
-    _app_control_resolve(req->GetTargetUID(), b->GetHandle());
-
-  if (_app_property_set_real_appid(req->GetTargetUID(),
-      b->GetHandle()) == 0 && req->GetCmd() == APP_RESUME)
-    b->Delete(AUL_K_INSTANCE_ID);
-
-  _app_property_set_real_widget_id(req->GetTargetUID(), b->GetHandle());
-  _appinfo_set_effective_appid(req->GetTargetUID(), b->GetHandle());
-
-  auto appid = b->GetString(AUL_K_APPID);
   auto pending_item = GetPendingItem(req, appid);
   if (pending_item == nullptr)
     return Request::Status::Normal;
@@ -457,6 +447,23 @@ void RequestManager::CynaraResponseCallback(amd_cynara_res res,
   return;
 }
 
+void RequestManager::CheckRequest(const RequestPtr& req) {
+  auto& b = req->GetBundle();
+  if (b == nullptr) return;
+
+  if (b->GetString(AUL_K_APPID).empty()) return;
+
+  if (req->CanBeImplicitLaunch())
+    _app_control_resolve(req->GetTargetUID(), b->GetHandle());
+
+  if (_app_property_set_real_appid(req->GetTargetUID(),
+      b->GetHandle()) == 0 && req->GetCmd() == APP_RESUME)
+    b->Delete(AUL_K_INSTANCE_ID);
+
+  _app_property_set_real_widget_id(req->GetTargetUID(), b->GetHandle());
+  _appinfo_set_effective_appid(req->GetTargetUID(), b->GetHandle());
+}
+
 gboolean RequestManager::RequestHandler(GIOChannel* io,
     GIOCondition cond, gpointer data) {
   int fd = g_io_channel_unix_get_fd(io);
@@ -483,6 +490,7 @@ gboolean RequestManager::RequestHandler(GIOChannel* io,
     return G_SOURCE_CONTINUE;
   }
 
+  GetInst().CheckRequest(req);
   if (req->GetUID() >= REGULAR_UID_MIN || req->IsIndirectRequest()) {
     if (req->GetUID() >= REGULAR_UID_MIN &&
         req->GetUID() != req->GetTargetUID()) {
index c7325b23389324f0c601c6ba85dc56750dd3bcfc..2f85e15288503179f506ff3e0ad43afe58518b6e 100644 (file)
@@ -85,6 +85,7 @@ class RequestManager : public Request::IEvent {
   static gboolean RequestHandler(GIOChannel *io, GIOCondition cond,
       gpointer data);
   static void CynaraResponseCallback(amd_cynara_res res, request_h request);
+  void CheckRequest(const RequestPtr& req);
 
  private:
   std::unordered_map<unsigned int, std::shared_ptr<PendingItem>> pending_items_;