From 5cf9395b94f68c701101207a1eb964eb565be55d Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 3 Oct 2022 13:46:02 +0200 Subject: [PATCH] nmcli: fix return code on "nmcli device connect" error Before: $ nmcli device connect veth0; echo $? Error: Connection activation failed: (5) IP configuration could not be reserved (no available address, timeout, etc.). 0 After $ nmcli device connect veth0; echo $? Error: Connection activation failed: (5) IP configuration could not be reserved (no available address, timeout, etc.). 4 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/902 --- src/nmcli/devices.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/nmcli/devices.c b/src/nmcli/devices.c index dbba6bb61c..7b70fa1645 100644 --- a/src/nmcli/devices.c +++ b/src/nmcli/devices.c @@ -2132,9 +2132,11 @@ connected_state_cb(AddAndActivateInfo *info) _("Hint: \"nmcli dev wifi show-password\" shows the Wi-Fi name and password.\n")); } else if (state <= NM_DEVICE_STATE_DISCONNECTED || state >= NM_DEVICE_STATE_DEACTIVATING) { reason = nm_device_get_state_reason(info->device); - g_print(_("Error: Connection activation failed: (%d) %s.\n"), - reason, - gettext(nmc_device_reason_to_string(reason))); + g_string_printf(info->nmc->return_text, + _("Error: Connection activation failed: (%d) %s."), + reason, + gettext(nmc_device_reason_to_string(reason))); + info->nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION; } else { return; }