diff --git a/ps/output.c b/ps/output.c index 4ccc6c3b..6b5f19c0 100644 --- a/ps/output.c +++ b/ps/output.c @@ -1258,6 +1258,26 @@ fail: return 1; } +static int pr_sd_seat(char *restrict const outbuf, const proc_t *restrict const pp){ + int r; + size_t len; + char *session; + char *seat; + r = sd_pid_get_session(pp->tgid, &session); + if(r<0) goto fail; + r = sd_session_get_seat(session, &seat); + free(session); + if(r<0) goto fail; + len = snprintf(outbuf, COLWID, "%s", seat); + free(seat); + return len; + +fail: + outbuf[0] = '-'; + outbuf[1] = '\0'; + return 1; +} + #endif /****************** FLASK & seLinux security stuff **********************/ // move the bulk of this to libproc sometime @@ -1588,6 +1608,7 @@ static const format_struct format_array[] = { #ifdef WITH_SYSTEMD {"sd_machine","MACHINE", pr_sd_machine, sr_nop, 31, 0, LNX, ET|LEFT}, {"sd_ouid", "OWNER", pr_sd_ouid, sr_nop, 5, 0, LNX, ET|LEFT}, +{"sd_seat", "SEAT", pr_sd_seat, 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_uunit", "UUNIT", pr_sd_uunit, sr_nop, 31, 0, LNX, ET|LEFT}, diff --git a/ps/ps.1 b/ps/ps.1 index df2400fa..af249c2c 100644 --- a/ps/ps.1 +++ b/ps/ps.1 @@ -1497,6 +1497,10 @@ sd_ouid OWNER T{ displays the Unix user identifier of the owner of the session of a process. T} +sd_seat SEAT T{ +displays login session identifier of a process. +T} + sd_session SESSION T{ displays login session identifier of a process. T}