summaryrefslogtreecommitdiffstats
path: root/usr.bin/procstat
diff options
context:
space:
mode:
authortrociny <trociny@FreeBSD.org>2012-02-26 14:27:34 +0000
committertrociny <trociny@FreeBSD.org>2012-02-26 14:27:34 +0000
commitb0cce2b35e7aed27791acc5e5a4e462830714425 (patch)
treece4ceb053b8dcf58d14f28222e37e74e9c168ac3 /usr.bin/procstat
parenta9902044d13d86ba035c143f8484325fc569be5c (diff)
downloadFreeBSD-src-b0cce2b35e7aed27791acc5e5a4e462830714425.zip
FreeBSD-src-b0cce2b35e7aed27791acc5e5a4e462830714425.tar.gz
When displaying security credential information show also process umask.
Submitted by: Dmitry Banschikov <me ubique spb ru> Discussed with: rwatson MFC after: 2 weeks
Diffstat (limited to 'usr.bin/procstat')
-rw-r--r--usr.bin/procstat/procstat_cred.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/usr.bin/procstat/procstat_cred.c b/usr.bin/procstat/procstat_cred.c
index 12db429..250747d 100644
--- a/usr.bin/procstat/procstat_cred.c
+++ b/usr.bin/procstat/procstat_cred.c
@@ -38,6 +38,8 @@
#include "procstat.h"
+static const char *get_umask(struct kinfo_proc *kipp);
+
void
procstat_cred(struct kinfo_proc *kipp)
{
@@ -48,9 +50,9 @@ procstat_cred(struct kinfo_proc *kipp)
gid_t *groups = NULL;
if (!hflag)
- printf("%5s %-16s %5s %5s %5s %5s %5s %5s %5s %-15s\n", "PID",
- "COMM", "EUID", "RUID", "SVUID", "EGID", "RGID", "SVGID",
- "FLAGS", "GROUPS");
+ printf("%5s %-16s %5s %5s %5s %5s %5s %5s %5s %5s %-15s\n",
+ "PID", "COMM", "EUID", "RUID", "SVUID", "EGID", "RGID",
+ "SVGID", "UMASK", "FLAGS", "GROUPS");
printf("%5d ", kipp->ki_pid);
printf("%-16s ", kipp->ki_comm);
@@ -60,6 +62,7 @@ procstat_cred(struct kinfo_proc *kipp)
printf("%5d ", kipp->ki_groups[0]);
printf("%5d ", kipp->ki_rgid);
printf("%5d ", kipp->ki_svgid);
+ printf("%5s ", get_umask(kipp));
printf("%s", kipp->ki_cr_flags & CRED_FLAG_CAPMODE ? "C" : "-");
printf(" ");
@@ -98,3 +101,26 @@ procstat_cred(struct kinfo_proc *kipp)
printf("\n");
}
+
+static const char *
+get_umask(struct kinfo_proc *kipp)
+{
+ int error;
+ int mib[4];
+ size_t len;
+ u_short fd_cmask;
+ static char umask[4];
+
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_UMASK;
+ mib[3] = kipp->ki_pid;
+ len = sizeof(fd_cmask);
+ error = sysctl(mib, 4, &fd_cmask, &len, NULL, 0);
+ if (error == 0) {
+ snprintf(umask, 4, "%03o", fd_cmask);
+ return (umask);
+ } else {
+ return ("-");
+ }
+}
OpenPOWER on IntegriCloud