Add MotD support.
Fixed config up. Better handling of config variables
This commit is contained in:
1 parent
bc88a30c0c
commit
28efbfb185
12 files changed
+261
-109
No files matched your search
+11
-15
@@ -183,29 +183,24 @@ void runClient(struct ftpconn* cfd) {
|
||||
void initializePlugins() {
|
||||
std::string plugin_dir = config->getValue("core", "plugin_path", PLUGIN_DIR);
|
||||
|
||||
// Load auth plugins
|
||||
auto& auth_manager = PluginManager<Auth>::getInstance();
|
||||
auth_manager.setLogger(logger);
|
||||
|
||||
// Load filer plugins
|
||||
auto& filer_manager = PluginManager<Filer>::getInstance();
|
||||
|
||||
auth_manager.setLogger(logger);
|
||||
filer_manager.setLogger(logger);
|
||||
|
||||
// Try loading all plugins into both managers
|
||||
for (const auto& entry : std::filesystem::directory_iterator(plugin_dir)) {
|
||||
if (entry.path().extension() == ".so") {
|
||||
const std::string& filename = entry.path().filename().string();
|
||||
if (filename.find(PluginTraits<Auth>::pluginPrefix()) == 0) {
|
||||
auth_manager.loadPlugin(entry.path().string());
|
||||
}
|
||||
else if (filename.find(PluginTraits<Filer>::pluginPrefix()) == 0) {
|
||||
filer_manager.loadPlugin(entry.path().string());
|
||||
}
|
||||
logger->print(LOGLEVEL_DEBUG, "Loading plugin: %s", entry.path().c_str());
|
||||
auth_manager.loadPlugin(entry.path().string());
|
||||
filer_manager.loadPlugin(entry.path().string());
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize auth
|
||||
std::string auth_type = config->getValue("core", "auth_engine", "pam");
|
||||
auth = auth_manager.createPlugin(auth_type);
|
||||
std::string auth_type = config->getValue("engines", "auth", "pam");
|
||||
auth = auth_manager.createPlugin(auth_type, config->get(auth_type)->get());
|
||||
|
||||
if (!auth) {
|
||||
logger->print(LOGLEVEL_CRITICAL, "Failed to create auth engine: %s", auth_type.c_str());
|
||||
@@ -213,7 +208,7 @@ void initializePlugins() {
|
||||
}
|
||||
|
||||
// Initialize filer
|
||||
std::string filer_type = config->getValue("core", "filer_engine", "local");
|
||||
std::string filer_type = config->getValue("engines", "filer", "local");
|
||||
default_filer_factory = filer_manager.getFactory(filer_type);
|
||||
|
||||
if (!default_filer_factory) {
|
||||
@@ -231,7 +226,8 @@ int main(int argc , char *argv[]) {
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
config = new ConfigFile(concatPath(std::string(CONFIG_DIR), "ftp.conf"));
|
||||
server_name = config->getValue("core", "server_name", "digFTP %v");
|
||||
server_name = config->getValue("core", "server_name", "%a %v");
|
||||
motd = config->getValue("core", "motd", "cmd:cowsay -r Welcome %u!");
|
||||
|
||||
sscanf(
|
||||
config->getValue("net", "listen", "127.0.0.1:21").c_str(),
|
||||
|
||||
Reference in new issue
Block a user