NetworkManager/src/nmcli
Beniamino Galvani 427a7cf257 nmcli: start the agent only after updating the connection
When connecting to a wifi network and providing the password on the
command line, nmcli first looks if there is a compatible connection to
reuse. If there is not, it creates and activates a new one via a
single call to AddAndActivate().

If there is a compatible connection, nmcli first calls Update() on it
to set the new password and then Activate() to bring it up. Before
that, it registers a secret agent that can prompt for a new password
in case of authentication failure.

However, as soon as nmcli registers a secret agent, NM tries to
activate again the connection if it was blocked due to a previous
authentication failure. This connection attempt is going to fail
because it still uses the old password, as new one hasn't been set via
Update().

Change the order of operations to register the agent after Update()
and before Activate().

Reproducer:

 nmcli device wifi connect SSID password BAD_PASSWORD
 nmcli device wifi connect SSID password GOOD_PASSWORD

Fixes: c8ff1b30fb ('nmcli/dev: use secret agent for nmcli d [wifi] connect')
2025-12-17 10:55:51 +01:00
..
agent.c cli: drop _NMC_RL_STARTUPHOOK_ARGS 2025-05-20 09:54:31 +02:00
common.c cli: drop _NMC_RL_STARTUPHOOK_ARGS 2025-05-20 09:54:31 +02:00
common.h cli: drop _NMC_RL_STARTUPHOOK_ARGS 2025-05-20 09:54:31 +02:00
connections.c nmcli: fix format 2025-07-09 15:08:15 +02:00
connections.h nmcli: connection: process port-type, type and controller first 2025-04-14 10:08:01 +00:00
devices.c nmcli: start the agent only after updating the connection 2025-12-17 10:55:51 +01:00
devices.h src: drop most master references from the code 2024-08-09 15:47:32 +02:00
gen-metadata-nm-settings-nmcli.c ethtool: support Forward Error Correction(fec) 2024-11-07 17:38:04 +08:00
gen-metadata-nm-settings-nmcli.xml.in libnm-core: fix the documentation of the gateway IP property 2025-12-04 16:40:07 +01:00
general.c core: rename NM_STATE_ASLEEP to NM_STATE_DISABLED 2025-09-23 09:17:03 +02:00
meson.build nmcli: rename "generate-docs-nm-settings-nmcli" to "gen-metadata-nm-settings-nmcli" 2022-10-31 09:11:30 +01:00
nmcli-completion nmcli: fix argument completion if nmcli is aliased 2025-03-24 14:29:19 +00:00
nmcli.c core: rename NM_STATE_ASLEEP to NM_STATE_DISABLED 2025-09-23 09:17:03 +02:00
nmcli.h nmcli: move offline flag from NmCli to NmcConfig struct 2023-07-17 12:56:03 +02:00
polkit-agent.c nmcli: replace all uses of g_print()/g_printerr() with nmc_print()/nmc_printerr() 2023-02-08 10:11:18 +01:00
polkit-agent.h cli: move from "clients/cli/" to "src/nmcli/" 2021-03-15 17:10:54 +01:00
README.md all: add some README.md files describing the purpose of our sources 2021-08-19 17:51:11 +02:00
settings.c nmcli: print to stderr where appropriate 2025-02-20 09:13:01 +00:00
settings.h nmcli: convert everywhere dhcp-send-hostname <-> dhcp-send-hostname-v2 2024-10-24 17:03:10 -04:00
utils.c nmcli: convert everywhere dhcp-send-hostname <-> dhcp-send-hostname-v2 2024-10-24 17:03:10 -04:00
utils.h format: run nm-code-format 2024-10-04 11:07:35 +02:00

nmcli

The command line user interface of NetworkManager. It uses the D-Bus API of NetworkManager (via libnm).

See:

  • man 1 nmcli ([www])
  • man 7 nmcli-examples ([www])
  • man 5 nm-settings-nmcli ([www])

Try also with bash-completion!