option('systemd',
type : 'boolean',
value : true,
- description : 'Systemd support in efl'
+ description : 'Systemd and Elogind support at runtime in efl'
)
option('pulseaudio',
description: 'Enable architecture native optimizations in efl'
)
-option('elogind',
- type : 'boolean',
- value : false,
- description : 'elogind support in efl (subset of systemd)'
-)
-
option('windows-version',
type : 'combo',
choices : ['vista', 'win7', 'win8', 'win81', 'win10'],
#ifdef HAVE_SYSTEMD
if (getenv("WATCHDOG_USEC"))
{
- double sec;
-
- sec = ((double) atoi(getenv("WATCHDOG_USEC"))) / 1000 / 1000;
+ double sec = ((double) atoi(getenv("WATCHDOG_USEC"))) / 1000 / 1000;
_systemd_watchdog =
efl_add(EFL_LOOP_TIMER_CLASS, efl_main_loop_get(),
unsetenv("WATCHDOG_USEC");
INF("Setup systemd watchdog to : %f", sec);
-
_systemd_watchdog_cb(NULL, NULL);
}
#endif
static void
_systemd_watchdog_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
- sd_notify(0, "WATCHDOG=1");
+ if (getenv("NOTIFY_SOCKET"))
+ {
+ _ecore_sd_init();
+ if (_ecore_sd_notify) _ecore_sd_notify(0, "WATCHDOG=1");
+ }
}
#endif
_ecore_memory_state = state;
ecore_event_add(ECORE_EVENT_MEMORY_STATE, NULL, NULL, NULL);
}
+
+#ifdef HAVE_SYSTEMD
+static Eina_Module *_libsystemd = NULL;
+static Eina_Bool _libsystemd_broken = EINA_FALSE;
+
+int (*_ecore_sd_notify) (int unset_environment, const char *state) = NULL;
+
+void
+_ecore_sd_init(void)
+{
+ if (_libsystemd_broken) return;
+ _libsystemd = eina_module_new("libsystemd.so.0");
+ if (_libsystemd)
+ {
+ if (!eina_module_load(_libsystemd))
+ {
+ eina_module_free(_libsystemd);
+ _libsystemd = NULL;
+ }
+ }
+ if (!_libsystemd)
+ {
+ _libsystemd_broken = EINA_TRUE;
+ return;
+ }
+ _ecore_sd_notify =
+ eina_module_symbol_get(_libsystemd, "sd_notify");
+ if (!_ecore_sd_notify)
+ {
+ _ecore_sd_notify = NULL;
+ eina_module_free(_libsystemd);
+ _libsystemd = NULL;
+ _libsystemd_broken = EINA_TRUE;
+ }
+}
+#endif
#include "efl_tracing.h"
-#ifdef HAVE_SYSTEMD
-# include <systemd/sd-daemon.h>
-#endif
-
#ifdef HAVE_IEEEFP_H
# include <ieeefp.h> // for Solaris
#endif
pd->loop_active++;
if (obj == ML_OBJ)
{
-#ifdef HAVE_SYSTEMD
- sd_notify(0, "READY=1");
-#endif
+ if (getenv("NOTIFY_SOCKET"))
+ {
+ _ecore_sd_init();
+ if (_ecore_sd_notify) _ecore_sd_notify(0, "READY=1");
+ }
#ifdef HAVE_LIBUV
if (!_dl_uv_run)
{
extern Ecore_Select_Function main_loop_select;
extern int in_main_loop;
+#ifdef HAVE_SYSTEMD
+void _ecore_sd_init(void);
+
+extern int (*_ecore_sd_notify) (int unset_environment, const char *state);
+#endif
+
Eina_Bool ecore_mempool_init(void);
void ecore_mempool_shutdown(void);
#define GENERIC_ALLOC_FREE_HEADER(TYPE, Type) \
endif
endif
-if get_option('systemd') == true
- ecore_deps += systemd
-endif
-
ecore_lib = library('ecore',
ecore_src, pub_eo_file_target,
dependencies: ecore_pub_deps + [m, buildsystem, ecore_deps],
# include <sys/filio.h>
#endif
-#ifdef HAVE_SYSTEMD
-# include <systemd/sd-daemon.h>
-#endif
-
#ifdef _WIN32
# include <ws2tcpip.h>
# include <evil_private.h> /* evil_init|shutdown */
EFL_NET_SOCKET_SSL_ERROR_CERTIFICATE_VERIFY_FAILED;
#ifdef HAVE_SYSTEMD
- sd_fd_max = sd_listen_fds(0);
+ if (getenv("LISTEN_PID") && getenv("LISTEN_FDS"))
+ {
+ _ecore_con_sd_init();
+ if (_ecore_sd_listen_fds) sd_fd_max = _ecore_sd_listen_fds(0);
+ }
#endif
eina_log_timing(_ecore_con_log_dom,
Eina_Error
efl_net_ip_socket_activate_check(const char *address, int family, int type, Eina_Bool *listening)
{
- SOCKET fd = SD_LISTEN_FDS_START + sd_fd_index;
+ SOCKET fd = /*SD_LISTEN_FDS_START*/3 + sd_fd_index;
int r;
+ // check first as this will return if we're not socket activated...
+ // or systemd not found, which means the below init will not be done then
if (sd_fd_index >= sd_fd_max) return ENOENT;
+ _ecore_con_sd_init();
+ if ((!_ecore_sd_is_socket_unix) || (!_ecore_sd_is_socket)) return ENOENT;
+
if (family == AF_UNIX)
{
char buf[sizeof(struct sockaddr_un)] = "";
len = strlen(address) + 1;
}
- r = sd_is_socket_unix(fd, type, 0, sun_path, len);
+ r = _ecore_sd_is_socket_unix(fd, type, 0, sun_path, len);
if (r < 0)
{
ERR("socket " SOCKET_FMT " is not of family=%d, type=%d", fd, family, type);
Eina_Error err;
int x;
- r = sd_is_socket(fd, family, type, (type == SOCK_DGRAM) ? -1 : 0);
+ r = _ecore_sd_is_socket(fd, family, type, (type == SOCK_DGRAM) ? -1 : 0);
if (r < 0)
{
ERR("socket " SOCKET_FMT " is not of family=%d, type=%d", fd, family, type);
free(*itr);
free(proxies);
}
+
+#ifdef HAVE_SYSTEMD
+static Eina_Module *_libsystemd = NULL;
+static Eina_Bool _libsystemd_broken = EINA_FALSE;
+
+int (*_ecore_sd_listen_fds) (int unset_environment) = NULL;
+int (*_ecore_sd_is_socket_unix) (int fd, int type, int listening, const char *path, size_t length) = NULL;
+int (*_ecore_sd_is_socket) (int fd, int family, int type, int listening) = NULL;
+
+void
+_ecore_con_sd_init(void)
+{
+ if (_libsystemd_broken) return;
+ _libsystemd = eina_module_new("libsystemd.so.0");
+ if (_libsystemd)
+ {
+ if (!eina_module_load(_libsystemd))
+ {
+ eina_module_free(_libsystemd);
+ _libsystemd = NULL;
+ }
+ }
+ if (!_libsystemd)
+ {
+ _libsystemd_broken = EINA_TRUE;
+ return;
+ }
+ _ecore_sd_listen_fds =
+ eina_module_symbol_get(_libsystemd, "sd_listen_fds");
+ _ecore_sd_is_socket_unix =
+ eina_module_symbol_get(_libsystemd, "sd_is_socket_unix");
+ _ecore_sd_is_socket =
+ eina_module_symbol_get(_libsystemd, "sd_is_socket");
+ if ((!_ecore_sd_listen_fds) ||
+ (!_ecore_sd_is_socket_unix) ||
+ (!_ecore_sd_is_socket))
+ {
+ _ecore_sd_listen_fds = NULL;
+ _ecore_sd_is_socket_unix = NULL;
+ _ecore_sd_is_socket = NULL;
+ eina_module_free(_libsystemd);
+ _libsystemd = NULL;
+ _libsystemd_broken = EINA_TRUE;
+ }
+}
+#endif
#endif
#include <libgen.h>
-#ifdef HAVE_SYSTEMD
-# include <systemd/sd-daemon.h>
-#endif
-
#ifdef _WIN32
# include <ws2tcpip.h>
#endif
#ifdef HAVE_SYSTEMD
extern int sd_fd_index;
extern int sd_fd_max;
+
+void _ecore_con_sd_init(void);
+
+extern int (*_ecore_sd_listen_fds) (int unset_environment);
+extern int (*_ecore_sd_is_socket_unix) (int fd, int type, int listening, const char *path, size_t length);
+extern int (*_ecore_sd_is_socket) (int fd, int family, int type, int listening);
+
#endif
/* init must be called from main thread */
# include <sys/socket.h>
#endif
-#ifdef HAVE_SYSTEMD
-# include <systemd/sd-daemon.h>
-#endif
-
#define MY_CLASS EFL_NET_SERVER_FD_CLASS
typedef struct _Efl_Net_Server_Fd_Data
}
else
{
- SOCKET fd = SD_LISTEN_FDS_START + sd_fd_index;
+ SOCKET fd = /*SD_LISTEN_FDS_START*/3 + sd_fd_index;
int family;
socklen_t len = sizeof(family);
ecore_con_lib = library('ecore_con',
ecore_con_src, pub_eo_file_target,
- dependencies: [ecore, ecore_con_deps, http_parser, eldbus, eet, systemd, buildsystem, dl],
+ dependencies: [ecore, ecore_con_deps, http_parser, eldbus, eet, buildsystem, dl],
include_directories : config_dir,
install: true,
c_args : package_c_args,
static Ecore_Event_Handler *active_hdlr;
#ifdef HAVE_SYSTEMD
-static inline Eina_Bool
+static Eina_Module *_libsystemd = NULL;
+static Eina_Bool _libsystemd_broken = EINA_FALSE;
+
+static int (*_ecore_sd_session_get_vt) (const char *session, unsigned *vtnr) = NULL;
+static int (*_ecore_sd_pid_get_session) (pid_t pid, char **session) = NULL;
+static int (*_ecore_sd_session_get_seat) (const char *session, char **seat) = NULL;
+
+void
+_ecore_drm_sd_init(void)
+{
+ if (_libsystemd_broken) return;
+ _libsystemd = eina_module_new("libsystemd.so.0");
+ if (_libsystemd)
+ {
+ if (!eina_module_load(_libsystemd))
+ {
+ eina_module_free(_libsystemd);
+ _libsystemd = NULL;
+ }
+ }
+ if (!_libsystemd)
+ {
+ _libsystemd_broken = EINA_TRUE;
+ return;
+ }
+ _ecore_sd_session_get_vt =
+ eina_module_symbol_get(_libsystemd, "sd_session_get_vt");
+ _ecore_sd_pid_get_session =
+ eina_module_symbol_get(_libsystemd, "sd_pid_get_session");
+ _ecore_sd_session_get_seat =
+ eina_module_symbol_get(_libsystemd, "sd_session_get_seat");
+ if ((!_ecore_sd_session_get_vt) ||
+ (!_ecore_sd_pid_get_session) ||
+ (!_ecore_sd_session_get_seat))
+ {
+ _ecore_sd_session_get_vt = NULL;
+ _ecore_sd_pid_get_session = NULL;
+ _ecore_sd_session_get_seat = NULL;
+ eina_module_free(_libsystemd);
+ _libsystemd = NULL;
+ _libsystemd_broken = EINA_TRUE;
+ }
+}
+
+static inline Eina_Bool
_ecore_drm_logind_vt_get(Ecore_Drm_Device *dev)
{
int ret;
- ret = sd_session_get_vt(dev->session, &dev->vt);
+ _ecore_drm_sd_init();
+ if (!_ecore_sd_session_get_vt)
+ {
+ ERR("Could not get systemd tty");
+ return EINA_FALSE;
+ }
+ ret = _ecore_sd_session_get_vt(dev->session, &dev->vt);
if (ret < 0)
{
ERR("Could not get systemd tty");
return ECORE_CALLBACK_PASS_ON;
}
-Eina_Bool
+Eina_Bool
_ecore_drm_logind_connect(Ecore_Drm_Device *dev)
{
#ifdef HAVE_SYSTEMD
- char *seat;
+ char *seat = NULL;
+ _ecore_drm_sd_init();
+ if ((!_ecore_sd_pid_get_session) ||
+ (!_ecore_sd_session_get_seat))
+ {
+ ERR("Could not get systemd session");
+ return EINA_FALSE;
+ }
/* get session id */
- if (sd_pid_get_session(getpid(), &dev->session) < 0)
+ if (_ecore_sd_pid_get_session(getpid(), &dev->session) < 0)
{
ERR("Could not get systemd session");
return EINA_FALSE;
}
-
- if (sd_session_get_seat(dev->session, &seat) < 0)
+ if (_ecore_sd_session_get_seat(dev->session, &seat) < 0)
{
ERR("Could not get systemd seat");
return EINA_FALSE;
free(seat);
return EINA_FALSE;
}
-
free(seat);
-
if (!_ecore_drm_logind_vt_get(dev)) return EINA_FALSE;
#endif
# include <linux/input.h>
# include <libinput.h>
-# ifdef HAVE_SYSTEMD
-# include <systemd/sd-login.h>
-# endif
-
# include <Eldbus.h>
# include <Ecore_Drm.h>
#endif
/*--- TIZEN_ONLY : end ---*/
-#ifdef HAVE_SYSTEMD
-# include <systemd/sd-journal.h>
-#endif
-
#ifdef _WIN32
# include <windows.h>
#endif
#include "eina_thread.h"
#include "eina_convert.h"
#include "eina_strbuf.h"
+#include "eina_module.h"
/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
#include "eina_safety_checks.h"
#endif
}
+#ifdef HAVE_SYSTEMD
+static Eina_Module *_libsystemd = NULL;
+static Eina_Bool _libsystemd_broken = EINA_FALSE;
+
+static int (*_eina_sd_journal_send_with_location) (const char *file, const char *line, const char *func, const char *format, ...) = NULL;
+
+static void
+_eina_sd_init(void)
+{
+ if (_libsystemd_broken) return;
+ _libsystemd = eina_module_new("libsystemd.so.0");
+ if (_libsystemd)
+ {
+ if (!eina_module_load(_libsystemd))
+ {
+ eina_module_free(_libsystemd);
+ _libsystemd = NULL;
+ }
+ }
+ if (!_libsystemd)
+ {
+ _libsystemd_broken = EINA_TRUE;
+ return;
+ }
+ _eina_sd_journal_send_with_location =
+ eina_module_symbol_get(_libsystemd, "sd_journal_send_with_location");
+ if (!_eina_sd_journal_send_with_location)
+ {
+ _eina_sd_journal_send_with_location = NULL;
+ eina_module_free(_libsystemd);
+ _libsystemd = NULL;
+ _libsystemd_broken = EINA_TRUE;
+ }
+}
+
+#endif
+
EAPI void
eina_log_print_cb_journald(const Eina_Log_Domain *d,
Eina_Log_Level level,
Eina_Thread cur;
int r;
+ _eina_sd_init();
+ if (!_eina_sd_journal_send_with_location) goto nosystemd;
+
r = asprintf(&file_prefixed, "CODE_FILE=%s", file);
if (r == -1)
{
#ifdef EINA_LOG_BACKTRACE
if (EINA_LIKELY(level > _backtrace_level))
#endif
- sd_journal_send_with_location(file_prefixed, line_str, fnc,
- "PRIORITY=%i", level,
- "MESSAGE=%s", message,
- "EFL_DOMAIN=%s", d->domain_str,
- "THREAD=%lu", cur,
- NULL);
+ _eina_sd_journal_send_with_location(file_prefixed, line_str, fnc,
+ "PRIORITY=%i", level,
+ "MESSAGE=%s", message,
+ "EFL_DOMAIN=%s", d->domain_str,
+ "THREAD=%lu", cur,
+ NULL);
#ifdef EINA_LOG_BACKTRACE
else
{
else
eina_strbuf_append_printf(bts, "[%s], ", strings[i]);
- sd_journal_send_with_location(file_prefixed, line_str, fnc,
- "PRIORITY=%i", level,
- "MESSAGE=%s", message,
- "EFL_DOMAIN=%s", d->domain_str,
- "THREAD=%lu", cur,
- "BACKTRACE=%s",
- eina_strbuf_string_get(bts),
- NULL);
+ _eina_sd_journal_send_with_location(file_prefixed, line_str, fnc,
+ "PRIORITY=%i", level,
+ "MESSAGE=%s", message,
+ "EFL_DOMAIN=%s", d->domain_str,
+ "THREAD=%lu", cur,
+ "BACKTRACE=%s",
+ eina_strbuf_string_get(bts),
+ NULL);
eina_strbuf_free(bts);
free(strings);
}
free(file_prefixed);
free(line_str);
free(message);
-
-#else
- eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, data, args);
+ return;
+nosystemd:
#endif
+ eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, data, args);
}
EAPI void
endif
if get_option('systemd') == true
- systemd = dependency('libsystemd')
- eina_deps += systemd
config_h.set('HAVE_SYSTEMD', '1')
- if systemd.version().version_compare('>=209')
- config_h.set('HAVE_SYSTEMD_LOGIN_209', '1')
- endif
-else
- systemd = []
endif
#include "elput_private.h"
-#if defined(HAVE_SYSTEMD) || defined(HAVE_ELOGIND)
+#ifdef HAVE_SYSTEMD
+static Eina_Module *_libsystemd = NULL;
+static Eina_Bool _libsystemd_broken = EINA_FALSE;
+
+static int (*_elput_sd_session_get_vt) (const char *session, unsigned *vtnr) = NULL;
+static int (*_elput_sd_session_get_tty) (const char *session, char **display) = NULL;
+static int (*_elput_sd_pid_get_session) (pid_t pid, char **session) = NULL;
+static int (*_elput_sd_session_get_seat) (const char *session, char **seat) = NULL;
+
+void
+_elput_sd_init(void)
+{
+ if (_libsystemd_broken) return;
+ _libsystemd = eina_module_new("libsystemd.so.0");
+ if (_libsystemd)
+ {
+ if (!eina_module_load(_libsystemd))
+ {
+ eina_module_free(_libsystemd);
+ _libsystemd = NULL;
+ }
+ }
+ if (!_libsystemd)
+ {
+ _libsystemd = eina_module_new("libelogind.so.0");
+ if (_libsystemd)
+ {
+ if (!eina_module_load(_libsystemd))
+ {
+ eina_module_free(_libsystemd);
+ _libsystemd = NULL;
+ }
+ }
+ }
+ if (!_libsystemd)
+ {
+ _libsystemd_broken = EINA_TRUE;
+ return;
+ }
+ // sd_session_get_vt == newere in systemd 207
+ _elput_sd_session_get_vt =
+ eina_module_symbol_get(_libsystemd, "sd_session_get_vt");
+ // sd_session_get_tty == older api in ssystemd 198
+ _elput_sd_session_get_tty =
+ eina_module_symbol_get(_libsystemd, "sd_session_get_tty");
+ _elput_sd_pid_get_session =
+ eina_module_symbol_get(_libsystemd, "sd_pid_get_session");
+ _elput_sd_session_get_seat =
+ eina_module_symbol_get(_libsystemd, "sd_session_get_seat");
+ if (((!_elput_sd_session_get_vt) && (!_elput_sd_session_get_tty)) ||
+ (!_elput_sd_pid_get_session) ||
+ (!_elput_sd_session_get_seat))
+ {
+ _elput_sd_session_get_vt = NULL;
+ _elput_sd_session_get_tty = NULL;
+ _elput_sd_pid_get_session = NULL;
+ _elput_sd_session_get_seat = NULL;
+ eina_module_free(_libsystemd);
+ _libsystemd = NULL;
+ _libsystemd_broken = EINA_TRUE;
+ }
+}
+
static void
_logind_session_active_cb_free(void *data EINA_UNUSED, void *event)
static Eina_Bool
_logind_session_vt_get(const char *sid, unsigned int *vt)
{
-# ifdef HAVE_SYSTEMD_LOGIN_209
- return (sd_session_get_vt(sid, vt) >= 0);
-# else
int ret = 0;
char *tty;
- ret = sd_session_get_tty(sid, &tty);
+ _elput_sd_init();
+ if ((!_elput_sd_session_get_vt) && (!_elput_sd_session_get_tty))
+ return EINA_FALSE;
+ if (_elput_sd_session_get_vt)
+ return (_elput_sd_session_get_vt(sid, vt) >= 0);
+
+ ret = _elput_sd_session_get_tty(sid, &tty);
if (ret < 0) return ret;
ret = sscanf(tty, "tty%u", vt);
if (ret != 1) return EINA_FALSE;
return EINA_TRUE;
-# endif
}
static Eina_Bool
int ret = 0;
char *s = NULL;
+ _elput_sd_init();
+ if (!_elput_sd_pid_get_session) return EINA_FALSE;
+
em = calloc(1, sizeof(Elput_Manager));
if (!em) return EINA_FALSE;
em->interface = &_logind_interface;
em->seat = eina_stringshare_add(seat);
- ret = sd_pid_get_session(getpid(), &em->sid);
+ ret = _elput_sd_pid_get_session(getpid(), &em->sid);
if (ret < 0)
{
if (!em->sid) goto session_err;
- ret = sd_session_get_seat(em->sid, &s);
+ ret = _elput_sd_session_get_seat(em->sid, &s);
if (ret < 0)
{
ERR("Failed to get session seat");
static Elput_Interface *_ifaces[] =
{
-#if defined(HAVE_SYSTEMD) || defined(HAVE_ELOGIND)
+#ifdef HAVE_SYSTEMD
&_logind_interface,
#endif
NULL,
# include <xkbcommon/xkbcommon.h>
# include <xkbcommon/xkbcommon-compose.h>
-# ifdef HAVE_SYSTEMD
-# include <systemd/sd-login.h>
-# endif
-
-# ifdef HAVE_ELOGIND
-# include <elogind/sd-login.h>
-# endif
-
#ifndef ELPUT_NODEFS
# ifdef ELPUT_DEFAULT_LOG_COLOR
# undef ELPUT_DEFAULT_LOG_COLOR
elput_deps += dependency('libinput', version : ['>=1.7.0'])
elput_deps += dependency('xkbcommon', version : ['>=0.3.0'])
elput_deps += dependency('libudev')
-if get_option('systemd')
- elput_deps += systemd
-endif
-if get_option('elogind')
- elput_deps += dependency('libelogind')
-endif
elput_lib = library('elput',
elput_src, pub_eo_file_target,