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>
#include "getopt.h"
#include "command.h"
#include "memory.h"
+#include "privs.h"
#include "vtysh/vtysh.h"
#include "vtysh/vtysh_user.h"
/* 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;
line_read = NULL;
setlinebuf(stdout);
+ zprivs_init (&vtysh_privs);
+
/* Signal and others. */
vtysh_signal_init ();