aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorKevin Abrams <21090310+kkabrams@users.noreply.github.com>2018-12-18 13:15:14 -0600
committerSmallJoker <SmallJoker@users.noreply.github.com>2018-12-18 20:15:14 +0100
commitb7eb81fed922f7215cfff1068389fa85b2ee4ab2 (patch)
tree08deceaecf06b9c53a6baec3421ceb3946d86ca9 /src/client
parent80eb762af13f11ca48b69c818b737c68f8b31822 (diff)
downloadminetest-b7eb81fed922f7215cfff1068389fa85b2ee4ab2.tar.gz
minetest-b7eb81fed922f7215cfff1068389fa85b2ee4ab2.tar.bz2
minetest-b7eb81fed922f7215cfff1068389fa85b2ee4ab2.zip
Add command line option to load password from file (#7832)
Diffstat (limited to 'src/client')
-rw-r--r--src/client/clientlauncher.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/client/clientlauncher.cpp b/src/client/clientlauncher.cpp
index 0820177b4..9dfd248a2 100644
--- a/src/client/clientlauncher.cpp
+++ b/src/client/clientlauncher.cpp
@@ -392,6 +392,20 @@ bool ClientLauncher::launch_game(std::string &error_message,
if (cmd_args.exists("password"))
menudata.password = cmd_args.get("password");
+
+ if (cmd_args.exists("password-file")) {
+ std::ifstream passfile(cmd_args.get("password-file"));
+ if (passfile.good()) {
+ getline(passfile, menudata.password);
+ } else {
+ error_message = gettext("Provided password file "
+ "failed to open: ")
+ + cmd_args.get("password-file");
+ errorstream << error_message << std::endl;
+ return false;
+ }
+ }
+
// If a world was commanded, append and select it
if (!game_params.world_path.empty()) {
worldspec.gameid = getWorldGameId(game_params.world_path, true);