summaryrefslogtreecommitdiffstats
path: root/vtysh/vtysh_main.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2016-04-01 15:18:22 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2016-04-01 21:27:19 +0200
commit5dd58b08299e85735f19fba1ee307c509fb19de7 (patch)
tree3326028ed2d6c04087a3019ec9914686e0e593f9 /vtysh/vtysh_main.c
parentlib, zebra: Fix vrf new hook callback. (diff)
downloadfrr-5dd58b08299e85735f19fba1ee307c509fb19de7.tar.xz
frr-5dd58b08299e85735f19fba1ee307c509fb19de7.zip
vtysh: Make vtysh run as quagga user
vtysh should be run as the quagga user, else when you execute a 'wr mem' the Quagga.conf and vtysh.conf files are owned by whomever started the process. This can cause file ownership issues. Ticket: CM-10217 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Dave Olson <olson@cumulusnetworks.com> Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Diffstat (limited to '')
-rw-r--r--vtysh/vtysh_main.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c
index d8b769ba2..a063425ff 100644
--- a/vtysh/vtysh_main.c
+++ b/vtysh/vtysh_main.c
@@ -33,6 +33,7 @@
#include "getopt.h"
#include "command.h"
#include "memory.h"
+#include "privs.h"
#include "vtysh/vtysh.h"
#include "vtysh/vtysh_user.h"
@@ -40,6 +41,27 @@
/* VTY shell program name. */
char *progname;
+static zebra_capabilities_t _caps_p [] =
+{
+ ZCAP_BIND,
+ ZCAP_NET_RAW,
+ ZCAP_NET_ADMIN,
+};
+
+struct zebra_privs_t vtysh_privs =
+{
+#if defined(QUAGGA_USER) && defined(QUAGGA_GROUP)
+ .user = QUAGGA_USER,
+ .group = QUAGGA_GROUP,
+#endif
+#ifdef VTY_GROUP
+ .vty_group = VTY_GROUP,
+#endif
+ .caps_p = _caps_p,
+ .cap_num_p = array_size(_caps_p),
+ .cap_num_i = 0,
+};
+
/* Configuration file name and directory. */
char config_default[] = SYSCONFDIR VTYSH_DEFAULT_CONFIG;
char quagga_config_default[] = SYSCONFDIR QUAGGA_DEFAULT_CONFIG;
@@ -303,6 +325,8 @@ main (int argc, char **argv, char **env)
line_read = NULL;
setlinebuf(stdout);
+ zprivs_init (&vtysh_privs);
+
/* Signal and others. */
vtysh_signal_init ();