aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkremlin <ian@kremlin.cc>2014-07-08 16:15:51 +0800
committerkremlin <ian@kremlin.cc>2014-07-08 16:15:51 +0800
commit7f0a0212d65905aea6c875b6250e0a87dc9820d8 (patch)
treeaabd94f29221a52021dc646ff91e0a3131f3c527 /src
parent5b005882b2af5868261a01a386028291516aabb0 (diff)
downloadsystembsd-7f0a0212d65905aea6c875b6250e0a87dc9820d8.tar
systembsd-7f0a0212d65905aea6c875b6250e0a87dc9820d8.tar.gz
systembsd-7f0a0212d65905aea6c875b6250e0a87dc9820d8.tar.bz2
systembsd-7f0a0212d65905aea6c875b6250e0a87dc9820d8.tar.lz
systembsd-7f0a0212d65905aea6c875b6250e0a87dc9820d8.tar.xz
systembsd-7f0a0212d65905aea6c875b6250e0a87dc9820d8.tar.zst
systembsd-7f0a0212d65905aea6c875b6250e0a87dc9820d8.zip
more work on managing four interfaces as separate PIDs, new makefile rules for building and installing standalone interface binaries, a little documentation and preproccessor logic
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/hostnamed/hostnamed.c16
-rw-r--r--src/interfaces/localed/localed.c3
-rw-r--r--src/main.c55
3 files changed, 44 insertions, 30 deletions
diff --git a/src/interfaces/hostnamed/hostnamed.c b/src/interfaces/hostnamed/hostnamed.c
index ad7df31..f250aaa 100644
--- a/src/interfaces/hostnamed/hostnamed.c
+++ b/src/interfaces/hostnamed/hostnamed.c
@@ -196,22 +196,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 +210,6 @@ GError *hostnamed_init() {
NULL);
/* TODO: malloc and return reference as if a main() closed */
- return err;
}
/* free()'s */
diff --git a/src/interfaces/localed/localed.c b/src/interfaces/localed/localed.c
index 910c1e1..ef4fdea 100644
--- a/src/interfaces/localed/localed.c
+++ b/src/interfaces/localed/localed.c
@@ -114,7 +114,7 @@ static void localed_on_name_lost(GDBusConnection *conn,
}
/* safe call to try and start localed */
-GError *localed_init() {
+void localed_init() {
guint bus_descriptor;
GError *err = NULL;
@@ -141,7 +141,6 @@ GError *localed_init() {
NULL);
/* TODO: malloc and return reference as if a main() closed */
- return err;
}
/* free()'s */
diff --git a/src/main.c b/src/main.c
index 3c30ae0..3bc4344 100644
--- a/src/main.c
+++ b/src/main.c
@@ -27,7 +27,8 @@
#include "interfaces/logind/logind.c"
gboolean systemd_utils_init() {
- if(!config_init()) {
+
+ if(!config_init()) {
gchar *tmp;
tmp = "/etc/systemd_compat.conf";
@@ -39,20 +40,48 @@ gboolean systemd_utils_init() {
int main() {
- GMainLoop *mloop;
-
- if(!systemd_utils_init()) {
- g_printf("failed to init, are you root?\n");
- return 1; /* TODO errno properly. grep for all "return 1;"s, not TODO'ing each one */
- }
+ GMainLoop *mloop;
+ mloop = g_main_loop_new(NULL, TRUE);
+
+ #ifdef COMPILE_HOSTNAMED_BINARY
+ hostnamed_init();
+ #endif
+ #ifdef COMPILE_LOCALED_BINARY
+ localed_init();
+ #endif
+ #ifdef COMPILE_TIMEDATED_BINARY
+ #endif
+ #ifdef COMPILE_LOGIND_BINARY
+ #endif
+
+ #if !defined(COMPILE_HOSTNAMED_BINARY) && !defined(COMPILE_LOCALED_BINARY) && !defined(COMPILE_TIMEDATED_BINARY) && !defined(COMPILE_LOGIND_BINARY)
+
+ if(!systemd_utils_init()) {
+ g_printf("failed to init, are you root?\n");
+ return 1; /* TODO errno properly. grep for all "return 1;"s, not TODO'ing each one */
+ }
+
+ gboolean hostnamed_init_ok, localed_init_ok;
+ GPid *hostnamed_pid, *localed_pid;
+ gchar *hostnamed_argv[0], *localed_argv[0];
+ GSource *hostnamed_source, *localed_source, *timedated_source, *logind_source;
+
+ hostnamed_argv[0] = "/usr/local/libexec/systemd-hostnamed-handler";
+ localed_argv[0] = "/usr/local/libexec/systemd-localed-handler";
+
+ hostnamed_init_ok = g_spawn_async(NULL, hostnamed_argv, NULL, G_SPAWN_DEFAULT, NULL, NULL, hostnamed_pid, NULL);
+ localed_init_ok = g_spawn_async(NULL, localed_argv, NULL, G_SPAWN_DEFAULT, NULL, NULL, localed_pid, NULL);
+
+ hostnamed_source = g_child_watch_source_new(*hostnamed_pid);
+ localed_source = g_child_watch_source_new(*localed_pid);
- hostnamed_init();
- localed_init();
+ /*g_source_attach(hostnamed_source, NULL);
+ g_source_attach(localed_source, NULL);*/
- mloop = g_main_loop_new(NULL, TRUE);
+ #endif
- g_main_loop_run(mloop);
- g_main_loop_unref(mloop);
+ g_main_loop_run(mloop);
+ g_main_loop_unref(mloop);
- return 0;
+ return 0;
}