Integrate parts of meta-intel-iot-security
[AGL/meta-agl.git] / meta-security / recipes-connectivity / connman / connman_%.bbappend
1 # Recent ConnMan releases started limiting the capabilities of
2 # ConnMan. When running on a Smack-enabled system, that change has the
3 # effect that connmand can no longer change network settings under
4 # /proc/net because the Smack label of /proc is "_", and connmand
5 # running with label "System" has no write access to that.
6 #
7 # It works when running as normal root with unrestricted capabilities
8 # because then CAP_MAC_OVERRIDE (a Smack-specific capability) allows
9 # the process to ignore Smack rules.
10 #
11 # We need to ensure that connmand still has that capability.
12 #
13 # The alternative would be to set up fine-grained labelling of
14 # /proc with corresponding rules, which is considerably more work
15 # and also may depend on kernel changes (like supporting smackfsroot
16 # for procfs, which seems to be missing at the moment).
17 #
18 # Because the solution is to some extend specific to the environment
19 # in which connmand runs, this change is not submitted upstream
20 # and it can be overridden by a distro via FIX_CONNMAN_CAPABILITIES.
21
22 FIX_CONNMAN_CAPABILITIES ??= ""
23 FIX_CONNMAN_CAPABILITIES_with-lsm-smack ??= "fix_connman_capabilities"
24 do_install[postfuncs] += "${FIX_CONNMAN_CAPABILITIES}"
25
26 fix_connman_capabilities () {
27     service="${D}/${systemd_unitdir}/system/connman.service"
28     if [ -f "$service" ] &&
29         grep -q '^CapabilityBoundingSet=' "$service"; then
30         sed -i -e 's/^CapabilityBoundingSet=/CapabilityBoundingSet=CAP_MAC_OVERRIDE /' "$service"
31     fi
32 }