]> git.proxmox.com Git - mirror_frr.git/commitdiff
vtysh: funnel integrated write through watchquagga
authorDavid Lamparter <equinox@opensourcerouting.org>
Tue, 8 Nov 2016 22:36:16 +0000 (23:36 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Wed, 9 Nov 2016 13:29:45 +0000 (14:29 +0100)
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 <equinox@opensourcerouting.org>
vtysh/vtysh.c

index 9888c35346c13e7f33c31679881dccc4671919d9..6a5a97bd2a9994e451e9c98a07a260e439e94bd1 100644 (file)
@@ -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");