summaryrefslogtreecommitdiffstats
path: root/discover
diff options
context:
space:
mode:
Diffstat (limited to 'discover')
-rw-r--r--discover/Makefile.am1
-rw-r--r--discover/sysinfo.c35
2 files changed, 33 insertions, 3 deletions
diff --git a/discover/Makefile.am b/discover/Makefile.am
index 1fd8d96..2a7885d 100644
--- a/discover/Makefile.am
+++ b/discover/Makefile.am
@@ -22,6 +22,7 @@ AM_CFLAGS = $(DEFAULT_CFLAGS) \
-DPREFIX='"$(prefix)"' \
-DPKG_SHARE_DIR='"$(pkgdatadir)"' \
-DPKG_SYSCONF_DIR='"$(pkgsysconfdir)"' \
+ -DPKG_LIBEXEC_DIR='"$(pkglibexecdir)"' \
-DLOCAL_STATE_DIR='"$(localstatedir)"'
EXTRA_DIST = native-parser.c
diff --git a/discover/sysinfo.c b/discover/sysinfo.c
index 19dac57..f75819b 100644
--- a/discover/sysinfo.c
+++ b/discover/sysinfo.c
@@ -2,6 +2,7 @@
#include <string.h>
#include <talloc/talloc.h>
+#include <process/process.h>
#include "discover-server.h"
#include "sysinfo.h"
@@ -9,6 +10,8 @@
static struct system_info *sysinfo;
static struct discover_server *server;
+static const char *sysinfo_helper = PKG_LIBEXEC_DIR "/pb-sysinfo";
+
const struct system_info *system_info_get(void)
{
return sysinfo;
@@ -50,10 +53,36 @@ void system_info_register_interface(unsigned int hwaddr_size, uint8_t *hwaddr,
discover_server_notify_system_info(server, sysinfo);
}
-static void system_info_set_identifier(struct system_info *info
- __attribute__((unused)))
+static void system_info_set_identifier(struct system_info *info)
{
- /* todo: call helpers to set type & id */
+ struct process *process;
+ int rc;
+ const char *argv[] = {
+ sysinfo_helper, NULL, NULL,
+ };
+
+ process = process_create(info);
+ process->path = sysinfo_helper;
+ process->argv = argv;
+ process->keep_stdout = true;
+
+ argv[1] = "--type";
+ rc = process_run_sync(process);
+
+ if (!rc) {
+ info->type = talloc_strndup(info, process->stdout_buf,
+ process->stdout_len);
+ }
+
+ argv[1] = "--id";
+ rc = process_run_sync(process);
+
+ if (!rc) {
+ info->identifier = talloc_strndup(info, process->stdout_buf,
+ process->stdout_len);
+ }
+
+ process_release(process);
}
void system_info_init(struct discover_server *s)
OpenPOWER on IntegriCloud