This helps in case then user doesn't have dmidecode in his PATH. For example, if user elevates his privileges with sudo, then he may not inherit some superuser's environmental variables ($PATH, contaning additional directories - /sbin, /usr/sbin and similar).
In case of failure to determine full path to dmidecode it just fallbacks to the default value.
Tested only on Linux.
Signed-off-by: Peter Lemenkov lemenkov@gmail.com --- Makefile | 5 ++++- dmi.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile index e83fc0b..7919e10 100644 --- a/Makefile +++ b/Makefile @@ -169,6 +169,9 @@ CONFIG_DEDIPROG ?= no # Disable wiki printing by default. It is only useful if you have wiki access. CONFIG_PRINT_WIKI ?= no
+# Try to detect full path for dmidecode +CONFIG_DMIDECODE_PATH ?= $(shell LC_ALL=C type -p dmidecode 2>/dev/null || echo "dmidecode") + ifeq ($(CONFIG_INTERNAL), yes) FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1' PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o dmi.o internal.o @@ -323,7 +326,7 @@ $(PROGRAM)$(EXEC_SUFFIX): $(OBJS) TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
%.o: %.c .features - $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $< + $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -DCONFIG_DMIDECODE_PATH="$(CONFIG_DMIDECODE_PATH)" -o $@ -c $<
# Make sure to add all names of generated binaries here. # This includes all frontends and libflashrom. diff --git a/dmi.c b/dmi.c index f18907f..d483acb 100644 --- a/dmi.c +++ b/dmi.c @@ -55,7 +55,7 @@ static const char *dmidecode_names[] = { };
#define DMI_COMMAND_LEN_MAX 260 -static const char *dmidecode_command = "dmidecode"; +static const char *dmidecode_command = CONFIG_DMIDECODE_PATH;
static char *dmistrings[ARRAY_SIZE(dmidecode_names)];