From jlh@felucia.tataz.chchile.org  Wed May  5 14:37:40 2010
Return-Path: <jlh@felucia.tataz.chchile.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 28ECF1065670
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  5 May 2010 14:37:40 +0000 (UTC)
	(envelope-from jlh@felucia.tataz.chchile.org)
Received: from smtp5-g21.free.fr (smtp5-g21.free.fr [212.27.42.5])
	by mx1.freebsd.org (Postfix) with ESMTP id C8A1F8FC14
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  5 May 2010 14:37:37 +0000 (UTC)
Received: from smtp5-g21.free.fr (localhost [127.0.0.1])
	by smtp5-g21.free.fr (Postfix) with ESMTP id 6B03FD4805A
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  5 May 2010 16:37:34 +0200 (CEST)
Received: from endor.tataz.chchile.org (tataz.chchile.org [82.233.239.98])
	by smtp5-g21.free.fr (Postfix) with ESMTP
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  5 May 2010 16:37:32 +0200 (CEST)
Received: from felucia.tataz.chchile.org (felucia.tataz.chchile.org [192.168.1.9])
	by endor.tataz.chchile.org (Postfix) with ESMTP id 0C9B733D2B
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  5 May 2010 14:37:32 +0000 (UTC)
Received: by felucia.tataz.chchile.org (Postfix, from userid 1000)
	id DF2D1A17B2; Wed,  5 May 2010 14:37:31 +0000 (UTC)
Message-Id: <20100505143731.DF2D1A17B2@felucia.tataz.chchile.org>
Date: Wed,  5 May 2010 14:37:31 +0000 (UTC)
From: "Jeremie Le Hen" <jeremie@le-hen.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] Grow ps(1) with "gid" and "group" keywords
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         146331
>Category:       bin
>Synopsis:       [patch] Grow ps(1) with "gid" and "group" keywords
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    trasz
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 05 14:40:04 UTC 2010
>Closed-Date:    Tue Jun 14 16:50:40 UTC 2011
>Last-Modified:  Tue Jun 14 17:00:16 UTC 2011
>Originator:     Jeremie Le Hen
>Release:        FreeBSD 9.0-CURRENT
>Organization:
None
>Environment:
System: FreeBSD felucia.tataz.chchile.org 9.0-CURRENT

>Description:
	ps(1) lacks "gid" and "group" keywords to inspect the effective
	group ID of processes.  This small patch implements this.
	I've also added three aliases:
	    egid -> gid
	    egroup -> group
	    euid -> uid
>How-To-Repeat:
>Fix:

--- ps.egid.diff begins here ---
Index: extern.h
===================================================================
RCS file: /mnt/repos/freebsd-cvsroot/src/bin/ps/extern.h,v
retrieving revision 1.40
diff -u -p -u -p -r1.40 extern.h
--- extern.h	17 Mar 2010 22:57:58 -0000	1.40
+++ extern.h	5 May 2010 13:51:43 -0000
@@ -69,11 +69,13 @@ void	 pmem(KINFO *, VARENT *);
 void	 pri(KINFO *, VARENT *);
 void	 printheader(void);
 void	 priorityr(KINFO *, VARENT *);
+void	 egroupname(KINFO *, VARENT *);
 void	 rgroupname(KINFO *, VARENT *);
 void	 runame(KINFO *, VARENT *);
 void	 rvar(KINFO *, VARENT *);
 int	 s_comm(KINFO *);
 int	 s_label(KINFO *);
+int	 s_egroupname(KINFO *);
 int	 s_rgroupname(KINFO *);
 int	 s_runame(KINFO *);
 int	 s_uname(KINFO *);
Index: keyword.c
===================================================================
RCS file: /mnt/repos/freebsd-cvsroot/src/bin/ps/keyword.c,v
retrieving revision 1.82
diff -u -p -u -p -r1.82 keyword.c
--- keyword.c	17 Mar 2010 22:57:58 -0000	1.82
+++ keyword.c	5 May 2010 14:04:21 -0000
@@ -86,12 +86,19 @@ static VAR var[] = {
 	{"cpu", "CPU", NULL, 0, kvar, NULL, 3, KOFF(ki_estcpu), UINT, "d",
 		0},
 	{"cputime", "", "time", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
+	{"egid", "", "gid", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
+	{"egroup", "", "group", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
+	{"euid", "", "uid", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
 	{"emul", "EMUL", NULL, LJUST, emulname, NULL, EMULLEN, 0, CHAR,
 		NULL, 0},
 	{"etime", "ELAPSED", NULL, USER, elapsed, NULL, 12, 0, CHAR, NULL, 0},
 	{"etimes", "ELAPSED", NULL, USER, elapseds, NULL, 12, 0, CHAR, NULL, 0},
 	{"f", "F", NULL, 0, kvar, NULL, 7, KOFF(ki_flag), INT, "x", 0},
 	{"flags", "", "f", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
+	{"gid", "GID", NULL, 0, kvar, NULL, UIDLEN, KOFF(ki_groups),
+		UINT, UIDFMT, 0},
+	{"group", "GROUP", NULL, LJUST|DSIZ, egroupname, s_egroupname,
+	    USERLEN, 0, CHAR, NULL, 0},
 	{"ignored", "", "sigignore", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
 	{"inblk", "INBLK", NULL, USER, rvar, NULL, 4, ROFF(ru_inblock), LONG,
 		"ld", 0},
Index: print.c
===================================================================
RCS file: /mnt/repos/freebsd-cvsroot/src/bin/ps/print.c,v
retrieving revision 1.101
diff -u -p -u -p -r1.101 print.c
--- print.c	17 Mar 2010 22:57:58 -0000	1.101
+++ print.c	5 May 2010 13:53:24 -0000
@@ -340,6 +340,22 @@ s_uname(KINFO *k)
 }
 
 void
+egroupname(KINFO *k, VARENT *ve)
+{
+	VAR *v;
+
+	v = ve->var;
+	(void)printf("%-*s", v->width,
+	    group_from_gid(k->ki_p->ki_groups[0], 0));
+}
+
+int
+s_egroupname(KINFO *k)
+{
+	return (strlen(group_from_gid(k->ki_p->ki_groups[0], 0)));
+}
+
+void
 rgroupname(KINFO *k, VARENT *ve)
 {
 	VAR *v;
Index: ps.1
===================================================================
RCS file: /mnt/repos/freebsd-cvsroot/src/bin/ps/ps.1,v
retrieving revision 1.95
diff -u -p -u -p -r1.95 ps.1
--- ps.1	13 Apr 2010 08:54:53 -0000	1.95
+++ ps.1	5 May 2010 14:27:17 -0000
@@ -489,6 +489,12 @@ elapsed running time, in decimal integer
 .It Cm flags
 the process flags, in hexadecimal (alias
 .Cm f )
+.It Cm gid
+effective group ID (alias
+.Cm egid )
+.It Cm group
+group name (from egid) (alias
+.Cm egroup )
 .It Cm inblk
 total blocks read (alias
 .Cm inblock )
@@ -612,7 +618,8 @@ process pointer
 .It Cm ucomm
 name to be used for accounting
 .It Cm uid
-effective user ID
+effective user ID (alias
+.Cm euid )
 .It Cm upr
 scheduling priority on return from system call (alias
 .Cm usrpri )
--- ps.egid.diff ends here ---


>Release-Note:
>Audit-Trail:

From: Chip Camden <sterling@camdensoftware.com>
To: bug-followup@FreeBSD.org, jeremie@le-hen.org
Cc:  
Subject: Re: bin/146331: [PATCH] Grow ps(1) with "gid" and "group" keywords
Date: Mon, 9 Aug 2010 16:04:54 -0700

 --AhhlLboLdkugWU4S
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 (Bugathon)
 
 For some reason, the patch did not apply cleanly to keyword.c.  I
 couldn't see anything different with it, so I patched that file by hand.  It
 all seems to work except for the 'euid' synonym, for some strange reason.
 
 Tested on 8.1-RELEASE, i386.
 
 --=20
 Sterling (Chip) Camden    | sterling@camdensoftware.com | 2048D/3A978E4F
 http://camdensoftware.com | http://chipstips.com        | http://chipsquips=
 .com
 
 --AhhlLboLdkugWU4S
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.10 (FreeBSD)
 
 iQEcBAEBAgAGBQJMYImWAAoJEIpckszW26+RK28H/A04JdYixm9K0LA4/bc+ZpcH
 r0Wcdlp4JHPPbD+l4ZNeXT9KlQzvOJSuYRBIqTq2B3sSx9eIW/DF+PMLXNamYF3M
 vWutXueldFctPg3g4Qwvc9iTSOcOvH3FUhzRdvUSSygZd2ZbBdDmxeMnhsSktdhv
 4OfK3mqUdoOfFSf1dRVsmD+Nnuc6NeSpdrmEV5OefSyzDUIfjnAhaC4Yto8XjxTF
 5kqhH/cWWu8BjR68gao+xvfMrqjhB4p+n8rsN+Bh18zBUfQbD2+i59C2mJ7Mmb4Z
 9q+426txrVPQvr3H8N7i/ZRW/zgCov12t9AHncH0ZJePKCKtMCC1SMTm9XSBs/8=
 =6E6T
 -----END PGP SIGNATURE-----
 
 --AhhlLboLdkugWU4S--

From: Jeremie Le Hen <jeremie@le-hen.org>
To: Chip Camden <sterling@camdensoftware.com>
Cc: bug-followup@FreeBSD.org, jeremie@le-hen.org
Subject: Re: bin/146331: [PATCH] Grow ps(1) with "gid" and "group" keywords
Date: Tue, 10 Aug 2010 09:19:14 +0200

 --jI8keyz6grp/JLjh
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Hi Chip,
 
 Thanks for looking at this patch.
 
 On Mon, Aug 09, 2010 at 04:04:54PM -0700, Chip Camden wrote:
 > (Bugathon)
 > 
 > For some reason, the patch did not apply cleanly to keyword.c.  I
 > couldn't see anything different with it, so I patched that file by hand.  It
 > all seems to work except for the 'euid' synonym, for some strange reason.
 > 
 > Tested on 8.1-RELEASE, i386.
 
 This patch is against -CURRENT.  I will willingly create a patch against
 RELENG_8 and RELENG_7 for the MFC if this finally gets commited.
 
 I can confirm that "euid" did't work.  I've attached a corrected
 patch.  The problem was that the list was not alphabetically sorted.
 
 Regards,
 -- 
 Jeremie Le Hen
 
 Humans are born free and equal.  But some are more equal than others.
 					    Coluche
 
 --jI8keyz6grp/JLjh
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="ps.egid.diff"
 
 Index: extern.h
 ===================================================================
 RCS file: /mnt/repos/freebsd-cvsroot/src/bin/ps/extern.h,v
 retrieving revision 1.40
 diff -u -p -u -p -r1.40 extern.h
 --- extern.h	17 Mar 2010 22:57:58 -0000	1.40
 +++ extern.h	5 May 2010 13:51:43 -0000
 @@ -69,11 +69,13 @@ void	 pmem(KINFO *, VARENT *);
  void	 pri(KINFO *, VARENT *);
  void	 printheader(void);
  void	 priorityr(KINFO *, VARENT *);
 +void	 egroupname(KINFO *, VARENT *);
  void	 rgroupname(KINFO *, VARENT *);
  void	 runame(KINFO *, VARENT *);
  void	 rvar(KINFO *, VARENT *);
  int	 s_comm(KINFO *);
  int	 s_label(KINFO *);
 +int	 s_egroupname(KINFO *);
  int	 s_rgroupname(KINFO *);
  int	 s_runame(KINFO *);
  int	 s_uname(KINFO *);
 Index: keyword.c
 ===================================================================
 RCS file: /mnt/repos/freebsd-cvsroot/src/bin/ps/keyword.c,v
 retrieving revision 1.83
 diff -u -p -u -p -r1.83 keyword.c
 --- keyword.c	24 Jul 2010 15:37:36 -0000	1.83
 +++ keyword.c	10 Aug 2010 07:16:00 -0000
 @@ -86,12 +86,19 @@ static VAR var[] = {
  	{"cpu", "CPU", NULL, 0, kvar, NULL, 3, KOFF(ki_estcpu), UINT, "d",
  		0},
  	{"cputime", "", "time", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
 +	{"egid", "", "gid", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
 +	{"egroup", "", "group", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
  	{"emul", "EMUL", NULL, LJUST, emulname, NULL, EMULLEN, 0, CHAR,
  		NULL, 0},
  	{"etime", "ELAPSED", NULL, USER, elapsed, NULL, 12, 0, CHAR, NULL, 0},
  	{"etimes", "ELAPSED", NULL, USER, elapseds, NULL, 12, 0, CHAR, NULL, 0},
 +	{"euid", "", "uid", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
  	{"f", "F", NULL, 0, kvar, NULL, 8, KOFF(ki_flag), INT, "x", 0},
  	{"flags", "", "f", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
 +	{"gid", "GID", NULL, 0, kvar, NULL, UIDLEN, KOFF(ki_groups),
 +		UINT, UIDFMT, 0},
 +	{"group", "GROUP", NULL, LJUST|DSIZ, egroupname, s_egroupname,
 +	    USERLEN, 0, CHAR, NULL, 0},
  	{"ignored", "", "sigignore", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
  	{"inblk", "INBLK", NULL, USER, rvar, NULL, 4, ROFF(ru_inblock), LONG,
  		"ld", 0},
 Index: print.c
 ===================================================================
 RCS file: /mnt/repos/freebsd-cvsroot/src/bin/ps/print.c,v
 retrieving revision 1.101
 diff -u -p -u -p -r1.101 print.c
 --- print.c	17 Mar 2010 22:57:58 -0000	1.101
 +++ print.c	5 May 2010 13:53:24 -0000
 @@ -340,6 +340,22 @@ s_uname(KINFO *k)
  }
  
  void
 +egroupname(KINFO *k, VARENT *ve)
 +{
 +	VAR *v;
 +
 +	v = ve->var;
 +	(void)printf("%-*s", v->width,
 +	    group_from_gid(k->ki_p->ki_groups[0], 0));
 +}
 +
 +int
 +s_egroupname(KINFO *k)
 +{
 +	return (strlen(group_from_gid(k->ki_p->ki_groups[0], 0)));
 +}
 +
 +void
  rgroupname(KINFO *k, VARENT *ve)
  {
  	VAR *v;
 Index: ps.1
 ===================================================================
 RCS file: /mnt/repos/freebsd-cvsroot/src/bin/ps/ps.1,v
 retrieving revision 1.96
 diff -u -p -u -p -r1.96 ps.1
 --- ps.1	24 Jul 2010 15:24:12 -0000	1.96
 +++ ps.1	10 Aug 2010 06:59:42 -0000
 @@ -490,6 +490,12 @@ elapsed running time, in decimal integer
  .It Cm flags
  the process flags, in hexadecimal (alias
  .Cm f )
 +.It Cm gid
 +effective group ID (alias
 +.Cm egid )
 +.It Cm group
 +group name (from egid) (alias
 +.Cm egroup )
  .It Cm inblk
  total blocks read (alias
  .Cm inblock )
 @@ -613,7 +619,8 @@ process pointer
  .It Cm ucomm
  name to be used for accounting
  .It Cm uid
 -effective user ID
 +effective user ID (alias
 +.Cm euid )
  .It Cm upr
  scheduling priority on return from system call (alias
  .Cm usrpri )
 
 --jI8keyz6grp/JLjh--
Responsible-Changed-From-To: freebsd-bugs->trasz 
Responsible-Changed-By: trasz 
Responsible-Changed-When: Tue Jun 14 16:33:14 UTC 2011 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=146331 
State-Changed-From-To: open->closed 
State-Changed-By: trasz 
State-Changed-When: Tue Jun 14 16:50:39 UTC 2011 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=146331 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/146331: commit references a PR
Date: Tue, 14 Jun 2011 16:50:31 +0000 (UTC)

 Author: trasz
 Date: Tue Jun 14 16:50:16 2011
 New Revision: 223086
 URL: http://svn.freebsd.org/changeset/base/223086
 
 Log:
   Add "gid" and "group" keywords to display the effective group ID
   and effective group name.  Also, add "egid", "egroup" and "euid" aliases.
   
   PR:		bin/146331
   Submitted by:	Jeremie Le Hen <jeremie at le-hen dot org>
 
 Modified:
   head/bin/ps/extern.h
   head/bin/ps/keyword.c
   head/bin/ps/print.c
   head/bin/ps/ps.1
 
 Modified: head/bin/ps/extern.h
 ==============================================================================
 --- head/bin/ps/extern.h	Tue Jun 14 16:29:43 2011	(r223085)
 +++ head/bin/ps/extern.h	Tue Jun 14 16:50:16 2011	(r223086)
 @@ -70,6 +70,7 @@ void	 pmem(KINFO *, VARENT *);
  void	 pri(KINFO *, VARENT *);
  void	 printheader(void);
  void	 priorityr(KINFO *, VARENT *);
 +void	 egroupname(KINFO *, VARENT *);
  void	 rgroupname(KINFO *, VARENT *);
  void	 runame(KINFO *, VARENT *);
  void	 rvar(KINFO *, VARENT *);
 @@ -78,6 +79,7 @@ int	 s_cputime(KINFO *);
  int	 s_label(KINFO *);
  int	 s_loginclass(KINFO *);
  int	 s_logname(KINFO *);
 +int	 s_egroupname(KINFO *);
  int	 s_rgroupname(KINFO *);
  int	 s_runame(KINFO *);
  int	 s_systime(KINFO *);
 
 Modified: head/bin/ps/keyword.c
 ==============================================================================
 --- head/bin/ps/keyword.c	Tue Jun 14 16:29:43 2011	(r223085)
 +++ head/bin/ps/keyword.c	Tue Jun 14 16:50:16 2011	(r223086)
 @@ -88,12 +88,19 @@ static VAR var[] = {
  	{"cpu", "CPU", NULL, 0, kvar, NULL, 3, KOFF(ki_estcpu), UINT, "d",
  		0},
  	{"cputime", "", "time", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
 +	{"egid", "", "gid", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
 +	{"egroup", "", "group", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
  	{"emul", "EMUL", NULL, LJUST, emulname, NULL, EMULLEN, 0, CHAR,
  		NULL, 0},
  	{"etime", "ELAPSED", NULL, USER, elapsed, NULL, 12, 0, CHAR, NULL, 0},
  	{"etimes", "ELAPSED", NULL, USER, elapseds, NULL, 12, 0, CHAR, NULL, 0},
 +	{"euid", "", "uid", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
  	{"f", "F", NULL, 0, kvar, NULL, 8, KOFF(ki_flag), INT, "x", 0},
  	{"flags", "", "f", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
 +	{"gid", "GID", NULL, 0, kvar, NULL, UIDLEN, KOFF(ki_groups),
 +		UINT, UIDFMT, 0},
 +	{"group", "GROUP", NULL, LJUST, egroupname, s_egroupname,
 +	    USERLEN, 0, CHAR, NULL, 0},
  	{"ignored", "", "sigignore", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
  	{"inblk", "INBLK", NULL, USER, rvar, NULL, 4, ROFF(ru_inblock), LONG,
  		"ld", 0},
 
 Modified: head/bin/ps/print.c
 ==============================================================================
 --- head/bin/ps/print.c	Tue Jun 14 16:29:43 2011	(r223085)
 +++ head/bin/ps/print.c	Tue Jun 14 16:50:16 2011	(r223086)
 @@ -341,6 +341,22 @@ s_uname(KINFO *k)
  }
  
  void
 +egroupname(KINFO *k, VARENT *ve)
 +{
 +	VAR *v;
 +
 +	v = ve->var;
 +	(void)printf("%-*s", v->width,
 +	    group_from_gid(k->ki_p->ki_groups[0], 0));
 +}
 +
 +int
 +s_egroupname(KINFO *k)
 +{
 +	return (strlen(group_from_gid(k->ki_p->ki_groups[0], 0)));
 +}
 +
 +void
  rgroupname(KINFO *k, VARENT *ve)
  {
  	VAR *v;
 
 Modified: head/bin/ps/ps.1
 ==============================================================================
 --- head/bin/ps/ps.1	Tue Jun 14 16:29:43 2011	(r223085)
 +++ head/bin/ps/ps.1	Tue Jun 14 16:50:16 2011	(r223086)
 @@ -29,7 +29,7 @@
  .\"     @(#)ps.1	8.3 (Berkeley) 4/18/94
  .\" $FreeBSD$
  .\"
 -.Dd April 18, 2011
 +.Dd June 14, 2011
  .Dt PS 1
  .Os
  .Sh NAME
 @@ -502,6 +502,12 @@ elapsed running time, in decimal integer
  .It Cm flags
  the process flags, in hexadecimal (alias
  .Cm f )
 +.It Cm gid
 +effective group ID (alias
 +.Cm egid )
 +.It Cm group
 +group name (from egid) (alias
 +.Cm egroup )
  .It Cm inblk
  total blocks read (alias
  .Cm inblock )
 @@ -629,7 +635,8 @@ process pointer
  .It Cm ucomm
  name to be used for accounting
  .It Cm uid
 -effective user ID
 +effective user ID (alias
 +.Cm euid )
  .It Cm upr
  scheduling priority on return from system call (alias
  .Cm usrpri )
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
