Skip to content

Commit

Permalink
Fallback on /proc/<pid>/exe if /proc/<pid>/root/<path> is inacces…
Browse files Browse the repository at this point in the history
…sible
  • Loading branch information
adsr committed May 12, 2020
1 parent 4ce41f4 commit f14b2d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions addr_objdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ static int get_php_bin_path(pid_t pid, char *path_root, char *path) {
return 1;
}
snprintf(path_root, PHPSPY_STR_SIZE, "/proc/%d/root/%s", (int)pid, buf);
if (access(path_root, F_OK) != 0) {
snprintf(path_root, PHPSPY_STR_SIZE, "/proc/%d/exe", (int)pid);
}
strcpy(path, buf);
return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion phpspy.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,10 @@ static void try_get_php_version(trace_target_t *target) {
"{ echo -n /proc/%d/root/; "
" awk '/libphp[78]/{print $NF; exit 0} END{exit 1}' /proc/%d/maps "
" || readlink /proc/%d/exe; } "
"| { xargs stat --printf=%%n 2>/dev/null || echo /proc/%d/exe; } "
"| xargs strings "
"| grep -Po '(?<=X-Powered-By: PHP/)\\d\\.\\d'",
pid, pid, pid
pid, pid, pid, pid
);
if ((pcmd = popen(version_cmd, "r")) == NULL) {
perror("try_get_php_version: popen");
Expand Down

0 comments on commit f14b2d6

Please sign in to comment.