Print this page
2989 Eliminate use of LOGNAME_MAX in ON
1166 useradd have warning with name more 8 chars

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/pwck/pwck.c
          +++ new/usr/src/cmd/pwck/pwck.c
↓ open down ↓ 11 lines elided ↑ open up ↑
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
       22 + * Copyright (c) 2013 Gary Mills
       23 + *
  22   24   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  23   25   * Use is subject to license terms.
  24   26   */
  25   27  
  26   28  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  27   29  /*        All Rights Reserved   */
  28   30  
  29   31  
  30      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  31      -
  32   32  #include <sys/types.h>
  33   33  #include <sys/param.h>
  34   34  #include <sys/signal.h>
  35   35  #include <sys/sysmacros.h>
  36   36  #include <sys/stat.h>
  37   37  #include <stdio.h>
  38   38  #include <stdlib.h>
  39   39  #include <string.h>
  40   40  #include <ctype.h>
  41   41  #include <locale.h>
  42   42  #include <errno.h>
  43   43  #include <unistd.h>
       44 +#include <limits.h>
  44   45  
  45   46  #define ERROR1  "Too many/few fields"
  46   47  #define ERROR2  "Bad character(s) in logname"
  47   48  #define ERROR2a "First char in logname not alphabetic"
  48   49  #define ERROR2b "Logname field NULL"
  49   50  #define ERROR2c "Logname contains no lower-case letters"
  50   51  #define ERROR3  "Logname too long/short"
  51   52  #define ERROR4  "Invalid UID"
  52   53  #define ERROR5  "Invalid GID"
  53   54  #define ERROR6  "Login directory not found"
↓ open down ↓ 88 lines elided ↑ open up ↑
 142  143                   * and that the name does not consist solely of uppercase
 143  144                   * alpha chars
 144  145                   */
 145  146                  if (buf[0] == ':')
 146  147                          error(ERROR2b);
 147  148                  else if (!isalpha(buf[0]))
 148  149                          error(ERROR2a);
 149  150  
 150  151                  for (i = 0; buf[i] != ':'; i++) {
 151  152                          if (!isalnum(buf[i]) &&
 152      -                                buf[i] != '_' &&
 153      -                                buf[i] != '-' &&
 154      -                                buf[i] != '.')
      153 +                            buf[i] != '_' &&
      154 +                            buf[i] != '-' &&
      155 +                            buf[i] != '.')
 155  156                                  badc++;
 156  157                          else if (islower(buf[i]))
 157  158                                  lc++;
 158  159                  }
 159  160                  if (lc == 0)
 160  161                          error(ERROR2c);
 161  162                  if (badc > 0)
 162  163                          error(ERROR2);
 163  164  
 164  165                  /* Check for valid number of characters in logname */
 165  166  
 166      -                if (i <= 0 || i > 8)
      167 +                if (i <= 0 || i > LOGNAME_MAX_ILLUMOS)
 167  168                          error(ERROR3);
 168  169  
 169  170                  /* Check that UID is numeric and <= MAXUID */
 170  171  
 171  172                  errno = 0;
 172  173                  str = &buf[delim[1] + 1];
 173  174                  uid = strtol(str, &lastc, 10);
 174  175                  if (lastc != str + (delim[2] - delim[1]) - 1 ||
 175  176                      uid > MAXUID || errno == ERANGE)
 176  177                          error(ERROR4);
↓ open down ↓ 60 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX