[RCAR] disable a default config in kernel
[AGL/meta-agl.git] / meta-security / recipes-core / base-files / base-files_%.bbappend
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
7 System _ -----l
8 System System::Log rwxa--
9 System System::Run rwxat-
10 System System::Shared rwxat-
11 System ^ rwxa--
12 _ System::Run rwxat-
13 _ System -wx---
14 ^ System::Log rwxa--
15 ^ System::Run rwxat-
16 ^ System rwxa--
17 EOF
18     chmod 0644 ${D}/${sysconfdir}/smack/accesses.d/default-access-domains
19
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=*
26 EOF
27     chmod 0644 ${D}/${libdir}/tmpfiles.d/packet-forwarding.conf
28
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/*'"
32
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}/*'"
34 EOF
35     chmod 0644 ${D}/${base_libdir}/udev/rules.d/85-netdev-ipconf-smacklabel.rules
36 }
37
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() {
46     #!/bin/sh -e
47
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}
58
59     # Same for /media. Any daemon running as "System" will get write access
60     # to everything.
61     install -d $D/media
62     chsmack -t $D/media
63     chsmack -a 'System::Shared' $D/media
64
65     # Same for /var. Any daemon running as "System" will get write access
66     # to everything.
67     install -d $D${localstatedir}
68     chsmack -t $D${localstatedir}
69     chsmack -a 'System::Shared' $D${localstatedir}
70
71     # <filesystem path="/tmp" label="*" />
72     mkdir -p $D/tmp
73     chsmack -a '*' $D/tmp
74
75     # <filesystem path="/var/log" label="System::Log" type="transmutable" />
76     # <filesystem path="/var/tmp" label="*" />
77     # These are in a file system mounted by systemd. We patch the systemd service
78     # to set these attributes.
79 }