Fix bug in name escaping for PSUSensor

PSU sensor has a bug where if the name includes any invalid characters,
it crashes when attempting to launch.  This is a problem, and very much
not expected behavior.

The root cause of this is that PSU combine event is creating a dbus API
path from the object name, but neglects to escape it properly.

The previous method to escape this was inlined inside sensor.hpp, so
that has been promoted to a new utility function, escapeForDbus which
can return an escaped name string to use in paths.

Through the course of adding this to the sensors namespace and including
it, it turns out that "sensors" is overloaded, and including it causes
both compile time errors from the overloaded name, and link time errors
from the lack of "inline" on the utility methods.  This commit also as a
matter of cleanup moves everything in SensorPaths.hpp into an
alternative file, SensorPaths.cpp, and includes that file in sensor
utils.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Id9ed915e7e0e13ee7bded67a785ab0fa58982ca8
6 files changed
tree: 0e0af04ba4211c609e32de23d3e30aa3cf8c4854
  1. include/
  2. service_files/
  3. src/
  4. tests/
  5. .clang-format
  6. .clang-ignore
  7. .clang-tidy
  8. .gitignore
  9. Jenkinsfile
  10. LICENSE
  11. MAINTAINERS
  12. meson.build
  13. meson_options.txt
  14. README.md
README.md

dbus-sensors

dbus-sensors is a collection of sensor applications that provide the xyz.openbmc_project.Sensor collection of interfaces. They read sensor values from hwmon, d-bus, or direct driver access to provide readings. Some advance non-sensor features such as fan presence, pwm control, and automatic cpu detection (x86) are also supported.

key features

  • runtime re-configurable from d-bus (entity-manager or the like)

  • isolated: each sensor type is isolated into its own daemon, so a bug in one sensor is unlikely to affect another, and single sensor modifications are possible

  • async single-threaded: uses sdbusplus/asio bindings

  • multiple data inputs: hwmon, d-bus, direct driver access