Fix loading json file causing coredump

If the json file is damaged, when the process is running and
deserializing, a coredump will occur and a cereal::RapidJSONException
will be thrown.

Error message:
```
terminate called after throwing an instance of'cereal::RapidJSONException'
what(): rapidjson internal assertion failure: IsObject()
```

Add try-catch to catch the exception, and when the exception occurs,
we need to re-serialize the json file and record the log.

Tested: Use broken json file and restart the process

hosphor-srvcfg-manager[753]: Failed to load json file, need to rewrite,
ERROR = rapidjson internal assertion failure: IsObject(),
file path = /etc/srvcfg-mgr.json

Also, we can seen a bad json file in `/tmp`, like this:
/tmp/srvcfg-mgr.json.bad

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I996e9e32f87c25d584a3b5912334d1a137b55b6c
1 file changed
tree: 443289dda30714a8bb9662218c684f98f6e9c4cc
  1. inc/
  2. src/
  3. subprojects/
  4. .clang-format
  5. .gitignore
  6. LICENSE
  7. MAINTAINERS
  8. meson.build
  9. OWNERS
  10. README.md
  11. srvcfg-manager.service
README.md

Service config manager

The service config manager provides a D-Bus interface to manage BMC services as described by the service management D-Bus interfaces.

The configuration settings are intended to persist across BMC reboots.

An example use case for this service is BMCWeb's implementation of the Redfish NetworkProtocol schema.

Design

Implementation details are described in the D-Bus interface README.

The service config manager generally makes configuration changes to systemd units via D-Bus interfaces.

The design pattern to add new services or controls is:

  • Determine if the service you want to control is socket activated.
  • To control the Running and Enabled properties of a service:
    • For a service which uses socket activation, control the socket.
    • For other services, control the service unit itself.