summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrofl0r <rofl0r@users.noreply.github.com>2020-01-15 15:42:20 +0000
committerrofl0r <rofl0r@users.noreply.github.com>2020-01-15 15:42:24 +0000
commitbffa70500562f0ed675ed8d7e2385925c25f14fc (patch)
tree4d4664958277e57ecb3e0a952229d1234391fb8c
parent180c0664aa2af528745f997df0fbeadb2c87bcff (diff)
remove config file name item from conf struct
since this is set via command line, we can deal with it easily from where it is actually needed.
-rw-r--r--src/conf.c10
-rw-r--r--src/conf.h1
-rw-r--r--src/main.c20
3 files changed, 7 insertions, 24 deletions
diff --git a/src/conf.c b/src/conf.c
index c74216d..c9a499e 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -287,7 +287,6 @@ free_added_headers (vector_t add_headers)
static void free_config (struct config_s *conf)
{
- safefree (conf->config_file);
safefree (conf->logf_name);
safefree (conf->stathost);
safefree (conf->user);
@@ -446,11 +445,6 @@ void initialize_config_defaults (struct config_s *conf)
{
memset (conf, 0, sizeof(*conf));
- conf->config_file = safestrdup (SYSCONFDIR "/tinyproxy.conf");
- if (!conf->config_file) {
- fprintf (stderr, PACKAGE ": Could not allocate memory.\n");
- exit (EX_SOFTWARE);
- }
/*
* Make sure the HTML error pages array is NULL to begin with.
* (FIXME: Should have a better API for all this)
@@ -470,10 +464,6 @@ static void initialize_with_defaults (struct config_s *conf,
conf->logf_name = safestrdup (defaults->logf_name);
}
- if (defaults->config_file) {
- conf->config_file = safestrdup (defaults->config_file);
- }
-
conf->syslog = defaults->syslog;
conf->port = defaults->port;
diff --git a/src/conf.h b/src/conf.h
index 02fb699..9e10898 100644
--- a/src/conf.h
+++ b/src/conf.h
@@ -39,7 +39,6 @@ typedef struct {
struct config_s {
vector_t basicauth_list;
char *logf_name;
- char *config_file;
unsigned int syslog; /* boolean */
unsigned int port;
char *stathost;
diff --git a/src/main.c b/src/main.c
index 8b2167d..b4a5e53 100644
--- a/src/main.c
+++ b/src/main.c
@@ -49,6 +49,7 @@
*/
struct config_s config;
struct config_s config_defaults;
+static const char* config_file;
unsigned int received_sighup = FALSE; /* boolean */
/*
@@ -248,7 +249,7 @@ int reload_config (void)
shutdown_logging ();
- ret = reload_config_file (config_defaults.config_file, &config,
+ ret = reload_config_file (config_file, &config,
&config_defaults);
if (ret != 0) {
goto done;
@@ -278,7 +279,7 @@ main (int argc, char **argv)
exit (EX_SOFTWARE);
}
- initialize_config_defaults (&config_defaults);
+ config_file = SYSCONFDIR "/tinyproxy.conf";
while ((opt = getopt (argc, argv, "c:vdh")) != EOF) {
switch (opt) {
@@ -291,16 +292,7 @@ main (int argc, char **argv)
break;
case 'c':
- if ((&config_defaults)->config_file != NULL) {
- safefree ((&config_defaults)->config_file);
- }
- (&config_defaults)->config_file = safestrdup (optarg);
- if (!(&config_defaults)->config_file) {
- fprintf (stderr,
- "%s: Could not allocate memory.\n",
- argv[0]);
- exit (EX_SOFTWARE);
- }
+ config_file = optarg;
break;
case 'h':
@@ -313,7 +305,9 @@ main (int argc, char **argv)
}
}
- if (reload_config_file (config_defaults.config_file,
+ initialize_config_defaults (&config_defaults);
+
+ if (reload_config_file (config_file,
&config,
&config_defaults)) {
exit (EX_SOFTWARE);