[*:yes],
AC_DEFINE([HAVE_LIBSYSTEMD], [1], [Define if libsystemd is available])
AC_DEFINE([USE_SYSTEMD], [1], [Define if systemd support is wanted ])
+ AC_CHECK_DECLS([sd_session_get_username], [], [], [#include <systemd/sd-login.h>])
)
])
AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$have_systemd" = xyes])
required : get_option('systemd'))
conf.set('HAVE_LIBSYSTEMD', lib_systemd.found() ? 1 : false)
+have = cc.has_function(
+ 'sd_session_get_username',
+ dependencies : lib_systemd)
+conf.set('HAVE_DECL_SD_SESSION_GET_USERNAME', have ? 1 : false)
+
lib_udev = dependency(
'libudev',
required : get_option('systemd'))
agetty_sources,
include_directories : includes,
link_with : [lib_common, logindefs_c],
- dependencies : BSD ? lib_util : [],
+ dependencies : [BSD ? lib_util : [], lib_systemd],
install_dir : sbindir,
install : opt,
build_by_default : opt)
wall_sources,
include_directories : includes,
link_with : [lib_common],
+ dependencies : [lib_systemd],
install_dir : usrbin_exec_dir,
install : opt,
build_by_default : opt)
write_sources,
include_directories : includes,
link_with : [lib_common],
+ dependencies : [lib_systemd],
install_dir : usrbin_exec_dir,
install : opt,
build_by_default : opt)
wall_CFLAGS = $(SUID_CFLAGS) $(AM_CFLAGS)
wall_LDFLAGS = $(SUID_LDFLAGS) $(AM_LDFLAGS)
wall_LDADD = $(LDADD) libcommon.la
+if HAVE_SYSTEMD
+wall_LDADD += $(SYSTEMD_LIBS)
+wall_CFLAGS += $(SYSTEMD_CFLAGS)
+endif
if USE_TTY_GROUP
if MAKEINSTALL_DO_CHOWN
install-exec-hook-wall::
#include <sys/types.h>
#include <grp.h>
+#if defined(USE_SYSTEMD) && HAVE_DECL_SD_SESSION_GET_USERNAME == 1
+# include <systemd/sd-login.h>
+# include <systemd/sd-daemon.h>
+#endif
+
#include "nls.h"
#include "xalloc.h"
#include "strutils.h"
iov.iov_base = mbuf;
iov.iov_len = mbufsize;
+#if defined(USE_SYSTEMD) && HAVE_DECL_SD_SESSION_GET_USERNAME == 1
+ if (sd_booted() > 0) {
+ char **sessions_list;
+ int sessions;
+
+ sessions = sd_get_sessions(&sessions_list);
+ if (sessions < 0)
+ errx(EXIT_FAILURE, _("error getting sessions: %s"),
+ strerror(-sessions));
+
+ for (int i = 0; i < sessions; i++) {
+ char *name, *tty;
+ int r;
+
+ if ((r = sd_session_get_username(sessions_list[i], &name)) < 0)
+ errx(EXIT_FAILURE, _("get user name failed: %s"), strerror (-r));
+
+ if (!(group_buf && !is_gr_member(name, group_buf))) {
+ if (sd_session_get_tty(sessions_list[i], &tty) >= 0) {
+ if ((p = ttymsg(&iov, 1, tty, timeout)) != NULL)
+ warnx("%s", p);
+
+ free(tty);
+ }
+ }
+ free(name);
+ free(sessions_list[i]);
+ }
+ free(sessions_list);
+ } else {
+#endif
while((utmpptr = getutxent())) {
if (!utmpptr->ut_user[0])
continue;
warnx("%s", p);
}
endutxent();
+#if defined(USE_SYSTEMD) && HAVE_DECL_SD_SESSION_GET_USERNAME == 1
+ }
+#endif
free(mbuf);
free_group_workspace(group_buf);
exit(EXIT_SUCCESS);