aboutsummaryrefslogtreecommitdiffstats
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
commitc09a09bfcbfbd12fb6b48e06f087429b1b6ac864 (patch)
treeaabd94f29221a52021dc646ff91e0a3131f3c527
parent828caf9aaa256154d5998d7d3f6b57b434550a7c (diff)
downloadsystembsd-c09a09bfcbfbd12fb6b48e06f087429b1b6ac864.tar
systembsd-c09a09bfcbfbd12fb6b48e06f087429b1b6ac864.tar.gz
systembsd-c09a09bfcbfbd12fb6b48e06f087429b1b6ac864.tar.bz2
systembsd-c09a09bfcbfbd12fb6b48e06f087429b1b6ac864.tar.lz
systembsd-c09a09bfcbfbd12fb6b48e06f087429b1b6ac864.tar.xz
systembsd-c09a09bfcbfbd12fb6b48e06f087429b1b6ac864.tar.zst
systembsd-c09a09bfcbfbd12fb6b48e06f087429b1b6ac864.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
-rw-r--r--.gitignore1
-rw-r--r--Makefile15
-rw-r--r--TODO1
-rw-r--r--src/interfaces/hostnamed/hostnamed.c16
-rw-r--r--src/interfaces/localed/localed.c3
-rw-r--r--src/main.c55
6 files changed, 60 insertions, 31 deletions
diff --git a/.gitignore b/.gitignore
index c2a04c0..725f52f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
*.core
+bin/*
bin/*.out
bin/*.bin
bin/*.o
diff --git a/Makefile b/Makefile
index bcf9813..2d0ad82 100644
--- a/Makefile
+++ b/Makefile
@@ -13,14 +13,27 @@ all: build
build:
gcc -o bin/out.bin $(DEBUGF) $(GLIBF) $(SANITY) $(SRCDIR)/main.c
+build-interface-binaries:
+ gcc -o bin/systemd-hostnamed-handler $(DEBUGF) $(GLIBF) $(SANITY) -D COMPILE_HOSTNAMED_BINARY $(SRCDIR)/main.c
+ gcc -o bin/systemd-localed-handler $(DEBUGF) $(GLIBF) $(SANITY) -D COMPILE_LOCALED_BINARY $(SRCDIR)/main.c
+ gcc -o bin/systemd-timedated-handler $(DEBUGF) $(GLIBF) $(SANITY) -D COMPILE_TIMEDATED_BINARY $(SRCDIR)/main.c
+ gcc -o bin/systemd-logind-handler $(DEBUGF) $(GLIBF) $(SANITY) -D COMPILE_LOGIND_BINARY $(SRCDIR)/main.c
+
publish:
gcc -o bin/out.bin $(CFLAGS) $(GLIBF) $(SANITY) $(SRCDIR)/main.c
clean:
rm bin/*
-install: _install_conf
+install: _install_conf _install_interface_binaries
_install_conf:
cp conf/*-dbus.conf /etc/dbus-1/system.d/
cp conf/systemd_compat.conf /etc/
+
+_install_interface_binaries:
+ cp bin/systemd-hostnamed-handler /usr/local/libexec/
+ cp bin/systemd-localed-handler /usr/local/libexec/
+ cp bin/systemd-timedated-handler /usr/local/libexec/
+ cp bin/systemd-logind-handler /usr/local/libexec/
+
diff --git a/TODO b/TODO
index 8463eba..6312812 100644
--- a/TODO
+++ b/TODO
@@ -1,2 +1,3 @@
* get autoconf stuff figured out
* handle SIGINTs so file descriptors are dropped properly, otherwise we get bus errors next run
+ * document how gdbus-codegen files always generate the same 'typedef structs' per interface pair, and how those pairs must be snipped as they cause "already defined" compiler errors
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;
}