cli: when NM is not running, give this error in 'nmcli connection'

Check whether NM is running before comparing nmcli and NM versions. Returning
NMC_RESULT_ERROR_NM_NOT_RUNNING is in accordance with other nmcli commands.
This commit is contained in:
Jiří Klimeš
2014-09-19 11:11:19 +02:00
parent 82947737b1
commit f27a259ee6

View File

@@ -8429,13 +8429,20 @@ do_connections (NmCli *nmc, int argc, char **argv)
return nmc->return_value;
}
/* Get NMClient object early */
nmc->get_client (nmc);
/* Check whether NetworkManager is runnung */
if (!nm_client_get_nm_running (nmc->client)) {
g_string_printf (nmc->return_text, _("Error: NetworkManager is not running."));
nmc->return_value = NMC_RESULT_ERROR_NM_NOT_RUNNING;
return nmc->return_value;
}
/* Compare NM and nmcli versions */
if (!nmc_versions_match (nmc))
return nmc->return_value;
/* Get NMClient object early */
nmc->get_client (nmc);
/* Get NMRemoteSettings object */
if (!(nmc->system_settings = nm_remote_settings_new (NULL, &error))) {
g_string_printf (nmc->return_text, _("Error: Could not get system settings: %s."), error->message);