From e10ca9b6b8789c7178dc24241d7ee158d3e757dd Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 8 Nov 2016 23:36:16 +0100 Subject: [PATCH] vtysh: funnel integrated write through watchquagga Running vtysh as normal user won't have permissions to write Quagga.conf. If we're connected to watchquagga, try "write integrated" first. In all cases if something fails, try directly. Signed-off-by: David Lamparter --- vtysh/vtysh.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 9888c35346..6a5a97bd2a 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -2579,7 +2579,23 @@ DEFUN (vtysh_write_memory, /* If integrated Quagga.conf explicitely set. */ if (want_config_integrated()) - return vtysh_write_config_integrated(); + { + ret = CMD_WARNING; + for (i = 0; i < array_size(vtysh_client); i++) + if (vtysh_client[i].flag == VTYSH_WATCHQUAGGA) + break; + if (i < array_size(vtysh_client) && vtysh_client[i].fd != -1) + ret = vtysh_client_execute (&vtysh_client[i], "write integrated", stdout); + + if (ret != CMD_SUCCESS) + { + printf("Warning: attempting direct configuration write without " + "watchquagga.\nFile permissions and ownership may be " + "incorrect, or write may fail.\n"); + ret = vtysh_write_config_integrated(); + } + return ret; + } fprintf (stdout,"Building Configuration...\n"); -- 2.39.5