ps: possibility to display uid of session owner for a process
Library systemd-login offers possibility to display the Unix user identifier of the owner of the session of a process. This information will also be displayed for user processes which are shared between multiple login sessions of the same user, where sd_session will be blank. This patch adds output option "sd_ouid" which will show user UID or "-", when there is no owner for a process. To maintain compatibility with non-systemd systems, procps must be configured with --with-systemd option to enable this option.
This commit is contained in:
parent
716d96b8eb
commit
785776c10d
16
ps/output.c
16
ps/output.c
@ -1209,6 +1209,21 @@ fail:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int pr_sd_ouid(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||||
|
int r;
|
||||||
|
size_t len;
|
||||||
|
uid_t ouid;
|
||||||
|
|
||||||
|
r = sd_pid_get_owner_uid(pp->tgid, &ouid);
|
||||||
|
if(r<0) goto fail;
|
||||||
|
return snprintf(outbuf, COLWID, "%d", ouid);
|
||||||
|
|
||||||
|
fail:
|
||||||
|
outbuf[0] = '-';
|
||||||
|
outbuf[1] = '\0';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/****************** FLASK & seLinux security stuff **********************/
|
/****************** FLASK & seLinux security stuff **********************/
|
||||||
@ -1538,6 +1553,7 @@ static const format_struct format_array[] = {
|
|||||||
{"scnt", "SCNT", pr_nop, sr_nop, 4, 0, DEC, AN|RIGHT}, /* man page misspelling of scount? */
|
{"scnt", "SCNT", pr_nop, sr_nop, 4, 0, DEC, AN|RIGHT}, /* man page misspelling of scount? */
|
||||||
{"scount", "SC", pr_nop, sr_nop, 4, 0, AIX, AN|RIGHT}, /* scnt==scount, DEC claims both */
|
{"scount", "SC", pr_nop, sr_nop, 4, 0, AIX, AN|RIGHT}, /* scnt==scount, DEC claims both */
|
||||||
#ifdef WITH_SYSTEMD
|
#ifdef WITH_SYSTEMD
|
||||||
|
{"sd_ouid", "OWNER", pr_sd_ouid, sr_nop, 5, 0, LNX, ET|LEFT},
|
||||||
{"sd_session","SESSION", pr_sd_session, sr_nop, 11, 0, LNX, ET|LEFT},
|
{"sd_session","SESSION", pr_sd_session, sr_nop, 11, 0, LNX, ET|LEFT},
|
||||||
{"sd_unit", "UNIT", pr_sd_unit, sr_nop, 31, 0, LNX, ET|LEFT},
|
{"sd_unit", "UNIT", pr_sd_unit, sr_nop, 31, 0, LNX, ET|LEFT},
|
||||||
#endif
|
#endif
|
||||||
|
4
ps/ps.1
4
ps/ps.1
@ -1489,6 +1489,10 @@ SCHED_FIFO, SCHED_RR, SCHED_BATCH, SCHED_ISO, and SCHED_IDLE are respectively
|
|||||||
displayed as 0, 1, 2, 3, 4, and 5.
|
displayed as 0, 1, 2, 3, 4, and 5.
|
||||||
T}
|
T}
|
||||||
|
|
||||||
|
sd_ouid OWNER T{
|
||||||
|
displays the Unix user identifier of the owner of the session of a process.
|
||||||
|
T}
|
||||||
|
|
||||||
sd_session SESSION T{
|
sd_session SESSION T{
|
||||||
displays login session identifier of a process.
|
displays login session identifier of a process.
|
||||||
T}
|
T}
|
||||||
|
Loading…
Reference in New Issue
Block a user