Print this page
4078 groupadd execs getent unnecessarily
Reviewed by: Rich Lowe <richlowe@richlowe.net>
Reviewed by: Gary Mills <gary_mills@fastmail.fm>
Reviewed by: Milan Jurik <milan.jurik@xylab.cz>
Reviewed by: Gordon Ross <Gordon.W.Ross@gmail.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/oamuser/group/groupadd.c
          +++ new/usr/src/cmd/oamuser/group/groupadd.c
↓ open down ↓ 19 lines elided ↑ open up ↑
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23   23   * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27   27  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  28   28  /*        All Rights Reserved   */
  29   29  
  30      -
  31      -#pragma ident   "%Z%%M% %I%     %E% SMI"
       30 +/*
       31 + * Copyright (c) 2013 RackTop Systems.
       32 + */
  32   33  
  33   34  #include        <sys/types.h>
       35 +#include        <sys/param.h>
  34   36  #include        <stdio.h>
  35   37  #include        <stdlib.h>
  36   38  #include        <ctype.h>
  37   39  #include        <limits.h>
  38   40  #include        <userdefs.h>
  39   41  #include        <users.h>
  40   42  #include        <errno.h>
       43 +#include        <libcmdutils.h>
  41   44  #include        "messages.h"
  42   45  
  43   46  extern int errmsg();
  44      -extern gid_t findnextgid();
  45   47  extern int valid_gid(), add_group();
  46   48  
  47   49  /*
  48   50   *  groupadd [-g gid [-o]] group
  49   51   *
  50   52   *      This command adds new groups to the system.  Arguments are:
  51   53   *
  52   54   *      gid - a gid_t less than MAXUID
  53   55   *      group - a string of printable characters excluding colon(:) and less
  54   56   *              than MAXGLEN characters long.
↓ open down ↓ 74 lines elided ↑ open up ↑
 129  131                          exit(EX_BADARG);
 130  132  
 131  133                  case TOOBIG:
 132  134                          errmsg(M_TOOBIG, gid);
 133  135                          exit(EX_BADARG);
 134  136  
 135  137                  }
 136  138  
 137  139          } else {
 138  140  
 139      -                if ((gid = findnextgid()) < 0) {
      141 +                if (findnextgid(DEFRID+1, MAXUID, &gid) != 0) {
 140  142                          errmsg(M_GID_INVALID, "default id");
 141  143                          exit(EX_ID_EXISTS);
 142  144                  }
 143  145  
 144  146          }
 145  147  
 146  148          if ((rc = add_group(grpname, gid)) != EX_SUCCESS)
 147  149                  errmsg(M_UPDATE, "created");
 148  150  
 149  151          return (rc);
 150  152  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX