blob: c1af995a128bf18cd3c669030b15e81d5b12aae4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#############################
# #
# Bluetooth configuration #
# #
#############################
create_missing_dir "/etc/bluetooth/"
cat << __EOF__ > "${TARGET_DIR}/etc/bluetooth/main.conf"
[General]
Class = 0x200428
DiscoverableTimeout = 0
PairableTimeout = 0
[Policy]
AutoEnable=true
__EOF__
# Accept any code from any connexion
echo "* *" > "${TARGET_DIR}/etc/bluetooth/pins"
# Run the Bluetooth agent
cat << __EOF__ > "${TARGET_DIR}/etc/systemd/system/bt-agent.service"
[Unit]
Description=Bluetooth Agent
After=bluetooth.service
Requires=bluetooth.service
[Service]
Type=simple
ExecStartPre=bt-adapter --set Discoverable 1
#ExecStart=bt-agent -c NoInputNoOutput
ExecStart=bt-agent -p /etc/bluetooth/pins
## Restart the service each 60s
#WatchdogSec=60
#RestartSec=60
#Restart=always
[Install]
WantedBy=multi-user.target
__EOF__
enable_service "bt-agent.service"
create_missing_dir "/etc/dbus-1/system.d/"
cat << __EOF__ > "${TARGET_DIR}/etc/dbus-1/system.d/bluetooth.conf"
<!-- This configuration file specifies the required security policies
for Bluetooth core daemon to work. -->
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- ../system.conf have denied everything, so we just punch some holes -->
<policy user="root">
<allow own="org.bluez"/>
<allow send_destination="org.bluez"/>
<allow send_interface="org.bluez.AdvertisementMonitor1"/>
<allow send_interface="org.bluez.Agent1"/>
<allow send_interface="org.bluez.MediaEndpoint1"/>
<allow send_interface="org.bluez.MediaPlayer1"/>
<allow send_interface="org.bluez.Profile1"/>
<allow send_interface="org.bluez.GattCharacteristic1"/>
<allow send_interface="org.bluez.GattDescriptor1"/>
<allow send_interface="org.bluez.LEAdvertisement1"/>
<allow send_interface="org.freedesktop.DBus.ObjectManager"/>
<allow send_interface="org.freedesktop.DBus.Properties"/>
<allow send_interface="org.mpris.MediaPlayer2.Player"/>
</policy>
<!-- allow users of bluetooth group to communicate -->
<policy group="bluetooth">
<allow send_destination="org.bluez"/>
</policy>
<policy context="default">
<allow send_destination="org.bluez"/>
</policy>
</busconfig>
__EOF__
# Set permission to 755 in the directory /var/lib/bluetooth/ (prevent a
# permission error)
sed --in-place "s/0555/0755/" ${TARGET_DIR}/usr/lib/systemd/system/bluetooth.service
## The same for the bluetooth, as bluetoothd keep a track for each paired device
create_missing_dir "/var/lib/bluetooth/"
#if ! grep -qE '/var/lib/bluetooth' "${TARGET_DIR}/etc/fstab"; then
# cat << __EOF__ >> "${TARGET_DIR}/etc/fstab"
#tmpfs /var/lib/bluetooth tmpfs rw 0 0
#__EOF__
#fi
|