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.
This commit is contained in:
Emil Renner Berthing 2014-09-24 17:25:00 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent 440c61c500
commit 37161c5148
7 changed files with 87 additions and 19 deletions

View File

@ -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 += \

View File

@ -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 += \

View File

@ -345,6 +345,16 @@ AS_IF([test "x$enable_dbus" != "xno"], [
[AC_MSG_ERROR([*** dbus-1 support requested but libraries not found])])])
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]),
@ -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}

View File

@ -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>

View File

@ -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>

View File

@ -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_ " " \

View File

@ -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 */