304 lines
9.9 KiB
Diff
304 lines
9.9 KiB
Diff
|
From 37161c5148396448921841ae1026b281c7949652 Mon Sep 17 00:00:00 2001
|
||
|
From: Emil Renner Berthing <systemd@esmil.dk>
|
||
|
Date: Wed, 24 Sep 2014 17:25:00 +0200
|
||
|
Subject: [PATCH] make utmp/wtmp support configurable
|
||
|
|
||
|
This adds --disable-utmp option to configure. If it is used, all
|
||
|
utmp-related functionality, including querying runlevel support,
|
||
|
is removed.
|
||
|
---
|
||
|
Makefile-man.am | 29 +++++++++++++++++------------
|
||
|
Makefile.am | 26 +++++++++++++++++++++-----
|
||
|
configure.ac | 11 +++++++++++
|
||
|
man/runlevel.xml | 3 ++-
|
||
|
man/systemd-update-utmp.service.xml | 2 +-
|
||
|
src/core/build.h | 7 +++++++
|
||
|
src/shared/utmp-wtmp.h | 28 ++++++++++++++++++++++++++++
|
||
|
7 files changed, 87 insertions(+), 19 deletions(-)
|
||
|
|
||
|
diff --git a/Makefile-man.am b/Makefile-man.am
|
||
|
index bd5306e676..2b3fa95e70 100644
|
||
|
--- a/Makefile-man.am
|
||
|
+++ b/Makefile-man.am
|
||
|
@@ -23,7 +23,6 @@ MANPAGES += \
|
||
|
man/machine-id.5 \
|
||
|
man/machine-info.5 \
|
||
|
man/os-release.5 \
|
||
|
- man/runlevel.8 \
|
||
|
man/sd-daemon.3 \
|
||
|
man/sd-id128.3 \
|
||
|
man/sd-journal.3 \
|
||
|
@@ -93,7 +92,6 @@ MANPAGES += \
|
||
|
man/systemd-tty-ask-password-agent.1 \
|
||
|
man/systemd-udevd.service.8 \
|
||
|
man/systemd-update-done.service.8 \
|
||
|
- man/systemd-update-utmp.service.8 \
|
||
|
man/systemd.1 \
|
||
|
man/systemd.automount.5 \
|
||
|
man/systemd.device.5 \
|
||
|
@@ -227,8 +225,6 @@ MANPAGES_ALIAS += \
|
||
|
man/systemd-udevd-kernel.socket.8 \
|
||
|
man/systemd-udevd.8 \
|
||
|
man/systemd-update-done.8 \
|
||
|
- man/systemd-update-utmp-runlevel.service.8 \
|
||
|
- man/systemd-update-utmp.8 \
|
||
|
man/systemd-user.conf.5
|
||
|
man/SD_ALERT.3: man/sd-daemon.3
|
||
|
man/SD_CRIT.3: man/sd-daemon.3
|
||
|
@@ -334,8 +330,6 @@ man/systemd-udevd-control.socket.8: man/systemd-udevd.service.8
|
||
|
man/systemd-udevd-kernel.socket.8: man/systemd-udevd.service.8
|
||
|
man/systemd-udevd.8: man/systemd-udevd.service.8
|
||
|
man/systemd-update-done.8: man/systemd-update-done.service.8
|
||
|
-man/systemd-update-utmp-runlevel.service.8: man/systemd-update-utmp.service.8
|
||
|
-man/systemd-update-utmp.8: man/systemd-update-utmp.service.8
|
||
|
man/systemd-user.conf.5: man/systemd-system.conf.5
|
||
|
man/SD_ALERT.html: man/sd-daemon.html
|
||
|
$(html-alias)
|
||
|
@@ -649,12 +643,6 @@ man/systemd-udevd.html: man/systemd-udevd.service.html
|
||
|
man/systemd-update-done.html: man/systemd-update-done.service.html
|
||
|
$(html-alias)
|
||
|
|
||
|
-man/systemd-update-utmp-runlevel.service.html: man/systemd-update-utmp.service.html
|
||
|
- $(html-alias)
|
||
|
-
|
||
|
-man/systemd-update-utmp.html: man/systemd-update-utmp.service.html
|
||
|
- $(html-alias)
|
||
|
-
|
||
|
man/systemd-user.conf.html: man/systemd-system.conf.html
|
||
|
$(html-alias)
|
||
|
|
||
|
@@ -1509,6 +1497,23 @@ MANPAGES_ALIAS += \
|
||
|
|
||
|
endif
|
||
|
|
||
|
+if HAVE_UTMP
|
||
|
+MANPAGES += \
|
||
|
+ man/runlevel.8 \
|
||
|
+ man/systemd-update-utmp.service.8
|
||
|
+MANPAGES_ALIAS += \
|
||
|
+ man/systemd-update-utmp-runlevel.service.8 \
|
||
|
+ man/systemd-update-utmp.8
|
||
|
+man/systemd-update-utmp-runlevel.service.8: man/systemd-update-utmp.service.8
|
||
|
+man/systemd-update-utmp.8: man/systemd-update-utmp.service.8
|
||
|
+man/systemd-update-utmp-runlevel.service.html: man/systemd-update-utmp.service.html
|
||
|
+ $(html-alias)
|
||
|
+
|
||
|
+man/systemd-update-utmp.html: man/systemd-update-utmp.service.html
|
||
|
+ $(html-alias)
|
||
|
+
|
||
|
+endif
|
||
|
+
|
||
|
# Really, do not edit this file.
|
||
|
|
||
|
EXTRA_DIST += \
|
||
|
diff --git a/Makefile.am b/Makefile.am
|
||
|
index 0f54c5c014..e0cba76329 100644
|
||
|
--- a/Makefile.am
|
||
|
+++ b/Makefile.am
|
||
|
@@ -378,7 +378,6 @@ rootlibexec_PROGRAMS = \
|
||
|
systemd \
|
||
|
systemd-cgroups-agent \
|
||
|
systemd-initctl \
|
||
|
- systemd-update-utmp \
|
||
|
systemd-shutdownd \
|
||
|
systemd-shutdown \
|
||
|
systemd-remount-fs \
|
||
|
@@ -391,6 +390,11 @@ rootlibexec_PROGRAMS = \
|
||
|
systemd-socket-proxyd \
|
||
|
systemd-update-done
|
||
|
|
||
|
+if HAVE_UTMP
|
||
|
+rootlibexec_PROGRAMS += \
|
||
|
+ systemd-update-utmp
|
||
|
+endif
|
||
|
+
|
||
|
systemgenerator_PROGRAMS = \
|
||
|
systemd-getty-generator \
|
||
|
systemd-fstab-generator \
|
||
|
@@ -517,8 +521,6 @@ nodist_systemunit_DATA = \
|
||
|
units/systemd-initctl.service \
|
||
|
units/systemd-shutdownd.service \
|
||
|
units/systemd-remount-fs.service \
|
||
|
- units/systemd-update-utmp.service \
|
||
|
- units/systemd-update-utmp-runlevel.service \
|
||
|
units/systemd-ask-password-wall.service \
|
||
|
units/systemd-ask-password-console.service \
|
||
|
units/systemd-sysctl.service \
|
||
|
@@ -544,6 +546,12 @@ nodist_systemunit_DATA = \
|
||
|
units/systemd-nspawn@.service \
|
||
|
units/systemd-update-done.service
|
||
|
|
||
|
+if HAVE_UTMP
|
||
|
+nodist_systemunit_DATA += \
|
||
|
+ units/systemd-update-utmp.service \
|
||
|
+ units/systemd-update-utmp-runlevel.service
|
||
|
+endif
|
||
|
+
|
||
|
dist_userunit_DATA = \
|
||
|
units/user/basic.target \
|
||
|
units/user/default.target \
|
||
|
@@ -804,7 +812,6 @@ libsystemd_shared_la_SOURCES = \
|
||
|
src/shared/cgroup-show.h \
|
||
|
src/shared/unit-name.c \
|
||
|
src/shared/unit-name.h \
|
||
|
- src/shared/utmp-wtmp.c \
|
||
|
src/shared/utmp-wtmp.h \
|
||
|
src/shared/watchdog.c \
|
||
|
src/shared/watchdog.h \
|
||
|
@@ -878,6 +885,11 @@ libsystemd_shared_la_SOURCES = \
|
||
|
src/shared/switch-root.c \
|
||
|
src/shared/nss-util.h
|
||
|
|
||
|
+if HAVE_UTMP
|
||
|
+libsystemd_shared_la_SOURCES += \
|
||
|
+ src/shared/utmp-wtmp.c
|
||
|
+endif
|
||
|
+
|
||
|
nodist_libsystemd_shared_la_SOURCES = \
|
||
|
src/shared/errno-from-name.h \
|
||
|
src/shared/errno-to-name.h \
|
||
|
@@ -5856,6 +5868,7 @@ SOCKETS_TARGET_WANTS += \
|
||
|
systemd-initctl.socket \
|
||
|
systemd-shutdownd.socket
|
||
|
|
||
|
+if HAVE_UTMP
|
||
|
if HAVE_SYSV_COMPAT
|
||
|
RUNLEVEL1_TARGET_WANTS += \
|
||
|
systemd-update-utmp-runlevel.service
|
||
|
@@ -5870,7 +5883,10 @@ RUNLEVEL5_TARGET_WANTS += \
|
||
|
endif
|
||
|
|
||
|
SYSINIT_TARGET_WANTS += \
|
||
|
- systemd-update-utmp.service \
|
||
|
+ systemd-update-utmp.service
|
||
|
+endif
|
||
|
+
|
||
|
+SYSINIT_TARGET_WANTS += \
|
||
|
systemd-update-done.service
|
||
|
|
||
|
LOCAL_FS_TARGET_WANTS += \
|
||
|
diff --git a/configure.ac b/configure.ac
|
||
|
index 84644e163f..e33c8f75ac 100644
|
||
|
--- a/configure.ac
|
||
|
+++ b/configure.ac
|
||
|
@@ -346,6 +346,16 @@ AS_IF([test "x$enable_dbus" != "xno"], [
|
||
|
AM_CONDITIONAL(HAVE_DBUS, [test "$have_dbus" = "yes"])
|
||
|
|
||
|
# ------------------------------------------------------------------------------
|
||
|
+have_utmp=yes
|
||
|
+AC_ARG_ENABLE([utmp], AS_HELP_STRING([--disable-utmp], [disable utmp/wtmp log handling]),
|
||
|
+ AS_CASE("x${enableval}",
|
||
|
+ [xyes], [have_utmp=yes],
|
||
|
+ [xno], [have_utmp=no],
|
||
|
+ AC_MSG_ERROR(bad value ${enableval} for --enable-utmp)))
|
||
|
+AS_IF([test "x$have_utmp" = "xyes"], [AC_DEFINE(HAVE_UTMP, 1, [Define if utmp/wtmp support is enabled])])
|
||
|
+AM_CONDITIONAL([HAVE_UTMP], [test "x$have_utmp" = "xyes"])
|
||
|
+
|
||
|
+# ------------------------------------------------------------------------------
|
||
|
have_compat_libs=no
|
||
|
AC_ARG_ENABLE([compat_libs], AS_HELP_STRING([--enable-compat-libs],[Enable creation of compatibility libraries]),
|
||
|
[case "${enableval}" in
|
||
|
@@ -1372,6 +1382,7 @@ AC_MSG_RESULT([
|
||
|
Split /usr: ${enable_split_usr}
|
||
|
SysV compatibility: ${SYSTEM_SYSV_COMPAT}
|
||
|
compatibility libraries: ${have_compat_libs}
|
||
|
+ utmp/wtmp support: ${have_utmp}
|
||
|
|
||
|
prefix: ${prefix}
|
||
|
rootprefix: ${with_rootprefix}
|
||
|
diff --git a/man/runlevel.xml b/man/runlevel.xml
|
||
|
index 976753a737..db9a436724 100644
|
||
|
--- a/man/runlevel.xml
|
||
|
+++ b/man/runlevel.xml
|
||
|
@@ -22,7 +22,8 @@
|
||
|
-->
|
||
|
|
||
|
<refentry id="runlevel"
|
||
|
- xmlns:xi="http://www.w3.org/2001/XInclude">
|
||
|
+ xmlns:xi="http://www.w3.org/2001/XInclude"
|
||
|
+ conditional="HAVE_UTMP">
|
||
|
|
||
|
<refentryinfo>
|
||
|
<title>runlevel</title>
|
||
|
diff --git a/man/systemd-update-utmp.service.xml b/man/systemd-update-utmp.service.xml
|
||
|
index 7d9e32e60a..caa1d8f568 100644
|
||
|
--- a/man/systemd-update-utmp.service.xml
|
||
|
+++ b/man/systemd-update-utmp.service.xml
|
||
|
@@ -19,7 +19,7 @@
|
||
|
You should have received a copy of the GNU Lesser General Public License
|
||
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||
|
-->
|
||
|
-<refentry id="systemd-update-utmp.service">
|
||
|
+<refentry id="systemd-update-utmp.service" conditional="HAVE_UTMP">
|
||
|
|
||
|
<refentryinfo>
|
||
|
<title>systemd-update-utmp.service</title>
|
||
|
diff --git a/src/core/build.h b/src/core/build.h
|
||
|
index a7f12a33e4..d5e55506cf 100644
|
||
|
--- a/src/core/build.h
|
||
|
+++ b/src/core/build.h
|
||
|
@@ -63,6 +63,12 @@
|
||
|
#define _SYSVINIT_FEATURE_ "-SYSVINIT"
|
||
|
#endif
|
||
|
|
||
|
+#ifdef HAVE_UTMP
|
||
|
+#define _UTMP_FEATURE_ "+UTMP"
|
||
|
+#else
|
||
|
+#define _UTMP_FEATURE_ "-UTMP"
|
||
|
+#endif
|
||
|
+
|
||
|
#ifdef HAVE_LIBCRYPTSETUP
|
||
|
#define _LIBCRYPTSETUP_FEATURE_ "+LIBCRYPTSETUP"
|
||
|
#else
|
||
|
@@ -137,6 +143,7 @@
|
||
|
_APPARMOR_FEATURE_ " " \
|
||
|
_SMACK_FEATURE_ " " \
|
||
|
_SYSVINIT_FEATURE_ " " \
|
||
|
+ _UTMP_FEATURE_ " " \
|
||
|
_LIBCRYPTSETUP_FEATURE_ " " \
|
||
|
_GCRYPT_FEATURE_ " " \
|
||
|
_GNUTLS_FEATURE_ " " \
|
||
|
diff --git a/src/shared/utmp-wtmp.h b/src/shared/utmp-wtmp.h
|
||
|
index 040a16e746..87d004e615 100644
|
||
|
--- a/src/shared/utmp-wtmp.h
|
||
|
+++ b/src/shared/utmp-wtmp.h
|
||
|
@@ -23,6 +23,7 @@
|
||
|
|
||
|
#include "util.h"
|
||
|
|
||
|
+#ifdef HAVE_UTMP
|
||
|
int utmp_get_runlevel(int *runlevel, int *previous);
|
||
|
|
||
|
int utmp_put_shutdown(void);
|
||
|
@@ -33,3 +34,30 @@ int utmp_put_dead_process(const char *id, pid_t pid, int code, int status);
|
||
|
int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line);
|
||
|
|
||
|
int utmp_wall(const char *message, const char *username, bool (*match_tty)(const char *tty));
|
||
|
+
|
||
|
+#else /* HAVE_UTMP */
|
||
|
+
|
||
|
+static inline int utmp_get_runlevel(int *runlevel, int *previous) {
|
||
|
+ return -ESRCH;
|
||
|
+}
|
||
|
+static inline int utmp_put_shutdown(void) {
|
||
|
+ return 0;
|
||
|
+}
|
||
|
+static inline int utmp_put_reboot(usec_t timestamp) {
|
||
|
+ return 0;
|
||
|
+}
|
||
|
+static inline int utmp_put_runlevel(int runlevel, int previous) {
|
||
|
+ return 0;
|
||
|
+}
|
||
|
+static inline int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) {
|
||
|
+ return 0;
|
||
|
+}
|
||
|
+static inline int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line) {
|
||
|
+ return 0;
|
||
|
+}
|
||
|
+static inline int utmp_wall(const char *message, const char *username,
|
||
|
+ bool (*match_tty)(const char *tty)) {
|
||
|
+ return 0;
|
||
|
+}
|
||
|
+
|
||
|
+#endif /* HAVE_UTMP */
|