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


   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  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 2008 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 #include        <sys/types.h>
  31 #include        <sys/stat.h>
  32 #include        <sys/param.h>
  33 #include        <stdio.h>
  34 #include        <stdlib.h>
  35 #include        <ctype.h>
  36 #include        <limits.h>
  37 #include        <string.h>
  38 #include        <userdefs.h>
  39 #include        <errno.h>
  40 #include        <project.h>
  41 #include        <unistd.h>


 376         /* check syntax */
 377         if (optind != argc - 1 || (skel_dir != NULL && !mflag)) {
 378                 if (is_role(usertype))
 379                         errmsg(M_ARUSAGE);
 380                 else
 381                         errmsg(M_AUSAGE);
 382                 exit(EX_SYNTAX);
 383         }
 384 
 385         logname = argv[optind];
 386         switch (valid_login(logname, (struct passwd **)NULL, &warning)) {
 387         case INVALID:
 388                 errmsg(M_INVALID, logname, "login name");
 389                 exit(EX_BADARG);
 390                 /*NOTREACHED*/
 391 
 392         case NOTUNIQUE:
 393                 errmsg(M_USED, logname);
 394                 exit(EX_NAME_EXISTS);
 395                 /*NOTREACHED*/





 396         }
 397 
 398         if (warning)
 399                 warningmsg(warning, logname);
 400         if (uidstr != NULL) {
 401                 /* convert uidstr to integer */
 402                 errno = 0;
 403                 uid = (uid_t)strtol(uidstr, &ptr, (int)10);
 404                 if (*ptr || errno == ERANGE) {
 405                         errmsg(M_INVALID, uidstr, "user id");
 406                         exit(EX_BADARG);
 407                 }
 408 
 409                 switch (valid_uid(uid, NULL)) {
 410                 case NOTUNIQUE:
 411                         if (!oflag) {
 412                                 /* override not specified */
 413                                 errmsg(M_UID_USED, uid);
 414                                 exit(EX_ID_EXISTS);
 415                         }




   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  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 (c) 2013 Gary Mills
  23  *
  24  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  25  * Use is subject to license terms.
  26  */
  27 
  28 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  29 /*        All Rights Reserved   */
  30 
  31 
  32 #include        <sys/types.h>
  33 #include        <sys/stat.h>
  34 #include        <sys/param.h>
  35 #include        <stdio.h>
  36 #include        <stdlib.h>
  37 #include        <ctype.h>
  38 #include        <limits.h>
  39 #include        <string.h>
  40 #include        <userdefs.h>
  41 #include        <errno.h>
  42 #include        <project.h>
  43 #include        <unistd.h>


 378         /* check syntax */
 379         if (optind != argc - 1 || (skel_dir != NULL && !mflag)) {
 380                 if (is_role(usertype))
 381                         errmsg(M_ARUSAGE);
 382                 else
 383                         errmsg(M_AUSAGE);
 384                 exit(EX_SYNTAX);
 385         }
 386 
 387         logname = argv[optind];
 388         switch (valid_login(logname, (struct passwd **)NULL, &warning)) {
 389         case INVALID:
 390                 errmsg(M_INVALID, logname, "login name");
 391                 exit(EX_BADARG);
 392                 /*NOTREACHED*/
 393 
 394         case NOTUNIQUE:
 395                 errmsg(M_USED, logname);
 396                 exit(EX_NAME_EXISTS);
 397                 /*NOTREACHED*/
 398 
 399         case LONGNAME:
 400                 errmsg(M_TOO_LONG, logname);
 401                 exit(EX_BADARG);
 402                 /*NOTREACHED*/
 403         }
 404 
 405         if (warning)
 406                 warningmsg(warning, logname);
 407         if (uidstr != NULL) {
 408                 /* convert uidstr to integer */
 409                 errno = 0;
 410                 uid = (uid_t)strtol(uidstr, &ptr, (int)10);
 411                 if (*ptr || errno == ERANGE) {
 412                         errmsg(M_INVALID, uidstr, "user id");
 413                         exit(EX_BADARG);
 414                 }
 415 
 416                 switch (valid_uid(uid, NULL)) {
 417                 case NOTUNIQUE:
 418                         if (!oflag) {
 419                                 /* override not specified */
 420                                 errmsg(M_UID_USED, uid);
 421                                 exit(EX_ID_EXISTS);
 422                         }