From: kremlin- Date: Thu, 26 Jun 2014 23:18:26 +0000 (-0500) Subject: cut out install code that should be handled in makefile X-Git-Tag: hostnamed-copyable~8 X-Git-Url: https://uglyman.kremlin.cc/gitweb/gitweb.cgi?a=commitdiff_plain;h=36961b20f9c3d6698db46c1bea91ed93f7122d9c;p=systembsd.git cut out install code that should be handled in makefile --- diff --git a/src/config.c b/src/config.c index 5cbecb1..7469e67 100644 --- a/src/config.c +++ b/src/config.c @@ -62,16 +62,16 @@ gboolean config_init() { config_path = "/etc/systemd_compat.conf"; config_lstat_ret = g_lstat(config_path, config_lstat); - /* does conf exist? */ + /* this should all be handled in the makefile + * does conf exist? if(config_lstat_ret) { - /* if not, can we write to where it should be? */ if(g_access("/etc/", W_OK)) { g_printf("%s\n", "no write permissions for /etc/! exiting.."); return FALSE; } - int config_descr; /*TODO add to descr array for sigints, etc */ + int config_descr; config_descr = g_open(config_path, O_CREAT, 644); gchar *posix_hostname; @@ -82,7 +82,7 @@ gboolean config_init() { g_key_file_set_string(config, "hostnamed", "Hostname", posix_hostname); g_key_file_set_string(config, "hostnamed", "PrettyHostname", ""); g_key_file_set_string(config, "hostnamed", "IconName", "Computer"); - g_key_file_set_string(config, "hostnamed", "ChassisType","laptop"); /*TODO set these correctly */ + g_key_file_set_string(config, "hostnamed", "ChassisType","laptop"); if(!g_key_file_save_to_file(config, config_path, NULL)) { g_printf("failed to write config to %s!\n", config_path); @@ -94,22 +94,22 @@ gboolean config_init() { g_free(posix_hostname); - return TRUE; + return TRUE; - /* it does exist, read it */ - } else { + } else { */ - if(g_access(config_path, W_OK)) { - g_printf("%s\n", "no write permissions for /etc/! exiting.."); - return FALSE; - } else if(g_key_file_load_from_file(config, config_path, G_KEY_FILE_KEEP_COMMENTS, NULL)) - return TRUE; + if(g_access(config_path, W_OK)) { - g_printf("could not read config at %s! exiting..", config_path); + g_printf("%s\n", "no write permissions for /etc/! exiting.."); return FALSE; - } -} + } else if(g_key_file_load_from_file(config, config_path, G_KEY_FILE_KEEP_COMMENTS, NULL)) + return TRUE; + + g_printf("could not read config at %s! exiting..", config_path); + return FALSE; +} +/* this definitely does not need to exist gboolean init_xml() { const gchar * const *data_dir_prefix; @@ -121,10 +121,8 @@ gboolean init_xml() { xml_lstat_ret = g_lstat(data_dir, xml_lstat); - /* does xml dir exist? */ if(xml_lstat_ret) { - /* if not, can we write to where it should be? */ if(g_access(data_dir_prefix[0], W_OK)) { g_printf("no write permissions for %s! exiting...\n", data_dir_prefix[0]); return FALSE; @@ -137,19 +135,16 @@ gboolean init_xml() { return FALSE; } - /* read in xml files from conf/ */ if(!read_xml_from_installconf()) { g_printf("failed to read xml configs in conf/...\n"); return FALSE; } - /* write our configs to system data dir */ if(!populate_xml_data_dir()) { g_printf("failed to write xml configs to %s...\n", data_dir); return FALSE; } - /* get descriptors from freshly-installed configs */ if(!set_xml_descriptors()) { g_printf("failed to fopen xml configs...\n"); return FALSE; @@ -157,7 +152,6 @@ gboolean init_xml() { return TRUE; - /* it does exist, read it */ } else { if(!set_xml_descriptors()) { @@ -167,7 +161,7 @@ gboolean init_xml() { return TRUE; } -} +} */ void clean_config() { diff --git a/src/config.h b/src/config.h index a209a1c..3fdf183 100644 --- a/src/config.h +++ b/src/config.h @@ -7,12 +7,13 @@ static gchar **hostnamed_ispect_xml, **hostnamed_dbus_xml, /* manually increment this if adding new functionality/config files */ static const guint XML_FILE_COUNT = 8; -static gchar **xml_contents[] = { +/* i'm not sure we even need to load in ispect xml.. +gchar **xml_contents[] = { hostnamed_ispect_xml, hostnamed_dbus_xml, localed_ispect_xml, localed_dbus_xml, timedated_ispect_xml, timedated_dbus_xml, logind_ispect_xml, logind_dbus_xml -}; +};*/ /* TODO ifdef allowed editable xml only take files that meet exact sizes * of ones hashed below */ @@ -29,11 +30,3 @@ static const gchar *timedated_dbus_sum = "d7d67482a821cbc7a6ab3a68f1c00e0dc61a static const gchar *timedated_ispect_sum = "f576cb908636a285c9cd2e42a71ad243a0d5eb0ff12398f0627cce56c15a8268"; #endif - -static gboolean populate_xml_data_dir() { - -} - -static gboolean read_xml_from_installconf() { - -} diff --git a/src/main.c b/src/main.c index a592502..3cf0ee0 100644 --- a/src/main.c +++ b/src/main.c @@ -14,36 +14,28 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* debugging */ -#define INSTALL 1 -//#define NO_BUILTIN_XML 1 -/* end debugging */ - #include #include #include #include #include "config.c" #include "interfaces/hostnamed/hostnamed.c" -//#include "main/h" gboolean systemd_utils_init() { - #ifdef INSTALL - if(!config_init()) { - gchar *tmp; - tmp = "/etc/"; //what the hell is /etc/xdg anyway - - g_printf("FAILED to install configs in %s!\n", tmp); - return FALSE; - } - if(!init_xml()) { - const gchar * const *tmp; - tmp = g_get_system_data_dirs(); - - g_printf("FAILED to install xml configs in %s!\n", tmp[0]); - return FALSE; - } - #endif + if(!config_init()) { + gchar *tmp; + tmp = "/etc/systemd_compat.conf"; + + g_printf("FAILED to open config %s!\n", tmp); + return FALSE; + } + /*if(!init_xml()) { + const gchar * const *tmp; + tmp = g_get_system_data_dirs(); + + g_printf("FAILED to install xml configs in %s!\n", tmp[0]); + return FALSE; + }*/ return TRUE; } diff --git a/src/main.h b/src/main.h deleted file mode 100644 index 8d1c257..0000000 --- a/src/main.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2014 Ian Sutton - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include - -//TODO change this to config dir, not data dir -gboolean install_conf() { - gchar *our_conf_uri = "systemd-utl/xml-conf/"; - gchar **data_dir = g_get_system_data_dirs(); - - if(g_strcmp0(data_dir[0], NULL)) { - const gchar our_conf_path[256]; - g_snprintf(our_conf_path, sizeof our_conf_path, "%s%s", *data_dir, our_conf_uri); - GError **errors; - - /*TODO permissions w/ this */ - g_mkdir_with_parents(our_conf_path, 0644); - - return FALSE; - //return (errors[0] == NULL); - - } else - return FALSE; -}