c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * CDDL HEADER START
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * The contents of this file are subject to the terms of the
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * Common Development and Distribution License (the "License").
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * You may not use this file except in compliance with the License.
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * See the License for the specific language governing permissions
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * and limitations under the License.
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * When distributing Covered Code, include this CDDL HEADER in each
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * If applicable, add the following below this CDDL HEADER, with the
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * fields enclosed by brackets "[]" replaced with your own identifying
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * information: Portions Copyright [yyyy] [name of copyright owner]
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * CDDL HEADER END
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson/* SMF service info */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson gettext("Configuration changed during processing. "\
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson "Check the configuration, then retry this command "\
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson "if appropriate."));\
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson gettext("Error, operation requires authorization %s"),\
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson return (1);\
c3a558e7c77127215b010652905be7916ec5a080Sue Gleesonstatic char m_def[] = "srptadm modify-defaults [-e] [-d]";
c3a558e7c77127215b010652905be7916ec5a080Sue Gleesonstatic char s_tgt[] = "srptadm modify-target [-e] [-d] [-r] <hca>";
c3a558e7c77127215b010652905be7916ec5a080Sue Gleesonstatic char l_tgt[] = "srptadm list-target [<hca>]";
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson/* keep the order of this enum in the same order as the 'subcmds' struct */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleesontypedef enum {
c3a558e7c77127215b010652905be7916ec5a080Sue Gleesontypedef struct {
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson/* used for checking if user is authorized */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson/* prototypes */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleesonstatic int get_local_hcas(char **hcaArray, int count);
c3a558e7c77127215b010652905be7916ec5a080Sue Gleesonstatic int list_defaults(void);
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson for (idx = 0; subcmds[idx].name != NULL; idx++) {
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson /* get the caller's user name for subsequent chkauthattr() calls */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson gettext("Could not determine callers user name."));
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson /* increment past command & subcommand */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson c = getopt_long(newargc, newargv, subcmds[idx].shortopts,
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson if (c == -1) {
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson switch (c) {
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson /* flag set by getopt */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * '?' is returned for both unrecognized
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * options and if explicitly provided on
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * the command line. The latter should
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * be handled the same as -h.
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson /* fall through to default */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson /* after getopt() to allow handling of -h option */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson /* These subcommands need operands */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson /* These subcommands should have at most one operand */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson * Make sure STMF service is enabled before proceeding.
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson (strcmp(smfstate, SCF_STATE_STRING_ONLINE) != 0)) {
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson "before running this command."));
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson gettext("Use 'svcadm enable -r %s'"), STMF_SVC);
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson gettext("to enable the service and its prerequisite "
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson "services and/or"));
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson gettext("'svcs -x %s' to determine why it is not online."),
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson } else if (dflag) {
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson } else if (eflag) {
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson } else if (dflag) {
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson (void) printf("%s\n", gettext(subcmds[idx].usemsg));
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson /* overall usage */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson (void) printf("%s\n\n", gettext("srptadm usage:"));
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson for (idx = 0; subcmds[idx].name != NULL; idx++) {
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson (void) printf("\t%s\n", gettext(subcmds[idx].usemsg));
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson /* only state set as default for now */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson gettext("SRP Target Service Default Properties"));
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson char *hcaArr[1024]; /* way bigger than we'll ever see */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson /* get list of HCAs configured on this system, from /dev/cfg */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson (void) memset(&hcaArr, 0, 1024 * sizeof (char *));
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson (void) fprintf(stderr, "Internal error: too many HCAs\n");
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson } else if (ret != 0) {
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson (void) fprintf(stderr, "Error getting list of HCAs: %d\n", ret);
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson for (i = 0; i < 1024; i++) {
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson for (i = 0; i < 1024; i++) {
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson ret = srpt_NormalizeGuid(hca, buf, sizeof (buf), &hcaguid);
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson (void) fprintf(stderr, "Invalid target HCA: %s\n",
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson /* only property set is enabled */
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson "Could not get enabled state for %s: %d\n",
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson (void) printf(PROPS_FORMAT, gettext("Enabled"));
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson (void) snprintf(euibuf, sizeof (euibuf), "eui.%016llX", hcaguid);
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson (void) printf(PROPS_FORMAT, gettext("SRP Target Name"));
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson (void) printf(PROPS_FORMAT, gettext("Operational Status"));
c3a558e7c77127215b010652905be7916ec5a080Sue Gleeson (void) fprintf(stderr, "Could not open %s: errno %d\n",