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/prstat/prtable.c
          +++ new/usr/src/cmd/prstat/prtable.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 2009 Sun Microsystems, Inc.  All rights reserved.
  23   25   * Use is subject to license terms.
  24   26   *
  25   27   * Portions Copyright 2009 Chad Mynhier
  26   28   */
  27   29  
  28   30  #include <procfs.h>
  29   31  #include <unistd.h>
  30   32  #include <stdlib.h>
  31   33  #include <pwd.h>
↓ open down ↓ 20 lines elided ↑ open up ↑
  52   54  pwd_getid(char *name)
  53   55  {
  54   56          struct passwd *pwd;
  55   57  
  56   58          if ((pwd = getpwnam(name)) == NULL)
  57   59                  Die(gettext("invalid user name: %s\n"), name);
  58   60          return (pwd->pw_uid);
  59   61  }
  60   62  
  61   63  void
  62      -pwd_getname(uid_t uid, char *name, int length, int noresolve)
       64 +pwd_getname(uid_t uid, char *name, size_t length, int noresolve,
       65 +    int termcap, size_t width)
  63   66  {
  64   67          struct passwd *pwd;
       68 +        size_t n;
  65   69  
  66   70          if (noresolve || (pwd = getpwuid(uid)) == NULL) {
  67   71                  (void) snprintf(name, length, "%u", uid);
  68   72          } else {
  69      -                (void) snprintf(name, length, "%s", pwd->pw_name);
       73 +                n = strlen(pwd->pw_name);
       74 +                if (termcap && n > width)
       75 +                        (void) snprintf(name, length, "%.*s%c",
       76 +                            width - 1, pwd->pw_name, '*');
       77 +                else
       78 +                        (void) snprintf(name, length, "%s", pwd->pw_name);
  70   79          }
  71   80  }
  72   81  
  73   82  void
  74   83  add_uid(uidtbl_t *tbl, char *name)
  75   84  {
  76   85          uid_t *uid;
  77   86  
  78   87          if (tbl->n_size == tbl->n_nent) {       /* reallocation */
  79   88                  if ((tbl->n_size *= 2) == 0)
↓ open down ↓ 237 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX