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;
|
||||
int abort;
|
||||
int pedantic;
|
||||
int (*open)(struct ipmi_intf *, char *, int, char *);
|
||||
int (*open)(struct ipmi_intf *, char *, int, char *, char *);
|
||||
void (*close)(struct ipmi_intf *);
|
||||
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");
|
||||
|
||||
/* open connection to openipmi device */
|
||||
r = intf->open(intf, NULL, 0, NULL);
|
||||
r = intf->open(intf, NULL, 0, NULL, NULL);
|
||||
if (r < 0) {
|
||||
printf("ERROR: Unable to open OpenIPMI device\n");
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -226,14 +226,14 @@ int main(int argc, char ** argv)
|
||||
{
|
||||
int (*submain)(struct ipmi_intf *, int, char **);
|
||||
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;
|
||||
char intfname[32];
|
||||
|
||||
if (ipmi_intf_init() < 0)
|
||||
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) {
|
||||
case 'h':
|
||||
@ -267,6 +267,9 @@ int main(int argc, char ** argv)
|
||||
case 'P':
|
||||
password = strdup(optarg);
|
||||
break;
|
||||
case 'U':
|
||||
username = strdup(optarg);
|
||||
break;
|
||||
case 'p':
|
||||
port = atoi(optarg);
|
||||
break;
|
||||
@ -292,7 +295,7 @@ int main(int argc, char ** argv)
|
||||
goto out_free;
|
||||
}
|
||||
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;
|
||||
ipmi_send_platform_event(intf);
|
||||
goto out_close;
|
||||
@ -324,7 +327,7 @@ int main(int argc, char ** argv)
|
||||
else if (!strncmp(argv[optind], "userinfo", 8)) {
|
||||
if (argc-optind-1 > 0) {
|
||||
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)
|
||||
goto out_free;
|
||||
ipmi_get_user_access(intf, c, 1);
|
||||
@ -338,7 +341,7 @@ int main(int argc, char ** argv)
|
||||
else if (!strncmp(argv[optind], "chaninfo", 8)) {
|
||||
if (argc-optind-1 > 0) {
|
||||
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)
|
||||
goto out_free;
|
||||
verbose++;
|
||||
@ -361,7 +364,7 @@ int main(int argc, char ** argv)
|
||||
goto out_free;
|
||||
|
||||
if (intf->open) {
|
||||
rc = intf->open(intf, hostname, port, password);
|
||||
rc = intf->open(intf, hostname, port, username, password);
|
||||
if (rc < 0)
|
||||
goto out_free;
|
||||
}
|
||||
@ -377,6 +380,8 @@ int main(int argc, char ** argv)
|
||||
out_free:
|
||||
if (hostname)
|
||||
free(hostname);
|
||||
if (username)
|
||||
free(username);
|
||||
if (password)
|
||||
free(password);
|
||||
|
||||
|
@ -38,7 +38,9 @@ plugindir = $(pluginpath)
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/include
|
||||
|
||||
intf_lan_la_LDFLAGS = -module -avoid-version
|
||||
plugin_LTLIBRARIES = intf_lan.la
|
||||
intf_lan_la_SOURCES = lan.c lan.h asf.h rmcp.h md5.c md5.h
|
||||
intf_lan_la_LDFLAGS = -module -avoid-version
|
||||
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
|
||||
|
||||
plugin_LTLIBRARIES = intf_lan.la
|
||||
|
||||
|
@ -83,6 +83,7 @@ query_alarm(int signo)
|
||||
siglongjmp(jmpbuf, 1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
const struct valstr ipmi_privlvl_vals[] = {
|
||||
{ IPMI_SESSION_PRIV_CALLBACK, "CALLBACK" },
|
||||
{ IPMI_SESSION_PRIV_USER, "USER" },
|
||||
@ -101,7 +102,7 @@ const struct valstr ipmi_authtype_vals[] = {
|
||||
{ IPMI_SESSION_AUTHTYPE_OEM, "OEM" },
|
||||
{ 0, NULL },
|
||||
};
|
||||
|
||||
#endif
|
||||
static const struct valstr ipmi_channel_protocol_vals[] = {
|
||||
{ 0x00, "reserved" },
|
||||
{ 0x01, "IPMB-1.0" },
|
||||
@ -716,6 +717,7 @@ ipmi_lan_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
|
||||
return rsp;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
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;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* IPMI Get Channel Authentication Capabilities Command
|
||||
@ -1192,7 +1195,7 @@ void ipmi_lan_close(struct ipmi_intf * intf)
|
||||
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;
|
||||
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));
|
||||
curr_seq = 0;
|
||||
|
||||
if (username) {
|
||||
memcpy(lan_session.username, username, strlen(username));
|
||||
}
|
||||
|
||||
if (password) {
|
||||
lan_session.password = 1;
|
||||
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);
|
||||
|
||||
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_get_channel_info(struct ipmi_intf * intf, unsigned char channel);
|
||||
int ipmi_lan_ping(struct ipmi_intf * intf);
|
||||
|
@ -38,6 +38,9 @@ plugindir = $(pluginpath)
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/include
|
||||
|
||||
intf_open_la_LDFLAGS = -module -avoid-version
|
||||
plugin_LTLIBRARIES = intf_open.la
|
||||
intf_open_la_SOURCES = open.c open.h
|
||||
intf_open_la_LDFLAGS = -module -avoid-version
|
||||
intf_open_la_LIBADD = $(top_srcdir)/lib/libipmitool.la
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
#define OPENIPMI_DEV "/dev/ipmi0"
|
||||
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user