util: move all to shared/ and split external dependencies in separate internal libraries
Before: $ ldd /lib/systemd/systemd-timestamp linux-vdso.so.1 => (0x00007fffb05ff000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f90aac57000) libcap.so.2 => /lib64/libcap.so.2 (0x00007f90aaa53000) librt.so.1 => /lib64/librt.so.1 (0x00007f90aa84a000) libc.so.6 => /lib64/libc.so.6 (0x00007f90aa494000) /lib64/ld-linux-x86-64.so.2 (0x00007f90aae90000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f90aa290000) libattr.so.1 => /lib64/libattr.so.1 (0x00007f90aa08a000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f90a9e6e000) After: $ ldd systemd-timestamp linux-vdso.so.1 => (0x00007fff3cbff000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f5eaa1c3000) librt.so.1 => /lib64/librt.so.1 (0x00007f5ea9fbb000) libc.so.6 => /lib64/libc.so.6 (0x00007f5ea9c04000) /lib64/ld-linux-x86-64.so.2 (0x00007f5eaa3fc000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f5ea9a00000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f5ea97e4000)
This commit is contained in:
parent
304b9f3078
commit
d7832d2c6e
115
Makefile.am
115
Makefile.am
|
@ -120,6 +120,7 @@ AM_CPPFLAGS = \
|
||||||
-DX_SERVER=\"$(bindir)/X\" \
|
-DX_SERVER=\"$(bindir)/X\" \
|
||||||
-DUDEVLIBEXECDIR=\""$(libexecdir)/udev"\" \
|
-DUDEVLIBEXECDIR=\""$(libexecdir)/udev"\" \
|
||||||
-I $(top_srcdir)/src \
|
-I $(top_srcdir)/src \
|
||||||
|
-I $(top_srcdir)/src/shared \
|
||||||
-I $(top_srcdir)/src/readahead \
|
-I $(top_srcdir)/src/readahead \
|
||||||
-I $(top_srcdir)/src/login \
|
-I $(top_srcdir)/src/login \
|
||||||
-I $(top_srcdir)/src/journal \
|
-I $(top_srcdir)/src/journal \
|
||||||
|
@ -129,6 +130,7 @@ AM_CPPFLAGS = \
|
||||||
AM_CFLAGS = $(WARNINGFLAGS)
|
AM_CFLAGS = $(WARNINGFLAGS)
|
||||||
AM_LDFLAGS = $(GCLDFLAGS)
|
AM_LDFLAGS = $(GCLDFLAGS)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
if TARGET_GENTOO
|
if TARGET_GENTOO
|
||||||
AM_CPPFLAGS += \
|
AM_CPPFLAGS += \
|
||||||
-DKBD_LOADKEYS=\"/usr/bin/loadkeys\" \
|
-DKBD_LOADKEYS=\"/usr/bin/loadkeys\" \
|
||||||
|
@ -183,6 +185,7 @@ endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
rootbin_PROGRAMS = \
|
rootbin_PROGRAMS = \
|
||||||
systemctl \
|
systemctl \
|
||||||
systemd-notify \
|
systemd-notify \
|
||||||
|
@ -472,42 +475,66 @@ EXTRA_DIST += \
|
||||||
|
|
||||||
noinst_LTLIBRARIES = \
|
noinst_LTLIBRARIES = \
|
||||||
libsystemd-basic.la \
|
libsystemd-basic.la \
|
||||||
|
libsystemd-capability.la \
|
||||||
|
libsystemd-audit.la \
|
||||||
libsystemd-core.la
|
libsystemd-core.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
libsystemd_basic_la_SOURCES = \
|
libsystemd_basic_la_SOURCES = \
|
||||||
src/util.c \
|
src/shared/util.c \
|
||||||
src/util.h \
|
src/shared/util.h \
|
||||||
src/virt.c \
|
src/shared/virt.c \
|
||||||
src/virt.h \
|
src/shared/virt.h \
|
||||||
src/label.c \
|
src/shared/label.c \
|
||||||
src/label.h \
|
src/shared/label.h \
|
||||||
src/hashmap.c \
|
src/shared/hashmap.c \
|
||||||
src/hashmap.h \
|
src/shared/hashmap.h \
|
||||||
src/set.c \
|
src/shared/set.c \
|
||||||
src/set.h \
|
src/shared/set.h \
|
||||||
src/strv.c \
|
src/shared/strv.c \
|
||||||
src/strv.h \
|
src/shared/strv.h \
|
||||||
src/conf-parser.c \
|
src/shared/conf-parser.c \
|
||||||
src/conf-parser.h \
|
src/shared/conf-parser.h \
|
||||||
src/socket-util.c \
|
src/shared/socket-util.c \
|
||||||
src/socket-util.h \
|
src/shared/socket-util.h \
|
||||||
src/log.c \
|
src/shared/log.c \
|
||||||
src/log.h \
|
src/shared/log.h \
|
||||||
src/ratelimit.h \
|
src/shared/ratelimit.h \
|
||||||
src/ratelimit.c \
|
src/shared/ratelimit.c \
|
||||||
src/exit-status.c \
|
src/shared/exit-status.c \
|
||||||
src/exit-status.h \
|
src/shared/exit-status.h \
|
||||||
src/utf8.c \
|
src/shared/utf8.c \
|
||||||
src/utf8.h
|
src/shared/utf8.h
|
||||||
|
|
||||||
libsystemd_basic_la_CFLAGS = \
|
libsystemd_basic_la_CFLAGS = \
|
||||||
$(AM_CFLAGS) \
|
$(AM_CFLAGS) \
|
||||||
$(SELINUX_CFLAGS)
|
$(SELINUX_CFLAGS)
|
||||||
|
|
||||||
libsystemd_basic_la_LIBADD = \
|
libsystemd_basic_la_LIBADD = \
|
||||||
$(SELINUX_LIBS) \
|
libsystemd-capability.la \
|
||||||
|
$(SELINUX_LIBS)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
libsystemd_capability_la_SOURCES = \
|
||||||
|
src/shared/capability.c \
|
||||||
|
src/shared/capability.h
|
||||||
|
|
||||||
|
libsystemd_capability_la_CFLAGS = \
|
||||||
|
$(AM_CFLAGS) \
|
||||||
|
$(CAP_CFLAGS)
|
||||||
|
|
||||||
|
libsystemd_capability_la_LIBADD = \
|
||||||
$(CAP_LIBS)
|
$(CAP_LIBS)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
libsystemd_audit_la_SOURCES = \
|
||||||
|
src/shared/audit.c \
|
||||||
|
src/shared/audit.h
|
||||||
|
|
||||||
|
libsystemd_audit_la_LIBADD = \
|
||||||
|
libsystemd-capability.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
libsystemd_core_la_SOURCES = \
|
libsystemd_core_la_SOURCES = \
|
||||||
src/unit.c \
|
src/unit.c \
|
||||||
src/unit.h \
|
src/unit.h \
|
||||||
|
@ -613,8 +640,8 @@ libsystemd_core_la_SOURCES = \
|
||||||
src/tcpwrap.h \
|
src/tcpwrap.h \
|
||||||
src/cgroup-attr.c \
|
src/cgroup-attr.c \
|
||||||
src/cgroup-attr.h \
|
src/cgroup-attr.h \
|
||||||
src/watchdog.c \
|
src/watchdog.c \
|
||||||
src/watchdog.h \
|
src/watchdog.h \
|
||||||
src/sd-daemon.c \
|
src/sd-daemon.c \
|
||||||
src/sd-id128.c \
|
src/sd-id128.c \
|
||||||
src/macro.h \
|
src/macro.h \
|
||||||
|
@ -667,6 +694,7 @@ libsystemd_core_la_LIBADD = \
|
||||||
$(CAP_LIBS) \
|
$(CAP_LIBS) \
|
||||||
$(KMOD_LIBS)
|
$(KMOD_LIBS)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
MANPAGES = \
|
MANPAGES = \
|
||||||
man/systemd.1 \
|
man/systemd.1 \
|
||||||
man/systemctl.1 \
|
man/systemctl.1 \
|
||||||
|
@ -741,6 +769,7 @@ EXTRA_DIST += \
|
||||||
$(MANPAGES) \
|
$(MANPAGES) \
|
||||||
$(MANPAGES_ALIAS)
|
$(MANPAGES_ALIAS)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_SOURCES = \
|
systemd_SOURCES = \
|
||||||
src/main.c
|
src/main.c
|
||||||
|
|
||||||
|
@ -751,6 +780,7 @@ systemd_CFLAGS = \
|
||||||
systemd_LDADD = \
|
systemd_LDADD = \
|
||||||
libsystemd-core.la
|
libsystemd-core.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
test_engine_SOURCES = \
|
test_engine_SOURCES = \
|
||||||
src/test-engine.c
|
src/test-engine.c
|
||||||
|
|
||||||
|
@ -831,6 +861,7 @@ test_watchdog_SOURCES = \
|
||||||
test_watchdog_LDADD = \
|
test_watchdog_LDADD = \
|
||||||
libsystemd-basic.la
|
libsystemd-basic.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_initctl_SOURCES = \
|
systemd_initctl_SOURCES = \
|
||||||
src/initctl.c \
|
src/initctl.c \
|
||||||
src/dbus-common.c
|
src/dbus-common.c
|
||||||
|
@ -844,6 +875,7 @@ systemd_initctl_LDADD = \
|
||||||
libsystemd-daemon.la \
|
libsystemd-daemon.la \
|
||||||
$(DBUS_LIBS)
|
$(DBUS_LIBS)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_update_utmp_SOURCES = \
|
systemd_update_utmp_SOURCES = \
|
||||||
src/update-utmp.c \
|
src/update-utmp.c \
|
||||||
src/dbus-common.c \
|
src/dbus-common.c \
|
||||||
|
@ -859,6 +891,7 @@ systemd_update_utmp_LDADD = \
|
||||||
$(DBUS_LIBS) \
|
$(DBUS_LIBS) \
|
||||||
$(AUDIT_LIBS)
|
$(AUDIT_LIBS)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_shutdownd_SOURCES = \
|
systemd_shutdownd_SOURCES = \
|
||||||
src/utmp-wtmp.c \
|
src/utmp-wtmp.c \
|
||||||
src/shutdownd.c
|
src/shutdownd.c
|
||||||
|
@ -881,6 +914,7 @@ systemd_shutdown_LDADD = \
|
||||||
libsystemd-basic.la \
|
libsystemd-basic.la \
|
||||||
libudev.la
|
libudev.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_modules_load_SOURCES = \
|
systemd_modules_load_SOURCES = \
|
||||||
src/modules-load.c
|
src/modules-load.c
|
||||||
|
|
||||||
|
@ -891,12 +925,14 @@ systemd_modules_load_LDADD = \
|
||||||
libsystemd-basic.la \
|
libsystemd-basic.la \
|
||||||
$(KMOD_LIBS)
|
$(KMOD_LIBS)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_tmpfiles_SOURCES = \
|
systemd_tmpfiles_SOURCES = \
|
||||||
src/tmpfiles.c
|
src/tmpfiles.c
|
||||||
|
|
||||||
systemd_tmpfiles_LDADD = \
|
systemd_tmpfiles_LDADD = \
|
||||||
libsystemd-basic.la
|
libsystemd-basic.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_machine_id_setup_SOURCES = \
|
systemd_machine_id_setup_SOURCES = \
|
||||||
src/machine-id-setup.c \
|
src/machine-id-setup.c \
|
||||||
src/machine-id-main.c \
|
src/machine-id-main.c \
|
||||||
|
@ -905,12 +941,14 @@ systemd_machine_id_setup_SOURCES = \
|
||||||
systemd_machine_id_setup_LDADD = \
|
systemd_machine_id_setup_LDADD = \
|
||||||
libsystemd-basic.la
|
libsystemd-basic.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_sysctl_SOURCES = \
|
systemd_sysctl_SOURCES = \
|
||||||
src/sysctl.c
|
src/sysctl.c
|
||||||
|
|
||||||
systemd_sysctl_LDADD = \
|
systemd_sysctl_LDADD = \
|
||||||
libsystemd-basic.la
|
libsystemd-basic.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_fsck_SOURCES = \
|
systemd_fsck_SOURCES = \
|
||||||
src/fsck.c \
|
src/fsck.c \
|
||||||
src/dbus-common.c
|
src/dbus-common.c
|
||||||
|
@ -924,12 +962,14 @@ systemd_fsck_LDADD = \
|
||||||
libudev.la \
|
libudev.la \
|
||||||
$(DBUS_LIBS)
|
$(DBUS_LIBS)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_timestamp_SOURCES = \
|
systemd_timestamp_SOURCES = \
|
||||||
src/timestamp.c
|
src/timestamp.c
|
||||||
|
|
||||||
systemd_timestamp_LDADD = \
|
systemd_timestamp_LDADD = \
|
||||||
libsystemd-basic.la
|
libsystemd-basic.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_ac_power_SOURCES = \
|
systemd_ac_power_SOURCES = \
|
||||||
src/ac-power.c
|
src/ac-power.c
|
||||||
|
|
||||||
|
@ -937,12 +977,14 @@ systemd_ac_power_LDADD = \
|
||||||
libsystemd-basic.la \
|
libsystemd-basic.la \
|
||||||
libudev.la
|
libudev.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_detect_virt_SOURCES = \
|
systemd_detect_virt_SOURCES = \
|
||||||
src/detect-virt.c
|
src/detect-virt.c
|
||||||
|
|
||||||
systemd_detect_virt_LDADD = \
|
systemd_detect_virt_LDADD = \
|
||||||
libsystemd-basic.la
|
libsystemd-basic.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_getty_generator_SOURCES = \
|
systemd_getty_generator_SOURCES = \
|
||||||
src/getty-generator.c \
|
src/getty-generator.c \
|
||||||
src/unit-name.c
|
src/unit-name.c
|
||||||
|
@ -950,20 +992,22 @@ systemd_getty_generator_SOURCES = \
|
||||||
systemd_getty_generator_LDADD = \
|
systemd_getty_generator_LDADD = \
|
||||||
libsystemd-basic.la
|
libsystemd-basic.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_rc_local_generator_SOURCES = \
|
systemd_rc_local_generator_SOURCES = \
|
||||||
src/rc-local-generator.c
|
src/rc-local-generator.c
|
||||||
|
|
||||||
systemd_rc_local_generator_LDADD = \
|
systemd_rc_local_generator_LDADD = \
|
||||||
libsystemd-basic.la
|
libsystemd-basic.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_remount_api_vfs_SOURCES = \
|
systemd_remount_api_vfs_SOURCES = \
|
||||||
src/remount-api-vfs.c \
|
src/remount-api-vfs.c \
|
||||||
src/mount-setup.c \
|
src/mount-setup.c
|
||||||
src/exit-status.c
|
|
||||||
|
|
||||||
systemd_remount_api_vfs_LDADD = \
|
systemd_remount_api_vfs_LDADD = \
|
||||||
libsystemd-basic.la
|
libsystemd-basic.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_cgroups_agent_SOURCES = \
|
systemd_cgroups_agent_SOURCES = \
|
||||||
src/cgroups-agent.c \
|
src/cgroups-agent.c \
|
||||||
src/dbus-common.c
|
src/dbus-common.c
|
||||||
|
@ -976,6 +1020,7 @@ systemd_cgroups_agent_LDADD = \
|
||||||
libsystemd-basic.la \
|
libsystemd-basic.la \
|
||||||
$(DBUS_LIBS)
|
$(DBUS_LIBS)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemctl_SOURCES = \
|
systemctl_SOURCES = \
|
||||||
src/systemctl.c \
|
src/systemctl.c \
|
||||||
src/utmp-wtmp.c \
|
src/utmp-wtmp.c \
|
||||||
|
@ -983,7 +1028,6 @@ systemctl_SOURCES = \
|
||||||
src/path-lookup.c \
|
src/path-lookup.c \
|
||||||
src/cgroup-show.c \
|
src/cgroup-show.c \
|
||||||
src/cgroup-util.c \
|
src/cgroup-util.c \
|
||||||
src/exit-status.c \
|
|
||||||
src/unit-name.c \
|
src/unit-name.c \
|
||||||
src/pager.c \
|
src/pager.c \
|
||||||
src/install.c \
|
src/install.c \
|
||||||
|
@ -1001,6 +1045,7 @@ systemctl_LDADD = \
|
||||||
libsystemd-id128.la \
|
libsystemd-id128.la \
|
||||||
$(DBUS_LIBS)
|
$(DBUS_LIBS)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_notify_SOURCES = \
|
systemd_notify_SOURCES = \
|
||||||
src/notify.c \
|
src/notify.c \
|
||||||
src/readahead/sd-readahead.c
|
src/readahead/sd-readahead.c
|
||||||
|
@ -1009,6 +1054,7 @@ systemd_notify_LDADD = \
|
||||||
libsystemd-basic.la \
|
libsystemd-basic.la \
|
||||||
libsystemd-daemon.la
|
libsystemd-daemon.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_ask_password_SOURCES = \
|
systemd_ask_password_SOURCES = \
|
||||||
src/ask-password.c \
|
src/ask-password.c \
|
||||||
src/ask-password-api.c
|
src/ask-password-api.c
|
||||||
|
@ -1016,12 +1062,14 @@ systemd_ask_password_SOURCES = \
|
||||||
systemd_ask_password_LDADD = \
|
systemd_ask_password_LDADD = \
|
||||||
libsystemd-basic.la
|
libsystemd-basic.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_reply_password_SOURCES = \
|
systemd_reply_password_SOURCES = \
|
||||||
src/reply-password.c
|
src/reply-password.c
|
||||||
|
|
||||||
systemd_reply_password_LDADD = \
|
systemd_reply_password_LDADD = \
|
||||||
libsystemd-basic.la
|
libsystemd-basic.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_cgls_SOURCES = \
|
systemd_cgls_SOURCES = \
|
||||||
src/cgls.c \
|
src/cgls.c \
|
||||||
src/cgroup-show.c \
|
src/cgroup-show.c \
|
||||||
|
@ -1031,6 +1079,7 @@ systemd_cgls_SOURCES = \
|
||||||
systemd_cgls_LDADD = \
|
systemd_cgls_LDADD = \
|
||||||
libsystemd-basic.la
|
libsystemd-basic.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_cgtop_SOURCES = \
|
systemd_cgtop_SOURCES = \
|
||||||
src/cgtop.c \
|
src/cgtop.c \
|
||||||
src/cgroup-util.c
|
src/cgroup-util.c
|
||||||
|
@ -1038,6 +1087,7 @@ systemd_cgtop_SOURCES = \
|
||||||
systemd_cgtop_LDADD = \
|
systemd_cgtop_LDADD = \
|
||||||
libsystemd-basic.la
|
libsystemd-basic.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_nspawn_SOURCES = \
|
systemd_nspawn_SOURCES = \
|
||||||
src/nspawn.c \
|
src/nspawn.c \
|
||||||
src/cgroup-util.c \
|
src/cgroup-util.c \
|
||||||
|
@ -1045,14 +1095,17 @@ systemd_nspawn_SOURCES = \
|
||||||
|
|
||||||
systemd_nspawn_LDADD = \
|
systemd_nspawn_LDADD = \
|
||||||
libsystemd-basic.la \
|
libsystemd-basic.la \
|
||||||
|
libsystemd-capability.la \
|
||||||
libsystemd-daemon.la
|
libsystemd-daemon.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_stdio_bridge_SOURCES = \
|
systemd_stdio_bridge_SOURCES = \
|
||||||
src/bridge.c
|
src/bridge.c
|
||||||
|
|
||||||
systemd_stdio_bridge_LDADD = \
|
systemd_stdio_bridge_LDADD = \
|
||||||
libsystemd-basic.la
|
libsystemd-basic.la
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
systemd_tty_ask_password_agent_SOURCES = \
|
systemd_tty_ask_password_agent_SOURCES = \
|
||||||
src/tty-ask-password-agent.c \
|
src/tty-ask-password-agent.c \
|
||||||
src/ask-password-api.c \
|
src/ask-password-api.c \
|
||||||
|
@ -1844,6 +1897,7 @@ systemd_journald_CFLAGS = \
|
||||||
|
|
||||||
systemd_journald_LDADD = \
|
systemd_journald_LDADD = \
|
||||||
libsystemd-basic.la \
|
libsystemd-basic.la \
|
||||||
|
libsystemd-audit.la \
|
||||||
libsystemd-daemon.la \
|
libsystemd-daemon.la \
|
||||||
libsystemd-login.la \
|
libsystemd-login.la \
|
||||||
$(ACL_LIBS)
|
$(ACL_LIBS)
|
||||||
|
@ -2452,6 +2506,7 @@ systemd_logind_CFLAGS = \
|
||||||
|
|
||||||
systemd_logind_LDADD = \
|
systemd_logind_LDADD = \
|
||||||
libsystemd-basic.la \
|
libsystemd-basic.la \
|
||||||
|
libsystemd-audit.la \
|
||||||
libsystemd-daemon.la \
|
libsystemd-daemon.la \
|
||||||
libudev.la \
|
libudev.la \
|
||||||
$(DBUS_LIBS) \
|
$(DBUS_LIBS) \
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "execute.h"
|
#include "execute.h"
|
||||||
#include "strv.h"
|
#include "strv.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
|
#include "capability.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "ioprio.h"
|
#include "ioprio.h"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "journal-file.h"
|
#include "journal-file.h"
|
||||||
#include "hashmap.h"
|
#include "hashmap.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "audit.h"
|
||||||
#include "journal-rate-limit.h"
|
#include "journal-rate-limit.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <libudev.h>
|
#include <libudev.h>
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "audit.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "hashmap.h"
|
#include "hashmap.h"
|
||||||
#include "cgroup-util.h"
|
#include "cgroup-util.h"
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <systemd/sd-daemon.h>
|
#include <systemd/sd-daemon.h>
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "audit.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
#include "strv.h"
|
#include "strv.h"
|
||||||
#include "dbus-common.h"
|
#include "dbus-common.h"
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "audit.h"
|
||||||
#include "missing.h"
|
#include "missing.h"
|
||||||
#include "cgroup-util.h"
|
#include "cgroup-util.h"
|
||||||
#include "strv.h"
|
#include "strv.h"
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||||
|
|
||||||
|
/***
|
||||||
|
This file is part of systemd.
|
||||||
|
|
||||||
|
Copyright 2010 Lennart Poettering
|
||||||
|
|
||||||
|
systemd is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
systemd is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
***/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#include <sys/capability.h>
|
||||||
|
|
||||||
|
#include "macro.h"
|
||||||
|
#include "audit.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
int audit_session_from_pid(pid_t pid, uint32_t *id) {
|
||||||
|
char *s;
|
||||||
|
uint32_t u;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(id);
|
||||||
|
|
||||||
|
if (have_effective_cap(CAP_AUDIT_CONTROL) <= 0)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
if (pid == 0)
|
||||||
|
r = read_one_line_file("/proc/self/sessionid", &s);
|
||||||
|
else {
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
if (asprintf(&p, "/proc/%lu/sessionid", (unsigned long) pid) < 0)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
r = read_one_line_file(p, &s);
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = safe_atou32(s, &u);
|
||||||
|
free(s);
|
||||||
|
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (u == (uint32_t) -1 || u <= 0)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
*id = u;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int audit_loginuid_from_pid(pid_t pid, uid_t *uid) {
|
||||||
|
char *s;
|
||||||
|
uid_t u;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(uid);
|
||||||
|
|
||||||
|
/* Only use audit login uid if we are executed with sufficient
|
||||||
|
* capabilities so that pam_loginuid could do its job. If we
|
||||||
|
* are lacking the CAP_AUDIT_CONTROL capabality we most likely
|
||||||
|
* are being run in a container and /proc/self/loginuid is
|
||||||
|
* useless since it probably contains a uid of the host
|
||||||
|
* system. */
|
||||||
|
|
||||||
|
if (have_effective_cap(CAP_AUDIT_CONTROL) <= 0)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
if (pid == 0)
|
||||||
|
r = read_one_line_file("/proc/self/loginuid", &s);
|
||||||
|
else {
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
if (asprintf(&p, "/proc/%lu/loginuid", (unsigned long) pid) < 0)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
r = read_one_line_file(p, &s);
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = parse_uid(s, &u);
|
||||||
|
free(s);
|
||||||
|
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (u == (uid_t) -1)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
*uid = (uid_t) u;
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||||
|
|
||||||
|
#ifndef fooaudithfoo
|
||||||
|
#define fooaudithfoo
|
||||||
|
|
||||||
|
/***
|
||||||
|
This file is part of systemd.
|
||||||
|
|
||||||
|
Copyright 2010 Lennart Poettering
|
||||||
|
|
||||||
|
systemd is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
systemd is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
***/
|
||||||
|
|
||||||
|
#include "capability.h"
|
||||||
|
|
||||||
|
int audit_session_from_pid(pid_t pid, uint32_t *id);
|
||||||
|
int audit_loginuid_from_pid(pid_t pid, uid_t *uid);
|
||||||
|
#endif
|
|
@ -0,0 +1,86 @@
|
||||||
|
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||||
|
|
||||||
|
/***
|
||||||
|
This file is part of systemd.
|
||||||
|
|
||||||
|
Copyright 2010 Lennart Poettering
|
||||||
|
|
||||||
|
systemd is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
systemd is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
***/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <sys/capability.h>
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
|
||||||
|
#include "macro.h"
|
||||||
|
#include "capability.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
int have_effective_cap(int value) {
|
||||||
|
cap_t cap;
|
||||||
|
cap_flag_value_t fv;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if (!(cap = cap_get_proc()))
|
||||||
|
return -errno;
|
||||||
|
|
||||||
|
if (cap_get_flag(cap, value, CAP_EFFECTIVE, &fv) < 0)
|
||||||
|
r = -errno;
|
||||||
|
else
|
||||||
|
r = fv == CAP_SET;
|
||||||
|
|
||||||
|
cap_free(cap);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long cap_last_cap(void) {
|
||||||
|
static __thread unsigned long saved;
|
||||||
|
static __thread bool valid = false;
|
||||||
|
unsigned long p;
|
||||||
|
|
||||||
|
if (valid)
|
||||||
|
return saved;
|
||||||
|
|
||||||
|
p = (unsigned long) CAP_LAST_CAP;
|
||||||
|
|
||||||
|
if (prctl(PR_CAPBSET_READ, p) < 0) {
|
||||||
|
|
||||||
|
/* Hmm, look downwards, until we find one that
|
||||||
|
* works */
|
||||||
|
for (p--; p > 0; p --)
|
||||||
|
if (prctl(PR_CAPBSET_READ, p) >= 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
/* Hmm, look upwards, until we find one that doesn't
|
||||||
|
* work */
|
||||||
|
for (;; p++)
|
||||||
|
if (prctl(PR_CAPBSET_READ, p+1) < 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
saved = p;
|
||||||
|
valid = true;
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||||
|
|
||||||
|
#ifndef foocapabilityhfoo
|
||||||
|
#define foocapabilityhfoo
|
||||||
|
|
||||||
|
/***
|
||||||
|
This file is part of systemd.
|
||||||
|
|
||||||
|
Copyright 2010 Lennart Poettering
|
||||||
|
|
||||||
|
systemd is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
systemd is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
***/
|
||||||
|
|
||||||
|
unsigned long cap_last_cap(void);
|
||||||
|
int have_effective_cap(int value);
|
||||||
|
#endif
|
|
@ -4716,23 +4716,6 @@ void skip_syslog_date(char **buf) {
|
||||||
*buf = p;
|
*buf = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
int have_effective_cap(int value) {
|
|
||||||
cap_t cap;
|
|
||||||
cap_flag_value_t fv;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
if (!(cap = cap_get_proc()))
|
|
||||||
return -errno;
|
|
||||||
|
|
||||||
if (cap_get_flag(cap, value, CAP_EFFECTIVE, &fv) < 0)
|
|
||||||
r = -errno;
|
|
||||||
else
|
|
||||||
r = fv == CAP_SET;
|
|
||||||
|
|
||||||
cap_free(cap);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* strshorten(char *s, size_t l) {
|
char* strshorten(char *s, size_t l) {
|
||||||
assert(s);
|
assert(s);
|
||||||
|
|
||||||
|
@ -5399,89 +5382,6 @@ int symlink_or_copy_atomic(const char *from, const char *to) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int audit_session_from_pid(pid_t pid, uint32_t *id) {
|
|
||||||
char *s;
|
|
||||||
uint32_t u;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
assert(id);
|
|
||||||
|
|
||||||
if (have_effective_cap(CAP_AUDIT_CONTROL) <= 0)
|
|
||||||
return -ENOENT;
|
|
||||||
|
|
||||||
if (pid == 0)
|
|
||||||
r = read_one_line_file("/proc/self/sessionid", &s);
|
|
||||||
else {
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
if (asprintf(&p, "/proc/%lu/sessionid", (unsigned long) pid) < 0)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
r = read_one_line_file(p, &s);
|
|
||||||
free(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
r = safe_atou32(s, &u);
|
|
||||||
free(s);
|
|
||||||
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
if (u == (uint32_t) -1 || u <= 0)
|
|
||||||
return -ENOENT;
|
|
||||||
|
|
||||||
*id = u;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int audit_loginuid_from_pid(pid_t pid, uid_t *uid) {
|
|
||||||
char *s;
|
|
||||||
uid_t u;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
assert(uid);
|
|
||||||
|
|
||||||
/* Only use audit login uid if we are executed with sufficient
|
|
||||||
* capabilities so that pam_loginuid could do its job. If we
|
|
||||||
* are lacking the CAP_AUDIT_CONTROL capabality we most likely
|
|
||||||
* are being run in a container and /proc/self/loginuid is
|
|
||||||
* useless since it probably contains a uid of the host
|
|
||||||
* system. */
|
|
||||||
|
|
||||||
if (have_effective_cap(CAP_AUDIT_CONTROL) <= 0)
|
|
||||||
return -ENOENT;
|
|
||||||
|
|
||||||
if (pid == 0)
|
|
||||||
r = read_one_line_file("/proc/self/loginuid", &s);
|
|
||||||
else {
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
if (asprintf(&p, "/proc/%lu/loginuid", (unsigned long) pid) < 0)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
r = read_one_line_file(p, &s);
|
|
||||||
free(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
r = parse_uid(s, &u);
|
|
||||||
free(s);
|
|
||||||
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
if (u == (uid_t) -1)
|
|
||||||
return -ENOENT;
|
|
||||||
|
|
||||||
*uid = (uid_t) u;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool display_is_local(const char *display) {
|
bool display_is_local(const char *display) {
|
||||||
assert(display);
|
assert(display);
|
||||||
|
|
||||||
|
@ -6137,39 +6037,6 @@ int prot_from_flags(int flags) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long cap_last_cap(void) {
|
|
||||||
static __thread unsigned long saved;
|
|
||||||
static __thread bool valid = false;
|
|
||||||
unsigned long p;
|
|
||||||
|
|
||||||
if (valid)
|
|
||||||
return saved;
|
|
||||||
|
|
||||||
p = (unsigned long) CAP_LAST_CAP;
|
|
||||||
|
|
||||||
if (prctl(PR_CAPBSET_READ, p) < 0) {
|
|
||||||
|
|
||||||
/* Hmm, look downwards, until we find one that
|
|
||||||
* works */
|
|
||||||
for (p--; p > 0; p --)
|
|
||||||
if (prctl(PR_CAPBSET_READ, p) >= 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* Hmm, look upwards, until we find one that doesn't
|
|
||||||
* work */
|
|
||||||
for (;; p++)
|
|
||||||
if (prctl(PR_CAPBSET_READ, p+1) < 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
saved = p;
|
|
||||||
valid = true;
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *format_bytes(char *buf, size_t l, off_t t) {
|
char *format_bytes(char *buf, size_t l, off_t t) {
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
|
@ -431,8 +431,6 @@ void parse_syslog_priority(char **p, int *priority);
|
||||||
void skip_syslog_pid(char **buf);
|
void skip_syslog_pid(char **buf);
|
||||||
void skip_syslog_date(char **buf);
|
void skip_syslog_date(char **buf);
|
||||||
|
|
||||||
int have_effective_cap(int value);
|
|
||||||
|
|
||||||
bool hostname_is_valid(const char *s);
|
bool hostname_is_valid(const char *s);
|
||||||
char* hostname_cleanup(char *s);
|
char* hostname_cleanup(char *s);
|
||||||
|
|
||||||
|
@ -457,9 +455,6 @@ int hwclock_reset_localtime_delta(void);
|
||||||
int hwclock_get_time(struct tm *tm);
|
int hwclock_get_time(struct tm *tm);
|
||||||
int hwclock_set_time(const struct tm *tm);
|
int hwclock_set_time(const struct tm *tm);
|
||||||
|
|
||||||
int audit_session_from_pid(pid_t pid, uint32_t *id);
|
|
||||||
int audit_loginuid_from_pid(pid_t pid, uid_t *uid);
|
|
||||||
|
|
||||||
bool display_is_local(const char *display);
|
bool display_is_local(const char *display);
|
||||||
int socket_from_display(const char *display, char **path);
|
int socket_from_display(const char *display, char **path);
|
||||||
|
|
||||||
|
@ -526,8 +521,6 @@ bool kexec_loaded(void);
|
||||||
|
|
||||||
int prot_from_flags(int flags);
|
int prot_from_flags(int flags);
|
||||||
|
|
||||||
unsigned long cap_last_cap(void);
|
|
||||||
|
|
||||||
char *format_bytes(char *buf, size_t l, off_t t);
|
char *format_bytes(char *buf, size_t l, off_t t);
|
||||||
|
|
||||||
int fd_wait_for_event(int fd, int event, usec_t timeout);
|
int fd_wait_for_event(int fd, int event, usec_t timeout);
|
||||||
|
@ -540,5 +533,4 @@ int is_kernel_thread(pid_t pid);
|
||||||
|
|
||||||
int fd_inc_sndbuf(int fd, size_t n);
|
int fd_inc_sndbuf(int fd, size_t n);
|
||||||
int fd_inc_rcvbuf(int fd, size_t n);
|
int fd_inc_rcvbuf(int fd, size_t n);
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue