1 FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
3 # Most patches from sandbox/jobol/v219. Cannot be applied unconditionally
4 # because systemd panics when booted without Smack support:
5 # systemd[1]: Cannot determine cgroup we are running in: No such file or directory
6 # systemd[1]: Failed to allocate manager object: No such file or directory
7 # [!!!!!!] Failed to allocate manager object, freezing.
9 # There's a slight dependency on the base systemd in 0005-tizen-smack-Handling-network.
10 # We use the beginning of PV (unexpanded here to prevent a cyclic dependency
11 # during resolution apparently caused by ${SRCPV}) to pick the right set of
14 # Patches are optional. Hopefully we won't need any for systemd >= 229.
15 SRC_URI_append_with-lsm-smack = " ${@d.getVar('SYSTEMD_SMACK_PATCHES_' + d.getVar('PV', False)[0:3], True) or ''}"
17 SYSTEMD_SMACK_PATCHES_216 = " \
18 file://0003-tizen-smack-Handling-of-run-and-sys-fs-cgroup-v216.patch \
19 file://0004-tizen-smack-Handling-of-dev-v216.patch \
20 file://0005-tizen-smack-Handling-network-v216.patch \
21 file://0007-tizen-smack-Runs-systemd-journald-with-v216.patch \
24 SYSTEMD_SMACK_PATCHES_219 = " \
25 file://0003-tizen-smack-Handling-of-run-and-sys-fs-cgroup.patch \
26 file://0004-tizen-smack-Handling-of-dev.patch \
27 file://0005-tizen-smack-Handling-network.patch \
28 file://0007-tizen-smack-Runs-systemd-journald-with.patch \
30 SYSTEMD_SMACK_PATCHES_225 = " \
31 file://0003-tizen-smack-Handling-of-run-and-sys-fs-cgroup.patch \
32 file://0004-tizen-smack-Handling-of-dev.patch \
33 file://0005-tizen-smack-Handling-network-v225.patch \
34 file://0007-tizen-smack-Runs-systemd-journald-with.patch \
37 SYSTEMD_SMACK_PATCHES_228 = " \
38 file://0005-tizen-smack-Handling-network-v228.patch \
39 file://mount-setup.c-fix-handling-of-symlink-Smack-labellin-v228.patch \
42 # From Tizen .spec file.
43 EXTRA_OECONF_append_with-lsm-smack = " --with-smack-run-label=System"
46 install -d $(dirname $1)
51 # We need to emulate parts of the filesystem permissions from Tizen here.
52 # The part for regular files is in base-files.bbappend, but /var/log and
53 # /var/tmp point into /var/volatile (tmpfs) and get created anew during
54 # startup. We set these permissions directly after creating them via
55 # /etc/tmpfiles.d/00-create-volatile.conf
56 RDEPENDS_${PN}_append_with-lsm-smack = " smack"
57 do_install_append_with-lsm-smack() {
58 install_file ${D}${systemd_unitdir}/system/systemd-tmpfiles-setup.service.d/smack.conf <<EOF
60 ExecStartPost=/bin/sh -c '([ ! -d /var/tmp ] || chsmack -L -a \"*\" /var/tmp) && ([ ! -d /var/log ] || chsmack -L -a System::Log /var/log && chsmack -L -t /var/log)'
63 # Mount /tmp publicly accessable. Based on patch by Michael Demeter <michael.demeter@intel.com>.
64 # Upstream systemd temporarily had SmackFileSystemRoot for this (https://github.com/systemd/systemd/pull/1664),
65 # but it was removed again (https://github.com/systemd/systemd/issues/1696) because
66 # util-linux mount will ignore smackfsroot when Smack is not active. However,
67 # busybox is not that intelligent.
69 # When using busybox mount, adding smackfsroot=* and booting without
70 # Smack (i.e. security=none), tmp.mount will fail with an error about
71 # "Bad mount option smackfsroot".
72 install_file ${D}${systemd_unitdir}/system/tmp.mount.d/smack.conf <<EOF
77 # Run systemd-journald with the hat ("^") Smack label.
79 # The journal daemon needs global read access to gather information
80 # about the services spawned by systemd. The hat label is intended
81 # for this purpose. The journal daemon is the only part of the
82 # System domain that needs read access to the User domain. Giving
83 # the journal daemon the hat label means that we can remove the
84 # System domain's read access to the User domain and we can avoid
85 # hard-coding a specific label name for that domain.
87 # Original author: Casey Schaufler <casey@schaufler-ca.com>
89 # This is considered a configuration change and thus distro specific.
90 install_file ${D}${systemd_unitdir}/system/systemd-journald.service.d/smack.conf <<EOF
96 # Will get installed in ${sysconfdir}/udev/rules.d/ by base systemd recipe.
97 SRC_URI += "file://udev-smack-default.rules"
99 # A workaround for a missing space in a SRC_URI_append in a private layer elsewhere:
102 # Maintaining trivial, non-upstreamable configuration changes as patches
103 # is tedious. But in same cases (like early mounting of special directories)
104 # the configuration has to be in code. We make these changes here directly.
105 do_patch[prefuncs] += "patch_systemd"
106 do_patch[vardeps] += "patch_systemd"
108 # Handling of /run and /sys/fs/cgroup. Make /run a transmuting directory to
109 # enable systemd communications with services in the User domain.
110 # Original patch by Michael Demeter <michael.demeter@intel.com>.
112 # We simplify the patching by touching only lines which check the result of
113 # mac_smack_use(). Those are the ones which are used when Smack is active.
115 # smackfsroot=* on /sys/fs/cgroup may be upstreamable, but smackfstransmute=System::Run
116 # is too distro specific (depends on Smack rules) and thus has to remain here.
117 sed -i -e 's;\("/sys/fs/cgroup", *"[^"]*", *"[^"]*\)\(.*mac_smack_use.*\);\1,smackfsroot=*\2;' \
118 -e 's;\("/run", *"[^"]*", *"[^"]*\)\(.*mac_smack_use.*\);\1,smackfstransmute=System::Run\2;' \
119 ${S}/src/core/mount-setup.c