new -M and Z options for security data

This commit is contained in:
albert 2004-03-27 03:55:52 +00:00
parent 9f9c3a16ce
commit 3f49530d77
7 changed files with 23 additions and 9 deletions

4
NEWS
View File

@ -1,7 +1,9 @@
procps-3.2.0 --> procps-3.2.1
build w/ curses in odd location
build even w/ curses in an odd location
ps: STAT flags for fg process group and session leader
ps: STAT flags for swapped out process dropped (was broken)
ps: new -M and Z options for security data (SE Linux, etc.)
procps-3.1.15 --> procps-3.2.0

View File

@ -264,6 +264,8 @@ static const char *set_personality(void){
case_tru64:
case_compaq:
case_digital:
// no PER_NO_DEFAULT_g even though man page claims it
// Reality: the g is a NOP
personality = PER_GOOD_o | PER_BSD_h;
prefer_bsd_defaults = 1;
sysv_f_format = "F5FMT";

View File

@ -1,5 +1,5 @@
/*
* Copyright 1998-2002 by Albert Cahalan; all rights reserved.
* Copyright 1998-2004 by Albert Cahalan; all rights reserved.
* This file may be used subject to the terms and conditions of the
* GNU Library General Public License Version 2, or any later version
* at your option, as published by the Free Software Foundation.
@ -31,21 +31,21 @@ const char *help_message =
"x processes w/o controlling ttys t by tty\n"
"*********** output format ********** *********** long options ***********\n"
"-o,o user-defined -f full --Group --User --pid --cols --ppid\n"
"-j,j job control s signal --group --user --sid --rows\n"
"-j,j job control s signal --group --user --sid --rows --info\n"
"-O,O preloaded -o v virtual memory --cumulative --format --deselect\n"
"-l,l long u user-oriented --sort --tty --forest --version\n"
"-F extra full X registers --heading --no-heading --context\n"
" ********* misc options *********\n"
"-V,V show version L list format codes f ASCII art forest\n"
"-m,m,-L,-T,H threads S children in sum -y change -l format\n"
"-c scheduling class c true command name n numeric WCHAN,UID\n"
"-w,w wide output e show environment -H process hierarchy\n"
"-M,Z security data c true command name -c scheduling class\n"
"-w,w wide output n numeric WCHAN,UID -H process hierarchy\n"
;
/* Missing:
*
* -P -M --info
* -P e
*
*/

View File

@ -1054,7 +1054,7 @@ static const format_struct format_array[] = {
{"cnswap", "-", pr_nop, sr_cnswap, 1, 0, LNX, AN|RIGHT},
{"comm", "COMMAND", pr_comm, sr_nop, 16, COM, U98, PO|UNLIMITED}, /*ucomm*/
{"command", "COMMAND", pr_args, sr_nop, 16, ARG, XXX, PO|UNLIMITED}, /*args*/
{"context", "CONTEXT", pr_context, sr_nop, 40, 0, LNX, PO|LEFT},
{"context", "CONTEXT", pr_context, sr_nop, 40, 0, LNX, ET|LEFT},
{"cp", "CP", pr_cp, sr_pcpu, 3, 0, DEC, ET|RIGHT}, /*cpu*/
{"cpu", "CPU", pr_nop, sr_nop, 3, 0, BSD, AN|RIGHT}, /* FIXME ... HP-UX wants this as the CPU number for SMP? */
{"cputime", "TIME", pr_time, sr_nop, 8, 0, DEC, ET|RIGHT}, /*time*/
@ -1094,7 +1094,7 @@ static const format_struct format_array[] = {
{"jobc", "JOBC", pr_nop, sr_nop, 4, 0, XXX, AN|RIGHT},
{"ktrace", "KTRACE", pr_nop, sr_nop, 8, 0, BSD, AN|RIGHT},
{"ktracep", "KTRACEP", pr_nop, sr_nop, 8, 0, BSD, AN|RIGHT},
{"label", "LABEL", pr_nop, sr_nop, 25, 0, SGI, PO|LEFT},
{"label", "LABEL", pr_context, sr_nop, 25, 0, SGI, ET|LEFT},
{"lim", "LIM", pr_lim, sr_rss_rlim, 5, 0, BSD, AN|RIGHT},
{"login", "LOGNAME", pr_nop, sr_nop, 8, 0, BSD, AN|LEFT}, /*logname*/ /* double check */
{"logname", "LOGNAME", pr_nop, sr_nop, 8, 0, XXX, AN|LEFT}, /*login*/

View File

@ -270,7 +270,6 @@ static const char *parse_sysv_option(void){
case 'M': /* someday, maybe, we will have MAC like SGI's Irix */
trace("-M Print security label for Mandatory Access Control.\n");
format_modifiers |= FM_M;
return "Sorry, no Mandatory Access Control support.";
break;
case 'N':
trace("-N negates.\n");
@ -568,6 +567,10 @@ static const char *parse_bsd_option(void){
trace("X Old Linux i386 register format\n");
format_flags |= FF_LX;
break;
case 'Z': /* FreeBSD does MAC like SGI's Irix does it */
trace("Z Print security label for Mandatory Access Control.\n");
format_modifiers |= FM_M;
break;
case 'a':
trace("a Select all w/tty, including other users\n");
simple_select |= SS_B_a;

View File

@ -82,6 +82,7 @@ t select by tty
OUTPUT FORMAT CONTROL
-O is preloaded "-o"
-F extra full format
-M add column for security data
-c different scheduler info for -l option
-f does full listing
-j jobs format
@ -90,6 +91,7 @@ OUTPUT FORMAT CONTROL
-y do not show flags; show rss in place of addr
O is preloaded "o" (overloaded)
X old Linux i386 register format
Z add column for security data
j job control format
l display long format
o specify user-defined format

View File

@ -925,6 +925,11 @@ did_lwp:
fn = do_one_spec("nlwp", NULL);
fmt_add_after("%CPU", fn);
}
if(format_modifiers & FM_M){ // Mandatory Access Control, IRIX style
fn = do_one_spec("label", NULL);
fn->next=format_list;
format_list=fn;
}
/* Do personality-specific translations not covered by format_flags.
* Generally, these only get hit when personality overrides unix output.
* That (mostly?) means the Digital and Debian personalities.