summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-03-18 04:31:22 +0100
committerLennart Poettering <lennart@poettering.net>2011-03-18 04:53:31 +0100
commitf1dd0c3f9b4a257e81ff9c6a08070c702a0db45a (patch)
tree34ae8bb9ab04facd195a83a6300306edac96479e
parent0732ec002ea941f32e8def518150d2b6423315e3 (diff)
syslog: rework syslog detection so that we need no compile-time option what the name of the syslog implementation is
-rw-r--r--Makefile.am1
-rw-r--r--TODO2
-rw-r--r--configure.ac39
-rw-r--r--man/systemd.special.xml.in31
-rw-r--r--src/manager.c47
-rw-r--r--src/manager.h2
-rw-r--r--src/special.h15
-rw-r--r--src/unit.c14
-rw-r--r--units/syslog.target.in6
9 files changed, 63 insertions, 94 deletions
diff --git a/Makefile.am b/Makefile.am
index a94d2a7f7d..93225aac20 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1102,7 +1102,6 @@ SED_PROCESS = \
$(SED) -e 's,@rootlibexecdir\@,$(rootlibexecdir),g' \
-e 's,@rootbindir\@,$(rootbindir),g' \
-e 's,@bindir\@,$(bindir),g' \
- -e 's,@SPECIAL_SYSLOG_SERVICE\@,$(SPECIAL_SYSLOG_SERVICE),g' \
-e 's,@SYSTEMCTL\@,$(rootbindir)/systemctl,g' \
-e 's,@SYSTEMD_NOTIFY\@,$(rootbindir)/systemd-notify,g' \
-e 's,@pkgsysconfdir\@,$(pkgsysconfdir),g' \
diff --git a/TODO b/TODO
index 620cdfff08..4191e5586d 100644
--- a/TODO
+++ b/TODO
@@ -29,6 +29,8 @@ F15:
* pull in .service from meta .targers AND vice versa too. i.e. syslog.target ←→ rsyslog.service, rpcbind similarly
+* document default dependencies
+
Features:
* hide passwords on TAB
diff --git a/configure.ac b/configure.ac
index 8a28c8e807..e6daf0354b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -297,30 +297,15 @@ fi
with_distro=`echo ${with_distro} | tr '[[:upper:]]' '[[:lower:]]' `
AC_DEFINE_UNQUOTED(DISTRIBUTION, ["${with_distro}"], [Target Distribution])
-# Default generic names
-SPECIAL_SYSLOG_SERVICE=syslog.service
-
# Location of the init scripts as mandated by LSB
SYSTEM_SYSVINIT_PATH=/etc/init.d
+SYSTEM_SYSVRCND_PATH=/etc/rc.d
M4_DISTRO_FLAG=
case $with_distro in
fedora)
SYSTEM_SYSVINIT_PATH=/etc/rc.d/init.d
- SYSTEM_SYSVRCND_PATH=/etc/rc.d
-
- # A little background why we define this special unit
- # names here in configure.ac: SysV services currently
- # cannot have aliases. As long as syslog is started
- # via a SysV init script we hence define this name to
- # the actual SysV name here. Later on when SysV init
- # scripts are not used anymore it is advisable to use
- # the generic name instead and use symlinks in the
- # unit directories to point to the right native unit
- # file.
-
- SPECIAL_SYSLOG_SERVICE=rsyslog.service
AC_DEFINE(TARGET_FEDORA, [], [Target is Fedora/RHEL])
M4_DISTRO_FLAG=-DTARGET_FEDORA=1
have_plymouth=true
@@ -333,61 +318,49 @@ case $with_distro in
;;
debian)
SYSTEM_SYSVRCND_PATH=/etc
- SPECIAL_SYSLOG_SERVICE=rsyslog.service
AC_DEFINE(TARGET_DEBIAN, [], [Target is Debian])
M4_DISTRO_FLAG=-DTARGET_DEBIAN=1
;;
ubuntu)
SYSTEM_SYSVRCND_PATH=/etc
- SPECIAL_SYSLOG_SERVICE=rsyslog.service
AC_DEFINE(TARGET_UBUNTU, [], [Target is Ubuntu])
M4_DISTRO_FLAG=-DTARGET_UBUNTU=1
;;
arch)
SYSTEM_SYSVINIT_PATH=/etc/rc.d
SYSTEM_SYSVRCND_PATH=/etc
- SPECIAL_SYSLOG_SERVICE=syslog-ng.service
AC_DEFINE(TARGET_ARCH, [], [Target is ArchLinux])
M4_DISTRO_FLAG=-DTARGET_ARCH=1
;;
gentoo)
SYSTEM_SYSVINIT_PATH=
SYSTEM_SYSVRCND_PATH=
- SPECIAL_SYSLOG_SERVICE=syslog-ng.service
AC_DEFINE(TARGET_GENTOO, [], [Target is Gentoo])
M4_DISTRO_FLAG=-DTARGET_GENTOO=1
;;
slackware)
SYSTEM_SYSVINIT_PATH=/etc/rc.d/init.d
- SYSTEM_SYSVRCND_PATH=/etc/rc.d
AC_DEFINE(TARGET_SLACKWARE, [], [Target is Slackware])
M4_DISTRO_FLAG=-DTARGET_SLACKWARE=1
;;
frugalware)
SYSTEM_SYSVINIT_PATH=/etc/rc.d
- SYSTEM_SYSVRCND_PATH=/etc/rc.d
AC_DEFINE(TARGET_FRUGALWARE, [], [Target is Frugalware])
M4_DISTRO_FLAG=-DTARGET_FRUGALWARE=1
;;
altlinux)
SYSTEM_SYSVINIT_PATH=/etc/rc.d/init.d
- SYSTEM_SYSVRCND_PATH=/etc/rc.d
- SPECIAL_SYSLOG_SERVICE=syslogd.service
AC_DEFINE(TARGET_ALTLINUX, [], [Target is ALTLinux])
M4_DISTRO_FLAG=-DTARGET_ALTLINUX=1
have_plymouth=true
;;
mandriva)
SYSTEM_SYSVINIT_PATH=/etc/rc.d/init.d
- SYSTEM_SYSVRCND_PATH=/etc/rc.d
- SPECIAL_SYSLOG_SERVICE=rsyslog.service
AC_DEFINE(TARGET_MANDRIVA, [], [Target is Mandriva])
M4_DISTRO_FLAG=-DTARGET_MANDRIVA=1
have_plymouth=true
;;
other)
- AS_IF([test "x$with_syslog_service" = "x"],
- [AC_MSG_ERROR([With --distro=other, you must pass --with-syslog-service= to configure])])
;;
*)
AC_MSG_ERROR([Your distribution (${with_distro}) is not yet supported, SysV init scripts could not be found! (patches welcome); you can specify --with-distro=other to skip this check])
@@ -406,15 +379,8 @@ AC_ARG_WITH([sysvrcd-path],
[SYSTEM_SYSVRCND_PATH="$withval"],
[])
-AC_ARG_WITH([syslog-service],
- [AS_HELP_STRING([--with-syslog-service=UNIT],
- [Specify the name of the special syslog service @<:@default=based on distro@:>@])],
- [SPECIAL_SYSLOG_SERVICE="$withval"],
- [])
-
AC_SUBST(SYSTEM_SYSVINIT_PATH)
AC_SUBST(SYSTEM_SYSVRCND_PATH)
-AC_SUBST(SPECIAL_SYSLOG_SERVICE)
AC_SUBST(M4_DISTRO_FLAG)
if test "x${SYSTEM_SYSVINIT_PATH}" != "x" -a "x${SYSTEM_SYSVRCND_PATH}" != "x"; then
@@ -446,8 +412,6 @@ AM_CONDITIONAL(TARGET_MANDRIVA, test x"$with_distro" = xmandriva)
AM_CONDITIONAL(HAVE_PLYMOUTH, test -n "$have_plymouth")
-AC_DEFINE_UNQUOTED(SPECIAL_SYSLOG_SERVICE, ["$SPECIAL_SYSLOG_SERVICE"], [Syslog service name])
-
AC_ARG_WITH([dbuspolicydir],
AS_HELP_STRING([--with-dbuspolicydir=DIR], [D-Bus policy directory]),
[],
@@ -501,7 +465,6 @@ echo "
SysV compatibility: ${SYSTEM_SYSV_COMPAT}
SysV init scripts: ${SYSTEM_SYSVINIT_PATH}
SysV rc?.d directories: ${SYSTEM_SYSVRCND_PATH}
- Syslog service: ${SPECIAL_SYSLOG_SERVICE}
Gtk: ${have_gtk}
libcryptsetup: ${have_libcryptsetup}
tcpwrap: ${have_tcpwrap}
diff --git a/man/systemd.special.xml.in b/man/systemd.special.xml.in
index 1506f34948..df62e9c4cd 100644
--- a/man/systemd.special.xml.in
+++ b/man/systemd.special.xml.in
@@ -78,7 +78,6 @@
<filename>sockets.target</filename>,
<filename>swap.target</filename>,
<filename>sysinit.target</filename>,
- <filename>@SPECIAL_SYSLOG_SERVICE@</filename>,
<filename>syslog.target</filename>,
<filename>systemd-initctl.service</filename>,
<filename>systemd-initctl.socket</filename>,
@@ -543,27 +542,6 @@
</listitem>
</varlistentry>
<varlistentry>
- <term><filename>@SPECIAL_SYSLOG_SERVICE@</filename></term>
- <listitem>
- <para>A special unit for the
- syslog daemon. As soon as
- this service is fully started
- up systemd will connect to it
- and use it for logging if it
- has been configured for
- that.</para>
-
- <para>Units should generally
- avoid depending on this unit
- directly and instead refer to
- the
- <filename>syslog.target</filename>
- unit instead, which pulls this
- one in directly or indirectly
- via socket-based activation.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
<term><filename>syslog.target</filename></term>
<listitem>
<para>systemd automatically
@@ -574,15 +552,6 @@
referring to the
<literal>$syslog</literal>
facility.</para>
-
- <para>Administrators should
- ensure that this target pulls
- in a service unit with the
- name or alias of
- <filename>@SPECIAL_SYSLOG_SERVICE@</filename>
- (or a socket unit that
- activates this
- service).</para>
</listitem>
</varlistentry>
<varlistentry>
diff --git a/src/manager.c b/src/manager.c
index 9edb8f09bb..a9aaee3d81 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -2451,6 +2451,12 @@ void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) {
if (m->n_deserializing > 0)
return;
+ if (m->running_as != MANAGER_SYSTEM)
+ return;
+
+ if (u->meta.type != UNIT_SERVICE)
+ return;
+
if (!(p = unit_name_to_prefix_and_instance(u->meta.id))) {
log_error("Failed to allocate unit name for audit message: %s", strerror(ENOMEM));
return;
@@ -2965,6 +2971,47 @@ int manager_set_default_controllers(Manager *m, char **controllers) {
return 0;
}
+void manager_recheck_syslog(Manager *m) {
+ Unit *u;
+
+ assert(m);
+
+ if (m->running_as != MANAGER_SYSTEM)
+ return;
+
+ if ((u = manager_get_unit(m, SPECIAL_SYSLOG_SOCKET))) {
+ SocketState state;
+
+ state = SOCKET(u)->state;
+
+ if (state != SOCKET_DEAD &&
+ state != SOCKET_FAILED &&
+ state != SOCKET_RUNNING) {
+
+ /* Hmm, the socket is not set up, or is still
+ * listening, let's better not try to use
+ * it. Note that we have no problem if the
+ * socket is completely down, since there
+ * might be a foreign /dev/log socket around
+ * and we want to make use of that.
+ */
+
+ log_close_syslog();
+ return;
+ }
+ }
+
+ if ((u = manager_get_unit(m, SPECIAL_SYSLOG_TARGET)))
+ if (TARGET(u)->state != TARGET_ACTIVE) {
+ log_close_syslog();
+ return;
+ }
+
+ /* Hmm, OK, so the socket is either fully up, or fully down,
+ * and the target is up, then let's make use of the socket */
+ log_open();
+}
+
static const char* const manager_running_as_table[_MANAGER_RUNNING_AS_MAX] = {
[MANAGER_SYSTEM] = "system",
[MANAGER_USER] = "user"
diff --git a/src/manager.h b/src/manager.h
index efca4ff7f6..c183e105af 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -285,6 +285,8 @@ void manager_check_finished(Manager *m);
void manager_run_generators(Manager *m);
void manager_undo_generators(Manager *m);
+void manager_recheck_syslog(Manager *m);
+
const char *manager_running_as_to_string(ManagerRunningAs i);
ManagerRunningAs manager_running_as_from_string(const char *s);
diff --git a/src/special.h b/src/special.h
index ba2bc143e0..6a75e2cf7d 100644
--- a/src/special.h
+++ b/src/special.h
@@ -24,21 +24,24 @@
#define SPECIAL_DEFAULT_TARGET "default.target"
+/* Shutdown targets */
+#define SPECIAL_UMOUNT_TARGET "umount.target"
/* This is not really intended to be started by directly. This is
* mostly so that other targets (reboot/halt/poweroff) can depend on
* it to bring all services down that want to be brought down on
* system shutdown. */
#define SPECIAL_SHUTDOWN_TARGET "shutdown.target"
-#define SPECIAL_UMOUNT_TARGET "umount.target"
#define SPECIAL_HALT_TARGET "halt.target"
#define SPECIAL_POWEROFF_TARGET "poweroff.target"
#define SPECIAL_REBOOT_TARGET "reboot.target"
#define SPECIAL_KEXEC_TARGET "kexec.target"
#define SPECIAL_EXIT_TARGET "exit.target"
+/* Special boot targets */
#define SPECIAL_RESCUE_TARGET "rescue.target"
#define SPECIAL_EMERGENCY_TARGET "emergency.target"
+/* Early boot targets */
#define SPECIAL_SYSINIT_TARGET "sysinit.target"
#define SPECIAL_SOCKETS_TARGET "sockets.target"
#define SPECIAL_LOCAL_FS_TARGET "local-fs.target" /* LSB's $local_fs */
@@ -46,8 +49,8 @@
#define SPECIAL_SWAP_TARGET "swap.target"
#define SPECIAL_BASIC_TARGET "basic.target"
+/* LSB compatibility */
#define SPECIAL_NETWORK_TARGET "network.target" /* LSB's $network */
-
#define SPECIAL_NSS_LOOKUP_TARGET "nss-lookup.target" /* LSB's $named */
#define SPECIAL_RPCBIND_TARGET "rpcbind.target" /* LSB's $portmap */
#define SPECIAL_SYSLOG_TARGET "syslog.target" /* LSB's $syslog; Should pull in syslog.socket or syslog.service */
@@ -56,22 +59,22 @@
#define SPECIAL_MAIL_TRANSFER_AGENT_TARGET "mail-transfer-agent.target" /* Debian's $mail-{transport|transfer-agent */
#define SPECIAL_HTTP_DAEMON_TARGET "http-daemon.target"
+/* Magic early boot services */
#define SPECIAL_FSCK_SERVICE "fsck@.service"
#define SPECIAL_QUOTACHECK_SERVICE "quotacheck.service"
#define SPECIAL_REMOUNT_ROOTFS_SERVICE "remount-rootfs.service"
+/* Services systemd relies on */
#define SPECIAL_DBUS_SERVICE "dbus.service"
#define SPECIAL_DBUS_SOCKET "dbus.socket"
#define SPECIAL_LOGGER_SOCKET "systemd-logger.socket"
+#define SPECIAL_SYSLOG_SOCKET "syslog.socket"
+/* Magic init signals */
#define SPECIAL_KBREQUEST_TARGET "kbrequest.target"
#define SPECIAL_SIGPWR_TARGET "sigpwr.target"
#define SPECIAL_CTRL_ALT_DEL_TARGET "ctrl-alt-del.target"
-#ifndef SPECIAL_SYSLOG_SERVICE
-#define SPECIAL_SYSLOG_SERVICE "syslog.service"
-#endif
-
/* For SysV compatibility. Usually an alias for a saner target. On
* SysV-free systems this doesn't exist. */
#define SPECIAL_RUNLEVEL2_TARGET "runlevel2.target"
diff --git a/src/unit.c b/src/unit.c
index 10de40affc..6f10f51fbd 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -1224,12 +1224,6 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
* yet connected. */
bus_init(u->meta.manager, true);
- if (unit_has_name(u, SPECIAL_SYSLOG_SERVICE))
- /* The syslog daemon just might have become
- * available, hence try to connect to it, if
- * we aren't yet connected. */
- log_open();
-
if (u->meta.type == UNIT_SERVICE &&
!UNIT_IS_ACTIVE_OR_RELOADING(os)) {
/* Write audit record if we have just finished starting up */
@@ -1242,12 +1236,6 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
} else {
- if (unit_has_name(u, SPECIAL_SYSLOG_SERVICE))
- /* The syslog daemon might just have
- * terminated, hence try to disconnect from
- * it. */
- log_close_syslog();
-
/* We don't care about D-Bus here, since we'll get an
* asynchronous notification for it anyway. */
@@ -1277,6 +1265,8 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
unit_add_to_dbus_queue(u);
unit_add_to_gc_queue(u);
+
+ manager_recheck_syslog(u->meta.manager);
}
int unit_watch_fd(Unit *u, int fd, uint32_t events, Watch *w) {
diff --git a/units/syslog.target.in b/units/syslog.target.in
index 37d5de368b..d5410cf580 100644
--- a/units/syslog.target.in
+++ b/units/syslog.target.in
@@ -9,9 +9,3 @@
[Unit]
Description=Syslog
-
-# As soon as all syslog services have native unit files this explicit
-# dependency should be dropped, and replaced by alias symlinks in the
-# .wants/ directory, to either the .service or .socket unit of the
-# syslog service.
-After=@SPECIAL_SYSLOG_SERVICE@