Removing code which looked at current dir for config file before attempting

to read system one.
This commit is contained in:
hasso 2004-06-20 19:54:37 +00:00
parent 6c0f9a782a
commit 320ec10a24
10 changed files with 79 additions and 102 deletions

View File

@ -1,3 +1,11 @@
2004-06-20 Hasso Tepper <hasso@estpak.ee>
* lib/vty.c: Don't attempt to load configuration file from current
directory.
* Update vty_read_config() calls in bgpd/bgp_main.c, isisd/isis_main.c,
ospf6d/ospf6_main.c, ospfd/ospf_main.c, ripd/rip_main.c,
ripngd/ripng_main.c and zebra/main.c.
2004-05-11 Paul Jakma <paul@dishone.st>
* configure.ac: Add solaris support for the zebra/*_solaris

View File

@ -79,7 +79,6 @@ struct quagga_signal_t bgp_signals[] =
};
/* Configuration file and directory. */
char config_current[] = BGP_DEFAULT_CONFIG;
char config_default[] = SYSCONFDIR BGP_DEFAULT_CONFIG;
/* Route retain mode flag. */
@ -159,7 +158,7 @@ sighup (void)
zlog_info ("bgpd restarting!");
/* Reload config file. */
vty_read_config (config_file, config_current, config_default);
vty_read_config (config_file, config_default);
/* Create VTY's socket */
vty_serv_sock (vty_addr, vty_port, BGP_VTYSH_PATH);
@ -287,7 +286,7 @@ main (int argc, char **argv)
sort_node ();
/* Parse config file. */
vty_read_config (config_file, config_current, config_default);
vty_read_config (config_file, config_default);
/* Turn into daemon if daemon_mode is set. */
if (daemon_mode)

View File

@ -87,7 +87,6 @@ struct option longopts[] =
};
/* Configuration file and directory. */
char config_current[] = ISISD_DEFAULT_CONFIG;
char config_default[] = SYSCONFDIR ISISD_DEFAULT_CONFIG;
char *config_file = NULL;
@ -311,9 +310,9 @@ main (int argc, char **argv, char **envp)
/* parse config file */
/* this is needed three times! because we have interfaces before the areas */
vty_read_config (config_file, config_current, config_default);
vty_read_config (config_file, config_current, config_default);
vty_read_config (config_file, config_current, config_default);
vty_read_config (config_file, config_default);
vty_read_config (config_file, config_default);
vty_read_config (config_file, config_default);
/* demonize */
if (daemon_mode)

140
lib/vty.c
View File

@ -2208,8 +2208,7 @@ vty_use_backup_config (char *fullpath)
/* Read up configuration file from file_name. */
void
vty_read_config (char *config_file,
char *config_current_dir,
char *config_default_dir)
char *config_default_dir)
{
char cwd[MAXPATHLEN];
FILE *confp = NULL;
@ -2219,101 +2218,78 @@ vty_read_config (char *config_file,
if (config_file != NULL)
{
if (! IS_DIRECTORY_SEP (config_file[0]))
{
getcwd (cwd, MAXPATHLEN);
fullpath = XMALLOC (MTYPE_TMP,
strlen (cwd) + strlen (config_file) + 2);
sprintf (fullpath, "%s/%s", cwd, config_file);
}
{
getcwd (cwd, MAXPATHLEN);
fullpath = XMALLOC (MTYPE_TMP,
strlen (cwd) + strlen (config_file) + 2);
sprintf (fullpath, "%s/%s", cwd, config_file);
}
else
fullpath = config_file;
fullpath = config_file;
confp = fopen (fullpath, "r");
if (confp == NULL)
{
confp = vty_use_backup_config (fullpath);
if (confp)
fprintf (stderr, "WARNING: using backup configuration file!\n");
else
{
fprintf (stderr, "can't open configuration file [%s]\n",
config_file);
exit(1);
}
}
{
confp = vty_use_backup_config (fullpath);
if (confp)
fprintf (stderr, "WARNING: using backup configuration file!\n");
else
{
fprintf (stderr, "can't open configuration file [%s]\n",
config_file);
exit(1);
}
}
}
else
{
/* Relative path configuration file open. */
if (config_current_dir)
{
confp = fopen (config_current_dir, "r");
if (confp == NULL)
{
confp = vty_use_backup_config (config_current_dir);
if (confp)
fprintf (stderr, "WARNING: using backup configuration file!\n");
}
}
/* If there is no relative path exists, open system default file. */
if (confp == NULL)
{
#ifdef VTYSH
int ret;
struct stat conf_stat;
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 */
/* !!!!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 */
/* 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;
}
}
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");
if (confp == NULL)
{
confp = vty_use_backup_config (config_default_dir);
if (confp)
{
fprintf (stderr, "WARNING: using backup configuration file!\n");
fullpath = config_default_dir;
}
else
{
fprintf (stderr, "can't open configuration file [%s]\n",
config_default_dir);
exit (1);
}
}
else
fullpath = config_default_dir;
}
confp = fopen (config_default_dir, "r");
if (confp == NULL)
{
confp = vty_use_backup_config (config_default_dir);
if (confp)
{
fprintf (stderr, "WARNING: using backup configuration file!\n");
fullpath = config_default_dir;
}
else
{
fprintf (stderr, "can't open configuration file [%s]\n",
config_default_dir);
exit (1);
}
}
else
{
/* Rleative path configuration file. */
getcwd (cwd, MAXPATHLEN);
fullpath = XMALLOC (MTYPE_TMP,
strlen (cwd) + strlen (config_current_dir) + 2);
sprintf (fullpath, "%s/%s", cwd, config_current_dir);
}
}
fullpath = config_default_dir;
}
vty_read_file (confp);
fclose (confp);

View File

@ -192,7 +192,7 @@ void vty_reset (void);
void vty_finish (void);
struct vty *vty_new (void);
int vty_out (struct vty *, const char *, ...) PRINTF_ATTRIBUTE(2, 3);
void vty_read_config (char *, char *, char *);
void vty_read_config (char *, char *);
void vty_time_print (struct vty *, int);
void vty_serv_sock (const char *, unsigned short, char *);
void vty_close (struct vty *);

View File

@ -79,7 +79,6 @@ struct option longopts[] =
};
/* Configuration file and directory. */
char config_current[] = OSPF6_DEFAULT_CONFIG;
char config_default[] = SYSCONFDIR OSPF6_DEFAULT_CONFIG;
/* ospf6d program name. */
@ -291,7 +290,7 @@ main (int argc, char *argv[], char *envp[])
sort_node ();
/* parse config file */
vty_read_config (config_file, config_current, config_default);
vty_read_config (config_file, config_default);
if (daemon_mode)
daemon (0, 0);

