set hostnamed's 'hostname' property before export
[systembsd.git] / src / interfaces / hostnamed / hostnamed.c
index ad7df31fa55ba1badf37f2b7aa7d7742c314db18..e1614978c1cb03309ac61ed3ffb49f1576282b3d 100644 (file)
@@ -17,6 +17,8 @@
 #include <unistd.h>
 #include <limits.h>
 
+#include <sys/param.h>
+
 #include <glib.h>
 #include <gio/gio.h>
 
@@ -79,7 +81,13 @@ on_handle_set_icon_name(hostnamedHostname1 *hn1_passed_interf,
 const gchar *
 our_get_hostname() {
 
-    return "TODO";
+       int hostname_try;
+       gchar *hostname_buf;
+
+       hostname_buf = (gchar*) g_malloc0(MAXHOSTNAMELEN);
+       hostname_try = gethostname(hostname_buf, MAXHOSTNAMELEN);
+
+       return hostname_buf;
 }
 
 const gchar *
@@ -196,22 +204,9 @@ static void hostnamed_on_name_lost(GDBusConnection *conn,
 }
 
 /* safe call to try and start hostnamed */
-GError *hostnamed_init() {
+void hostnamed_init() {
 
     guint bus_descriptor;
-    GError *err = NULL;
-    gchar **hostnamed_ispect_xml;
-    gchar  *hostnamed_joined_xml;
-
-    hostnamed_freeable = g_ptr_array_new();
-    hostnamed_ispect_xml = g_malloc(3000);
-
-    g_file_get_contents("conf/hostnamed-ispect.xml", hostnamed_ispect_xml, NULL, NULL);
-    hostnamed_joined_xml = g_strjoinv("\n", hostnamed_ispect_xml);
-    spect_data = g_dbus_node_info_new_for_xml(hostnamed_joined_xml, NULL);
-
-    g_free(hostnamed_ispect_xml);
-    g_ptr_array_add(hostnamed_freeable, hostnamed_joined_xml);
 
     bus_descriptor = g_bus_own_name(G_BUS_TYPE_SYSTEM,
                                     "org.freedesktop.hostname1",
@@ -223,7 +218,6 @@ GError *hostnamed_init() {
                                     NULL);
 
     /* TODO: malloc and return reference as if a main() closed */
-    return err;
 }
 
 /* free()'s */