From: kremlin Date: Sat, 9 Aug 2014 15:44:36 +0000 (-0500) Subject: add set_names(), complement to icon/chassis setters X-Git-Url: https://uglyman.kremlin.cc/gitweb/gitweb.cgi?a=commitdiff_plain;h=e51864d107f420547cea1246cf4e2c71d992562d;p=systembsd.git add set_names(), complement to icon/chassis setters it runs during init and acts just like like icon/chassis/uname(3) functions work --- diff --git a/src/interfaces/hostnamed/hostnamed.c b/src/interfaces/hostnamed/hostnamed.c index 2fa5d7c..c9f1b4d 100644 --- a/src/interfaces/hostnamed/hostnamed.c +++ b/src/interfaces/hostnamed/hostnamed.c @@ -188,22 +188,6 @@ on_handle_set_icon_name(Hostname1 *hn1_passed_interf, const gchar * our_get_hostname() { - /*gchar *hostname_buf, *ret; - size_t hostname_divider; - - hostname_buf = (gchar*) g_malloc0(MAXHOSTNAMELEN); - ret = (gchar*) g_malloc0(MAXHOSTNAMELEN); - - g_ptr_array_add(hostnamed_freeable, hostname_buf); - g_ptr_array_add(hostnamed_freeable, ret); - - if(gethostname(hostname_buf, MAXHOSTNAMELEN) || g_strcmp0(hostname_buf, "") == 0) - return "localhost"; - - hostname_divider = strcspn(hostname_buf, "."); - - return strncpy(ret, hostname_buf, hostname_divider);*/ - if(HOSTNAME) return HOSTNAME; @@ -213,22 +197,6 @@ our_get_hostname() { const gchar * our_get_static_hostname() { - /*const gchar *pretty_hostname; - const gchar *ret; - - pretty_hostname = our_get_pretty_hostname(); - - if(g_strcmp0(pretty_hostname, "") == 0) - ret = our_get_hostname(); - - else if((ret = g_hostname_to_ascii(pretty_hostname))) { - - g_ptr_array_add(hostnamed_freeable, (gpointer)ret); - return ret; - } - - return ret;*/ - if(STATIC_HOSTNAME) return STATIC_HOSTNAME; else if(HOSTNAME) @@ -240,23 +208,6 @@ our_get_static_hostname() { const gchar * our_get_pretty_hostname() { - /*GKeyFile *config; - gchar *ret; - - config = g_key_file_new(); - - if(g_key_file_load_from_file(config, "/etc/systemd_compat.conf", G_KEY_FILE_NONE, NULL) - && (ret = g_key_file_get_value(config, "hostnamed", "PrettyHostname", NULL))) { ret might need to be freed, docs dont specify but i am suspicious - - g_key_file_unref(config); - return ret; - } - - if(config) - g_free(config); - - return "";*/ - if(PRETTY_HOSTNAME) return PRETTY_HOSTNAME; @@ -434,7 +385,7 @@ int main() { set_signal_handlers(); - if(!determine_chassis_and_icon() || !set_uname_properties()) + if(!determine_chassis_and_icon() || !set_uname_properties() || !set_names()) return 1; hostnamed_loop = g_main_loop_new(NULL, TRUE); @@ -461,6 +412,67 @@ int main() { return 0; } +gboolean set_names() { + + /*gchar *hostname_buf, *ret; + size_t hostname_divider; + + hostname_buf = (gchar*) g_malloc0(MAXHOSTNAMELEN); + ret = (gchar*) g_malloc0(MAXHOSTNAMELEN); + + g_ptr_array_add(hostnamed_freeable, hostname_buf); + g_ptr_array_add(hostnamed_freeable, ret); + + if(gethostname(hostname_buf, MAXHOSTNAMELEN) || g_strcmp0(hostname_buf, "") == 0) + return "localhost"; + + hostname_divider = strcspn(hostname_buf, "."); + + return strncpy(ret, hostname_buf, hostname_divider);*/ + + + + /*const gchar *pretty_hostname; + const gchar *ret; + + pretty_hostname = our_get_pretty_hostname(); + + if(g_strcmp0(pretty_hostname, "") == 0) + ret = our_get_hostname(); + + else if((ret = g_hostname_to_ascii(pretty_hostname))) { + + g_ptr_array_add(hostnamed_freeable, (gpointer)ret); + return ret; + } + + return ret;*/ + + + + /*GKeyFile *config; + gchar *ret; + + config = g_key_file_new(); + + if(g_key_file_load_from_file(config, "/etc/systemd_compat.conf", G_KEY_FILE_NONE, NULL) + && (ret = g_key_file_get_value(config, "hostnamed", "PrettyHostname", NULL))) { ret might need to be freed, docs dont specify but i am suspicious + + g_key_file_unref(config); + return ret; + } + + if(config) + g_free(config); + + return "";*/ + + + + + return FALSE; /* temp */ +} + gboolean set_uname_properties() { struct utsname un; diff --git a/src/interfaces/hostnamed/hostnamed.h b/src/interfaces/hostnamed/hostnamed.h index 6c5f207..8fc523e 100644 --- a/src/interfaces/hostnamed/hostnamed.h +++ b/src/interfaces/hostnamed/hostnamed.h @@ -25,3 +25,4 @@ gboolean up_native_get_sensordev(const char * id, struct sensordev * snsrdev); gboolean up_native_is_laptop(); gboolean is_server(gchar *arch); gboolean set_uname_properties(); +gboolean set_names();