ipmi_user.c revision 1af98250c8b03bdc43d8ac3aac6390221d75b92e
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <libipmi.h>
#include <string.h>
#include "ipmi_impl.h"
/*
* Get User Access. See section 22.27.
*
* See libipmi.h for a complete description of IPMI reference material.
*/
typedef struct ipmi_get_user_access_req {
#if defined(_BIT_FIELDS_LTOH)
#else
#endif
#define IPMI_CMD_GET_USER_ACCESS 0x44
typedef struct ipmi_get_user_access {
#if defined(_BIT_FIELDS_LTOH)
#else
#endif
#define IPMI_USER_ENABLE_UNSPECIFIED 0x00
#define IPMI_USER_ENABLE_SETPASSWD 0x01
#define IPMI_USER_DISABLE_SETPASSWD 0x02
#define IPMI_USER_CHANNEL_CURRENT 0xe
/*
* Get User Name. See section 22.29
*/
#define IPMI_CMD_GET_USER_NAME 0x46
/*
* Set User Password. See section 22.30
*/
#define IPMI_CMD_SET_USER_PASSWORD 0x47
typedef struct ipmi_set_user_password {
#if defined(_BIT_FIELDS_LTOH)
#else
#endif
char isup_passwd[20];
#define IPMI_PASSWORD_OP_DISABLE 0x0
#define IPMI_PASSWORD_OP_ENABLE 0x1
#define IPMI_PASSWORD_OP_SET 0x2
#define IPMI_PASSWORD_OP_TEST 0x3
static ipmi_get_user_access_t *
{
ipmi_get_user_access_req_t req = { 0 };
/*
* If sessions aren't supported on the current channel, some
* service processors (notably Sun's ILOM) will return an
* invalid request completion code (0xCC). For these SPs, we
* translate this to the more appropriate EIPMI_INVALID_COMMAND.
*/
NULL);
return (NULL);
}
return (NULL);
}
}
static const char *
{
return (NULL);
return (NULL);
}
}
void
{
}
}
/*
* Returns user information in a well-defined structure.
*/
int
void *data)
{
uint8_t i;
const char *name;
/*
* First get the number of active users on the system by requesting the
* reserved user ID (0).
*/
IPMI_USER_CHANNEL_CURRENT, 0)) == NULL)
return (-1);
IPMI_USER_CHANNEL_CURRENT, i)) == NULL)
return (-1);
return (-1);
return (-1);
if (*name != '\0' &&
return (-1);
}
return (-1);
}
return (0);
}
typedef struct ipmi_user_cb {
const char *uic_name;
static int
{
return (0);
}
return (0);
}
{
ipmi_user_cb_t cb = { 0 };
return (NULL);
"no such user");
return (cb.uic_result);
}
{
ipmi_user_cb_t cb = { 0 };
return (NULL);
"no such user");
return (cb.uic_result);
}
int
{
ipmi_set_user_password_t req = { 0 };
"password length must be less than 20 characters"));
if (req.isup_len20)
else
return (-1);
return (0);
}