Check process group ID for getting appid and pkgid 30/286630/1
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 10 Jan 2023 23:56:50 +0000 (23:56 +0000)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 11 Jan 2023 00:00:21 +0000 (00:00 +0000)
The web engine is running as a child process of the web app.
If the web engine calls AUL APIs, the request is delivered to AMD.
Because, the process ID is not equal to the web app.
After this patch is applied, AUL API checks whether the process group ID
is equal to the process ID or not. Before executing an application,
the child process of the launchpad-process-pool calls the setsid() to
run the process in a new session. In that time, the process group is separated
from the launchpad-process-pool. Checking the process group ID can reduce
the IPC between AMD and the caller process.

Change-Id: I3746046c36328ecacc27c6cda16afbe44c1e1cfd
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/pkginfo.cc

index d70cf6b..d1f0483 100644 (file)
@@ -301,7 +301,7 @@ extern "C" API int aul_app_get_appid_bypid_for_uid(int pid, char* appid,
     return AUL_R_EINVAL;
   }
 
-  if (getpid() == pid) {
+  if (getpid() == pid || getpgid(getpid()) == pid) {
     context.Initialize();
     auto& preinit_appid = context.GetPreInitAppId();
     if (!preinit_appid.empty()) {
@@ -341,7 +341,7 @@ extern "C" API int aul_app_get_pkgid_bypid_for_uid(int pid, char* pkgid,
     return AUL_R_EINVAL;
   }
 
-  if (getpid() == pid) {
+  if (getpid() == pid || getpgid(getpid()) == pid) {
     context.Initialize();
     auto& preinit_pkgid = context.GetPreInitPkgId();
     if (!preinit_pkgid.empty()) {