Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Sep 2002 17:40:06 -0700 (PDT)
From:      Juan Salaverria <rael@vectorstar.net>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: misc/41817: pw groupshow doesn't include the login group
Message-ID:  <200209050040.g850e646069249@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR misc/41817; it has been noted by GNATS.

From: Juan Salaverria <rael@vectorstar.net>
To: "freebsd-gnats-submit@FreeBSD.org" <freebsd-gnats-submit@FreeBSD.org>
Cc:  
Subject: Re: misc/41817: pw groupshow doesn't include the login group
Date: 04 Sep 2002 21:53:22 -0300

 Hi, I found some problems in the patch with white spaces.
 Here's the same patch with those problems fixed.
 
 Thanks
 
 Juan
 
 --- usr.sbin/pw/pw_group.c.ori	Wed Sep  4 21:24:49 2002
 +++ usr.sbin/pw/pw_group.c	Wed Sep  4 21:35:38 2002
 @@ -37,7 +37,7 @@
  #include "pw.h"
  #include "bitmap.h"
  
 -
 +static int     chk_usrname(char ** mem, char * usr);
  static int      print_group(struct group * grp, int pretty);
  static gid_t    gr_gidpolicy(struct userconf * cnf, struct cargs * args);
  
 @@ -51,6 +51,12 @@
  	struct group   *grp = NULL;
  	int	        grmembers = 0;
  	char           **members = NULL;
 +	int            pwmembers = 0;
 +	int            idx = 0;
 +	int            idx_gr_mem = 0;
 +	int            last_gr_mem= 0;
 +	struct passwd   *usr_pass=NULL;
 +	char           **pass_mem= NULL;
  
  	static struct group fakegroup =
  	{
 @@ -94,6 +100,33 @@
  		}
  	}
  	grp = (a_name != NULL) ? GETGRNAM(a_name->val) : GETGRGID((gid_t) atoi(a_gid->val));
 + 
 +	/* This is to take care of the initial groups defined in the passwd file */
 +	if (grp != NULL) {
 +		extendarray(&pass_mem, &pwmembers, 200);
 +		while (grp->gr_mem[idx] != NULL) ++idx;
 +		last_gr_mem = idx;
 +
 +		SETPWENT();
 +		idx = 0;
 +		while ((usr_pass= GETPWENT()) != NULL) {
 +
 +			if ( (gid_t) usr_pass->pw_gid == (gid_t) grp->gr_gid ) {
 +				if (extendarray(&pass_mem, &pwmembers, idx + 2) != -1) {
 +					pass_mem[idx] = malloc(strlen(usr_pass->pw_name)+1);
 +					strcpy(pass_mem[idx], usr_pass->pw_name);
 +					if (!chk_usrname(grp->gr_mem, pass_mem[idx])) {
 +						grp->gr_mem[last_gr_mem+idx_gr_mem] = pass_mem[idx];
 +						idx_gr_mem++;
 +					}
 +				idx++;
 +				}
 +			}
 +		}
 +		pass_mem[idx] = NULL;
 +		grp->gr_mem[last_gr_mem+idx_gr_mem] = NULL;
 +		ENDPWENT();
 +	}
  
  	if (mode == M_UPDATE || mode == M_DELETE || mode == M_PRINT) {
  		if (a_name == NULL && grp == NULL)	/* Try harder */
 @@ -350,3 +383,18 @@
  	}
  	return EXIT_SUCCESS;
  }
 + 
 +static int
 +chk_usrname(char ** mem, char * usr)
 +{
 +int u = 0;
 +
 +	while (mem[u] != NULL) {
 +		if(!strcmp(mem[u],usr))
 +			return 1;
 +	u++;
 +	}
 +
 +return 0;
 +}
 +
 
 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209050040.g850e646069249>