From 22887a61e1dc6f73af7f44f4bd9b6d8e817bd433 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sun, 11 Feb 2018 02:22:22 -0600 Subject: [PATCH] ps: changed to exploit a newly added UID used at login 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 --- ps/common.h | 1 + ps/global.c | 1 + ps/output.c | 7 ++++++- ps/ps.1 | 6 +++++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ps/common.h b/ps/common.h index 62b96c55..9c471734 100644 --- a/ps/common.h +++ b/ps/common.h @@ -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) diff --git a/ps/global.c b/ps/global.c index 46a85c85..31eee600 100644 --- a/ps/global.c +++ b/ps/global.c @@ -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) diff --git a/ps/output.c b/ps/output.c index 39439161..bf1b1652 100644 --- a/ps/output.c +++ b/ps/output.c @@ -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 1d0e2f17..834b7b18 100644 --- 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 ). -- 2.40.0