]> granicus.if.org Git - procps-ng/commitdiff
ps: changed to exploit a newly added UID used at login
authorJim Warner <james.warner@comcast.net>
Sun, 11 Feb 2018 08:22:22 +0000 (02:22 -0600)
committerCraig Small <csmall@enc.com.au>
Mon, 19 Feb 2018 09:33:59 +0000 (20:33 +1100)
This patch represents a newlib adaptation of the merge
request offered by Jan Rybar that is referenced below.

Reference(s):
https://gitlab.com/procps-ng/procps/merge_requests/57
https://bugzilla.redhat.com/show_bug.cgi?id=1518986

Signed-off-by: Jim Warner <james.warner@comcast.net>
ps/common.h
ps/global.c
ps/output.c
ps/ps.1

index 62b96c55efe73f4ca5bccaf911b194560aee71b6..9c47173436400e5645fa2a7a6b165d2c39f8538a 100644 (file)
@@ -88,6 +88,7 @@ makEXT(ID_FGID)
 makEXT(ID_FGROUP)
 makEXT(ID_FUID)
 makEXT(ID_FUSER)
+makEXT(ID_LOGIN)
 makEXT(ID_PGRP)
 makEXT(ID_PID)
 makEXT(ID_PPID)
index 46a85c858fd123f2ef2eadfb11457c92f4173951..31eee6004aae7e2353a27fbd3838e35807ede1db 100644 (file)
@@ -78,6 +78,7 @@ makREL(ID_FGID)
 makREL(ID_FGROUP)
 makREL(ID_FUID)
 makREL(ID_FUSER)
+makREL(ID_LOGIN)
 makREL(ID_PGRP)
 makREL(ID_PID)
 makREL(ID_PPID)
index 394391612d2464e560069acd2ffe6071e8484cfa..bf1b1652d094ea890299b244363875248a016001 100644 (file)
@@ -999,6 +999,11 @@ static int pr_fuid(char *restrict const outbuf, const proc_t *restrict const pp)
 setREL1(ID_FUID)
   return snprintf(outbuf, COLWID, "%d", rSv(ID_FUID, u_int, pp));
 }
+static int pr_luid(char *restrict const outbuf, const proc_t *restrict const pp){
+setREL1(ID_LOGIN)
+  if(rSv(ID_LOGIN, s_int, pp)==-1) return snprintf(outbuf, COLWID, "-");
+  return snprintf(outbuf, COLWID, "%d", rSv(ID_LOGIN, s_int, pp));
+}
 
 // The Open Group Base Specifications Issue 6 (IEEE Std 1003.1, 2004 Edition)
 // requires that user and group names print as decimal numbers if there is
@@ -1428,7 +1433,7 @@ static const format_struct format_array[] = { /*
 {"longtname", "TTY",     pr_tty8,          PIDS_TTY_NAME,            8,    DEC,  PO|LEFT},
 {"lsession",  "SESSION", pr_sd_session,    PIDS_SD_SESS,            11,    LNX,  ET|LEFT},
 {"lstart",    "STARTED", pr_lstart,        PIDS_TIME_START,         24,    XXX,  ET|RIGHT},
-{"luid",      "LUID",    pr_nop,           PIDS_noop,                5,    LNX,  ET|RIGHT}, /* login ID */
+{"luid",      "LUID",    pr_luid,          PIDS_ID_LOGIN,            5,    LNX,  ET|RIGHT}, /* login ID */
 {"luser",     "LUSER",   pr_nop,           PIDS_noop,                8,    LNX,  ET|USER},  /* login USER */
 {"lwp",       "LWP",     pr_tasks,         PIDS_ID_PID,              5,    SUN,  TO|PIDMAX|RIGHT},
 {"lxc",       "LXC",     pr_lxcname,       PIDS_LXCNAME,             8,    LNX,  ET|LEFT},
diff --git a/ps/ps.1 b/ps/ps.1
index 1d0e2f17c35c0c48309ec79d274d31d2d1818501..834b7b1828e8e19da425e98df70ca60079889e31 100644 (file)
--- a/ps/ps.1
+++ b/ps/ps.1
@@ -4,7 +4,7 @@
 .\" Quick hack conversion by Albert Cahalan, 1998.
 .\" Licensed under version 2 of the Gnu General Public License.
 .\"
-.TH PS 1 2018-01-13 "procps-ng" "User Commands"
+.TH PS 1 "February, 2018" "procps-ng" "User Commands"
 .\"
 .\" To render this page:
 .\"    groff -t -b -man -X -P-resolution -P100 -Tps ps.1 &
@@ -1329,6 +1329,10 @@ displays the login session identifier of a process,
 if systemd support has been included.
 T}
 
+luid   LUID    T{
+displays Login ID associated with a process.
+T}
+
 lwp    LWP     T{
 light weight process (thread) ID of the dispatchable entity (alias
 .BR spid , \ tid ).