diff options
Diffstat (limited to '')
-rw-r--r-- | src/ConfigGlobal.cxx | 6 | ||||
-rw-r--r-- | src/ConfigGlobal.hxx | 8 | ||||
-rw-r--r-- | src/Listen.cxx | 6 |
3 files changed, 18 insertions, 2 deletions
diff --git a/src/ConfigGlobal.cxx b/src/ConfigGlobal.cxx index 11e53fc3c..bd1440a5e 100644 --- a/src/ConfigGlobal.cxx +++ b/src/ConfigGlobal.cxx @@ -105,6 +105,12 @@ config_get_path(ConfigOption option, Error &error) if (param == nullptr) return Path::Null(); + return config_parse_path(param, error); +} + +Path +config_parse_path(const struct config_param *param, Error & error) +{ Path path = ParsePath(param->value, error); if (gcc_unlikely(path.IsNull())) error.FormatPrefix("Invalid path at line %i: ", diff --git a/src/ConfigGlobal.hxx b/src/ConfigGlobal.hxx index c49679942..76b237153 100644 --- a/src/ConfigGlobal.hxx +++ b/src/ConfigGlobal.hxx @@ -72,6 +72,14 @@ config_get_string(enum ConfigOption option, const char *default_value); Path config_get_path(enum ConfigOption option, Error &error); +/** + * Parse a configuration parameter as a path. + * If there is a tilde prefix, it is expanded. If the path could + * not be parsed, returns Path::Null() and sets the error. + */ +Path +config_parse_path(const struct config_param *param, Error & error_r); + gcc_pure unsigned config_get_unsigned(enum ConfigOption option, unsigned default_value); diff --git a/src/Listen.cxx b/src/Listen.cxx index 2813c6bfb..0dcd6fddf 100644 --- a/src/Listen.cxx +++ b/src/Listen.cxx @@ -27,6 +27,7 @@ #include "ConfigOption.hxx" #include "event/ServerSocket.hxx" #include "util/Error.hxx" +#include "fs/Path.hxx" #include <string.h> #include <assert.h> @@ -64,8 +65,9 @@ listen_add_config_param(unsigned int port, if (0 == strcmp(param->value, "any")) { return listen_socket->AddPort(port, error_r); - } else if (param->value[0] == '/') { - return listen_socket->AddPath(param->value, error_r); + } else if (param->value[0] == '/' || param->value[0] == '~') { + Path path = config_parse_path(param, error_r); + return !path.IsNull() && listen_socket->AddPath(path.c_str(), error_r); } else { return listen_socket->AddHost(param->value, port, error_r); } |