View File

@ -74,7 +74,6 @@ struct zebra_privs_t ospfd_privs =
};
/* Configuration filename and directory. */
char config_current[] = OSPF_DEFAULT_CONFIG;
char config_default[] = SYSCONFDIR OSPF_DEFAULT_CONFIG;
/* OSPFd options. */
@ -286,7 +285,7 @@ main (int argc, char **argv)
sort_node ();
/* Get configuration file. */
vty_read_config (config_file, config_current, config_default);
vty_read_config (config_file, config_default);
/* Change to the daemon program. */
if (daemon_mode)

View File

@ -74,7 +74,6 @@ struct zebra_privs_t ripd_privs =
};
/* Configuration file and directory. */
char config_current[] = RIPD_DEFAULT_CONFIG;
char config_default[] = SYSCONFDIR RIPD_DEFAULT_CONFIG;
char *config_file = NULL;
@ -131,7 +130,7 @@ sighup (void)
zlog_info ("ripd restarting!");
/* Reload config file. */
vty_read_config (config_file, config_current, config_default);
vty_read_config (config_file, config_default);
/* Create VTY's socket */
vty_serv_sock (vty_addr, vty_port, RIP_VTYSH_PATH);
@ -274,7 +273,7 @@ main (int argc, char **argv)
sort_node ();
/* Get configuration file. */
vty_read_config (config_file, config_current, config_default);
vty_read_config (config_file, config_default);
/* Change to the daemon program. */
if (daemon_mode)

View File

@ -38,7 +38,6 @@
#include "ripngd/ripngd.h"
/* Configuration filename and directory. */
char config_current[] = RIPNG_DEFAULT_CONFIG;
char config_default[] = SYSCONFDIR RIPNG_DEFAULT_CONFIG;
char *config_file = NULL;
@ -135,7 +134,7 @@ sighup (void)
zlog_info ("Terminating on signal");
/* Reload config file. */
vty_read_config (config_file, config_current, config_default);
vty_read_config (config_file, config_default);
/* Create VTY's socket */
vty_serv_sock (vty_addr, vty_port, RIPNG_VTYSH_PATH);
@ -276,7 +275,7 @@ main (int argc, char **argv)
sort_node ();
/* Get configuration file. */
vty_read_config (config_file, config_current, config_default);
vty_read_config (config_file, config_default);
/* Change to the daemon program. */
if (daemon_mode)

View File

@ -95,7 +95,6 @@ struct zebra_privs_t zserv_privs =
};
/* Default configuration file path. */
char config_current[] = DEFAULT_CONFIG_FILE;
char config_default[] = SYSCONFDIR DEFAULT_CONFIG_FILE;
/* Process ID saved for use by init system */
@ -317,7 +316,7 @@ main (int argc, char **argv)
rib_sweep_route ();
/* Configuration file read*/
vty_read_config (config_file, config_current, config_default);
vty_read_config (config_file, config_default);
/* Clean up rib. */
rib_weed_tables ();