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>
42 #include <errno.h>
43 #include <project.h>
44 #include "users.h"
45 #include "messages.h"
46 #include "funcs.h"
47
48 /*
49 * usermod [-u uid [-o] | -g group | -G group [[,group]...] | -d dir [-m]
493 if (REL_PATH(shell)) {
494 errmsg(M_RELPATH, shell);
495 exit(EX_BADARG);
496 }
497 if (strcmp(pstruct->pw_shell, shell) == 0) {
498 /* ignore s option if shell is not different */
499 shell = NULL;
500 } else {
501 if (stat(shell, &statbuf) < 0 ||
502 (statbuf.st_mode & S_IFMT) != S_IFREG ||
503 (statbuf.st_mode & 0555) != 0555) {
504
505 errmsg(M_INVALID, shell, "shell");
506 exit(EX_BADARG);
507 }
508
509 call_pass = 1;
510 }
511 }
512
513 if (comment)
514 /* ignore comment if comment is not changed */
515 if (strcmp(pstruct->pw_comment, comment))
516 call_pass = 1;
517 else
518 comment = NULL;
519
520 /* inactive string is a positive integer */
521 if (inactstr) {
522 /* convert inactstr to integer */
523 inact = (int)strtol(inactstr, &ptr, 10);
524 if (*ptr || inact < 0) {
525 errmsg(M_INVALID, inactstr, "inactivity period");
526 exit(EX_BADARG);
527 }
528 call_pass = 1;
529 }
530
531 /* expiration string is a date, newer than today */
532 if (expire) {
533 if (*expire &&
534 valid_expire(expire, (time_t *)0) == INVALID) {
535 errmsg(M_INVALID, expire, "expiration date");
536 exit(EX_BADARG);
537 }
538 call_pass = 1;
|
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 * Copyright (c) 2013 RackTop Systems.
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>
44 #include <errno.h>
45 #include <project.h>
46 #include "users.h"
47 #include "messages.h"
48 #include "funcs.h"
49
50 /*
51 * usermod [-u uid [-o] | -g group | -G group [[,group]...] | -d dir [-m]
495 if (REL_PATH(shell)) {
496 errmsg(M_RELPATH, shell);
497 exit(EX_BADARG);
498 }
499 if (strcmp(pstruct->pw_shell, shell) == 0) {
500 /* ignore s option if shell is not different */
501 shell = NULL;
502 } else {
503 if (stat(shell, &statbuf) < 0 ||
504 (statbuf.st_mode & S_IFMT) != S_IFREG ||
505 (statbuf.st_mode & 0555) != 0555) {
506
507 errmsg(M_INVALID, shell, "shell");
508 exit(EX_BADARG);
509 }
510
511 call_pass = 1;
512 }
513 }
514
515 if (comment) {
516 /* ignore comment if comment is not changed */
517 if (strcmp(pstruct->pw_comment, comment))
518 call_pass = 1;
519 else
520 comment = NULL;
521 }
522
523 /* inactive string is a positive integer */
524 if (inactstr) {
525 /* convert inactstr to integer */
526 inact = (int)strtol(inactstr, &ptr, 10);
527 if (*ptr || inact < 0) {
528 errmsg(M_INVALID, inactstr, "inactivity period");
529 exit(EX_BADARG);
530 }
531 call_pass = 1;
532 }
533
534 /* expiration string is a date, newer than today */
535 if (expire) {
536 if (*expire &&
537 valid_expire(expire, (time_t *)0) == INVALID) {
538 errmsg(M_INVALID, expire, "expiration date");
539 exit(EX_BADARG);
540 }
541 call_pass = 1;
|