Print this page
Remove include userdefs.h where not needed


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




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

  37 #include <pwd.h>
  38 #include <libcmdutils.h>
  39 
  40 static int findunuseduid(uid_t start, uid_t stop, uid_t *ret);
  41 static boolean_t isreserveduid(uid_t uid);
  42 
  43 /*
  44  * Find the highest unused uid. If the highest unused uid is "stop",
  45  * then attempt to find a hole in the range. Returns 0 on success.
  46  */
  47 int
  48 findnextuid(uid_t start, uid_t stop, uid_t *ret)
  49 {
  50         uid_t uid = start;
  51         struct passwd *pwd;
  52         boolean_t overflow = B_FALSE;
  53 
  54         setpwent();
  55         for (pwd = getpwent(); pwd != NULL; pwd = getpwent()) {
  56                 if (isreserveduid(pwd->pw_uid))              /* Skip reserved IDs */