Print this page
Remove include userdefs.h where not needed


  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  27 /*        All Rights Reserved   */
  28 
  29 /*
  30  * Copyright (c) 2013 RackTop Systems.
  31  */
  32 
  33 #include <errno.h>
  34 #include <sys/types.h>
  35 #include <stdio.h>
  36 #include <userdefs.h>
  37 #include <grp.h>
  38 #include <libcmdutils.h>
  39 
  40 static int findunusedgid(gid_t start, gid_t stop, gid_t *ret);
  41 static boolean_t isreservedgid(gid_t gid);
  42 
  43 /*
  44  * Find the highest unused uid. If the highest unused gid is "stop",
  45  * then attempt to find a hole in the range. Returns 0 on success.
  46  */
  47 int
  48 findnextgid(gid_t start, gid_t stop, gid_t *ret)
  49 {
  50         gid_t gid = start;
  51         struct group *grp;
  52         boolean_t overflow = B_FALSE;
  53 
  54         setgrent();
  55         for (grp = getgrent(); grp != NULL; grp = getgrent()) {
  56                 if (isreservedgid(grp->gr_gid))              /* Skip reserved IDs */




  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  27 /*        All Rights Reserved   */
  28 
  29 /*
  30  * Copyright (c) 2013 RackTop Systems.
  31  */
  32 
  33 #include <errno.h>
  34 #include <sys/types.h>
  35 #include <stdio.h>

  36 #include <grp.h>
  37 #include <libcmdutils.h>
  38 
  39 static int findunusedgid(gid_t start, gid_t stop, gid_t *ret);
  40 static boolean_t isreservedgid(gid_t gid);
  41 
  42 /*
  43  * Find the highest unused uid. If the highest unused gid is "stop",
  44  * then attempt to find a hole in the range. Returns 0 on success.
  45  */
  46 int
  47 findnextgid(gid_t start, gid_t stop, gid_t *ret)
  48 {
  49         gid_t gid = start;
  50         struct group *grp;
  51         boolean_t overflow = B_FALSE;
  52 
  53         setgrent();
  54         for (grp = getgrent(); grp != NULL; grp = getgrent()) {
  55                 if (isreservedgid(grp->gr_gid))              /* Skip reserved IDs */