mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 10:37:22 +00:00
ID#277 - support for hostnames longer than 64 chars
ID#313 ipmitool doesn't support hostname long than 64 symbols ID#277 Minor issue with ipmi_intf_session_set_hostname() Commit adds support pretty much for FQDN not just up to the length of one label. This is achieved by change in in struct ipmi_session; and strdup() of user input. Of course, we have to free() this once we're done.
This commit is contained in:
parent
58837647c2
commit
deb9a4ed5d
@ -63,7 +63,7 @@ enum LANPLUS_SESSION_STATE {
|
||||
#define IPMI_KG_BUFFER_SIZE 21 /* key plus null byte */
|
||||
|
||||
struct ipmi_session {
|
||||
uint8_t hostname[64];
|
||||
char *hostname; /* Numeric IP adress or DNS name - see RFC 1034/RFC 1035 */
|
||||
uint8_t username[17];
|
||||
uint8_t authcode[IPMI_AUTHCODE_BUFFER_SIZE + 1];
|
||||
uint8_t challenge[16];
|
||||
@ -213,6 +213,7 @@ void ipmi_intf_session_set_port(struct ipmi_intf * intf, int port);
|
||||
void ipmi_intf_session_set_authtype(struct ipmi_intf * intf, uint8_t authtype);
|
||||
void ipmi_intf_session_set_timeout(struct ipmi_intf * intf, uint32_t timeout);
|
||||
void ipmi_intf_session_set_retry(struct ipmi_intf * intf, int retry);
|
||||
void ipmi_intf_session_cleanup(struct ipmi_intf *intf);
|
||||
void ipmi_cleanup(struct ipmi_intf * intf);
|
||||
|
||||
#if defined(IPMI_INTF_LAN) || defined (IPMI_INTF_LANPLUS)
|
||||
|
@ -194,15 +194,14 @@ struct ipmi_intf * ipmi_intf_load(char * name)
|
||||
void
|
||||
ipmi_intf_session_set_hostname(struct ipmi_intf * intf, char * hostname)
|
||||
{
|
||||
if (intf->session == NULL)
|
||||
if (intf->session == NULL || hostname == NULL) {
|
||||
return;
|
||||
|
||||
memset(intf->session->hostname, 0, 16);
|
||||
|
||||
if (hostname != NULL) {
|
||||
memcpy(intf->session->hostname, hostname,
|
||||
__min(strlen(hostname), 64));
|
||||
}
|
||||
if (intf->session->hostname != NULL) {
|
||||
free(intf->session->hostname);
|
||||
intf->session->hostname = NULL;
|
||||
}
|
||||
intf->session->hostname = strdup(hostname);
|
||||
}
|
||||
|
||||
void
|
||||
@ -330,6 +329,20 @@ ipmi_intf_session_set_retry(struct ipmi_intf * intf, int retry)
|
||||
intf->session->retry = retry;
|
||||
}
|
||||
|
||||
void
|
||||
ipmi_intf_session_cleanup(struct ipmi_intf *intf)
|
||||
{
|
||||
if (intf->session == NULL) {
|
||||
return;
|
||||
}
|
||||
if (intf->session->hostname != NULL) {
|
||||
free(intf->session->hostname);
|
||||
intf->session->hostname = NULL;
|
||||
}
|
||||
free(intf->session);
|
||||
intf->session = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
ipmi_cleanup(struct ipmi_intf * intf)
|
||||
{
|
||||
|
@ -2005,12 +2005,7 @@ ipmi_lan_close(struct ipmi_intf * intf)
|
||||
close(intf->fd);
|
||||
|
||||
ipmi_req_clear_entries();
|
||||
|
||||
if (intf->session != NULL) {
|
||||
free(intf->session);
|
||||
intf->session = NULL;
|
||||
}
|
||||
|
||||
ipmi_intf_session_cleanup(intf);
|
||||
intf->opened = 0;
|
||||
intf->manufacturer_id = IPMI_OEM_UNKNOWN;
|
||||
intf = NULL;
|
||||
|
@ -3291,12 +3291,7 @@ ipmi_lanplus_close(struct ipmi_intf * intf)
|
||||
close(intf->fd);
|
||||
|
||||
ipmi_req_clear_entries();
|
||||
|
||||
if (intf->session) {
|
||||
free(intf->session);
|
||||
intf->session = NULL;
|
||||
}
|
||||
|
||||
ipmi_intf_session_cleanup(intf);
|
||||
intf->session = NULL;
|
||||
intf->opened = 0;
|
||||
intf->manufacturer_id = IPMI_OEM_UNKNOWN;
|
||||
@ -3367,7 +3362,6 @@ ipmi_lanplus_open(struct ipmi_intf * intf)
|
||||
return -1;
|
||||
session = intf->session;
|
||||
|
||||
|
||||
if (!session->port)
|
||||
session->port = IPMI_LANPLUS_PORT;
|
||||
if (!session->privlvl)
|
||||
|
@ -305,12 +305,7 @@ serial_bm_close(struct ipmi_intf * intf)
|
||||
close(intf->fd);
|
||||
intf->fd = -1;
|
||||
}
|
||||
|
||||
if (intf->session) {
|
||||
free(intf->session);
|
||||
intf->session = NULL;
|
||||
}
|
||||
|
||||
ipmi_intf_session_cleanup(intf);
|
||||
intf->opened = 0;
|
||||
}
|
||||
|
||||
|
@ -242,12 +242,7 @@ ipmi_serial_term_close(struct ipmi_intf * intf)
|
||||
close(intf->fd);
|
||||
intf->fd = -1;
|
||||
}
|
||||
|
||||
if (intf->session) {
|
||||
free(intf->session);
|
||||
intf->session = NULL;
|
||||
}
|
||||
|
||||
ipmi_intf_session_cleanup(intf);
|
||||
intf->opened = 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user