blob: 72ca96329b7684210cb5583a6aacbcb40f034d8a [file] [log] [blame]
# Copyright 2021 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Bluetooth Adapter"
author "ChromeOS BT <chromeos-bt-team@google.com>"
# Limit respawning in case of crashloop
respawn limit 10 5
respawn
# This daemon manages the Bluetooth connections on a system. It can be killed at
# the cost of an interruption in Bluetooth connectivity.
oom score -100
import HCI
instance $HCI
pre-start script
if [ "$HCI" -ge "0" ] 2>/dev/null; then
# HCI is a valid value (number >= 0) so do nothing.
# Values < 0 and non-numerical values will fall through.
:
else
# Invalid HCI value should fail
logger -is -p daemon.warning -t "${UPSTART_JOB}" -- \
"Invalid params on btadapterd. HCI=${HCI}"
exit 1
fi
end script
post-stop script
rm "/run/bluetooth/bluetooth${HCI}.pid"
end script
# Set GD flags; format is INIT_gd_<>
env GD_FLAGS="INIT_gd_hci=true"
script
# -u bluetooth changes user.
# -g bluetooth changes group.
# -G inherit bluetooth's supplementary groups.
# -n prevents that execve gains privileges, required for seccomp filters.
# -c 803500 = cap_sys_nice (1 << 23) | cap_net_raw (1 << 13) | \
# cap_net_admin (1 << 12) | cap_net_bind_service (1 << 10) | \
# cap_setpcap (1 << 8)
exec minijail0 \
-u bluetooth -g bluetooth -G -n \
-c 803500 \
-- /usr/bin/btadapterd --hci=$HCI ${GD_FLAGS}
end script