diff --git a/ChangeLog b/ChangeLog index aaf0bf9c..2b40c2f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,8 @@ compile-time are not parsed any more. - When virtual quotas were configured, files were removed after an upload if the size quota was exceeded, but not during the upload. This has been fixed. + - A configuration file can now include other files with the `Include` +directive. * Version 1.0.49: - This version fixes a regression introduced in version 1.0.48 that broke diff --git a/pure-ftpd.conf.in b/pure-ftpd.conf.in index f350f6a0..b7392633 100644 --- a/pure-ftpd.conf.in +++ b/pure-ftpd.conf.in @@ -457,3 +457,11 @@ CustomerProof yes # By default, both IPv4 and IPv6 are enabled. # IPV6Only yes + + + +# Append the content of another file, if the file exists. +# If the file doesn't exist, the directive is ignored. +# More files can be recursively included. + +# Include additional_configuration.conf diff --git a/src/ftpd.c b/src/ftpd.c index e647a828..53f4de4d 100644 --- a/src/ftpd.c +++ b/src/ftpd.c @@ -5443,6 +5443,24 @@ static struct passwd *fakegetpwnam(const char * const name) } #endif +#ifndef MINIMAL +static SimpleConfSpecialHandlerResult sc_special_handler(void **output_p, + const char *arg, + void *user_data) +{ + struct stat st; + (void) user_data; + + if (stat(arg, &st) != 0) { + return SC_SPECIAL_HANDLER_RESULT_NEXT; + } + if ((*output_p = strdup(arg)) == NULL) { + return SC_SPECIAL_HANDLER_RESULT_ERROR; + } + return SC_SPECIAL_HANDLER_RESULT_INCLUDE; +} +#endif + int pureftpd_start(int argc, char *argv[], const char *home_directory_) { #ifndef NO_GETOPT_LONG @@ -5507,12 +5525,17 @@ int pureftpd_start(int argc, char *argv[], const char *home_directory_) #endif #ifndef MINIMAL - if (argc == 2 && *argv[1] != '-' && - sc_build_command_line_from_file(argv[1], NULL, simpleconf_options, - (sizeof simpleconf_options) / - (sizeof simpleconf_options[0]), - argv[0], &argc, &argv) != 0) { - die(421, LOG_ERR, MSG_CONF_ERR); + { + static SimpleConfConfig config = { NULL, sc_special_handler }; + + if (argc == 2 && *argv[1] != '-' && + sc_build_command_line_from_file(argv[1], &config, + simpleconf_options, + (sizeof simpleconf_options) / + (sizeof simpleconf_options[0]), + argv[0], &argc, &argv) != 0) { + die(421, LOG_ERR, MSG_CONF_ERR); + } } #endif diff --git a/src/simpleconf_ftpd.h b/src/simpleconf_ftpd.h index fd414d82..1d697d9a 100644 --- a/src/simpleconf_ftpd.h +++ b/src/simpleconf_ftpd.h @@ -117,7 +117,8 @@ static const SimpleConfEntry simpleconf_options[] = { #ifdef RATIOS {"UserRatio () ()", "--userratio=$0:$1"}, #endif - {"VerboseLog? ", "--verboselog"} + {"VerboseLog? ", "--verboselog"}, + {"!Include ", "$*"} }; #endif