mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
Use configurable path to IANA PEN registry
Add support for IANADIR and IANAUSERDIR variables to configure to allow for customizable locations of system and user-supplied IANA PEN registry. Also make path building code portable to Windows. Partially resolves ipmitool/ipmitool#11 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
parent
bd0475ce4a
commit
54abbaf0e8
26
configure.ac
26
configure.ac
@ -691,6 +691,32 @@ if test "x${!xdefault_intf_is_enabled}" != "xyes"; then
|
|||||||
AC_MSG_ERROR([** Cannot set ${DEFAULT_INTF} as default; ${DEFAULT_INTF} is not enabled. :${!xdefault_intf_is_enabled}:])
|
AC_MSG_ERROR([** Cannot set ${DEFAULT_INTF} as default; ${DEFAULT_INTF} is not enabled. :${!xdefault_intf_is_enabled}:])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
AC_ARG_VAR(IANADIR, [Configure the path to IANA PEN dictionary (default=DATAROOTDIR/misc)])
|
||||||
|
AC_ARG_VAR(IANAUSERDIR, [Configure the path to IANA PEN dictionary wihtin the user's HOME directory (default=.local/usr/share/misc)])
|
||||||
|
|
||||||
|
if test "x${IANADIR}" == "x"; then
|
||||||
|
echo Set IANA PEN dictionary search path to ${datarootdir}/misc
|
||||||
|
IANADIR="${datarootdir}/misc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "x${IANAUSERDIR}" == "x"; then
|
||||||
|
IANAUSERDIR=".local/usr/share/misc"
|
||||||
|
echo Set user\'s IANA PEN dictionary search path to ${IANAUSERDIR}
|
||||||
|
fi
|
||||||
|
|
||||||
|
AH_TEMPLATE([IANADIR],[The path to system IANA PEN dictionary])
|
||||||
|
AC_DEFINE_UNQUOTED(IANADIR, "`eval "echo ${IANADIR}"`", [])
|
||||||
|
|
||||||
|
AH_TEMPLATE([IANAUSERDIR],[The subpath to user IANA PEN dictionary within the user's HOME])
|
||||||
|
AC_DEFINE_UNQUOTED(IANAUSERDIR, "`eval "echo ${IANAUSERDIR}"`", [])
|
||||||
|
|
||||||
|
AH_TEMPLATE([PATH_SEPARATOR], [The path separator string])
|
||||||
|
#if defined _WIN32 || defined __CYGWIN__
|
||||||
|
AC_DEFINE(PATH_SEPARATOR, "\\")
|
||||||
|
#else
|
||||||
|
AC_DEFINE(PATH_SEPARATOR, "/")
|
||||||
|
#endif
|
||||||
|
|
||||||
dnl Generate files for build
|
dnl Generate files for build
|
||||||
AC_CONFIG_FILES([Makefile
|
AC_CONFIG_FILES([Makefile
|
||||||
doc/Makefile
|
doc/Makefile
|
||||||
|
@ -812,7 +812,7 @@ size_t count_bytes(const char *s, unsigned char c)
|
|||||||
* That is, IANA PEN at position 0, enterprise name at position 2.
|
* That is, IANA PEN at position 0, enterprise name at position 2.
|
||||||
*/
|
*/
|
||||||
#define IANA_NAME_OFFSET 2
|
#define IANA_NAME_OFFSET 2
|
||||||
#define IANA_PEN_REGISTRY "/usr/share/misc/enterprise-numbers"
|
#define IANA_PEN_REGISTRY "enterprise-numbers"
|
||||||
static
|
static
|
||||||
int oem_info_list_load(oem_valstr_list_t **list)
|
int oem_info_list_load(oem_valstr_list_t **list)
|
||||||
{
|
{
|
||||||
@ -826,8 +826,9 @@ int oem_info_list_load(oem_valstr_list_t **list)
|
|||||||
*/
|
*/
|
||||||
if ((home = getenv("HOME"))) {
|
if ((home = getenv("HOME"))) {
|
||||||
char path[PATH_MAX + 1] = { 0 };
|
char path[PATH_MAX + 1] = { 0 };
|
||||||
strncpy(path, home, sizeof(path));
|
snprintf(path, PATH_MAX, "%s%s",
|
||||||
strncat(path, "/.local" IANA_PEN_REGISTRY, PATH_MAX);
|
home,
|
||||||
|
PATH_SEPARATOR IANAUSERDIR PATH_SEPARATOR IANA_PEN_REGISTRY);
|
||||||
in = fopen(path, "r");
|
in = fopen(path, "r");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -835,7 +836,7 @@ int oem_info_list_load(oem_valstr_list_t **list)
|
|||||||
/*
|
/*
|
||||||
* Now open the system default file
|
* Now open the system default file
|
||||||
*/
|
*/
|
||||||
in = fopen(IANA_PEN_REGISTRY, "r");
|
in = fopen(IANADIR PATH_SEPARATOR IANA_PEN_REGISTRY, "r");
|
||||||
if (!in) {
|
if (!in) {
|
||||||
lperror(LOG_ERR, "IANA PEN registry open failed");
|
lperror(LOG_ERR, "IANA PEN registry open failed");
|
||||||
return -1;
|
return -1;
|
||||||
@ -923,8 +924,17 @@ int oem_info_list_load(oem_valstr_list_t **list)
|
|||||||
/* Just stop reading, and process what has already been read */
|
/* Just stop reading, and process what has already been read */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
strncpy((void *)item->valstr.str, line + IANA_NAME_OFFSET, len);
|
|
||||||
((char *)(item->valstr.str))[len] = 0;
|
/*
|
||||||
|
* Most other valstr arrays are constant and all of them aren't meant
|
||||||
|
* for modification, so the string inside 'struct valstr' is const.
|
||||||
|
* Here we're loading the strings dynamically so we intentionally
|
||||||
|
* cast to a non-const type to be able to modify data here and
|
||||||
|
* keep the compiler silent about it. Restrictions still apply to
|
||||||
|
* other places where these strings are used.
|
||||||
|
*/
|
||||||
|
snprintf((void *)item->valstr.str, len + 1,
|
||||||
|
"%s", line + IANA_NAME_OFFSET);
|
||||||
free_n(&line);
|
free_n(&line);
|
||||||
item->next = oemlist;
|
item->next = oemlist;
|
||||||
oemlist = item;
|
oemlist = item;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user