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 
  31 #include <sys/types.h>
  32 #include <sys/stat.h>
  33 #include <sys/param.h>
  34 #include <stdio.h>
  35 #include <stdlib.h>
  36 #include <ctype.h>
  37 #include <limits.h>
  38 #include <string.h>
  39 #include <userdefs.h>
  40 #include <user_attr.h>
  41 #include <nss_dbdefs.h>


 351         if (isbusy(logname)) {
 352                 if (fail_if_busy) {
 353                         errmsg(M_BUSY, logname, "change");
 354                         exit(EX_BUSY);
 355                 }
 356                 warningmsg(WARN_LOGGED_IN, logname);
 357         }
 358 
 359         if (new_logname && strcmp(new_logname, logname)) {
 360                 switch (valid_login(new_logname, (struct passwd **)NULL,
 361                         &warning)) {
 362                 case INVALID:
 363                         errmsg(M_INVALID, new_logname, "login name");
 364                         exit(EX_BADARG);
 365                         /*NOTREACHED*/
 366 
 367                 case NOTUNIQUE:
 368                         errmsg(M_USED, new_logname);
 369                         exit(EX_NAME_EXISTS);
 370                         /*NOTREACHED*/






 371                 default:
 372                         call_pass = 1;
 373                         break;
 374                 }
 375                 if (warning)
 376                         warningmsg(warning, logname);
 377         }
 378 
 379         if (uidstr) {
 380                 /* convert uidstr to integer */
 381                 errno = 0;
 382                 uid = (uid_t)strtol(uidstr, &ptr, (int)10);
 383                 if (*ptr || errno == ERANGE) {
 384                         errmsg(M_INVALID, uidstr, "user id");
 385                         exit(EX_BADARG);
 386                 }
 387 
 388                 if (uid != pstruct->pw_uid) {
 389                         switch (valid_uid(uid, NULL)) {
 390                         case NOTUNIQUE:




   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 
  33 #include <sys/types.h>
  34 #include <sys/stat.h>
  35 #include <sys/param.h>
  36 #include <stdio.h>
  37 #include <stdlib.h>
  38 #include <ctype.h>
  39 #include <limits.h>
  40 #include <string.h>
  41 #include <userdefs.h>
  42 #include <user_attr.h>
  43 #include <nss_dbdefs.h>


 353         if (isbusy(logname)) {
 354                 if (fail_if_busy) {
 355                         errmsg(M_BUSY, logname, "change");
 356                         exit(EX_BUSY);
 357                 }
 358                 warningmsg(WARN_LOGGED_IN, logname);
 359         }
 360 
 361         if (new_logname && strcmp(new_logname, logname)) {
 362                 switch (valid_login(new_logname, (struct passwd **)NULL,
 363                         &warning)) {
 364                 case INVALID:
 365                         errmsg(M_INVALID, new_logname, "login name");
 366                         exit(EX_BADARG);
 367                         /*NOTREACHED*/
 368 
 369                 case NOTUNIQUE:
 370                         errmsg(M_USED, new_logname);
 371                         exit(EX_NAME_EXISTS);
 372                         /*NOTREACHED*/
 373 
 374                 case LONGNAME:
 375                         errmsg(M_TOO_LONG, new_logname);
 376                         exit(EX_BADARG);
 377                         /*NOTREACHED*/
 378 
 379                 default:
 380                         call_pass = 1;
 381                         break;
 382                 }
 383                 if (warning)
 384                         warningmsg(warning, logname);
 385         }
 386 
 387         if (uidstr) {
 388                 /* convert uidstr to integer */
 389                 errno = 0;
 390                 uid = (uid_t)strtol(uidstr, &ptr, (int)10);
 391                 if (*ptr || errno == ERANGE) {
 392                         errmsg(M_INVALID, uidstr, "user id");
 393                         exit(EX_BADARG);
 394                 }
 395 
 396                 if (uid != pstruct->pw_uid) {
 397                         switch (valid_uid(uid, NULL)) {
 398                         case NOTUNIQUE: