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/
+
}
/* 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",
NULL);
/* TODO: malloc and return reference as if a main() closed */
- return err;
}
/* free()'s */
#include "interfaces/logind/logind.c"
gboolean systemd_utils_init() {
- if(!config_init()) {
+
+ if(!config_init()) {
gchar *tmp;
tmp = "/etc/systemd_compat.conf";
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;
}