From 907f121d0c47174da0e94f6fb54608e89fc10e53 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Tue, 29 Dec 2020 20:18:25 +0100 Subject: [PATCH] do not overwrite PW with random PW --- htroot/ConfigAccounts_p.java | 7 ------- source/net/yacy/search/Switchboard.java | 7 ------- source/net/yacy/server/serverSwitch.java | 26 ------------------------ 3 files changed, 40 deletions(-) diff --git a/htroot/ConfigAccounts_p.java b/htroot/ConfigAccounts_p.java index 2b5a39f88..5c8fc4e7f 100644 --- a/htroot/ConfigAccounts_p.java +++ b/htroot/ConfigAccounts_p.java @@ -97,14 +97,7 @@ public class ConfigAccounts_p { if (inputerror == 0) { if (localhostAccess) { - sb.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, true); - // if an localhost access is configured, check if a local password is given - // if not, set a random password - if (env.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").isEmpty()) { - // make a 'random' password - env.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "0000" + sb.genRandomPassword()); - } } else { sb.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false); if (env.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").startsWith("0000")) { diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.java index 713591c2b..eae4b82d0 100644 --- a/source/net/yacy/search/Switchboard.java +++ b/source/net/yacy/search/Switchboard.java @@ -2620,13 +2620,6 @@ public final class Switchboard extends serverSwitch { GuiHandler.clear(); } - // set a random password if no password is configured - if ( getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false) - && getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").isEmpty() ) { - // make a 'random' password, this will keep the ability to log in from localhost without password - setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "0000" + this.genRandomPassword()); - } - // stop greedylearning if limit is reached if (getConfigBool(SwitchboardConstants.GREEDYLEARNING_ACTIVE, false)) { long cs = this.index.fulltext().collectionSize(); diff --git a/source/net/yacy/server/serverSwitch.java b/source/net/yacy/server/serverSwitch.java index d4abab13f..06b5cfbf3 100644 --- a/source/net/yacy/server/serverSwitch.java +++ b/source/net/yacy/server/serverSwitch.java @@ -38,13 +38,11 @@ import java.util.LinkedHashSet; import java.util.Map; import java.util.NavigableMap; import java.util.Properties; -import java.util.Random; import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import net.yacy.cora.order.Digest; import net.yacy.cora.protocol.ClientIdentification; import net.yacy.cora.protocol.Domains; import net.yacy.cora.protocol.HeaderFramework; @@ -737,30 +735,6 @@ public class serverSwitch { throw new FileNotFoundException(f.toString()); } - private static Random pwGenerator = new Random(); - - /** - * Generates a random password. - * - * @return random password which is 20 characters long. - */ - public String genRandomPassword() { - return genRandomPassword(20); - } - - /** - * Generates a random password of a given length. - * - * @param length - * length o password - * @return password of given length - */ - public String genRandomPassword(final int length) { - byte[] bytes = new byte[length]; - pwGenerator.nextBytes(bytes); - return Digest.encodeMD5Hex(bytes); - } - /** * set/remember jetty server *