# ------------------------------------------------------------------------------
noinst_LTLIBRARIES += \
- libsystemd-basic.la
+ libsystemd-shared.la
-libsystemd_basic_la_SOURCES = \
+libsystemd_shared_la_SOURCES = \
src/shared/util.c \
src/shared/util.h \
src/shared/virt.c \
src/shared/virt.h \
- src/shared/label.c \
- src/shared/label.h \
src/shared/hashmap.c \
src/shared/hashmap.h \
src/shared/set.c \
src/shared/strv.h \
src/shared/conf-parser.c \
src/shared/conf-parser.h \
- src/shared/socket-util.c \
- src/shared/socket-util.h \
src/shared/log.c \
src/shared/log.h \
src/shared/ratelimit.h \
src/shared/exit-status.h \
src/shared/utf8.c \
src/shared/utf8.h \
- src/shared/cgroup-util.c \
- src/shared/cgroup-util.h \
src/shared/pager.c \
src/shared/pager.h \
src/shared/ioprio.h \
src/shared/list.h \
src/shared/macro.h
-libsystemd_basic_la_CFLAGS = \
+# ------------------------------------------------------------------------------
+noinst_LTLIBRARIES += \
+ libsystemd-shared-selinux.la
+
+libsystemd_shared_selinux_la_SOURCES = \
+ src/shared/cgroup-util.c \
+ src/shared/cgroup-util.h \
+ src/shared/socket-util.c \
+ src/shared/socket-util.h \
+ src/shared/label.c \
+ src/shared/label.h \
+ src/shared/mkdir.c \
+ src/shared/mkdir.h
+
+libsystemd_shared_selinux_la_CFLAGS = \
$(AM_CFLAGS) \
$(SELINUX_CFLAGS)
-libsystemd_basic_la_LIBADD = \
+libsystemd_shared_selinux_la_LIBADD = \
+ libsystemd-shared.la \
$(SELINUX_LIBS)
# ------------------------------------------------------------------------------
$(KMOD_CFLAGS)
libsystemd_core_la_LIBADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libsystemd-capability.la \
libudev.la \
$(DBUS_LIBS) \
src/loopback-setup.c
test_loopback_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared-selinux.la
test_hostname_SOURCES = \
src/test-hostname.c \
src/hostname-setup.c
test_hostname_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared.la
test_daemon_SOURCES = \
src/test-daemon.c
test_daemon_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared.la \
libsystemd-daemon.la
test_cgroup_SOURCES = \
src/test-cgroup.c
test_cgroup_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared-selinux.la
test_env_replace_SOURCES = \
src/test-env-replace.c
test_env_replace_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared.la
test_strv_SOURCES = \
src/test-strv.c \
src/specifier.c
test_strv_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared.la
test_install_SOURCES = \
src/test-install.c \
$(DBUS_CFLAGS)
test_install_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared-selinux.la
test_watchdog_SOURCES = \
src/test-watchdog.c \
src/watchdog.h
test_watchdog_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared.la
# ------------------------------------------------------------------------------
systemd_initctl_SOURCES = \
$(DBUS_CFLAGS)
systemd_initctl_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared.la \
libsystemd-daemon.la \
$(DBUS_LIBS)
$(AUDIT_CFLAGS)
systemd_update_utmp_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared.la \
$(DBUS_LIBS) \
$(AUDIT_LIBS)
src/shutdownd.c
systemd_shutdownd_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared.la \
libsystemd-daemon.la
systemd_shutdown_SOURCES = \
src/watchdog.h
systemd_shutdown_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libudev.la
# ------------------------------------------------------------------------------
$(KMOD_CFLAGS)
systemd_modules_load_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared.la \
$(KMOD_LIBS)
# ------------------------------------------------------------------------------
src/tmpfiles.c
systemd_tmpfiles_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared-selinux.la
# ------------------------------------------------------------------------------
systemd_machine_id_setup_SOURCES = \
src/machine-id-main.c
systemd_machine_id_setup_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libsystemd-id128.la
# ------------------------------------------------------------------------------
src/sysctl.c
systemd_sysctl_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared.la
# ------------------------------------------------------------------------------
systemd_fsck_SOURCES = \
$(DBUS_CFLAGS)
systemd_fsck_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared.la \
libudev.la \
$(DBUS_LIBS)
src/timestamp.c
systemd_timestamp_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared.la
# ------------------------------------------------------------------------------
systemd_ac_power_SOURCES = \
src/ac-power.c
systemd_ac_power_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared.la \
libudev.la
# ------------------------------------------------------------------------------
src/detect-virt.c
systemd_detect_virt_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared.la
# ------------------------------------------------------------------------------
systemd_getty_generator_SOURCES = \
src/unit-name.c
systemd_getty_generator_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared-selinux.la
# ------------------------------------------------------------------------------
systemd_rc_local_generator_SOURCES = \
src/rc-local-generator.c
systemd_rc_local_generator_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared-selinux.la
# ------------------------------------------------------------------------------
systemd_remount_api_vfs_SOURCES = \
src/mount-setup.c
systemd_remount_api_vfs_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared.la
# ------------------------------------------------------------------------------
systemd_cgroups_agent_SOURCES = \
$(DBUS_CFLAGS)
systemd_cgroups_agent_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared.la \
$(DBUS_LIBS)
# ------------------------------------------------------------------------------
$(DBUS_CFLAGS)
systemctl_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libsystemd-daemon.la \
libsystemd-journal.la \
libsystemd-id128.la \
src/readahead/sd-readahead.c
systemd_notify_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared.la \
libsystemd-daemon.la
# ------------------------------------------------------------------------------
src/ask-password-api.c
systemd_ask_password_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared-selinux.la
# ------------------------------------------------------------------------------
systemd_reply_password_SOURCES = \
src/reply-password.c
systemd_reply_password_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared.la
# ------------------------------------------------------------------------------
systemd_cgls_SOURCES = \
src/cgroup-show.c
systemd_cgls_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared-selinux.la
# ------------------------------------------------------------------------------
systemd_cgtop_SOURCES = \
src/cgtop.c
systemd_cgtop_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared-selinux.la
# ------------------------------------------------------------------------------
systemd_nspawn_SOURCES = \
src/loopback-setup.c
systemd_nspawn_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libsystemd-capability.la \
libsystemd-daemon.la
src/bridge.c
systemd_stdio_bridge_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared.la
# ------------------------------------------------------------------------------
systemd_tty_ask_password_agent_SOURCES = \
src/utmp-wtmp.c
systemd_tty_ask_password_agent_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared-selinux.la
# ------------------------------------------------------------------------------
libsystemd_daemon_la_SOURCES = \
src/udev/libudev-device-private.c \
src/udev/libudev-queue-private.c
-libudev_private_la_CFLAGS = \
- $(AM_CFLAGS) \
- -fvisibility=default
-
if HAVE_SELINUX
libudev_private_la_SOURCES +=\
src/udev/libudev-selinux-private.c
+endif
+
+libudev_private_la_CFLAGS = \
+ $(AM_CFLAGS) \
+ $(SELINUX_CFLAGS)
+ -fvisibility=default
libudev_private_la_LIBADD = \
$(SELINUX_LIBS)
-endif
# ------------------------------------------------------------------------------
MANPAGES += \
libudev_core_la_LIBADD = \
libudev-private.la \
- libsystemd-basic.la \
libsystemd-daemon.la \
+ libsystemd-shared-selinux.la \
$(BLKID_LIBS) \
$(KMOD_LIBS)
src/udev/udevadm-test-builtin.c
udevadm_LDADD = \
- libudev-core.la
+ libudev-core.la \
+ libsystemd-shared-selinux.la
# ------------------------------------------------------------------------------
TESTS = \
test_udev_LDADD = \
libudev-core.la \
libudev-private.la \
- libsystemd-basic.la
+ libsystemd-shared.la
test_udev_DEPENDENCIES = \
src/udev/test/sys
ata_id_LDADD = \
libudev-private.la \
- libsystemd-basic.la
+ libsystemd-shared.la
udevlibexec_PROGRAMS += \
ata_id
cdrom_id_LDADD = \
libudev.la \
- libsystemd-basic.la
+ libsystemd-shared.la
udevlibexec_PROGRAMS += \
cdrom_id
scsi_id_LDADD = \
libudev-private.la \
- libsystemd-basic.la
+ libsystemd-shared.la
udevlibexec_PROGRAMS += \
scsi_id
accelerometer_LDADD = \
libudev.la -lm \
- libsystemd-basic.la
+ libsystemd-shared.la
udevlibexec_PROGRAMS += \
accelerometer
-Wl,--version-script=$(top_srcdir)/src/libsystemd-id128.sym
libsystemd_id128_la_LIBADD = \
- libsystemd-basic.la
+ libsystemd-shared.la
test_id128_SOURCES = \
src/test-id128.c
test_id128_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libsystemd-id128.la
noinst_PROGRAMS += \
systemd_journald_CFLAGS =
systemd_journald_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libsystemd-audit.la \
libsystemd-daemon.la \
libsystemd-login.la \
src/journal/cat.c
systemd_cat_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libsystemd-journal.la
journalctl_SOURCES = \
src/logs-show.c
journalctl_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libsystemd-journal.la \
libsystemd-id128.la
src/journal/journal-send.c
test_journal_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libsystemd-id128.la
if HAVE_XZ
src/journal/test-journal-send.c
test_journal_send_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libsystemd-journal.la
libsystemd_journal_la_SOURCES = \
-Wl,--version-script=$(top_srcdir)/src/journal/libsystemd-journal.sym
libsystemd_journal_la_LIBADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libsystemd-id128.la
if HAVE_XZ
noinst_PROGRAMS += \
test-journal \
- test-journal-send
+ test-journal-send
pkginclude_HEADERS += \
src/systemd/sd-journal.h \
src/journal/coredump.c
systemd_coredump_LDADD = \
- libsystemd-basic.la \
libsystemd-journal.la \
- libsystemd-login.la
+ libsystemd-login.la \
+ libsystemd-shared-selinux.la
rootlibexec_PROGRAMS += \
systemd-coredump
src/binfmt/binfmt.c
systemd_binfmt_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared.la
rootlibexec_PROGRAMS += \
systemd-binfmt
src/vconsole/vconsole-setup.c
systemd_vconsole_setup_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared.la
rootlibexec_PROGRAMS += \
systemd-vconsole-setup
src/readahead/readahead-common.c
systemd_readahead_collect_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared.la \
libsystemd-daemon.la \
libudev.la
src/readahead/readahead-common.c
systemd_readahead_replay_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared.la \
libsystemd-daemon.la \
libudev.la
src/quotacheck.c
systemd_quotacheck_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared.la
endif
# ------------------------------------------------------------------------------
src/random-seed.c
systemd_random_seed_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared-selinux.la
randomseed-install-data-hook:
$(MKDIR_P) -m 0755 \
$(LIBCRYPTSETUP_CFLAGS)
systemd_cryptsetup_LDADD = \
- $(LIBCRYPTSETUP_LIBS) \
+ libsystemd-shared-selinux.la \
libudev.la \
- libsystemd-basic.la
+ $(LIBCRYPTSETUP_LIBS)
systemd_cryptsetup_generator_SOURCES = \
src/cryptsetup/cryptsetup-generator.c \
src/unit-name.c
systemd_cryptsetup_generator_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared-selinux.la
cryptsetup-install-data-hook:
$(MKDIR_P) -m 0755 \
$(DBUS_CFLAGS)
systemd_hostnamed_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared.la \
libsystemd-daemon.la \
$(DBUS_LIBS)
$(DBUS_CFLAGS)
systemd_localed_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libsystemd-daemon.la \
$(DBUS_LIBS)
$(DBUS_CFLAGS)
systemd_timedated_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared.la \
libsystemd-daemon.la \
$(DBUS_LIBS)
$(DBUS_CFLAGS)
systemd_logind_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libsystemd-audit.la \
libsystemd-daemon.la \
libudev.la \
src/login/user-sessions.c
systemd_user_sessions_LDADD = \
- libsystemd-basic.la
+ libsystemd-shared-selinux.la
rootlibexec_PROGRAMS += \
systemd-logind \
$(DBUS_CFLAGS)
loginctl_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libudev.la \
$(DBUS_LIBS)
src/login/test-login.c
test_login_LDADD = \
- libsystemd-basic.la \
- libsystemd-login.la
+ libsystemd-login.la \
+ libsystemd-shared-selinux.la
noinst_PROGRAMS += \
test-login
-Wl,--version-script=$(top_srcdir)/src/login/libsystemd-login.sym
libsystemd_login_la_LIBADD = \
- libsystemd-basic.la
+ libsystemd-shared-selinux.la
if HAVE_PAM
pam_systemd_la_SOURCES = \
-export-symbols-regex '^pam_sm_.*'
pam_systemd_la_LIBADD = \
- libsystemd-basic.la \
+ libsystemd-shared.la \
libsystemd-daemon.la \
$(PAM_LIBS) \
$(DBUS_LIBS)
src/login/multi-seat-x.c
systemd_multi_seat_x_LDADD = \
- libsystemd-basic.la \
+ libsystemd-shared-selinux.la \
libudev.la
rootlibexec_PROGRAMS += \
--- /dev/null
+/*-*- 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 "mkdir.h"
+#include "label.h"
+#include "util.h"
+#include "log.h"
+
+int safe_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid) {
+ struct stat st;
+
+ if (label_mkdir(path, mode) >= 0)
+ if (chmod_and_chown(path, mode, uid, gid) < 0)
+ return -errno;
+
+ if (lstat(path, &st) < 0)
+ return -errno;
+
+ if ((st.st_mode & 0777) != mode ||
+ st.st_uid != uid ||
+ st.st_gid != gid ||
+ !S_ISDIR(st.st_mode)) {
+ errno = EEXIST;
+ return -errno;
+ }
+
+ return 0;
+}
+
+int mkdir_parents(const char *path, mode_t mode) {
+ const char *p, *e;
+
+ assert(path);
+
+ /* Creates every parent directory in the path except the last
+ * component. */
+
+ p = path + strspn(path, "/");
+ for (;;) {
+ int r;
+ char *t;
+
+ e = p + strcspn(p, "/");
+ p = e + strspn(e, "/");
+
+ /* Is this the last component? If so, then we're
+ * done */
+ if (*p == 0)
+ return 0;
+
+ if (!(t = strndup(path, e - path)))
+ return -ENOMEM;
+
+ r = label_mkdir(t, mode);
+ free(t);
+
+ if (r < 0 && errno != EEXIST)
+ return -errno;
+ }
+}
+
+int mkdir_p(const char *path, mode_t mode) {
+ int r;
+
+ /* Like mkdir -p */
+
+ if ((r = mkdir_parents(path, mode)) < 0)
+ return r;
+
+ if (label_mkdir(path, mode) < 0 && errno != EEXIST)
+ return -errno;
+
+ return 0;
+}