NetBSD Problem Report #11223

Received: (qmail 10382 invoked from network); 14 Oct 2000 16:35:39 -0000
Message-Id: <Pine.SOL.4.21.0010141731310.3055-100000@draco.cus.cam.ac.uk>
Date: Sat, 14 Oct 2000 17:35:35 +0100 (BST)
From: Ben Harris <bjh21@netbsd.org>
Sender: Ben Harris <bjh21@cus.cam.ac.uk>
To: gnats-bugs@gnats.netbsd.org
Subject: POSIX.2: ps -G <grouplist> not supported

>Number:         11223
>Category:       standards
>Synopsis:       POSIX.2: ps -G <grouplist> not supported
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    simonb
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 14 16:36:00 +0000 2000
>Closed-Date:    
>Last-Modified:  Thu Mar 13 19:41:01 +0000 2003
>Originator:     Ben Harris
>Release:        2000-02-07
>Organization:
>Environment:
NetBSD cromarty 1.4X NetBSD 1.4X (CROMARTY) #9: Wed May  3 23:49:51 BST 2000
     bjh21@cromarty:/usr/src/sys/arch/macppc/compile/CROMARTY macppc

>Description:
According to POSIX.2, ps should take a -G <grouplist> argument to allow
selection of processes by real group ID.  NetBSD's doesn't.

>How-To-Repeat:
cromarty:~$ ps -G bjh21
ps: illegal option -- G
usage:  ps [-aChjKlmrSTuvwx] [-O|o fmt] [-p pid] [-t tty]
           [-M core] [-N system] [-W swap] [-U username]
        ps [-L]

>Fix:

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: standards-manager->simonb 
Responsible-Changed-By: simonb 
Responsible-Changed-When: Sat Oct 14 18:18:35 PDT 2000 
Responsible-Changed-Why:  
I'll take care of this one. 

From: Jonathan Perkin <sketch@rd.bbc.co.uk>
To: gnats-bugs@gnats.netbsd.org
Cc: simonb@netbsd.org, bjh21@netbsd.org
Subject: Re: standards/11223: POSIX.2: ps -G <grouplist> not supported
Date: Thu, 13 Mar 2003 19:31:53 +0000

 This patch adds support for a single group argument (as per -U allowing
 single user argument).  Supporting proper POSIX.2 user/group lists can
 be done if you wish.

 Also at http://www.perkin.org.uk/projects/netbsd/ps.patch

 Index: ps.1
 ===================================================================
 RCS file: /cvsroot/src/bin/ps/ps.1,v
 retrieving revision 1.60
 diff -u -r1.60 ps.1
 --- ps.1	2003/03/06 09:04:21	1.60
 +++ ps.1	2003/03/13 19:22:46
 @@ -67,6 +67,9 @@
  .Op Fl U Ar username
  .Ek
  .Bk -words
 +.Op Fl G Ar groupname
 +.Ek
 +.Bk -words
  .Op Fl W Ar swap
  .Ek
  .Nm
 @@ -195,6 +198,11 @@
  Displays processes belonging to the user whose username or uid has
  been given to the
  .Fl U
 +switch.
 +.It Fl G
 +Displays processes belonging to the users whose groupname or gid has
 +been given to the
 +.Fl G
  switch.
  .It Fl u
  Display information associated with the following keywords:
 Index: ps.c
 ===================================================================
 RCS file: /cvsroot/src/bin/ps/ps.c,v
 retrieving revision 1.49
 diff -u -r1.49 ps.c
 --- ps.c	2003/03/06 09:02:16	1.49
 +++ ps.c	2003/03/13 19:22:46
 @@ -98,6 +98,7 @@
  #include <err.h>
  #include <errno.h>
  #include <fcntl.h>
 +#include <grp.h>
  #include <kvm.h>
  #include <limits.h>
  #include <nlist.h>
 @@ -114,8 +115,8 @@
   * ARGOPTS must contain all option characters that take arguments
   * (except for 't'!) - it is used in kludge_oldps_options()
   */
 -#define	GETOPTSTR	"acCeghjk:LlM:mN:O:o:p:rSsTt:U:uvW:wx"
 -#define	ARGOPTS		"kMNOopUW"
 +#define	GETOPTSTR	"acCegG:hjk:LlM:mN:O:o:p:rSsTt:U:uvW:wx"
 +#define	ARGOPTS		"GkMNOopUW"

  struct kinfo_proc2 *kinfo;
  struct varent *vhead, *sorthead;
 @@ -197,6 +198,25 @@
  			break;
  		case 'g':
  			break;			/* no-op */
 +		case 'G':
 +			if (*optarg != '\0') {
 +				struct group *gr;
 +				char *ep;
 +
 +				what = KERN_PROC_GID;
 +				gr = getgrnam(optarg);
 +				if (gr == NULL) {
 +					errno = 0;
 +					flag = strtoul(optarg, &ep, 10);
 +					if (errno)
 +						err(1, "%s", optarg);
 +					if (*ep != '\0')
 +						errx(1, "%s: illegal group",
 +						    optarg);
 +				} else
 +					flag = gr->gr_gid;
 +			}
 +			break;
  		case 'h':
  			prtheader = ws.ws_row > 5 ? ws.ws_row : 22;
  			break;
 @@ -736,7 +756,7 @@
  	(void)fprintf(stderr,
  	    "usage:\t%s\n\t   %s\n\t%s\n",
  	    "ps [-acCehjlmrsSTuvwx] [-k key] [-O|o fmt] [-p pid] [-t tty]",
 -	    "[-M core] [-N system] [-W swap] [-U username]",
 +	    "[-M core] [-N system] [-W swap] [-U username] [-G groupname]",
  	    "ps [-L]");
  	exit(1);
  	/* NOTREACHED */

 -- 
 Jonathan Perkin - Internet Operations Engineer - BBC Internet Services
 24x7 Hotline: +44 (0)1628 407 777 (x37777) - http://support.bbc.co.uk/
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.