Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Jul 2015 23:56:56 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r285414 - head/usr.sbin/pw
Message-ID:  <201507112356.t6BNuuqj096188@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Sat Jul 11 23:56:55 2015
New Revision: 285414
URL: https://svnweb.freebsd.org/changeset/base/285414

Log:
  Fix regression: ensure when try to create the group and the user with the same
  id if possible and nothing in particular was specified

Modified:
  head/usr.sbin/pw/pw_user.c

Modified: head/usr.sbin/pw/pw_user.c
==============================================================================
--- head/usr.sbin/pw/pw_user.c	Sat Jul 11 23:17:13 2015	(r285413)
+++ head/usr.sbin/pw/pw_user.c	Sat Jul 11 23:56:55 2015	(r285414)
@@ -875,7 +875,7 @@ pw_gidpolicy(struct cargs * args, char *
 		gid = grp->gr_gid;  /* Already created? Use it anyway... */
 	} else {
 		struct cargs    grpargs;
-		char            tmp[32];
+		gid_t		grid = -1;
 
 		LIST_INIT(&grpargs);
 
@@ -888,23 +888,15 @@ pw_gidpolicy(struct cargs * args, char *
 		 * user's name dups an existing group, then the group add
 		 * function will happily handle that case for us and exit.
 		 */
-		if (GETGRGID(prefer) == NULL) {
-			snprintf(tmp, sizeof(tmp), "%u", prefer);
-			addarg(&grpargs, 'g', tmp);
-		}
+		if (GETGRGID(prefer) == NULL)
+			grid = prefer;
 		if (conf.dryrun) {
 			gid = pw_groupnext(cnf, true);
 		} else {
-			pw_group(M_ADD, nam, -1, &grpargs);
+			pw_group(M_ADD, nam, grid, &grpargs);
 			if ((grp = GETGRNAM(nam)) != NULL)
 				gid = grp->gr_gid;
 		}
-		a_gid = LIST_FIRST(&grpargs);
-		while (a_gid != NULL) {
-			struct carg    *t = LIST_NEXT(a_gid, list);
-			LIST_REMOVE(a_gid, list);
-			a_gid = t;
-		}
 	}
 	ENDGRENT();
 	return gid;



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