From 6658492df6756fd8ff60db305beda118b75ecc9e Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Fri, 22 Jun 2018 00:00:00 -0500 Subject: [PATCH] ps: exploited that newly added field 'executable path' Signed-off-by: Jim Warner --- ps/common.h | 1 + ps/global.c | 1 + ps/output.c | 7 +++++++ ps/ps.1 | 8 ++++++++ 4 files changed, 17 insertions(+) diff --git a/ps/common.h b/ps/common.h index 9c471734..5bf8cb74 100644 --- a/ps/common.h +++ b/ps/common.h @@ -75,6 +75,7 @@ makEXT(CGROUP) makEXT(CMD) makEXT(CMDLINE) makEXT(ENVIRON) +makEXT(EXE) makEXT(FLAGS) makEXT(FLT_MAJ) makEXT(FLT_MAJ_C) diff --git a/ps/global.c b/ps/global.c index 31eee600..3ef8926d 100644 --- a/ps/global.c +++ b/ps/global.c @@ -65,6 +65,7 @@ makREL(CGROUP) makREL(CMD) makREL(CMDLINE) makREL(ENVIRON) +makREL(EXE) makREL(FLAGS) makREL(FLT_MAJ) makREL(FLT_MAJ_C) diff --git a/ps/output.c b/ps/output.c index 07b1c0d5..ef05b6cc 100644 --- a/ps/output.c +++ b/ps/output.c @@ -1159,6 +1159,12 @@ setREL2(STATE,PROCESSOR) return snprintf(outbuf, COLWID, "*"); } +/* full path to executable */ +static int pr_exe(char *restrict const outbuf, const proc_t *restrict const pp){ +setREL1(EXE) + return snprintf(outbuf, COLWID, "%s", rSv(EXE, str, pp)); +} + /************************* Systemd stuff ********************************/ static int pr_sd_unit(char *restrict const outbuf, const proc_t *restrict const pp){ setREL1(SD_UNIT) @@ -1442,6 +1448,7 @@ static const format_struct format_array[] = { /* {"etimes", "ELAPSED", pr_etimes, PIDS_TIME_ELAPSED, 7, BSD, ET|RIGHT}, /* FreeBSD */ {"euid", "EUID", pr_euid, PIDS_ID_EUID, 5, LNX, ET|RIGHT}, {"euser", "EUSER", pr_euser, PIDS_ID_EUSER, 8, LNX, ET|USER}, +{"exe", "EXE", pr_exe, PIDS_EXE, 27, LNX, PO|UNLIMITED}, {"f", "F", pr_flag, PIDS_FLAGS, 1, XXX, ET|RIGHT}, /*flags*/ {"fgid", "FGID", pr_fgid, PIDS_FLAGS, 5, LNX, ET|RIGHT}, {"fgroup", "FGROUP", pr_fgroup, PIDS_ID_FGROUP, 8, LNX, ET|USER}, diff --git a/ps/ps.1 b/ps/ps.1 index 547b3de7..82f973b9 100644 --- a/ps/ps.1 +++ b/ps/ps.1 @@ -1243,6 +1243,14 @@ option can be used to force the decimal representation. (alias .BR uname , \ user ). T} +exe EXE T{ +path to the executable. Useful if path cannot be printed via +.BR cmd ", " comm +or +.BR args +format options. +T} + f F T{ flags associated with the process, see the .B PROCESS FLAGS