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;
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);
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;
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;
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;
return TRUE;
- /* it does exist, read it */
} else {
if(!set_xml_descriptors()) {
return TRUE;
}
-}
+} */
void clean_config() {
/* 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 */
static const gchar *timedated_ispect_sum = "f576cb908636a285c9cd2e42a71ad243a0d5eb0ff12398f0627cce56c15a8268";
#endif
-
-static gboolean populate_xml_data_dir() {
-
-}
-
-static gboolean read_xml_from_installconf() {
-
-}
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* debugging */
-#define INSTALL 1
-//#define NO_BUILTIN_XML 1
-/* end debugging */
-
#include <gio/gio.h>
#include <glib.h>
#include <glib/gprintf.h>
#include <glib/gstdio.h>
#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;
}
+++ /dev/null
-/*
- * Copyright (c) 2014 Ian Sutton <ian@kremlin.cc>
- *
- * 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 <gio/gio.h>
-
-//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;
-}