hal: Branch 'master'

Danny Kukawka dkukawka at kemper.freedesktop.org
Tue Feb 20 06:59:34 PST 2007


 hald/linux/probing/probe-smbios.c |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletion(-)

New commits:
diff-tree fc72b90bc52d357be8cabbe188b56bbe0dc8cf6d (from c80d811ece728dfeba60c1a10af12eca4bb9bbc5)
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Tue Feb 20 15:58:59 2007 +0100

    detect path to dmidecode on runtime (fd.o bug #9318)
    
    This adds detection of the location of dmidecode to the prober.
    This would fix fd.o bug #9318

diff --git a/hald/linux/probing/probe-smbios.c b/hald/linux/probing/probe-smbios.c
index bb9ace3..f74b2f0 100644
--- a/hald/linux/probing/probe-smbios.c
+++ b/hald/linux/probing/probe-smbios.c
@@ -34,6 +34,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/stat.h>
 #include <unistd.h>
 
 #include "libhal/libhal.h"
@@ -100,6 +101,16 @@ main (int argc, char *argv[])
 	int dmiparser_done_system = FALSE;
 	int dmiparser_done_chassis = FALSE;
 
+	uint i;
+	struct stat s;
+	const char *path = NULL;
+	const char *possible_paths[] = {
+		"/usr/sbin/dmidecode",
+		"/bin/dmidecode",
+		"/sbin/dmidecode",
+		"/usr/local/sbin/dmidecode",
+        };
+
 	/* assume failure */
 	ret = 1;
 
@@ -117,6 +128,20 @@ main (int argc, char *argv[])
 		goto out;
 	}
 
+
+	/* find the path to dmidecode */
+        for (i = 0; i < sizeof (possible_paths) / sizeof (char *); i++) {
+                if (stat (possible_paths[i], &s) == 0 && S_ISREG (s.st_mode)) {
+                        path = possible_paths[i];
+                        break;
+                }
+        }
+
+        if (path == NULL) {
+                HAL_ERROR(("Could not find dmidecode, exit!"));
+		exit(1);
+	}
+
 	tmp_ret = pipe (dmipipe);	
 	f = fdopen (dmipipe[0], "r");
 	nullfd = open ("/dev/null", O_RDONLY);
@@ -132,7 +157,7 @@ main (int argc, char *argv[])
 		close (dmipipe[1]);
 		
 		/* execute the child */
-		execl ("/usr/sbin/dmidecode", "/usr/sbin/dmidecode", NULL);
+		execl (path, path, NULL);
 		
 		/* throw an error if we ever reach this point */
 		HAL_ERROR (("Failed to execute dmidecode!"));


More information about the hal-commit mailing list