mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
fix segfault and channel problem with user priv command
This commit is contained in:
parent
533582e9e3
commit
520aa05c07
@ -72,11 +72,10 @@ extern int csv_output;
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ipmi_get_user_access(
|
ipmi_get_user_access(
|
||||||
struct ipmi_intf * intf,
|
struct ipmi_intf *intf,
|
||||||
uint8_t channel_number,
|
uint8_t channel_number,
|
||||||
uint8_t user_id,
|
uint8_t user_id,
|
||||||
struct user_access_rsp * user_access)
|
struct user_access_rsp *user_access)
|
||||||
|
|
||||||
{
|
{
|
||||||
struct ipmi_rs * rsp;
|
struct ipmi_rs * rsp;
|
||||||
struct ipmi_rq req;
|
struct ipmi_rq req;
|
||||||
@ -129,10 +128,9 @@ ipmi_get_user_access(
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ipmi_get_user_name(
|
ipmi_get_user_name(
|
||||||
struct ipmi_intf * intf,
|
struct ipmi_intf *intf,
|
||||||
uint8_t user_id,
|
uint8_t user_id,
|
||||||
char * user_name)
|
char *user_name)
|
||||||
|
|
||||||
{
|
{
|
||||||
struct ipmi_rs * rsp;
|
struct ipmi_rs * rsp;
|
||||||
struct ipmi_rq req;
|
struct ipmi_rq req;
|
||||||
@ -186,7 +184,6 @@ dump_user_access(
|
|||||||
printed_header = 1;
|
printed_header = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
printf("%-4d%-17s%-8s%-11s%-11s%-s\n",
|
printf("%-4d%-17s%-8s%-11s%-11s%-s\n",
|
||||||
user_id,
|
user_id,
|
||||||
user_name,
|
user_name,
|
||||||
@ -202,8 +199,8 @@ dump_user_access(
|
|||||||
static void
|
static void
|
||||||
dump_user_access_csv(
|
dump_user_access_csv(
|
||||||
uint8_t user_id,
|
uint8_t user_id,
|
||||||
const char * user_name,
|
const char *user_name,
|
||||||
struct user_access_rsp * user_access)
|
struct user_access_rsp *user_access)
|
||||||
{
|
{
|
||||||
printf("%d,%s,%s,%s,%s,%s\n",
|
printf("%d,%s,%s,%s,%s,%s\n",
|
||||||
user_id,
|
user_id,
|
||||||
@ -219,7 +216,7 @@ dump_user_access_csv(
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
ipmi_print_user_list(
|
ipmi_print_user_list(
|
||||||
struct ipmi_intf * intf,
|
struct ipmi_intf *intf,
|
||||||
uint8_t channel_number)
|
uint8_t channel_number)
|
||||||
{
|
{
|
||||||
/* This is where you were! */
|
/* This is where you were! */
|
||||||
@ -242,7 +239,6 @@ ipmi_print_user_list(
|
|||||||
user_name))
|
user_name))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
if ((current_user_id == 0) ||
|
if ((current_user_id == 0) ||
|
||||||
user_access.link_auth_access ||
|
user_access.link_auth_access ||
|
||||||
user_access.ipmi_messaging_access ||
|
user_access.ipmi_messaging_access ||
|
||||||
@ -308,9 +304,9 @@ ipmi_print_user_summary(
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ipmi_user_set_username(
|
ipmi_user_set_username(
|
||||||
struct ipmi_intf * intf,
|
struct ipmi_intf *intf,
|
||||||
uint8_t user_id,
|
uint8_t user_id,
|
||||||
const char * name)
|
const char *name)
|
||||||
{
|
{
|
||||||
struct ipmi_rs * rsp;
|
struct ipmi_rs * rsp;
|
||||||
struct ipmi_rq req;
|
struct ipmi_rq req;
|
||||||
@ -344,15 +340,14 @@ ipmi_user_set_username(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ipmi_user_set_userpriv(
|
ipmi_user_set_userpriv(
|
||||||
struct ipmi_intf * intf,
|
struct ipmi_intf *intf,
|
||||||
uint8_t channel,
|
uint8_t channel,
|
||||||
uint8_t user_id,
|
uint8_t user_id,
|
||||||
const unsigned char privLevel)
|
const unsigned char privLevel)
|
||||||
{
|
{
|
||||||
struct ipmi_rs * rsp;
|
struct ipmi_rs *rsp;
|
||||||
struct ipmi_rq req;
|
struct ipmi_rq req;
|
||||||
uint8_t msg_data[3];
|
uint8_t msg_data[3];
|
||||||
|
|
||||||
@ -362,7 +357,6 @@ ipmi_user_set_userpriv(
|
|||||||
req.msg.data = msg_data;
|
req.msg.data = msg_data;
|
||||||
req.msg.data_len = 3;
|
req.msg.data_len = 3;
|
||||||
|
|
||||||
|
|
||||||
/* The channel number will remain constant throughout this function */
|
/* The channel number will remain constant throughout this function */
|
||||||
msg_data[0] = (channel & 0x0f); /* Do not change any bytes */
|
msg_data[0] = (channel & 0x0f); /* Do not change any bytes */
|
||||||
msg_data[1] = (user_id & 0x3f);
|
msg_data[1] = (user_id & 0x3f);
|
||||||
@ -386,7 +380,6 @@ ipmi_user_set_userpriv(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ipmi_user_set_password
|
* ipmi_user_set_password
|
||||||
*
|
*
|
||||||
@ -399,7 +392,7 @@ ipmi_user_set_password(
|
|||||||
struct ipmi_intf * intf,
|
struct ipmi_intf * intf,
|
||||||
uint8_t user_id,
|
uint8_t user_id,
|
||||||
uint8_t operation,
|
uint8_t operation,
|
||||||
const char * password,
|
const char *password,
|
||||||
int is_twenty_byte_password)
|
int is_twenty_byte_password)
|
||||||
{
|
{
|
||||||
struct ipmi_rs * rsp;
|
struct ipmi_rs * rsp;
|
||||||
@ -487,7 +480,6 @@ ipmi_user_test_password(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* print_user_usage
|
* print_user_usage
|
||||||
*/
|
*/
|
||||||
@ -606,7 +598,6 @@ ipmi_user_main(struct ipmi_intf * intf, int argc, char ** argv)
|
|||||||
char * tmp;
|
char * tmp;
|
||||||
const char * password_prompt =
|
const char * password_prompt =
|
||||||
ipmi_user_build_password_prompt(user_id);
|
ipmi_user_build_password_prompt(user_id);
|
||||||
|
|
||||||
#ifdef HAVE_GETPASSPHRASE
|
#ifdef HAVE_GETPASSPHRASE
|
||||||
tmp = getpassphrase (password_prompt);
|
tmp = getpassphrase (password_prompt);
|
||||||
#else
|
#else
|
||||||
@ -637,7 +628,6 @@ ipmi_user_main(struct ipmi_intf * intf, int argc, char ** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set
|
* Set
|
||||||
*/
|
*/
|
||||||
@ -710,7 +700,6 @@ ipmi_user_main(struct ipmi_intf * intf, int argc, char ** argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
retval = ipmi_user_set_password(intf,
|
retval = ipmi_user_set_password(intf,
|
||||||
user_id,
|
user_id,
|
||||||
IPMI_PASSWORD_SET_PASSWORD,
|
IPMI_PASSWORD_SET_PASSWORD,
|
||||||
@ -718,7 +707,6 @@ ipmi_user_main(struct ipmi_intf * intf, int argc, char ** argv)
|
|||||||
strlen(password) > 16);
|
strlen(password) > 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set Name
|
* Set Name
|
||||||
*/
|
*/
|
||||||
@ -742,7 +730,6 @@ ipmi_user_main(struct ipmi_intf * intf, int argc, char ** argv)
|
|||||||
print_user_usage();
|
print_user_usage();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (strncmp(argv[0], "priv", 4) == 0)
|
else if (strncmp(argv[0], "priv", 4) == 0)
|
||||||
@ -751,12 +738,11 @@ ipmi_user_main(struct ipmi_intf * intf, int argc, char ** argv)
|
|||||||
uint8_t priv_level;
|
uint8_t priv_level;
|
||||||
uint8_t channel = 0x0e; /* Use channel running on */
|
uint8_t channel = 0x0e; /* Use channel running on */
|
||||||
|
|
||||||
if (
|
if (argc != 3 && argc != 4)
|
||||||
(argc != 3) &&
|
{
|
||||||
(argc != 4)
|
print_user_usage();
|
||||||
)
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (argc == 4)
|
if (argc == 4)
|
||||||
{
|
{
|
||||||
channel = (uint8_t)strtol(argv[3], NULL, 0);
|
channel = (uint8_t)strtol(argv[3], NULL, 0);
|
||||||
@ -814,7 +800,6 @@ ipmi_user_main(struct ipmi_intf * intf, int argc, char ** argv)
|
|||||||
null_password,
|
null_password,
|
||||||
0); /* This field is ignored */
|
0); /* This field is ignored */
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
retval = -1;
|
retval = -1;
|
||||||
@ -822,6 +807,5 @@ ipmi_user_main(struct ipmi_intf * intf, int argc, char ** argv)
|
|||||||
print_user_usage();
|
print_user_usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user