mmsinit.c revision cee0fb94c0d4227de0a00efc162fb2739844b641
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdlib.h>
#include <getopt.h>
#include <stdio.h>
#include <strings.h>
#include <ctype.h>
#include <errno.h>
#include <libnvpair.h>
#include <fcntl.h>
#include "mms_trace.h"
#include "mms_mgmt.h"
#include "mgmt_util.h"
#include "mms_cfg.h"
extern char *optarg;
#ifdef MMS_VAR_CFG
static char *usemsg = \
"Usage: \n\
\tmmsinit [-?|-h]\n\
\tmmsinit -t server -o options [-P passwordfile]\n\
\tmmsinit -t client -M serverhost[:port] [-P passwordfile]\n\
\tmmsinit -u\n";
#else
static char *usemsg = \
"Usage: \n\
\tmmsinit [-h|-?]\n\
\tmmsinit -t server -o options [-P passwordfile]\n";
#endif /* MMS_VAR_CFG */
#ifdef MMS_VAR_CFG
static int uflag = 0;
#endif /* MMS_VAR_CFG */
static int hflag = 0;
static char *mmsinit_opts = ":M:P:t:o:fuv?";
static char *passphrases[2] = {
"Enter MMS Administrative password: ",
"Re-enter password: "
};
static struct option mmsinit_long[] = {
};
static void usage(void);
int
{
int st = 0;
int mmsind = 0;
char c;
char *mmtype = "server";
#ifdef MMS_VAR_CFG
char *mmhost = "localhost";
char *mmport = "7151";
char *bufp;
#endif
char buf[2048];
if (argc < 2) {
st = 1;
}
if (st != 0) {
return (st);
}
while (st == 0) {
&mmsind);
/* catch end-of-args */
if (c == -1) {
break;
}
switch (c) {
case 0:
/* flag set by getopt */
break;
case 't':
#ifdef MMS_VAR_CFG
if (*mmtype == 'c') {
"client");
} else if (*mmtype == 's') {
"server");
} else {
st = 1;
mmtype);
}
#else
if (*mmtype != 's') {
"Type must be 'server'\n");
st = 1;
}
#endif /* MMS_VAR_CFG */
break;
#ifdef MMS_VAR_CFG
case 'f':
break;
case 'M':
} else {
*bufp = '\0';
}
buf);
} else {
mmhost);
}
if (st != 0) {
break;
}
break;
#endif /* MMS_VAR_CFG */
case 'P':
break;
case 'o':
break;
#ifdef MMS_VAR_CFG
case 'u':
uflag++;
break;
#endif /* MMS_VAR_CFG */
case '?':
hflag++;
break;
case ':':
"Option %s requires an operand\n",
st = 1;
break;
default:
st = 1;
break;
}
}
usage();
goto done;
}
#ifdef MMS_VAR_CFG
if (uflag) {
char yesno = 'n';
/* remove everything except the DB */
"To uninitialize from a script, "
"please use the -f option.\n");
st = 1;
goto done;
}
"Do you really want to stop using MMS services on "
"this system? [y|n] ");
st = mms_mgmt_uninitialize();
} else {
"Uninitialize will not be performed.\n");
}
goto done;
}
/* check to see if this host has already been initialized first */
goto done;
} else {
st = 0;
}
if (!mmtype) {
"Either -t client or -t server must be specified.\n");
st = 1;
goto done;
}
#endif /* MMS_VAR_CFG */
/* Prompt the user for the MM password or read it from a file */
if (st != 0) {
goto done;
}
#ifdef MMS_VAR_CFG
if (*mmtype == 's') {
/* set mmhost to localhost */
}
#endif /* MMS_VAR_CFG */
if (st != 0) {
goto done;
}
done:
if (st != 0) {
if (st == EOPNOTSUPP) {
"Cannot change MMS host type. To change ");
"this value, first run 'mmsinit -u'.\n");
"\nMMS already initialized on this system.\nTo ");
"change options, use the 'mmsadm set' command.\n");
} else if (errlist) {
int nvl = 0;
errmsg);
} else {
}
}
}
}
if (errlist) {
}
if (mmnv) {
}
if (st != 0) {
}
return (st);
}
static void
usage(void)
{
}