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/config.c b/config.c
index 707c024..3d7bd20 100644
--- a/config.c
+++ b/config.c
@@ -332,6 +332,29 @@
return 0;
}
+/* Default console id if not specified on command line or in config */
+#define DEFAULT_CONSOLE_ID "default"
+
+/* Get the console id */
+const char *config_resolve_console_id(struct config *config, const char *id_arg)
+{
+ const char *configured;
+
+ if (id_arg) {
+ return id_arg;
+ }
+
+ if ((configured = config_get_value(config, "console-id"))) {
+ return configured;
+ }
+
+ if ((configured = config_get_value(config, "socket-id"))) {
+ return configured;
+ }
+
+ return DEFAULT_CONSOLE_ID;
+}
+
#ifdef CONFIG_TEST
int main(void)
{