1 # Install default Smack rules, copied from a running Tizen IVI 3.0.
2 # Corresponds to manifest file from default-access-domains in Tizen:
3 # https://review.tizen.org/git?p=platform/core/security/default-ac-domains.git;a=blob;f=packaging/default-ac-domains.manifest
4 do_install_append_with-lsm-smack () {
5 install -d ${D}/${sysconfdir}/smack/accesses.d
6 cat >${D}/${sysconfdir}/smack/accesses.d/default-access-domains <<EOF
8 System System::Log rwxa--
9 System System::Run rwxat-
10 System System::Shared rwxat-
18 chmod 0644 ${D}/${sysconfdir}/smack/accesses.d/default-access-domains
20 install -d ${D}/${libdir}/tmpfiles.d
21 cat >${D}/${libdir}/tmpfiles.d/packet-forwarding.conf <<EOF
22 t /proc/sys/net/ipv4/conf/all/forwarding - - - - security.SMACK64=*
23 t /proc/sys/net/ipv6/conf/all/forwarding - - - - security.SMACK64=*
24 t /proc/sys/net/ipv4/conf/default/forwarding - - - - security.SMACK64=*
25 t /proc/sys/net/ipv6/conf/default/forwarding - - - - security.SMACK64=*
27 chmod 0644 ${D}/${libdir}/tmpfiles.d/packet-forwarding.conf
29 install -d ${D}/${base_libdir}/udev/rules.d
30 cat >${D}/${base_libdir}/udev/rules.d/85-netdev-ipconf-smacklabel.rules <<EOF
31 SUBSYSTEM=="net", ENV{ID_NET_NAME}=="", RUN+="/bin/sh -c '/usr/bin/chsmack -a \* /proc/sys/net/ipv4/conf/%k/*'", RUN+="/bin/sh -c '/usr/bin/chsmack -a \* /proc/sys/net/ipv6/conf/%k/*'"
33 SUBSYSTEM=="net", ENV{ID_NET_NAME}!="", RUN+="/bin/sh -c '/usr/bin/chsmack -a \* /proc/sys/net/ipv4/conf/\$env{ID_NET_NAME}/*'", RUN+="/bin/sh -c '/usr/bin/chsmack -a \* /proc/sys/net/ipv6/conf/\$env{ID_NET_NAME}/*'"
35 chmod 0644 ${D}/${base_libdir}/udev/rules.d/85-netdev-ipconf-smacklabel.rules
38 # Do not rely on an rpm with manifest support. Apparently that approach
39 # will no longer be used in Tizen 3.0. Instead set special Smack attributes
40 # via postinst. This is much easier to use with bitbake, too:
41 # - no need to maintain a patched rpm
42 # - works for directories which are not packaged by default when empty
43 RDEPENDS_${PN}_append_with-lsm-smack = " smack"
44 DEPENDS_append_with-lsm-smack = " smack-native"
45 pkg_postinst_${PN}_with-lsm-smack() {
48 # https://review.tizen.org/gerrit/gitweb?p=platform/upstream/filesystem.git;a=blob;f=packaging/filesystem.manifest:
49 # <filesystem path="/etc" label="System::Shared" type="transmutable" />
50 install -d $D${sysconfdir}
51 # This has no effect on files installed into /etc during image construction
52 # because pseudo does not know the special semantic of SMACK::TRANSMUTE.
53 # To avoid having different xattrs on files inside /etc when pre-installed
54 # in an image vs. installed on a device, the xattr-images.bbclass has
55 # a workaround for this deficiency in pseudo.
56 chsmack -t $D${sysconfdir}
57 chsmack -a 'System::Shared' $D${sysconfdir}
59 # Same for /var. Any daemon running as "System" will get write access
61 install -d $D${localstatedir}
62 chsmack -t $D${localstatedir}
63 chsmack -a 'System::Shared' $D${localstatedir}
65 # <filesystem path="/tmp" label="*" />
69 # <filesystem path="/var/log" label="System::Log" type="transmutable" />
70 # <filesystem path="/var/tmp" label="*" />
71 # These are in a file system mounted by systemd. We patch the systemd service
72 # to set these attributes.