/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2013 Gary Mills
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 2013 RackTop Systems.
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
#include <userdefs.h>
#include <user_attr.h>
#include <nss_dbdefs.h>
#include <errno.h>
#include <project.h>
#include "users.h"
#include "messages.h"
#include "funcs.h"
/*
* usermod [-u uid [-o] | -g group | -G group [[,group]...]
* | -d dir [-m [-z|Z]]
* | -s shell | -c comment | -l new_logname]
* | -f inactive | -e expire ]
* [ -A authorization [, authorization ...]]
* [ -P profile [, profile ...]]
* [ -R role [, role ...]]
* [ -K key=value ]
* [ -p project [, project]] login
*
* This command adds new user logins to the system. Arguments are:
*
* uid - an integer less than MAXUID
* group - an existing group's integer ID or char string name
* dir - a directory
* shell - a program to be used as a shell
* comment - any text string
* skel_dir - a directory
* base_dir - a directory
* rid - an integer less than 2**16 (USHORT)
* login - a string of printable chars except colon (:)
* inactive - number of days a login maybe inactive before it is locked
* expire - date when a login is no longer valid
* authorization - One or more comma separated authorizations defined
* in auth_attr(4).
* profile - One or more comma separated execution profiles defined
* in prof_attr(4)
* role - One or more comma-separated role names defined in user_attr(4)
* key=value - One or more -K options each specifying a valid user_attr(4)
* attribute.
*
*/
extern projid_t **valid_lproject();
static char *usertype;
char *cmdname;
char *
char *str;
{
return (NULL);
}
struct passwd *
{
return (NULL);
return (npw);
}
int
int argc;
char **argv;
{
char *ptr;
#ifndef att
#endif
int warning;
char *val;
if (geteuid() != 0) {
}
opterr = 0; /* no print errors from getopt */
/* get user type based on the program name */
"c:d:e:f:G:g:l:mzZop:s:u:A:P:R:K:")) != EOF)
switch (ch) {
case 'c':
flag++;
break;
case 'd':
flag++;
break;
case 'e':
flag++;
break;
case 'f':
flag++;
break;
case 'G':
flag++;
break;
case 'g':
flag++;
break;
case 'l':
flag++;
break;
case 'm':
mflag++;
flag++;
break;
case 'o':
oflag++;
flag++;
break;
case 'p':
flag++;
break;
case 's':
flag++;
break;
case 'u':
flag++;
break;
case 'Z':
Zflag++;
break;
case 'z':
zflag++;
break;
case 'A':
flag++;
break;
case 'P':
flag++;
break;
case 'R':
flag++;
break;
case 'K':
flag++;
break;
default:
case '?':
else
}
else
}
else
}
else
}
/* Determine whether the account is a role or not */
isrole = 0;
else
isrole = 1;
/* Verify that rolemod is used for roles and usermod for users */
if (isrole)
else
}
/* Set the usertype key; defaults to the commandline */
/* Roles can't have roles */
}
/* If it was an ordinary user, delete its roles */
if (!isrole)
}
#ifdef att
#else
/*
* Do this with fgetpwent to make sure we are only looking on local
* system (since passmgmt only works on local system).
*/
}
break;
#endif
/* This user does not exist. */
} else {
/* This user exists in non-local name service. */
}
}
/*
* We can't modify a logged in user if any of the following
* are being changed:
* uid (-u & -o), group (-g), home dir (-m), loginname (-l).
* If none of those are specified it is okay to go ahead
* some types of changes only take effect on next login, some
* like authorisations and profiles take effect instantly.
* One might think that -K type=role should require that the
* user not be logged in, however this would make it very
* difficult to make the root account a role using this command.
*/
if (fail_if_busy) {
}
}
&warning)) {
case INVALID:
/*NOTREACHED*/
case NOTUNIQUE:
/*NOTREACHED*/
case LONGNAME:
/*NOTREACHED*/
default:
call_pass = 1;
break;
}
if (warning)
}
if (uidstr) {
/* convert uidstr to integer */
errno = 0;
}
case NOTUNIQUE:
if (!oflag) {
/* override not specified */
}
break;
case RESERVED:
break;
case TOOBIG:
break;
}
call_pass = 1;
} else {
/* uid's the same, so don't change anything */
oflag = 0;
}
if (group) {
case INVALID:
/*NOTREACHED*/
case TOOBIG:
/*NOTREACHED*/
case UNIQUE:
/*NOTREACHED*/
case RESERVED:
break;
}
if (warning)
else
/* call passmgmt if gid is different, else ignore group */
call_pass = 1;
} else
gidlist = (int **)0;
} else
if (dir) {
}
/* home directory is the same so ignore dflag & mflag */
mflag = 0;
} else call_pass = 1;
}
if (mflag) {
/* Home directory exists */
}
} else {
zfs_flags |= MANAGE_ZFS;
else if (Zflag)
zfs_flags &= ~MANAGE_ZFS;
}
if (ret == EX_SUCCESS)
if (ret != EX_SUCCESS)
}
if (shell) {
}
/* ignore s option if shell is not different */
} else {
}
call_pass = 1;
}
}
if (comment) {
/* ignore comment if comment is not changed */
call_pass = 1;
else
}
/* inactive string is a positive integer */
if (inactstr) {
/* convert inactstr to integer */
}
call_pass = 1;
}
/* expiration string is a date, newer than today */
if (expire) {
if (*expire &&
}
call_pass = 1;
}
if (nkeys > 0)
call_pass = 1;
/* that's it for validations - now do the work */
if (grps) {
/* redefine login's supplentary group memberships */
if (ret != EX_SUCCESS) {
}
}
if (projects) {
if (ret != EX_SUCCESS) {
}
}
/* only get to here if need to call passmgmt */
/* set up arguments to passmgmt in nargv array */
argindex = 0;
if (comment) { /* comment */
}
if (dir) {
/* flags for home directory */
}
if (group) {
/* set gid flag */
}
if (shell) { /* shell */
}
if (inactstr) {
}
if (expire) {
}
if (uidstr) { /* set uid flag */
}
if (new_logname) { /* redefine login name */
}
if (nkeys > 0)
/* finally - login name */
/* set the last to null */
/* now call passmgmt */
ret = PEX_FAILED;
case PEX_SUCCESS:
case PEX_BUSY:
break;
case PEX_HOSED_FILES:
break;
case PEX_SYNTAX:
case PEX_BADARG:
/* should NEVER occur that passmgmt usage is wrong */
else
break;
case PEX_BADUID:
/* uid in use - shouldn't happen print message anyway */
break;
case PEX_BADNAME:
/* invalid loname */
break;
default:
break;
}
}
if (tries == 0) {
}
/*NOTREACHED*/
}