useradd.c (c651b32e) useradd.c (a7fe1d5b)
1/*
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

--- 12 unchanged lines hidden (view full) ---

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
1/*
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

--- 12 unchanged lines hidden (view full) ---

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 */
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>
42#include <user_attr.h>
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 <errno.h>
43#include <project.h>
44#include <unistd.h>
45#include <user_attr.h>
46#include <libcmdutils.h>
43#include "users.h"
44#include "messages.h"
45#include "userdisp.h"
46#include "funcs.h"
47
48/*
49 * useradd [-u uid [-o] | -g group | -G group [[, group]...] | -d dir [-m]
50 * | -s shell | -c comment | -k skel_dir | -b base_dir] ]

--- 26 unchanged lines hidden (view full) ---

77 *
78 */
79
80extern struct userdefs *getusrdef();
81extern void dispusrdef();
82
83static void cleanup();
84
47#include "users.h"
48#include "messages.h"
49#include "userdisp.h"
50#include "funcs.h"
51
52/*
53 * useradd [-u uid [-o] | -g group | -G group [[, group]...] | -d dir [-m]
54 * | -s shell | -c comment | -k skel_dir | -b base_dir] ]

--- 26 unchanged lines hidden (view full) ---

81 *
82 */
83
84extern struct userdefs *getusrdef();
85extern void dispusrdef();
86
87static void cleanup();
88
85extern uid_t findnextuid(void);
86extern int check_perm(), valid_expire();
87extern int putusrdef(), valid_uid();
88extern int call_passmgmt(), edit_group(), create_home();
89extern int edit_project();
90extern int **valid_lgroup();
91extern projid_t **valid_lproject();
92extern void update_def(struct userdefs *);
93extern void import_def(struct userdefs *);

--- 33 unchanged lines hidden (view full) ---

127
128static void valid_input(path_opt_t, const char *);
129
130int
131main(argc, argv)
132int argc;
133char *argv[];
134{
89extern int check_perm(), valid_expire();
90extern int putusrdef(), valid_uid();
91extern int call_passmgmt(), edit_group(), create_home();
92extern int edit_project();
93extern int **valid_lgroup();
94extern projid_t **valid_lproject();
95extern void update_def(struct userdefs *);
96extern void import_def(struct userdefs *);

--- 33 unchanged lines hidden (view full) ---

130
131static void valid_input(path_opt_t, const char *);
132
133int
134main(argc, argv)
135int argc;
136char *argv[];
137{
135 int ch, ret, mflag = 0, oflag = 0, Dflag = 0, **gidlist;
136 projid_t **projlist;
138 int ch, ret, mflag = 0, oflag = 0, Dflag = 0, **gidlist = NULL;
139 projid_t **projlist = NULL;
137 char *ptr; /* loc in a str, may be set by strtol */
138 struct group *g_ptr;
139 struct project p_ptr;
140 char mybuf[PROJECT_BUFSZ];
141 struct stat statbuf; /* status buffer for stat */
142 int warning;
143 int busy = 0;
144 char **nargv; /* arguments for execvp of passmgmt */

--- 275 unchanged lines hidden (view full) ---

420 case TOOBIG:
421 errmsg(M_TOOBIG, "uid", uid);
422 exit(EX_BADARG);
423 break;
424 }
425
426 } else {
427
140 char *ptr; /* loc in a str, may be set by strtol */
141 struct group *g_ptr;
142 struct project p_ptr;
143 char mybuf[PROJECT_BUFSZ];
144 struct stat statbuf; /* status buffer for stat */
145 int warning;
146 int busy = 0;
147 char **nargv; /* arguments for execvp of passmgmt */

--- 275 unchanged lines hidden (view full) ---

423 case TOOBIG:
424 errmsg(M_TOOBIG, "uid", uid);
425 exit(EX_BADARG);
426 break;
427 }
428
429 } else {
430
428 if ((uid = findnextuid()) < 0) {
431 if (findnextuid(DEFRID+1, MAXUID, &uid) != 0) {
429 errmsg(M_INVALID, "default id", "user id");
430 exit(EX_ID_EXISTS);
431 }
432 }
433
434 if (group != NULL) {
435 switch (valid_group(group, &g_ptr, &warning)) {
436 case INVALID:

--- 192 unchanged lines hidden (view full) ---

629 * The uid has been taken. If it was specified by a
630 * user, then we must fail. Otherwise, keep trying
631 * to get a good uid until we run out of IDs.
632 */
633 if (uidstr != NULL) {
634 errmsg(M_UID_USED, uid);
635 exit(EX_ID_EXISTS);
636 } else {
432 errmsg(M_INVALID, "default id", "user id");
433 exit(EX_ID_EXISTS);
434 }
435 }
436
437 if (group != NULL) {
438 switch (valid_group(group, &g_ptr, &warning)) {
439 case INVALID:

--- 192 unchanged lines hidden (view full) ---

632 * The uid has been taken. If it was specified by a
633 * user, then we must fail. Otherwise, keep trying
634 * to get a good uid until we run out of IDs.
635 */
636 if (uidstr != NULL) {
637 errmsg(M_UID_USED, uid);
638 exit(EX_ID_EXISTS);
639 } else {
637 if ((uid = findnextuid()) < 0) {
640 if (findnextuid(DEFRID+1, MAXUID, &uid) != 0) {
638 errmsg(M_INVALID, "default id",
639 "user id");
640 exit(EX_ID_EXISTS);
641 }
642 (void) sprintf(uidstring, "%u", uid);
643 }
644 break;
645

--- 110 unchanged lines hidden ---
641 errmsg(M_INVALID, "default id",
642 "user id");
643 exit(EX_ID_EXISTS);
644 }
645 (void) sprintf(uidstring, "%u", uid);
646 }
647 break;
648

--- 110 unchanged lines hidden ---