/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* user.c: support for the scadm useradd, userdel, usershow, userpassword,
* userperm options (administration of service processor users)
*/
#include <libintl.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include "librsc.h"
#include "adm.h"
static void ADM_Get_Password(char *password);
static void ADM_Destroy_Password(char *password);
static void max_username();
static void malformed_username();
static void wrong_response();
static void no_user();
static void no_info();
static void userperm_usage();
static void show_header();
static void cleanup();
/* Globals so that exit routine can clean up echo */
static int echoOff = 0;
typedef union {
void *DataBuffer_p;
void
{
char *userName;
if (argc != 3) {
gettext("USAGE: scadm useradd <username>"));
exit(-1);
}
ADM_Start();
max_username();
exit(-1);
}
exit(-1);
}
gettext("scadm: all user slots are full"));
exit(-1);
gettext("scadm: user already exists"));
exit(-1);
gettext("scadm: username did not start with letter\n"
" or did not contain lower case letter\n"));
exit(-1);
exit(-1);
} else if (admResponse->status != 0) {
gettext("scadm: couldn't add user"));
exit(-1);
}
}
void
{
char *userName;
if (argc != 3) {
gettext("USAGE: scadm userdel <username>"));
exit(-1);
}
ADM_Start();
max_username();
exit(-1);
}
exit(-1);
}
no_user();
exit(-1);
exit(-1);
} else if (admResponse->status != 0) {
gettext("scadm: couldn't delete user"));
exit(-1);
}
}
void
{
char *userName;
char *permissions;
char *passwd;
int index;
gettext("USAGE: scadm usershow [username]"));
exit(-1);
}
ADM_Start();
if (argc == 3) {
max_username();
exit(-1);
}
userName = (char *)(&((char *)admMessage)[
sizeof (dp_user_adm_t)]);
DP_USER_ADM_R, sizeof (dp_user_adm_r_t));
exit(-1);
}
no_user();
exit(-1);
exit(-1);
} else if (admResponse->status != 0) {
no_info();
exit(-1);
}
userName = &(((char *)admResponse)[
sizeof (dp_user_adm_r_t)]);
show_header();
} else {
}
} else {
show_header();
DP_USER_ADM_R, sizeof (dp_user_adm_r_t));
exit(-1);
}
continue;
exit(-1);
} else if (admResponse->status != 0) {
no_info();
exit(-1);
}
userName = &(((char *)admResponse)[
sizeof (dp_user_adm_r_t)]);
(void) printf(" %-16s %-15s ",
} else {
}
}
(void) printf("\n");
}
}
void
{
char *userName;
char *password;
int passTry;
/* Try to set password up to 3 times on Malformed password */
passTry = 3;
if (argc != 3) {
gettext("USAGE: scadm userpassword <username>"));
exit(-1);
}
ADM_Start();
max_username();
exit(-1);
}
for (;;) {
DP_USER_ADM_R, sizeof (dp_user_adm_r_t));
exit(-1);
}
no_user();
exit(-1);
exit(-1);
gettext("scadm: malformed password\n"
" A valid password is between 6 and 8 "
"characters,\n"
" has at least two alphabetic characters, "
"and at\n"
" least one numeric or special character. "
"The\n"
" password must differ from the user's "
"login name\n"
" and any reverse or circular shift of that "
"login\n"
" name.\n"));
passTry--;
if (passTry > 0) {
continue;
} else
exit(-1);
} else if (admResponse->status != 0) {
gettext("scadm: couldn't change password"));
exit(-1);
}
/* password was changed successfully, get out of while */
break;
}
}
void
{
char *userName;
int permissions;
int index;
exit(-1);
}
if (argc == 3) {
permissions = 0;
} else {
exit(-1);
}
permissions = 0;
exit(-1);
}
/* See if this field was entered twice */
if ((permissions & DP_USER_PERM_C) != 0) {
exit(-1);
}
}
/* See if this field was enetered twice */
if ((permissions & DP_USER_PERM_U) != 0) {
exit(-1);
}
}
/* See if this field was enetered twice */
if ((permissions & DP_USER_PERM_A) != 0) {
exit(-1);
}
}
/* See if this field was enetered twice */
if ((permissions & DP_USER_PERM_R) != 0) {
exit(-1);
}
}
}
}
ADM_Start();
max_username();
exit(-1);
}
exit(-1);
}
no_user();
exit(-1);
exit(-1);
} else if (admResponse->status != 0) {
gettext("scadm: couldn't change permissions"));
exit(-1);
}
}
static void
{
int passTry;
int validPass;
validPass = 0;
passTry = 3;
gettext("scadm: cleanup() registration failed"));
exit(-1);
}
echoOff = 1;
(void) printf("\n");
(void) printf("\n");
/* Truncate at 8 characters */
gettext("Passwords didn't match, try again"));
gettext("scadm: ERROR, passwords didn't match"));
exit(-1);
} else {
validPass = 1;
}
}
echoOff = 0;
}
static void
cleanup()
{
if (echoOff)
exit(-1);
}
static void
{
int index;
}
static void
{
gettext("\nscadm: maximum username length is %d\n\n"),
}
static void
{
}
static void
{
gettext("scadm: SC returned wrong response"));
}
static void
no_user()
{
}
static void
no_info()
{
gettext("scadm: couldn't get information on user"));
}
static void
{
gettext("USAGE: scadm userperm <username> [cuar]"));
}
static void
{
int i;
(void) printf("\n");
(void) putchar(' ');
for (i = 0; i < (20 - usernLen); i++)
(void) putchar(' ');
for (i = 0; i < (19 - permLen); i++)
(void) putchar(' ');
(void) putchar(' ');
for (i = 0; i < usernLen; i++)
(void) putchar('-');
for (; i < 20; i++)
(void) putchar(' ');
for (i = 0; i < permLen; i++)
(void) putchar('-');
for (; i < 19; i++)
(void) putchar(' ');
for (i = 0; i < pwdLen; i++)
(void) putchar('-');
(void) printf("\n");
}