diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-07-13 18:25:03 -0400 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-07-28 14:35:37 -0400 |
commit | 4117ace97e487a15fbc3e84b9a29a1a963b04589 (patch) | |
tree | e115ec04bba077bb767cbded394e2fe9b2ccfc58 /meta-phosphor | |
parent | 8ffb402ac41c87b3b78c72d979168b0a2ada5fb5 (diff) | |
download | talos-openbmc-4117ace97e487a15fbc3e84b9a29a1a963b04589.tar.gz talos-openbmc-4117ace97e487a15fbc3e84b9a29a1a963b04589.zip |
classes-dbus: Create a default dbus config file
Create a default dbus configuration file when one doesn't exist in
${FILESPATH}.
The default configuration allows the configured user to own the
service name and allows send_destination="*".
Change-Id: If309d2aed02f6326201ce156be3133f05c720b9c
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'meta-phosphor')
-rw-r--r-- | meta-phosphor/classes/obmc-phosphor-dbus-service.bbclass | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/meta-phosphor/classes/obmc-phosphor-dbus-service.bbclass b/meta-phosphor/classes/obmc-phosphor-dbus-service.bbclass index 3277cdb48..e7f6340d2 100644 --- a/meta-phosphor/classes/obmc-phosphor-dbus-service.bbclass +++ b/meta-phosphor/classes/obmc-phosphor-dbus-service.bbclass @@ -4,9 +4,12 @@ # The list of packages to which files should be added. # # DBUS_SERVICE_${PN} += "org.openbmc.Foo" -# A list of dbus service names. The class will look for a dbus -# configuration file with the same name with .conf appended. -# +# A list of dbus service names. The class will look for a +# dbus configuration file with the same name with .conf +# appended. If one is found, it is added to the package +# and used verbatim. If it is not found, a default one +# (with very open permissions) is generated and used. + inherit dbus-dir inherit obmc-phosphor-utils @@ -14,16 +17,42 @@ RDEPENDS_${PN} += "dbus-perms" DBUS_PACKAGES ?= "${PN}" _INSTALL_DBUS_CONFIGS="" +_DEFAULT_DBUS_CONFIGS="" + + +python dbus_do_postinst() { + def make_default_dbus_config(d, service): + path = d.getVar('D', True) + path += d.getVar('dbus_system_confdir', True) + with open('%s/%s.conf' % (path, service), 'w+') as fd: + fd.write('<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"\n') + fd.write(' "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">\n') + fd.write('<busconfig>\n') + fd.write(' <policy user="root">\n') + fd.write(' <allow own="%s"/>\n' % service) + fd.write(' <allow send_destination="%s"/>\n' % service) + fd.write(' </policy>\n') + fd.write('</busconfig>\n') + fd.close() + + + for service in listvar_to_list(d, '_DEFAULT_DBUS_CONFIGS'): + make_default_dbus_config(d, service) +} python() { searchpaths = d.getVar('FILESPATH', True) def add_dbus_config(d, service, pkg): - set_append(d, 'SRC_URI', 'file://%s.conf' % service) + path = bb.utils.which(searchpaths, '%s.conf' % service) + if not os.path.isfile(path): + set_append(d, '_DEFAULT_DBUS_CONFIGS', service) + else: + set_append(d, 'SRC_URI', 'file://%s.conf' % service) + set_append(d, '_INSTALL_DBUS_CONFIGS', '%s.conf' % service) set_append(d, 'FILES_%s' % pkg, '%s%s.conf' \ % (d.getVar('dbus_system_confdir', True), service)) - set_append(d, '_INSTALL_DBUS_CONFIGS', '%s.conf' % service) for pkg in listvar_to_list(d, 'DBUS_PACKAGES'): @@ -36,10 +65,13 @@ python() { do_install_append() { # install the dbus configuration files - [ -z "${_INSTALL_DBUS_CONFIGS}" ] || \ + [ -z "${_INSTALL_DBUS_CONFIGS}" ] && \ + [ -z "${_DEFAULT_DBUS_CONFIGS}" ] || \ install -d ${D}${dbus_system_confdir} for c in ${_INSTALL_DBUS_CONFIGS}; do install -m 0644 ${WORKDIR}/$c \ ${D}${dbus_system_confdir}$c done } + +do_install[postfuncs] += "dbus_do_postinst" |