aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Rostovtsev <tetromino@gentoo.org>2012-09-06 01:03:34 -0400
committerAlexandre Rostovtsev <tetromino@gentoo.org>2012-09-06 01:09:08 -0400
commit30d1b0efed5f89eb3969937aa9d8695081b1aabb (patch)
tree3e52c3c7da943ab8c5fd0c925d92a250f04449b0
parentFix memory leaks (diff)
downloadopenrc-settingsd-30d1b0efed5f89eb3969937aa9d8695081b1aabb.tar.gz
openrc-settingsd-30d1b0efed5f89eb3969937aa9d8695081b1aabb.tar.bz2
openrc-settingsd-30d1b0efed5f89eb3969937aa9d8695081b1aabb.zip
Use rc_sys for vm detection
-rw-r--r--TODO3
-rw-r--r--src/hostnamed.c9
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 <gio/gio.h>
#include <polkit/polkit.h>
+#include <rc.h>
+
#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