+ g_main_loop_run(hostnamed_loop);
+ /* runs until single g_main_loop_quit() call is raised inside <interface>_mem_clean() */
+ g_main_loop_unref(hostnamed_loop);
+
+ /* guaranteed unownable */
+ g_bus_unown_name(bus_descriptor);
+
+ /* at this point no operations can occur with our data, it is safe to free it + its container */
+ g_ptr_array_free(hostnamed_freeable, TRUE);
+
+ return 0;
+}
+
+gboolean set_names() {
+
+ /* (1) set up */
+ gchar *hostname_buf, *static_hostname_buf, *pretty_hostname_buf;
+ GKeyFile *config;
+ size_t hostname_divider;
+
+ hostname_buf = (gchar*) g_malloc0(MAXHOSTNAMELEN);
+ static_hostname_buf = (gchar*) g_malloc0(4096);
+ pretty_hostname_buf = (gchar*) g_malloc0(4096);
+
+ config = g_key_file_new();
+
+ g_ptr_array_add(hostnamed_freeable, hostname_buf);
+ g_ptr_array_add(hostnamed_freeable, static_hostname_buf);
+ g_ptr_array_add(hostnamed_freeable, pretty_hostname_buf);
+
+ /* (2) set HOSTNAME */
+ if(gethostname(hostname_buf, MAXHOSTNAMELEN) || !g_strcmp0(hostname_buf, ""))
+ HOSTNAME = "localhost";
+
+ HOSTNAME = hostname_buf;
+
+ /* this bit gets you the /etc/myname style hostname
+ hostname_divider = strcspn(hostname_buf, ".");
+ strncpy(ret, hostname_buf, hostname_divider); */
+
+ /* (3) set PRETTY_HOSTNAME */
+ if(g_key_file_load_from_file(config, "/etc/systemd_compat.conf", G_KEY_FILE_NONE, NULL)
+ && (pretty_hostname_buf = g_key_file_get_value(config, "hostnamed", "PrettyHostname", NULL)))
+ PRETTY_HOSTNAME = pretty_hostname_buf;
+ else
+ PRETTY_HOSTNAME = "";
+
+ if(config)
+ g_key_file_unref(config);
+
+ /* (4) set STATIC_HOSTNAME */
+ if(!g_strcmp0(PRETTY_HOSTNAME, ""))
+ STATIC_HOSTNAME = HOSTNAME;
+
+ else if((static_hostname_buf = g_hostname_to_ascii(PRETTY_HOSTNAME)))
+ STATIC_HOSTNAME = static_hostname_buf;
+
+ return (HOSTNAME && STATIC_HOSTNAME && PRETTY_HOSTNAME) ? TRUE : FALSE;
+
+}
+
+gboolean set_uname_properties() {
+
+ struct utsname un;
+
+ if(-1 == uname(&un))
+ return FALSE;
+
+ KERN_NAME = (gchar*)g_malloc0(sizeof(un.sysname));
+ g_ptr_array_add(hostnamed_freeable, KERN_NAME);
+ g_strlcpy(KERN_NAME, un.sysname, sizeof(un.sysname));