mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
add -U option for setting lan username
fix -v usage for plugins
This commit is contained in:
parent
fcb6595b6e
commit
b502dc0bc7
@ -104,7 +104,7 @@ struct ipmi_intf {
|
|||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
int abort;
|
int abort;
|
||||||
int pedantic;
|
int pedantic;
|
||||||
int (*open)(struct ipmi_intf *, char *, int, char *);
|
int (*open)(struct ipmi_intf *, char *, int, char *, char *);
|
||||||
void (*close)(struct ipmi_intf *);
|
void (*close)(struct ipmi_intf *);
|
||||||
struct ipmi_rs *(*sendrecv)(struct ipmi_intf *, struct ipmi_rq *);
|
struct ipmi_rs *(*sendrecv)(struct ipmi_intf *, struct ipmi_rq *);
|
||||||
};
|
};
|
||||||
|
@ -205,7 +205,7 @@ int main(int argc, char ** argv)
|
|||||||
printf("Connecting to OpenIPMI device.\n");
|
printf("Connecting to OpenIPMI device.\n");
|
||||||
|
|
||||||
/* open connection to openipmi device */
|
/* open connection to openipmi device */
|
||||||
r = intf->open(intf, NULL, 0, NULL);
|
r = intf->open(intf, NULL, 0, NULL, NULL);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
printf("ERROR: Unable to open OpenIPMI device\n");
|
printf("ERROR: Unable to open OpenIPMI device\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -226,14 +226,14 @@ int main(int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
int (*submain)(struct ipmi_intf *, int, char **);
|
int (*submain)(struct ipmi_intf *, int, char **);
|
||||||
struct ipmi_intf * intf = NULL;
|
struct ipmi_intf * intf = NULL;
|
||||||
char * hostname = NULL, * password = NULL;
|
char * hostname = NULL, * password = NULL, * username = NULL;
|
||||||
int argflag, i, rc=0, port = 623, pedantic = 0;
|
int argflag, i, rc=0, port = 623, pedantic = 0;
|
||||||
char intfname[32];
|
char intfname[32];
|
||||||
|
|
||||||
if (ipmi_intf_init() < 0)
|
if (ipmi_intf_init() < 0)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
while ((argflag = getopt(argc, (char **)argv, "hVvcgI:H:P:p:")) != -1)
|
while ((argflag = getopt(argc, (char **)argv, "hVvcgI:H:P:U:p:")) != -1)
|
||||||
{
|
{
|
||||||
switch (argflag) {
|
switch (argflag) {
|
||||||
case 'h':
|
case 'h':
|
||||||
@ -267,6 +267,9 @@ int main(int argc, char ** argv)
|
|||||||
case 'P':
|
case 'P':
|
||||||
password = strdup(optarg);
|
password = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'U':
|
||||||
|
username = strdup(optarg);
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
port = atoi(optarg);
|
port = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
@ -292,7 +295,7 @@ int main(int argc, char ** argv)
|
|||||||
goto out_free;
|
goto out_free;
|
||||||
}
|
}
|
||||||
else if (!strncmp(argv[optind], "event", 5)) {
|
else if (!strncmp(argv[optind], "event", 5)) {
|
||||||
if (intf->open(intf, hostname, port, password) < 0)
|
if (intf->open(intf, hostname, port, username, password) < 0)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
ipmi_send_platform_event(intf);
|
ipmi_send_platform_event(intf);
|
||||||
goto out_close;
|
goto out_close;
|
||||||
@ -324,7 +327,7 @@ int main(int argc, char ** argv)
|
|||||||
else if (!strncmp(argv[optind], "userinfo", 8)) {
|
else if (!strncmp(argv[optind], "userinfo", 8)) {
|
||||||
if (argc-optind-1 > 0) {
|
if (argc-optind-1 > 0) {
|
||||||
unsigned char c = strtod(argv[optind+1], NULL);
|
unsigned char c = strtod(argv[optind+1], NULL);
|
||||||
rc = intf->open(intf, hostname, port, password);
|
rc = intf->open(intf, hostname, port, username, password);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
ipmi_get_user_access(intf, c, 1);
|
ipmi_get_user_access(intf, c, 1);
|
||||||
@ -338,7 +341,7 @@ int main(int argc, char ** argv)
|
|||||||
else if (!strncmp(argv[optind], "chaninfo", 8)) {
|
else if (!strncmp(argv[optind], "chaninfo", 8)) {
|
||||||
if (argc-optind-1 > 0) {
|
if (argc-optind-1 > 0) {
|
||||||
unsigned char c = strtod(argv[optind+1], NULL);
|
unsigned char c = strtod(argv[optind+1], NULL);
|
||||||
rc = intf->open(intf, hostname, port, password);
|
rc = intf->open(intf, hostname, port, username, password);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
verbose++;
|
verbose++;
|
||||||
@ -361,7 +364,7 @@ int main(int argc, char ** argv)
|
|||||||
goto out_free;
|
goto out_free;
|
||||||
|
|
||||||
if (intf->open) {
|
if (intf->open) {
|
||||||
rc = intf->open(intf, hostname, port, password);
|
rc = intf->open(intf, hostname, port, username, password);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
}
|
}
|
||||||
@ -377,6 +380,8 @@ int main(int argc, char ** argv)
|
|||||||
out_free:
|
out_free:
|
||||||
if (hostname)
|
if (hostname)
|
||||||
free(hostname);
|
free(hostname);
|
||||||
|
if (username)
|
||||||
|
free(username);
|
||||||
if (password)
|
if (password)
|
||||||
free(password);
|
free(password);
|
||||||
|
|
||||||
|
@ -38,7 +38,9 @@ plugindir = $(pluginpath)
|
|||||||
|
|
||||||
INCLUDES = -I$(top_srcdir)/include
|
INCLUDES = -I$(top_srcdir)/include
|
||||||
|
|
||||||
intf_lan_la_LDFLAGS = -module -avoid-version
|
intf_lan_la_LDFLAGS = -module -avoid-version
|
||||||
plugin_LTLIBRARIES = intf_lan.la
|
intf_lan_la_LIBADD = $(top_srcdir)/lib/libipmitool.la
|
||||||
intf_lan_la_SOURCES = lan.c lan.h asf.h rmcp.h md5.c md5.h
|
intf_lan_la_SOURCES = lan.c lan.h asf.h rmcp.h md5.c md5.h
|
||||||
|
|
||||||
|
plugin_LTLIBRARIES = intf_lan.la
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ query_alarm(int signo)
|
|||||||
siglongjmp(jmpbuf, 1);
|
siglongjmp(jmpbuf, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
const struct valstr ipmi_privlvl_vals[] = {
|
const struct valstr ipmi_privlvl_vals[] = {
|
||||||
{ IPMI_SESSION_PRIV_CALLBACK, "CALLBACK" },
|
{ IPMI_SESSION_PRIV_CALLBACK, "CALLBACK" },
|
||||||
{ IPMI_SESSION_PRIV_USER, "USER" },
|
{ IPMI_SESSION_PRIV_USER, "USER" },
|
||||||
@ -101,7 +102,7 @@ const struct valstr ipmi_authtype_vals[] = {
|
|||||||
{ IPMI_SESSION_AUTHTYPE_OEM, "OEM" },
|
{ IPMI_SESSION_AUTHTYPE_OEM, "OEM" },
|
||||||
{ 0, NULL },
|
{ 0, NULL },
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
static const struct valstr ipmi_channel_protocol_vals[] = {
|
static const struct valstr ipmi_channel_protocol_vals[] = {
|
||||||
{ 0x00, "reserved" },
|
{ 0x00, "reserved" },
|
||||||
{ 0x01, "IPMB-1.0" },
|
{ 0x01, "IPMB-1.0" },
|
||||||
@ -716,6 +717,7 @@ ipmi_lan_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
|
|||||||
return rsp;
|
return rsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
void
|
void
|
||||||
ipmi_get_channel_info(struct ipmi_intf * intf, unsigned char channel)
|
ipmi_get_channel_info(struct ipmi_intf * intf, unsigned char channel)
|
||||||
{
|
{
|
||||||
@ -810,6 +812,7 @@ ipmi_get_channel_info(struct ipmi_intf * intf, unsigned char channel)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IPMI Get Channel Authentication Capabilities Command
|
* IPMI Get Channel Authentication Capabilities Command
|
||||||
@ -1192,7 +1195,7 @@ void ipmi_lan_close(struct ipmi_intf * intf)
|
|||||||
ipmi_req_clear_entries();
|
ipmi_req_clear_entries();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ipmi_lan_open(struct ipmi_intf * intf, char * hostname, int port, char * password)
|
int ipmi_lan_open(struct ipmi_intf * intf, char * hostname, int port, char * username, char * password)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
@ -1211,6 +1214,10 @@ int ipmi_lan_open(struct ipmi_intf * intf, char * hostname, int port, char * pas
|
|||||||
memset(&lan_session, 0, sizeof(lan_session));
|
memset(&lan_session, 0, sizeof(lan_session));
|
||||||
curr_seq = 0;
|
curr_seq = 0;
|
||||||
|
|
||||||
|
if (username) {
|
||||||
|
memcpy(lan_session.username, username, strlen(username));
|
||||||
|
}
|
||||||
|
|
||||||
if (password) {
|
if (password) {
|
||||||
lan_session.password = 1;
|
lan_session.password = 1;
|
||||||
memcpy(lan_session.authcode, password, strlen(password));
|
memcpy(lan_session.authcode, password, strlen(password));
|
||||||
|
@ -63,7 +63,7 @@ unsigned char * ipmi_auth_md5(unsigned char * data, int data_len);
|
|||||||
unsigned char ipmi_csum(unsigned char * d, int s);
|
unsigned char ipmi_csum(unsigned char * d, int s);
|
||||||
|
|
||||||
struct ipmi_rs * ipmi_lan_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req);
|
struct ipmi_rs * ipmi_lan_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req);
|
||||||
int ipmi_lan_open(struct ipmi_intf * intf, char * hostname, int port, char * password);
|
int ipmi_lan_open(struct ipmi_intf * intf, char * hostname, int port, char * username, char * password);
|
||||||
void ipmi_lan_close(struct ipmi_intf * intf);
|
void ipmi_lan_close(struct ipmi_intf * intf);
|
||||||
void ipmi_get_channel_info(struct ipmi_intf * intf, unsigned char channel);
|
void ipmi_get_channel_info(struct ipmi_intf * intf, unsigned char channel);
|
||||||
int ipmi_lan_ping(struct ipmi_intf * intf);
|
int ipmi_lan_ping(struct ipmi_intf * intf);
|
||||||
|
@ -38,6 +38,9 @@ plugindir = $(pluginpath)
|
|||||||
|
|
||||||
INCLUDES = -I$(top_srcdir)/include
|
INCLUDES = -I$(top_srcdir)/include
|
||||||
|
|
||||||
intf_open_la_LDFLAGS = -module -avoid-version
|
intf_open_la_LDFLAGS = -module -avoid-version
|
||||||
plugin_LTLIBRARIES = intf_open.la
|
intf_open_la_LIBADD = $(top_srcdir)/lib/libipmitool.la
|
||||||
intf_open_la_SOURCES = open.c open.h
|
intf_open_la_SOURCES = open.c open.h
|
||||||
|
|
||||||
|
plugin_LTLIBRARIES = intf_open.la
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ void ipmi_openipmi_close(struct ipmi_intf * intf)
|
|||||||
close(intf->fd);
|
close(intf->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ipmi_openipmi_open(struct ipmi_intf * intf, char * dev, int __unused1, char * __unused2)
|
int ipmi_openipmi_open(struct ipmi_intf * intf, char * dev, int __unused1, char * __unused2, char * __unused3)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#define OPENIPMI_DEV "/dev/ipmi0"
|
#define OPENIPMI_DEV "/dev/ipmi0"
|
||||||
|
|
||||||
struct ipmi_rs * ipmi_openipmi_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req);
|
struct ipmi_rs * ipmi_openipmi_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req);
|
||||||
int ipmi_openipmi_open(struct ipmi_intf * intf, char * dev, int __unused1, char * __unused2);
|
int ipmi_openipmi_open(struct ipmi_intf * intf, char * dev, int __unused1, char * __unused2, char * __unused3);
|
||||||
void ipmi_openipmi_close(struct ipmi_intf * intf);
|
void ipmi_openipmi_close(struct ipmi_intf * intf);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user