mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 10:00:07 +01:00
nmcli/devices: make get_device_list() terminate on "--"
Don't consider "--" a device name. Instead, treat it as a signal to stop reading the device list. If a caller expects nothing beyond the device names, it now has to check.
This commit is contained in:
parent
d576f4df44
commit
767afeffd8
1 changed files with 22 additions and 0 deletions
|
|
@ -1140,6 +1140,12 @@ get_device_list(NmCli *nmc, int *argc, const char *const **argv)
|
|||
|
||||
devices = nmc_get_devices_sorted(nmc->client);
|
||||
while (*argc > 0) {
|
||||
if (strcmp(**argv, "--") == 0) {
|
||||
(*argc)--;
|
||||
(*argv)++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (*argc == 1 && nmc->complete)
|
||||
complete_device(devices, **argv, FALSE);
|
||||
|
||||
|
|
@ -2627,6 +2633,11 @@ do_devices_disconnect(const NMCCommand *cmd, NmCli *nmc, int argc, const char *c
|
|||
|
||||
next_arg(nmc, &argc, &argv, NULL);
|
||||
queue = get_device_list(nmc, &argc, &argv);
|
||||
if (argc) {
|
||||
g_string_printf(nmc->return_text, _("Error: invalid extra argument '%s'."), *argv);
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return;
|
||||
}
|
||||
if (!queue)
|
||||
return;
|
||||
if (nmc->complete)
|
||||
|
|
@ -2695,6 +2706,11 @@ do_devices_delete(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const
|
|||
|
||||
next_arg(nmc, &argc, &argv, NULL);
|
||||
queue = get_device_list(nmc, &argc, &argv);
|
||||
if (argc) {
|
||||
g_string_printf(nmc->return_text, _("Error: invalid extra argument '%s'."), *argv);
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return;
|
||||
}
|
||||
if (!queue)
|
||||
return;
|
||||
if (nmc->complete)
|
||||
|
|
@ -2907,6 +2923,12 @@ do_devices_monitor(const NMCCommand *cmd, NmCli *nmc, int argc, const char *cons
|
|||
GSList *queue = get_device_list(nmc, &argc, &argv);
|
||||
GSList *iter;
|
||||
|
||||
if (argc) {
|
||||
g_string_printf(nmc->return_text, _("Error: invalid extra argument '%s'."), *argv);
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Monitor the specified devices. */
|
||||
for (iter = queue; iter; iter = g_slist_next(iter))
|
||||
device_watch(nmc, NM_DEVICE(iter->data));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue