mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 09:20:25 +00:00
quagga: vtysh-integrated-fix.patch
Fixup to allow 'no service-integrated-vtysh' to work properly and vice versa Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by:
This commit is contained in:
parent
f64e741e65
commit
a72222764f
38
debian/patches/80_vtysh__vtysh.c__privs.diff
vendored
38
debian/patches/80_vtysh__vtysh.c__privs.diff
vendored
@ -1,7 +1,9 @@
|
|||||||
Description: Fixes group permission. (line numbers adjusted for 0.99.22)
|
Description: Fixes group permission. (line numbers adjusted for 0.99.22)
|
||||||
|
|
||||||
--- old/vtysh/vtysh.c.orig 2004-10-30 23:16:08.000000000 +0200
|
Index: quagga-0.99.23.1/vtysh/vtysh.c
|
||||||
+++ new/vtysh/vtysh.c 2004-10-30 23:16:41.000000000 +0200
|
===================================================================
|
||||||
|
--- quagga-0.99.23.1.orig/vtysh/vtysh.c 2015-04-16 07:58:08.000000000 -0700
|
||||||
|
+++ quagga-0.99.23.1/vtysh/vtysh.c 2015-04-16 08:02:16.108035000 -0700
|
||||||
@@ -26,6 +26,8 @@
|
@@ -26,6 +26,8 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
@ -11,21 +13,20 @@ Description: Fixes group permission. (line numbers adjusted for 0.99.22)
|
|||||||
|
|
||||||
#include <readline/readline.h>
|
#include <readline/readline.h>
|
||||||
#include <readline/history.h>
|
#include <readline/history.h>
|
||||||
@@ -1786,6 +1794,9 @@
|
@@ -2026,6 +2028,9 @@
|
||||||
FILE *fp;
|
char line[] = "write terminal\n";
|
||||||
char *integrate_sav = NULL;
|
FILE *fp, *fp1;
|
||||||
|
|
||||||
+ /* Setting file permissions */
|
+ /* Setting file permissions */
|
||||||
+ struct group *quagga_vty_group;
|
+ struct group *quagga_vty_group;
|
||||||
+
|
+
|
||||||
integrate_sav = malloc (strlen (integrate_default) +
|
fprintf (stdout,"Building Configuration...\n");
|
||||||
strlen (CONF_BACKUP_EXT) + 1);
|
|
||||||
strcpy (integrate_sav, integrate_default);
|
backup_config_file(integrate_default);
|
||||||
@@ -1812,6 +1823,21 @@
|
@@ -2058,16 +2063,31 @@
|
||||||
vtysh_config_dump (fp);
|
|
||||||
|
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
+
|
|
||||||
+ errno = 0;
|
+ errno = 0;
|
||||||
+ if ((quagga_vty_group = getgrnam(VTY_GROUP)) == NULL)
|
+ if ((quagga_vty_group = getgrnam(VTY_GROUP)) == NULL)
|
||||||
+ {
|
+ {
|
||||||
@ -40,6 +41,19 @@ Description: Fixes group permission. (line numbers adjusted for 0.99.22)
|
|||||||
+ integrate_default, strerror(errno), errno);
|
+ integrate_default, strerror(errno), errno);
|
||||||
+ return CMD_WARNING;
|
+ return CMD_WARNING;
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
if (chmod (integrate_default, CONFIGFILE_MASK) != 0)
|
if (chmod (integrate_default, CONFIGFILE_MASK) != 0)
|
||||||
{
|
{
|
||||||
|
- fprintf (stdout,"%% Can't chmod configuration file %s: %s (%d)\n",
|
||||||
|
+ fprintf (stdout,"%% Can't chmod configuration file %s: %s (%d)\n",
|
||||||
|
integrate_default, safe_strerror(errno), errno);
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chmod (host.config, CONFIGFILE_MASK) != 0)
|
||||||
|
{
|
||||||
|
- fprintf (stdout,"%% Can't chmod configuration file %s: %s (%d)\n",
|
||||||
|
+ fprintf (stdout,"%% Can't chmod configuration file %s: %s (%d)\n",
|
||||||
|
integrate_default, safe_strerror(errno), errno);
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
56
lib/vty.c
56
lib/vty.c
@ -2366,32 +2366,6 @@ vty_read_config (char *config_file,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef VTYSH
|
|
||||||
int ret;
|
|
||||||
struct stat conf_stat;
|
|
||||||
|
|
||||||
/* !!!!PLEASE LEAVE!!!!
|
|
||||||
* This is NEEDED for use with vtysh -b, or else you can get
|
|
||||||
* a real configuration food fight with a lot garbage in the
|
|
||||||
* merged configuration file it creates coming from the per
|
|
||||||
* daemon configuration files. This also allows the daemons
|
|
||||||
* to start if there default configuration file is not
|
|
||||||
* present or ignore them, as needed when using vtysh -b to
|
|
||||||
* configure the daemons at boot - MAG
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Stat for vtysh Zebra.conf, if found startup and wait for
|
|
||||||
* boot configuration
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( strstr(config_default_dir, "vtysh") == NULL)
|
|
||||||
{
|
|
||||||
ret = stat (integrate_default, &conf_stat);
|
|
||||||
if (ret >= 0)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif /* VTYSH */
|
|
||||||
|
|
||||||
confp = fopen (config_default_dir, "r");
|
confp = fopen (config_default_dir, "r");
|
||||||
if (confp == NULL)
|
if (confp == NULL)
|
||||||
{
|
{
|
||||||
@ -2415,6 +2389,36 @@ vty_read_config (char *config_file,
|
|||||||
fullpath = config_default_dir;
|
fullpath = config_default_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
host_config_set (fullpath);
|
||||||
|
|
||||||
|
#ifdef VTYSH
|
||||||
|
if (config_file)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct stat conf_stat;
|
||||||
|
|
||||||
|
/* !!!!PLEASE LEAVE!!!!
|
||||||
|
* This is NEEDED for use with vtysh -b, or else you can get
|
||||||
|
* a real configuration food fight with a lot garbage in the
|
||||||
|
* merged configuration file it creates coming from the per
|
||||||
|
* daemon configuration files. This also allows the daemons
|
||||||
|
* to start if there default configuration file is not
|
||||||
|
* present or ignore them, as needed when using vtysh -b to
|
||||||
|
* configure the daemons at boot - MAG
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Stat for vtysh Zebra.conf, if found startup and wait for
|
||||||
|
* boot configuration
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( strstr(config_default_dir, "vtysh") == NULL)
|
||||||
|
{
|
||||||
|
ret = stat (integrate_default, &conf_stat);
|
||||||
|
if (ret >= 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* VTYSH */
|
||||||
vty_read_file (confp);
|
vty_read_file (confp);
|
||||||
|
|
||||||
fclose (confp);
|
fclose (confp);
|
||||||
|
@ -2001,25 +2001,33 @@ DEFUN (no_vtysh_integrated_config,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
backup_config_file (const char *fbackup)
|
||||||
|
{
|
||||||
|
char *integrate_sav = NULL;
|
||||||
|
|
||||||
|
integrate_sav = malloc (strlen (fbackup) +
|
||||||
|
strlen (CONF_BACKUP_EXT) + 1);
|
||||||
|
strcpy (integrate_sav, fbackup);
|
||||||
|
strcat (integrate_sav, CONF_BACKUP_EXT);
|
||||||
|
|
||||||
|
/* Move current configuration file to backup config file. */
|
||||||
|
unlink (integrate_sav);
|
||||||
|
rename (fbackup, integrate_sav);
|
||||||
|
free (integrate_sav);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
write_config_integrated(void)
|
write_config_integrated(void)
|
||||||
{
|
{
|
||||||
u_int i;
|
u_int i;
|
||||||
char line[] = "write terminal\n";
|
char line[] = "write terminal\n";
|
||||||
FILE *fp;
|
FILE *fp, *fp1;
|
||||||
char *integrate_sav = NULL;
|
|
||||||
|
|
||||||
integrate_sav = malloc (strlen (integrate_default) +
|
|
||||||
strlen (CONF_BACKUP_EXT) + 1);
|
|
||||||
strcpy (integrate_sav, integrate_default);
|
|
||||||
strcat (integrate_sav, CONF_BACKUP_EXT);
|
|
||||||
|
|
||||||
fprintf (stdout,"Building Configuration...\n");
|
fprintf (stdout,"Building Configuration...\n");
|
||||||
|
|
||||||
/* Move current configuration file to backup config file. */
|
backup_config_file(integrate_default);
|
||||||
unlink (integrate_sav);
|
backup_config_file(host.config);
|
||||||
rename (integrate_default, integrate_sav);
|
|
||||||
free (integrate_sav);
|
|
||||||
|
|
||||||
fp = fopen (integrate_default, "w");
|
fp = fopen (integrate_default, "w");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
@ -2029,6 +2037,18 @@ write_config_integrated(void)
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fp1 = fopen (host.config, "w");
|
||||||
|
if (fp1 == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stdout,"%% Can't open configuration file %s.\n",
|
||||||
|
host.config);
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
vtysh_config_write ();
|
||||||
|
vtysh_config_dump (fp1);
|
||||||
|
|
||||||
|
fclose (fp1);
|
||||||
for (i = 0; i < array_size(vtysh_client); i++)
|
for (i = 0; i < array_size(vtysh_client); i++)
|
||||||
vtysh_client_config (&vtysh_client[i], line);
|
vtysh_client_config (&vtysh_client[i], line);
|
||||||
|
|
||||||
@ -2044,6 +2064,12 @@ write_config_integrated(void)
|
|||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chmod (host.config, CONFIGFILE_MASK) != 0)
|
||||||
|
{
|
||||||
|
fprintf (stdout,"%% Can't chmod configuration file %s: %s (%d)\n",
|
||||||
|
integrate_default, safe_strerror(errno), errno);
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
fprintf(stdout,"Integrated configuration saved to %s\n",integrate_default);
|
fprintf(stdout,"Integrated configuration saved to %s\n",integrate_default);
|
||||||
|
|
||||||
fprintf (stdout,"[OK]\n");
|
fprintf (stdout,"[OK]\n");
|
||||||
@ -2060,16 +2086,40 @@ DEFUN (vtysh_write_memory,
|
|||||||
int ret = CMD_SUCCESS;
|
int ret = CMD_SUCCESS;
|
||||||
char line[] = "write memory\n";
|
char line[] = "write memory\n";
|
||||||
u_int i;
|
u_int i;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
/* If integrated Quagga.conf explicitely set. */
|
/* If integrated Quagga.conf explicitely set. */
|
||||||
if (vtysh_writeconfig_integrated)
|
if (vtysh_writeconfig_integrated)
|
||||||
return write_config_integrated();
|
return write_config_integrated();
|
||||||
|
else
|
||||||
|
backup_config_file(integrate_default);
|
||||||
|
|
||||||
fprintf (stdout,"Building Configuration...\n");
|
fprintf (stdout,"Building Configuration...\n");
|
||||||
|
|
||||||
for (i = 0; i < array_size(vtysh_client); i++)
|
for (i = 0; i < array_size(vtysh_client); i++)
|
||||||
ret = vtysh_client_execute (&vtysh_client[i], line, stdout);
|
ret = vtysh_client_execute (&vtysh_client[i], line, stdout);
|
||||||
|
|
||||||
|
|
||||||
|
fp = fopen(host.config, "w");
|
||||||
|
if (fp == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stdout,"%% Can't open configuration file %s.\n",
|
||||||
|
host.config);
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
vtysh_config_write ();
|
||||||
|
vtysh_config_dump (fp);
|
||||||
|
|
||||||
|
fclose (fp);
|
||||||
|
|
||||||
|
if (chmod (host.config, CONFIGFILE_MASK) != 0)
|
||||||
|
{
|
||||||
|
fprintf (stdout,"%% Can't chmod configuration file %s: %s (%d)\n",
|
||||||
|
integrate_default, safe_strerror(errno), errno);
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf (stdout,"[OK]\n");
|
fprintf (stdout,"[OK]\n");
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -437,6 +437,8 @@ vtysh_config_write ()
|
|||||||
}
|
}
|
||||||
if (vtysh_writeconfig_integrated)
|
if (vtysh_writeconfig_integrated)
|
||||||
vtysh_config_parse_line ("service integrated-vtysh-config");
|
vtysh_config_parse_line ("service integrated-vtysh-config");
|
||||||
|
|
||||||
|
user_config_write ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -38,6 +38,9 @@
|
|||||||
#include "linklist.h"
|
#include "linklist.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
|
||||||
|
extern struct list *config_top;
|
||||||
|
extern void config_add_line(struct list *config, const char *line);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compiler is warning about prototypes not being declared.
|
* Compiler is warning about prototypes not being declared.
|
||||||
* The DEFUNSH and DEFUN macro's are messing with the
|
* The DEFUNSH and DEFUN macro's are messing with the
|
||||||
@ -143,11 +146,15 @@ user_config_write ()
|
|||||||
{
|
{
|
||||||
struct listnode *node, *nnode;
|
struct listnode *node, *nnode;
|
||||||
struct vtysh_user *user;
|
struct vtysh_user *user;
|
||||||
|
char line[128];
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS (userlist, node, nnode, user))
|
for (ALL_LIST_ELEMENTS (userlist, node, nnode, user))
|
||||||
{
|
{
|
||||||
if (user->nopassword)
|
if (user->nopassword)
|
||||||
printf (" username %s nopassword\n", user->name);
|
{
|
||||||
|
sprintf(line, "username %s nopassword", user->name);
|
||||||
|
config_add_line (config_top, line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user