Bug 15691

Summary: ps -Z The displayed Context field is truncated.
Product: Busybox Reporter: chunren_r <renchunhui2>
Component: OtherAssignee: unassigned
Status: NEW ---    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.34.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description chunren_r 2023-07-11 01:47:11 UTC
In ps.c, the output length of the Context field is fixed to 32 characters.
Consider increasing the width of this field?
736                         len = printf("%5u %-32.32s %s  ",
737                                         p->pid,
738                                         p->context ? p->context : "unknown",
739                                         p->state);

If some process types are too long, the security attributes are truncated:
 PID CONTEXT                           STAT COMMAND
 1370 system_u:system_r:os_busybox_t:s S    /usr/sbin/rpc.mountd
 1374 system_u:system_r:kernel_t:s0:c0 IW<  [kworker/3:1H]
 1411 system_u:system_r:os_busybox_t:s S    {e3_daemon} /usr/local/UnifiedTest
 1413 system_u:system_r:os_busybox_t:s S    {e3_daemon} /usr/local/UnifiedTest
 1419 system_u:system_r:os_busybox_t:s S    sshd: /usr/sbin/sshd -D [listener]
 1421 system_u:system_r:os_log_rsyslog S    /usr/sbin/rsyslogd
 1496 system_u:system_r:os_busybox_t:s S    /bin/login --
 1497 system_u:system_r:os_busybox_t:s S    -bash
 1504 system_u:system_r:os_busybox_t:s R    ps -Z
 1505 system_u:system_r:os_busybox_t:s S    tail -n 10

The complete information is as follows:
 PID CONTEXT                                           STAT COMMAND
 1370 system_u:system_r:os_busybox_t:s0:c0             S    {rpc.mountd} /usr/
 1374 system_u:system_r:kernel_t:s0:c0                 IW<  [kworker/3:1H]
 1411 system_u:system_r:os_busybox_t:s0:c0             S    {e3_daemon} /usr/l
 1413 system_u:system_r:os_busybox_t:s0:c0             S    {e3_daemon} /usr/l
 1419 system_u:system_r:os_busybox_t:s0:c0             S    sshd: /usr/sbin/ss
 1421 system_u:system_r:os_log_rsyslogd_t:s0:c0        S    /usr/sbin/rsyslogd
 1496 system_u:system_r:os_busybox_t:s0:c0             S    /bin/login --
 1497 system_u:system_r:os_busybox_t:s0:c0             S    -bash
 1506 system_u:system_r:os_busybox_t:s0:c0             R    ./ps -Z
 1507 system_u:system_r:os_busybox_t:s0:c0             S    tail -n 10