Skip to content

Commit bd4a9d3

Browse files
committed
Setup D-Bus policy for tests.
1 parent 14040ad commit bd4a9d3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/Tests/bash-testlib.sh

+23
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,26 @@ function execute()
240240

241241
return $job_rc
242242
}
243+
244+
function setup_test_dbus_policy() {
245+
local config_file='/etc/dbus-1/system.d/test.org.usbguard1.conf'
246+
if [[ -e "${config_file}" ]]; then
247+
return
248+
fi
249+
250+
sudo -n tee "${config_file}" <<EOF
251+
<?xml version="1.0" encoding="UTF-8"?>
252+
<!DOCTYPE busconfig PUBLIC
253+
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
254+
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
255+
<busconfig>
256+
<policy user="root">
257+
<allow own="org.usbguard1"/>
258+
</policy>
259+
</busconfig>
260+
EOF
261+
sudo -n dbus-send --system --dest=org.freedesktop.DBus --type=method_call \
262+
/org org.freedesktop.DBus.ReloadConfig
263+
}
264+
265+
setup_test_dbus_policy

0 commit comments

Comments
 (0)