|
|
9a85b1 |
diff -up ./ps/output.c.ori ./ps/output.c
|
|
|
9a85b1 |
--- ./ps/output.c.ori 2018-04-19 15:18:36.510737173 +0200
|
|
|
9a85b1 |
+++ ./ps/output.c 2018-04-19 15:18:07.850849743 +0200
|
|
|
9a85b1 |
@@ -1087,6 +1087,34 @@ static int pr_fuid(char *restrict const
|
|
|
9a85b1 |
return snprintf(outbuf, COLWID, "%d", pp->fuid);
|
|
|
9a85b1 |
}
|
|
|
9a85b1 |
|
|
|
9a85b1 |
+/* LoginID implementation */
|
|
|
9a85b1 |
+static int pr_luid(char *restrict const outbuf, const proc_t *restrict const pp){
|
|
|
9a85b1 |
+ char filename[48];
|
|
|
9a85b1 |
+ ssize_t num_read;
|
|
|
9a85b1 |
+ int fd;
|
|
|
9a85b1 |
+ u_int32_t luid;
|
|
|
9a85b1 |
+
|
|
|
9a85b1 |
+ snprintf(filename, sizeof filename, "/proc/%d/loginuid", pp->tgid);
|
|
|
9a85b1 |
+
|
|
|
9a85b1 |
+ if ((fd = open(filename, O_RDONLY, 0)) != -1) {
|
|
|
9a85b1 |
+ num_read = read(fd, outbuf, OUTBUF_SIZE - 1);
|
|
|
9a85b1 |
+ close(fd);
|
|
|
9a85b1 |
+ if (num_read > 0) {
|
|
|
9a85b1 |
+ outbuf[num_read] = '\0';
|
|
|
9a85b1 |
+
|
|
|
9a85b1 |
+ // processes born before audit have no LoginID set
|
|
|
9a85b1 |
+ luid = (u_int32_t) atoi(outbuf);
|
|
|
9a85b1 |
+ if (luid != -1)
|
|
|
9a85b1 |
+ return num_read;
|
|
|
9a85b1 |
+ }
|
|
|
9a85b1 |
+ }
|
|
|
9a85b1 |
+ outbuf[0] = '-';
|
|
|
9a85b1 |
+ outbuf[1] = '\0';
|
|
|
9a85b1 |
+ num_read = 1;
|
|
|
9a85b1 |
+ return num_read;
|
|
|
9a85b1 |
+}
|
|
|
9a85b1 |
+
|
|
|
9a85b1 |
+
|
|
|
9a85b1 |
// The Open Group Base Specifications Issue 6 (IEEE Std 1003.1, 2004 Edition)
|
|
|
9a85b1 |
// requires that user and group names print as decimal numbers if there is
|
|
|
9a85b1 |
// not enough room in the column. However, we will now truncate such names
|
|
|
9a85b1 |
@@ -1531,7 +1559,7 @@ static const format_struct format_array[
|
|
|
9a85b1 |
{"lsession", "SESSION", pr_sd_session, sr_nop, 11, SD, LNX, ET|LEFT},
|
|
|
9a85b1 |
#endif
|
|
|
9a85b1 |
{"lstart", "STARTED", pr_lstart, sr_nop, 24, 0, XXX, ET|RIGHT},
|
|
|
9a85b1 |
-{"luid", "LUID", pr_nop, sr_nop, 5, 0, LNX, ET|RIGHT}, /* login ID */
|
|
|
9a85b1 |
+{"luid", "LUID", pr_luid, sr_nop, 5, 0, LNX, ET|RIGHT}, /* login ID */
|
|
|
9a85b1 |
{"luser", "LUSER", pr_nop, sr_nop, 8, USR, LNX, ET|USER}, /* login USER */
|
|
|
9a85b1 |
{"lwp", "LWP", pr_tasks, sr_tasks, 5, 0, SUN, TO|PIDMAX|RIGHT},
|
|
|
9a85b1 |
{"m_drs", "DRS", pr_drs, sr_drs, 5, MEM, LNx, PO|RIGHT},
|
|
|
9a85b1 |
diff -up ./ps/ps.1.ori ./ps/ps.1
|
|
|
9a85b1 |
--- ./ps/ps.1.ori 2018-04-19 15:18:36.510737173 +0200
|
|
|
9a85b1 |
+++ ./ps/ps.1 2018-04-19 15:18:25.175781694 +0200
|
|
|
9a85b1 |
@@ -1353,6 +1353,10 @@ displays the login session identifier of
|
|
|
9a85b1 |
if systemd support has been included.
|
|
|
9a85b1 |
T}
|
|
|
9a85b1 |
|
|
|
9a85b1 |
+luid LUID T{
|
|
|
9a85b1 |
+displays Login ID associated with a process.
|
|
|
9a85b1 |
+T}
|
|
|
9a85b1 |
+
|
|
|
9a85b1 |
lwp LWP T{
|
|
|
9a85b1 |
light weight process (thread) ID of the dispatchable entity (alias
|
|
|
9a85b1 |
.BR spid , \ tid ).
|