From: Perttu Ahola Date: Wed, 6 Jun 2012 23:11:28 +0000 (+0300) Subject: Add disallow_empty_password setting X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=4b2cc38abaa9b4d19e6e483c811c58f79cc86584;p=zefram%2Fminetest%2Fminetest_engine.git Add disallow_empty_password setting --- diff --git a/minetest.conf.example b/minetest.conf.example index 7a8a2719..ebfa70aa 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -152,6 +152,8 @@ #enable_pvp = true # If this is set, players will always (re)spawn at the given position #static_spawnpoint = 0, 10, 0 +# If true, new players cannot join with an empty password +#disallow_empty_password = false # Profiler data print interval. #0 = disable. #profiler_print_interval = 0 diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index f13ab367..13cfab72 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -119,6 +119,7 @@ void set_default_settings(Settings *settings) settings->setDefault("default_privs", "interact, shout"); settings->setDefault("unlimited_player_transfer_distance", "true"); settings->setDefault("enable_pvp", "true"); + settings->setDefault("disallow_empty_password", "false"); settings->setDefault("profiler_print_interval", "0"); settings->setDefault("enable_mapgen_debug_info", "false"); diff --git a/src/server.cpp b/src/server.cpp index 212be19a..a7bd5e95 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2089,41 +2089,50 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) <getBool("disallow_empty_password") && + std::string(given_password) == ""){ + SendAccessDenied(m_con, peer_id, L"Empty passwords are " + L"disallowed. Set a password and try again."); + return; + } std::wstring raw_default_password = narrow_to_wide(g_settings->get("default_password")); - std::string use_password = + std::string initial_password = translatePassword(playername, raw_default_password); // If default_password is empty, allow any initial password if (raw_default_password.length() == 0) - use_password = password; + initial_password = given_password; - scriptapi_create_auth(m_lua, playername, use_password); + scriptapi_create_auth(m_lua, playername, initial_password); } has_auth = scriptapi_get_auth(m_lua, playername, &checkpwd, NULL); @@ -2133,7 +2142,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) return; } - if(password != checkpwd){ + if(given_password != checkpwd){ infostream<<"Server: peer_id="<