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-client.c b/console-client.c
index de2b1e3..3dc3190 100644
--- a/console-client.c
+++ b/console-client.c
@@ -212,8 +212,10 @@
return 0;
}
-static int client_init(struct console_client *client, const char *console_id)
+static int client_init(struct console_client *client, struct config *config,
+ const char *console_id)
{
+ const char *resolved_id = NULL;
struct sockaddr_un addr;
socket_path_t path;
ssize_t len;
@@ -225,9 +227,12 @@
return -1;
}
+ /* Get the console id */
+ resolved_id = config_resolve_console_id(config, console_id);
+
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- len = console_socket_path(addr.sun_path, console_id);
+ len = console_socket_path(addr.sun_path, resolved_id);
if (len < 0) {
if (errno) {
warn("Failed to configure socket: %s", strerror(errno));
@@ -325,15 +330,6 @@
esc = (const uint8_t *)config_get_value(
config, "escape-sequence");
}
-
- if (!console_id) {
- console_id = config_get_value(config, "console-id");
- }
-
- /* socket-id is deprecated */
- if (!console_id) {
- console_id = config_get_value(config, "socket-id");
- }
}
if (esc) {
@@ -341,7 +337,7 @@
client->esc_state.str.str = esc;
}
- rc = client_init(client, console_id);
+ rc = client_init(client, config, console_id);
if (rc) {
goto out_config_fini;
}