From 3f49530d779fdcf020cf6bec4c0340318b20ce36 Mon Sep 17 00:00:00 2001 From: albert <> Date: Sat, 27 Mar 2004 03:55:52 +0000 Subject: [PATCH] new -M and Z options for security data --- NEWS | 4 +++- ps/global.c | 2 ++ ps/help.c | 10 +++++----- ps/output.c | 4 ++-- ps/parser.c | 5 ++++- ps/ps.1 | 2 ++ ps/sortformat.c | 5 +++++ 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 6c00fc8d..2f3eeb3c 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/ps/global.c b/ps/global.c index ea77d916..07d9f85a 100644 --- a/ps/global.c +++ b/ps/global.c @@ -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"; diff --git a/ps/help.c b/ps/help.c index db18ee4c..65686aae 100644 --- a/ps/help.c +++ b/ps/help.c @@ -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 * */ diff --git a/ps/output.c b/ps/output.c index 10413ab9..b56e1d94 100644 --- a/ps/output.c +++ b/ps/output.c @@ -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*/ diff --git a/ps/parser.c b/ps/parser.c index 02f9fdaa..8bb81d61 100644 --- a/ps/parser.c +++ b/ps/parser.c @@ -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; diff --git a/ps/ps.1 b/ps/ps.1 index bfaae524..6cb9d43d 100644 --- a/ps/ps.1 +++ b/ps/ps.1 @@ -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 diff --git a/ps/sortformat.c b/ps/sortformat.c index 64fb6bf7..a7bfe43b 100644 --- a/ps/sortformat.c +++ b/ps/sortformat.c @@ -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.