summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikko Ylinen <mikko.ylinen@intel.com>2013-10-31 15:26:20 +0200
committerMikko Ylinen <mikko.ylinen@intel.com>2013-10-31 15:26:20 +0200
commitf0a2ea7fc9076d3ce20593fceb2d85eb074786db (patch)
tree0f461bcb60863fca278f95af6a8cc737e24785c4
parent960c7c7588e20420bdeb6e6eadadefb35da2ae4c (diff)
downloadico-uxf-weston-plugin-ppid_walk.tar.gz
ico-uxf-weston-plugin-ppid_walk.tar.bz2
ico-uxf-weston-plugin-ppid_walk.zip
Walk through child processes until app ID is found.ppid_walk
Change-Id: I5094ccad0db56e72c4433d76e61659da854348db Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
-rw-r--r--src/ico_window_mgr.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/ico_window_mgr.c b/src/ico_window_mgr.c
index 300d95a..485c234 100644
--- a/src/ico_window_mgr.c
+++ b/src/ico_window_mgr.c
@@ -44,6 +44,7 @@
#include <fcntl.h>
#include <limits.h>
#include <wayland-server.h>
+#include <dirent.h>
#include <aul/aul.h>
#include <bundle.h>
@@ -895,6 +896,63 @@ win_mgr_get_client_appid(struct uifw_client *uclient)
}
+ /*
+ * Walk the child process chain as well since app ID was not yet found
+ */
+ if (status != AUL_R_OK) {
+
+ DIR *dr;
+ struct dirent *de;
+ struct stat ps;
+ pid_t tpid;
+ uid_t uid;
+ gid_t gid;
+
+ dr = opendir("/proc/");
+
+ /* get uid */
+ wl_client_get_credentials(uclient->client, &tpid, &uid, &gid);
+
+ while(((de = readdir(dr)) != NULL) && (status != AUL_R_OK)) {
+
+ char fullpath[PATH_MAX] = { 0 };
+ int is_child = 0;
+ int tmppid;
+
+ snprintf(fullpath, sizeof(fullpath)-1, "/proc/%s", de->d_name);
+
+ if (stat(fullpath, &ps) == -1) {
+ continue;
+ }
+
+ /* find pid dirs for this user (uid) only */
+ if (ps.st_uid != uid)
+ continue;
+
+ pid = atoi(de->d_name);
+
+ /* check if it's a valid child */
+ if (pid < uclient->pid)
+ continue;
+
+ /* scan up to pid to find if a chain exists */
+ for (tmppid = pid; tmppid > uclient->pid;) {
+ tmppid = win_mgr_get_ppid(tmppid);
+ if (tmppid == uclient->pid)
+ is_child = 1;
+ }
+
+ if (is_child) {
+ status = aul_app_get_appid_bypid(pid, uclient->appid,
+ ICO_IVI_APPID_LENGTH);
+
+ uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid "
+ "ret=%d pid=%d appid=<%s>", status, pid,
+ uclient->appid);
+ }
+ }
+ }
+
if (uclient->appid[0] != 0) {
/* OK, end of get appid */
uclient->fixed_appid = ICO_WINDOW_MGR_APPID_FIXCOUNT;