From 30d1b0efed5f89eb3969937aa9d8695081b1aabb Mon Sep 17 00:00:00 2001 From: Alexandre Rostovtsev Date: Thu, 6 Sep 2012 01:03:34 -0400 Subject: Use rc_sys for vm detection --- TODO | 3 --- src/hostnamed.c | 9 ++++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index ff32ee0..9b68c84 100644 --- a/TODO +++ b/TODO @@ -6,9 +6,6 @@ if the relevant variable is set in /etc/rc.conf (go to read-only mode?) What happens if e.g. /etc/conf.d/hostname.{runlevel} files exist? Just document that this case is not supported? -Write an init.d file to read RC_SYS so that we can piggyback on openrc's -built-in virtualization detection. - De-systemd-ize hwclock.c Do something about runtime dependency on systemd's org.freedesktop.hostname1.policy, diff --git a/src/hostnamed.c b/src/hostnamed.c index 1fb14c0..b476cdb 100644 --- a/src/hostnamed.c +++ b/src/hostnamed.c @@ -26,6 +26,8 @@ #include #include +#include + #include "hostnamed.h" #include "hostname1-generated.h" #include "utils.h" @@ -68,10 +70,15 @@ hostname_is_valid (const gchar *name) static gchar * guess_icon_name () { - /* TODO: detect virtualization by reading rc_sys */ gchar *filebuf = NULL; gchar *ret = NULL; + /* Note that rc_sys() leaks memory :( */ + if (rc_sys() != NULL) { + ret = g_strdup ("computer-vm"); + goto out; + } + #if defined(__i386__) || defined(__x86_64__) /* Taken with a few minor changes from systemd's hostnamed -- cgit v1.2.3-65-gdbad