diff options
author | rwatson <rwatson@FreeBSD.org> | 2002-10-24 00:00:57 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2002-10-24 00:00:57 +0000 |
commit | c1f79de8c7e95092759b8bf882668ce50bc83a7c (patch) | |
tree | affb696135e5bafb9ef35aa4bddc59b5f810ab27 /bin/ps/print.c | |
parent | f39fb18da2b62bda9a9ba207ddb60f83ec48c7e9 (diff) | |
download | FreeBSD-src-c1f79de8c7e95092759b8bf882668ce50bc83a7c.zip FreeBSD-src-c1f79de8c7e95092759b8bf882668ce50bc83a7c.tar.gz |
Use the MAC interface to list process MAC labels rather than using
the LOMAC-specific interface (which is being deprecated). The
revised LOMAC using the MAC framework will export levels listable
using this mechanism.
Approved by: re
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
Diffstat (limited to 'bin/ps/print.c')
-rw-r--r-- | bin/ps/print.c | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c index 3fd367a..31a857b 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include <sys/proc.h> #include <sys/stat.h> +#include <sys/mac.h> #include <sys/user.h> #include <sys/sysctl.h> @@ -62,7 +63,6 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include <vis.h> -#include "lomac.h" #include "ps.h" #define ps_pgtok(a) (((a) * getpagesize()) / 1024) @@ -726,10 +726,53 @@ rvar(KINFO *k, VARENT *ve) } void -lattr(KINFO *k, VARENT *ve) +label(KINFO *k, VARENT *ve) { + char *string; + mac_t label; + int error; VAR *v; v = ve->var; - (void)printf("%-*d", v->width, get_lattr(k->ki_p->ki_pid)); + string = NULL; + + if (mac_prepare_process_label(&label) == -1) { + perror("mac_prepare_process_label"); + goto out; + } + + error = mac_get_pid(k->ki_p->ki_pid, label); + if (error == 0) { + if (mac_to_text(label, &string) == -1) + string = NULL; + } + mac_free(label); + +out: + if (string != NULL) { + (void)printf("%-*s", v->width, string); + free(string); + } else + (void)printf("%-*s", v->width, ""); + return; +} + +int +s_label(KINFO *k) +{ + char *string = NULL; + mac_t label; + int error, size = 0; + + if (mac_prepare_process_label(&label) == -1) { + perror("mac_prepare_process_label"); + return (0); + } + error = mac_get_pid(k->ki_p->ki_pid, label); + if (error == 0 && mac_to_text(label, &string) == 0) { + size = strlen(string); + free(string); + } + mac_free(label); + return (size); } |