diff options
-rw-r--r-- | meta-phosphor/classes/obmc-phosphor-dbus-service.bbclass | 43 | ||||
-rw-r--r-- | meta-phosphor/common/recipes-phosphor/dbus/obmc-mapper/org.openbmc.ObjectMapper.service (renamed from meta-phosphor/common/recipes-phosphor/dbus/obmc-mapper/obmc-mapper.service) | 0 | ||||
-rw-r--r-- | meta-phosphor/common/recipes-phosphor/dbus/obmc-rest/obmc-rest.service | 4 | ||||
-rw-r--r-- | meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService.service (renamed from meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.service) | 0 | ||||
-rw-r--r-- | meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-sdbus/files/org.openbmc.examples.SDBusService.service (renamed from meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-sdbus/files/obmc-phosphor-example-sdbus.service) | 0 | ||||
-rw-r--r-- | meta-phosphor/common/recipes-phosphor/obmc-phosphor-sys/obmc-mgr-system/obmc-mgr-system.service | 4 |
6 files changed, 42 insertions, 9 deletions
diff --git a/meta-phosphor/classes/obmc-phosphor-dbus-service.bbclass b/meta-phosphor/classes/obmc-phosphor-dbus-service.bbclass index e7f6340d20..7616d9436f 100644 --- a/meta-phosphor/classes/obmc-phosphor-dbus-service.bbclass +++ b/meta-phosphor/classes/obmc-phosphor-dbus-service.bbclass @@ -9,6 +9,14 @@ # 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. +# +# Additionally the class will instantiate obmc-phosphor-systemd +# with any SYSTEMD_SERVICE_%s variables translated appropriately. +# +# DBUS_USER_${PN}_org.openbmc.Foo = "dbususer" +# The user a service should be configured to run as. If unspecified +# no User property is added. + inherit dbus-dir inherit obmc-phosphor-utils @@ -21,14 +29,14 @@ _DEFAULT_DBUS_CONFIGS="" python dbus_do_postinst() { - def make_default_dbus_config(d, service): + def make_default_dbus_config(d, service, user): 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(' <policy user="%s">\n' % user) fd.write(' <allow own="%s"/>\n' % service) fd.write(' <allow send_destination="%s"/>\n' % service) fd.write(' </policy>\n') @@ -36,8 +44,8 @@ python dbus_do_postinst() { fd.close() - for service in listvar_to_list(d, '_DEFAULT_DBUS_CONFIGS'): - make_default_dbus_config(d, service) + for service_user in listvar_to_list(d, '_DEFAULT_DBUS_CONFIGS'): + make_default_dbus_config(d, *service_user.split(':')) } @@ -47,7 +55,10 @@ python() { def add_dbus_config(d, service, pkg): path = bb.utils.which(searchpaths, '%s.conf' % service) if not os.path.isfile(path): - set_append(d, '_DEFAULT_DBUS_CONFIGS', service) + user = d.getVar( + 'DBUS_USER_%s_%s' % (pkg, service), True) or 'root' + set_append(d, '_DEFAULT_DBUS_CONFIGS', '%s:%s' % ( + service, user)) else: set_append(d, 'SRC_URI', 'file://%s.conf' % service) set_append(d, '_INSTALL_DBUS_CONFIGS', '%s.conf' % service) @@ -55,11 +66,31 @@ python() { % (d.getVar('dbus_system_confdir', True), service)) + def add_sd_unit(d, service, pkg): + set_append( + d, 'SYSTEMD_SERVICE_%s' % pkg, '%s.service' % service) + set_append(d, 'SYSTEMD_SUBSTITUTIONS_%s.service' % service, + 'BUSNAME:%s' % service) + + + def add_sd_user(d, service, pkg): + user = d.getVar( + 'DBUS_USER_%s_%s' % (pkg, service), True) + if user: + set_append(d, 'SYSTEMD_USER_%s_%s.service' % ( + pkg, service), user) + + for pkg in listvar_to_list(d, 'DBUS_PACKAGES'): + if pkg not in (d.getVar('SYSTEMD_PACKAGES', True) or ''): + set_append(d, 'SYSTEMD_PACKAGES', pkg) + services = listvar_to_list(d, 'DBUS_SERVICE_%s' % pkg) for service in services: add_dbus_config(d, service, pkg) + add_sd_unit(d, service, pkg) + add_sd_user(d, service, pkg) } @@ -75,3 +106,5 @@ do_install_append() { } do_install[postfuncs] += "dbus_do_postinst" + +inherit obmc-phosphor-systemd diff --git a/meta-phosphor/common/recipes-phosphor/dbus/obmc-mapper/obmc-mapper.service b/meta-phosphor/common/recipes-phosphor/dbus/obmc-mapper/org.openbmc.ObjectMapper.service index ff863ea0db..ff863ea0db 100644 --- a/meta-phosphor/common/recipes-phosphor/dbus/obmc-mapper/obmc-mapper.service +++ b/meta-phosphor/common/recipes-phosphor/dbus/obmc-mapper/org.openbmc.ObjectMapper.service diff --git a/meta-phosphor/common/recipes-phosphor/dbus/obmc-rest/obmc-rest.service b/meta-phosphor/common/recipes-phosphor/dbus/obmc-rest/obmc-rest.service index 8612b9899f..4defe5e968 100644 --- a/meta-phosphor/common/recipes-phosphor/dbus/obmc-rest/obmc-rest.service +++ b/meta-phosphor/common/recipes-phosphor/dbus/obmc-rest/obmc-rest.service @@ -1,7 +1,7 @@ [Unit] Description=Phosphor OpenBMC DBus REST daemon -Requires=obmc-mapper.service -After=obmc-mapper.service +Requires=org.openbmc.ObjectMapper.service +After=org.openbmc.ObjectMapper.service [Service] Restart=always diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.service b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService.service index 27d9bfe129..27d9bfe129 100644 --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.service +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService.service diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-sdbus/files/obmc-phosphor-example-sdbus.service b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-sdbus/files/org.openbmc.examples.SDBusService.service index 442e910fba..442e910fba 100644 --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-sdbus/files/obmc-phosphor-example-sdbus.service +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-sdbus/files/org.openbmc.examples.SDBusService.service diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-sys/obmc-mgr-system/obmc-mgr-system.service b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-sys/obmc-mgr-system/obmc-mgr-system.service index 9cb04cf4c7..076a60a9a7 100644 --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-sys/obmc-mgr-system/obmc-mgr-system.service +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-sys/obmc-mgr-system/obmc-mgr-system.service @@ -1,7 +1,7 @@ [Unit] Description=OpenBMC system manager -Requires=obmc-mapper.service -After=obmc-mapper.service +Requires=org.openbmc.ObjectMapper.service +After=org.openbmc.ObjectMapper.service [Service] Restart=always |