added SELINUX patches
This commit is contained in:
@@ -65,6 +65,7 @@ DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
ECHO = @ECHO@
|
||||
EXEEXT = @EXEEXT@
|
||||
FLASK_LINUX = @FLASK_LINUX@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
|
||||
@@ -105,6 +105,10 @@
|
||||
#define FF_Bv 0x0080 /* v */
|
||||
#define FF_LX 0x0100 /* X */
|
||||
#define FF_Lm 0x0200 /* m */ /* overloaded: threads, sort, format */
|
||||
#ifdef FLASK_LINUX
|
||||
#define FF_Fc 0x0400 /* --context */ /* Flask security context format */
|
||||
#define FF_Fs 0x0800 /* --SID */ /* Flask SID format */
|
||||
#endif
|
||||
|
||||
/* predefined format modifier flags such as: -l -f l u s -j */
|
||||
#define FM_c 0x0001 /* -c */
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
* The help message must not become longer, because it must fit
|
||||
* on an 80x24 screen _with_ the error message and command prompt.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
const char *help_message =
|
||||
"********* simple selection ********* ********* selection by list *********\n"
|
||||
@@ -33,6 +35,9 @@ const char *help_message =
|
||||
"-O,O preloaded -o v virtual memory --cumulative --format --deselect\n"
|
||||
"-l,l long u user-oriented --sort --tty --forest --version\n"
|
||||
" X registers --heading --no-heading\n"
|
||||
#ifdef FLASK_LINUX
|
||||
" --context --SID (Flask only)\n"
|
||||
#endif
|
||||
" ********* misc options *********\n"
|
||||
"-V,V show version L list format codes f ASCII art forest\n"
|
||||
"-m,m show threads S children in sum -y change -l format\n"
|
||||
|
||||
154
ps/output.c
154
ps/output.c
@@ -38,7 +38,9 @@
|
||||
*
|
||||
* Table 5 could go in a file with the output functions.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* proc_t offset macro */
|
||||
#define PO(q) ((unsigned long)(&(((proc_t*)0)->q)))
|
||||
@@ -64,6 +66,13 @@
|
||||
#include "../proc/devname.h"
|
||||
#include "common.h"
|
||||
|
||||
#ifdef FLASK_LINUX
|
||||
#include <errno.h>
|
||||
#include <fs_secure.h>
|
||||
#include <ss.h>
|
||||
#define DEF_CTXTLEN 255
|
||||
#endif
|
||||
|
||||
|
||||
/* TODO:
|
||||
* Stop assuming system time is local time.
|
||||
@@ -192,6 +201,10 @@ CMP_INT(pcpu)
|
||||
|
||||
CMP_INT(state)
|
||||
|
||||
#ifdef FLASK_LINUX
|
||||
CMP_INT(sid)
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
/************ Lots of format functions, starting with the NOP **************/
|
||||
|
||||
@@ -911,6 +924,134 @@ static int pr_sgi_p(void){ /* FIXME */
|
||||
|
||||
|
||||
|
||||
#ifdef FLASK_LINUX
|
||||
|
||||
/*
|
||||
* The sr_fn() calls -- for sorting -- don't return errors because the same errors
|
||||
* should show up when the printing function pr_fn() is called, at which point the
|
||||
* error goes onscreen.
|
||||
*/
|
||||
|
||||
static int pr_sid ( void ) {
|
||||
return sprintf(outbuf, "%d", (int) pp->sid);
|
||||
}
|
||||
|
||||
static int pr_context ( void ) {
|
||||
char *ctxt; /* should be security_context_t */
|
||||
unsigned int len;
|
||||
int rv;
|
||||
|
||||
|
||||
len = DEF_CTXTLEN;
|
||||
ctxt = (char *) calloc(1, len);
|
||||
if ( ctxt != NULL )
|
||||
rv = security_sid_to_context(pp->sid, (security_context_t) ctxt, &len);
|
||||
else
|
||||
return sprintf(outbuf, "-");
|
||||
|
||||
if ( rv ) {
|
||||
if ( errno != ENOSPC ) {
|
||||
free(ctxt);
|
||||
return sprintf(outbuf, "-");
|
||||
}
|
||||
else {
|
||||
free(ctxt);
|
||||
ctxt = (char *) calloc(1, len);
|
||||
if ( ctxt != NULL ) {
|
||||
rv = security_sid_to_context(pp->sid, (security_context_t) ctxt, &len);
|
||||
if ( rv ) {
|
||||
free(ctxt);
|
||||
return sprintf(outbuf, "-");
|
||||
}
|
||||
else {
|
||||
rv = sprintf(outbuf, "%s", ctxt);
|
||||
free(ctxt);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else /* calloc() failed */
|
||||
return sprintf(outbuf, "-");
|
||||
}
|
||||
}
|
||||
else {
|
||||
rv = sprintf(outbuf, "%s", ctxt);
|
||||
free(ctxt);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int sr_context ( const proc_t* P, const proc_t* Q ) {
|
||||
char *ctxt_P, *ctxt_Q; /* type should be security_context_t */
|
||||
unsigned int len;
|
||||
int rv;
|
||||
|
||||
len = DEF_CTXTLEN;
|
||||
ctxt_P = (char *) calloc(1, len);
|
||||
ctxt_Q = (char *) calloc(1, len);
|
||||
|
||||
rv = security_sid_to_context(P->sid, (security_context_t) ctxt_P, &len);
|
||||
if ( rv ) {
|
||||
if ( errno != ENOSPC ) {
|
||||
free(ctxt_P);
|
||||
/* error should resurface during printing */
|
||||
return( 0 );
|
||||
}
|
||||
else {
|
||||
free(ctxt_P);
|
||||
ctxt_P = (char *) calloc(1, len);
|
||||
if ( ctxt_P != NULL ) {
|
||||
rv = security_sid_to_context(P->sid, (security_context_t) ctxt_P, &len);
|
||||
if ( rv ) {
|
||||
free(ctxt_P);
|
||||
/* error should resurface during printing */
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
else /* calloc() failed */
|
||||
/* error should resurface during printing */
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
len = DEF_CTXTLEN;
|
||||
|
||||
rv = security_sid_to_context(Q->sid, (security_context_t) ctxt_Q, &len);
|
||||
if ( rv ) {
|
||||
if ( errno != ENOSPC ) {
|
||||
free(ctxt_P);
|
||||
free(ctxt_Q);
|
||||
/* error should resurface during printing */
|
||||
return( 0 );
|
||||
}
|
||||
else {
|
||||
free(ctxt_Q);
|
||||
ctxt_Q = (char *) calloc(1, len);
|
||||
if ( ctxt_Q != NULL ) {
|
||||
rv = security_sid_to_context(Q->sid, (security_context_t) ctxt_Q, &len);
|
||||
if ( rv ) {
|
||||
free(ctxt_P);
|
||||
free(ctxt_Q);
|
||||
/* error should resurface during printing */
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
else /* calloc() failed */
|
||||
/* error should resurface during printing */
|
||||
free(ctxt_P);
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
rv = strcmp(ctxt_P, ctxt_Q);
|
||||
|
||||
free(ctxt_P);
|
||||
free(ctxt_Q);
|
||||
|
||||
return( rv );
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
/*************************** other stuff ***********************************/
|
||||
|
||||
@@ -981,6 +1122,9 @@ static const format_struct format_array[] = {
|
||||
{"cnswap", "-", pr_nop, sr_cnswap, 1, 0, LNX, RIGHT},
|
||||
{"comm", "COMMAND", pr_comm, sr_nop, 16, 0, U98, UNLIMITED}, /*ucomm*/
|
||||
{"command", "COMMAND", pr_args, sr_nop, 16, 0, XXX, UNLIMITED}, /*args*/
|
||||
#ifdef FLASK_LINUX
|
||||
{"context", "CONTEXT", pr_context, sr_context,40, 0, LNX, LEFT},
|
||||
#endif
|
||||
{"cp", "CP", pr_cp, sr_pcpu, 3, 0, DEC, RIGHT}, /*cpu*/
|
||||
{"cpu", "CPU", pr_nop, sr_nop, 3, 0, BSD, RIGHT}, /* FIXME ... HP-UX wants this as the CPU number for SMP? */
|
||||
{"cputime", "TIME", pr_time, sr_nop, 8, 0, DEC, RIGHT}, /*time*/
|
||||
@@ -1090,6 +1234,9 @@ static const format_struct format_array[] = {
|
||||
{"sched", "SCH", pr_nop, sr_nop, 1, 0, AIX, RIGHT},
|
||||
{"scnt", "SCNT", pr_nop, sr_nop, 4, 0, DEC, RIGHT}, /* man page misspelling of scount? */
|
||||
{"scount", "SC", pr_nop, sr_nop, 4, 0, AIX, RIGHT}, /* scnt==scount, DEC claims both */
|
||||
#ifdef FLASK_LINUX
|
||||
{"secsid", "SID", pr_sid, sr_sid, 6, 0, LNX, RIGHT}, /* Flask Linux */
|
||||
#endif
|
||||
{"sess", "SESS", pr_sess, sr_session, 5, 0, XXX, RIGHT},
|
||||
{"session", "SESS", pr_sess, sr_session, 5, 0, LNX, RIGHT},
|
||||
{"sgi_p", "P", pr_sgi_p, sr_nop, 1, 0, LNX, RIGHT}, /* "cpu" number */
|
||||
@@ -1199,6 +1346,11 @@ static const macro_struct macro_array[] = {
|
||||
|
||||
{"FL5FMT", "f,state,uid,pid,ppid,pcpu,pri,nice,rss,wchan,start,time,command"}, /* Digital -fl */
|
||||
|
||||
#ifdef FLASK_LINUX
|
||||
{"FLASK_context", "pid,secsid,context,command"}, /* Flask Linux context, --context */
|
||||
{"FLASK_sid", "pid,secsid,command"}, /* Flask Linux SID, --SID */
|
||||
#endif
|
||||
|
||||
{"HP_", "pid,tty,time,comm"}, /* HP default */
|
||||
{"HP_f", "user,pid,ppid,cpu,stime,tty,time,args"}, /* HP -f */
|
||||
{"HP_fl", "flags,state,user,pid,ppid,cpu,intpri,nice,addr,sz,wchan,stime,tty,time,args"}, /* HP -fl */
|
||||
|
||||
23
ps/parser.c
23
ps/parser.c
@@ -12,7 +12,9 @@
|
||||
/* Ought to have debug print stuff like this:
|
||||
* #define Print(fmt, args...) printf("Debug: " fmt, ## args)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -724,9 +726,15 @@ static const char *parse_gnu_option(void){
|
||||
gnu_table_struct *found;
|
||||
static const gnu_table_struct gnu_table[] = {
|
||||
{"Group", &&case_Group}, /* rgid */
|
||||
#ifdef FLASK_LINUX
|
||||
{"SID", &&case_secsid},
|
||||
#endif
|
||||
{"User", &&case_User}, /* ruid */
|
||||
{"cols", &&case_cols},
|
||||
{"columns", &&case_columns},
|
||||
#ifdef FLASK_LINUX
|
||||
{"context", &&case_context},
|
||||
#endif
|
||||
{"cumulative", &&case_cumulative},
|
||||
{"deselect", &&case_deselect}, /* -N */
|
||||
{"forest", &&case_forest}, /* f -H */
|
||||
@@ -749,6 +757,9 @@ static const char *parse_gnu_option(void){
|
||||
{"noheadings", &&case_noheadings},
|
||||
{"pid", &&case_pid},
|
||||
{"rows", &&case_rows},
|
||||
#ifdef FLASK_LINUX
|
||||
{"secsid", &&case_secsid},
|
||||
#endif
|
||||
{"sid", &&case_sid},
|
||||
{"sort", &&case_sort},
|
||||
{"tty", &&case_tty},
|
||||
@@ -925,6 +936,16 @@ static const char *parse_gnu_option(void){
|
||||
display_version();
|
||||
exit(0);
|
||||
return NULL;
|
||||
#ifdef FLASK_LINUX
|
||||
case_context:
|
||||
trace("--context\n");
|
||||
format_flags |= FF_Fc;
|
||||
return NULL;
|
||||
case_secsid:
|
||||
trace("--secsid\n");
|
||||
format_flags |= FF_Fs;
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*************** process trailing PIDs **********************/
|
||||
|
||||
5
ps/ps.1
5
ps/ps.1
@@ -95,6 +95,9 @@ s display signal format
|
||||
u display user-oriented format
|
||||
v display virtual memory format
|
||||
--format user-defined format
|
||||
--context (SELinux only) Display security context format; implies --SID
|
||||
--secsid (SELinux only) Display Security ID (SID)
|
||||
--SID (SELinux only) Display Security ID (SID)
|
||||
|
||||
OUTPUT MODIFIERS
|
||||
-H show process hierarchy (forest)
|
||||
@@ -323,6 +326,7 @@ caught CAUGHT
|
||||
cmd CMD
|
||||
comm COMMAND
|
||||
command COMMAND
|
||||
context CONTEXT
|
||||
cputime TIME
|
||||
drs DRS
|
||||
dsiz DSIZ
|
||||
@@ -380,6 +384,7 @@ rsz RSZ
|
||||
ruid RUID
|
||||
ruser RUSER
|
||||
s S
|
||||
secsid SECSID
|
||||
sess SESS
|
||||
session SESS
|
||||
sgi_p P
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -797,6 +800,10 @@ const char *process_sf_options(int localbroken){
|
||||
/* These are old Linux options. Option m is overloaded. */
|
||||
case FF_LX: spec="OL_X"; break;
|
||||
case FF_Lm: spec="OL_m"; break;
|
||||
#ifdef FLASK_LINUX
|
||||
case FF_Fc: spec="FLASK_context"; break;
|
||||
case FF_Fs: spec="FLASK_sid"; break;
|
||||
#endif
|
||||
|
||||
} /* end switch(format_flags) */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user