From owner-svn-src-all@FreeBSD.ORG Mon Apr 2 19:17:02 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7AC3C1065670; Mon, 2 Apr 2012 19:17:02 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4BFB18FC0A; Mon, 2 Apr 2012 19:17:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q32JH2kL012952; Mon, 2 Apr 2012 19:17:02 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q32JH26q012950; Mon, 2 Apr 2012 19:17:02 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201204021917.q32JH26q012950@svn.freebsd.org> From: Mikolaj Golub Date: Mon, 2 Apr 2012 19:17:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r233807 - stable/9/usr.bin/procstat X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2012 19:17:02 -0000 Author: trociny Date: Mon Apr 2 19:17:01 2012 New Revision: 233807 URL: http://svn.freebsd.org/changeset/base/233807 Log: MFC r232182: When displaying security credential information show also process umask. Submitted by: Dmitry Banschikov Discussed with: rwatson Modified: stable/9/usr.bin/procstat/procstat_cred.c Directory Properties: stable/9/usr.bin/procstat/ (props changed) Modified: stable/9/usr.bin/procstat/procstat_cred.c ============================================================================== --- stable/9/usr.bin/procstat/procstat_cred.c Mon Apr 2 19:15:32 2012 (r233806) +++ stable/9/usr.bin/procstat/procstat_cred.c Mon Apr 2 19:17:01 2012 (r233807) @@ -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 ("-"); + } +}