Skip to content

nmcli: fix endless loop with --offline --ask

Íñigo Huguet requested to merge ihuguet_ask_offline into main

Summary

If --offline and --ask were used at the same time, and endless loop showing the readline's prompt but without waiting for user's input happened.

This was because when using --offline, all arguments are parsed and resolved before running the g_main_loop. In nmc_readline_helper it was checked that the main loop is running, so if g_main_loop_quit is called we can stop waiting for user's input.

Fix this bug by continue polling for user input if the main loop is running or if we are in offline mode. Move offline flag from NmCli to NmcConfig so we can check it from nmc_readline_helper.

Cancelling the user input is still possible both in normal and offline mode with Ctrl+C or Ctrl+D.

Added a test case to verify that this still works after future changes.

Purpose

Fixes #1306 (closed)

Checklist

Please read https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/main/CONTRIBUTING.md before opening the merge request. In particular, check that:

  • the subject for all commits is concise and explicative
  • the message for all commits explains the reason for the change
  • the source is properly formatted
  • any relevant documentation is up to date
  • you have added unit tests if applicable
Edited by Wen Liang

Merge request reports