obmc-console: Consolidate handling of default socket-id
If console-id is not specified on command line or in the config file
then use the default value. ae2460d0b8e8 ("obmc-console: Provide a
default value for `console-id`.") only implemented the default value for
naming the abstract listening socket and overlooked the new DBus path
naming convention. This caused issues during dbus registration:
```
obmc-console-server: Object name: /xyz/openbmc_project/console/(null)
obmc-console-server: Failed to issue method call: Invalid argument
```
Fixes: ae2460d0b8e8 ("obmc-console: Provide a default value for `console-id`.")
Change-Id: I6d0f7b23cc085992189cd4463129a6aae590b3e7
Signed-off-by: Ninad Palsule <ninadpalsule@us.ibm.com>
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/console-server.c b/console-server.c
index 815431c..e60e280 100644
--- a/console-server.c
+++ b/console-server.c
@@ -391,28 +391,17 @@
return write_buf_to_fd(console->tty.fd, data, len);
}
-/* Read console if from config and prepare a socket name */
+/* Prepare a socket name */
static int set_socket_info(struct console *console, struct config *config,
const char *console_id)
{
- const char *resolved_id;
ssize_t len;
- if (console_id) {
- resolved_id = console_id;
- } else {
- resolved_id = config_get_value(config, "console-id");
-
- /* socket-id is deprecated */
- if (!resolved_id) {
- resolved_id = config_get_value(config, "socket-id");
- }
- }
-
- console->console_id = resolved_id;
+ /* Get console id */
+ console->console_id = config_resolve_console_id(config, console_id);
/* Get the socket name/path */
- len = console_socket_path(console->socket_name, resolved_id);
+ len = console_socket_path(console->socket_name, console->console_id);
if (len < 0) {
warn("Failed to set socket path: %s", strerror(errno));
return EXIT_FAILURE;