I have this file on my laptop /etc/dbus-1/system.d/org.freedesktop.thermald.conf
:
<?xml version="1.0"?> <!--*-nxml-*-->
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<!--
This file is part of systemd.
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-->
<busconfig>
<policy user="root">
<allow own="org.freedesktop.thermald"/>
<allow send_destination="org.freedesktop.thermald"/>
<allow receive_sender="org.freedesktop.thermald"/>
</policy>
<policy context="default">
<deny send_destination="org.freedesktop.thermald"/>
<allow receive_sender="org.freedesktop.thermald"/>
</policy>
</busconfig>
I need to know if:
<allow send_destination="org.freedesktop.thermald"/>
exists but only if it's not under root
and must be under default
.
Searching the file must only be between:
<policy context="default">
and the next line that contains:
</policy>
I'm looking for the most elegant (and readable) way of doing this without any bias towards grep
, sed
, awk
or any other common utility.
This is part of a python program displaying a expandable/collapsible tkinter treeview of DBus. I am trapping out permission errors on system bus that can't be introspected. Introspect and deny are already successfully trapping but trapping too much. Because it is python the json
and xmltree
modules are already being used and python built-in list
and dict
functions are available.
sed -n '/<policy context="default">/,/<\/policy>/p' /etc/dbus-1/system.d/org.freedesktop.thermald.conf | grep '<allow send_destination="org.freedesktop.thermald"\/>' || echo "Not Found"
allow own
was yesterday's mission which worked great. Today's mission isallow send_destination
which is causing problems.