···11+#!/bin/sh
22+33+# dbus-daemon wrapper script for dbus-vmstate testing
44+#
55+# This script allows to tweak the dbus-daemon policy during the test
66+# to test different configurations.
77+#
88+# This program is free software; you can redistribute it and/or modify
99+# it under the terms of the GNU General Public License as published by
1010+# the Free Software Foundation; either version 2 of the License, or
1111+# (at your option) any later version.
1212+#
1313+# This program is distributed in the hope that it will be useful,
1414+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1515+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616+# GNU General Public License for more details.
1717+#
1818+# You should have received a copy of the GNU General Public License
1919+# along with this program; if not, see <http://www.gnu.org/licenses/>.
2020+#
2121+# Copyright (C) 2019 Red Hat, Inc.
2222+2323+write_config()
2424+{
2525+ CONF="$1"
2626+ cat > "$CONF" <<EOF
2727+<busconfig>
2828+ <type>session</type>
2929+ <listen>unix:tmpdir=$DBUS_VMSTATE_TEST_TMPDIR</listen>
3030+3131+ <policy context="default">
3232+ <!-- Holes must be punched in service configuration files for
3333+ name ownership and sending method calls -->
3434+ <deny own="*"/>
3535+ <deny send_type="method_call"/>
3636+3737+ <!-- Signals and reply messages (method returns, errors) are allowed
3838+ by default -->
3939+ <allow send_type="signal"/>
4040+ <allow send_requested_reply="true" send_type="method_return"/>
4141+ <allow send_requested_reply="true" send_type="error"/>
4242+4343+ <!-- All messages may be received by default -->
4444+ <allow receive_type="method_call"/>
4545+ <allow receive_type="method_return"/>
4646+ <allow receive_type="error"/>
4747+ <allow receive_type="signal"/>
4848+4949+ <!-- Allow anyone to talk to the message bus -->
5050+ <allow send_destination="org.freedesktop.DBus"
5151+ send_interface="org.freedesktop.DBus" />
5252+ <allow send_destination="org.freedesktop.DBus"
5353+ send_interface="org.freedesktop.DBus.Introspectable"/>
5454+ <allow send_destination="org.freedesktop.DBus"
5555+ send_interface="org.freedesktop.DBus.Properties"/>
5656+ <!-- But disallow some specific bus services -->
5757+ <deny send_destination="org.freedesktop.DBus"
5858+ send_interface="org.freedesktop.DBus"
5959+ send_member="UpdateActivationEnvironment"/>
6060+ <deny send_destination="org.freedesktop.DBus"
6161+ send_interface="org.freedesktop.DBus.Debug.Stats"/>
6262+ <deny send_destination="org.freedesktop.DBus"
6363+ send_interface="org.freedesktop.systemd1.Activator"/>
6464+6565+ <allow own="org.qemu.VMState1"/>
6666+ <allow send_destination="org.qemu.VMState1"/>
6767+ <allow receive_sender="org.qemu.VMState1"/>
6868+6969+ </policy>
7070+7171+ <include if_selinux_enabled="yes"
7272+ selinux_root_relative="yes">contexts/dbus_contexts</include>
7373+7474+</busconfig>
7575+EOF
7676+}
7777+7878+ARGS=
7979+for arg in "$@"
8080+do
8181+ case $arg in
8282+ --config-file=*)
8383+ CONF="${arg#*=}"
8484+ write_config "$CONF"
8585+ ARGS="$ARGS $1"
8686+ shift
8787+ ;;
8888+ *)
8989+ ARGS="$ARGS $1"
9090+ shift
9191+ ;;
9292+ esac
9393+done
9494+9595+exec dbus-daemon $ARGS