This is an automated email from the ASF dual-hosted git repository. mmiller pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push: new 93acb14430 Adding ChangeSecret utility to the accumulo admin command (#2814) 93acb14430 is described below commit 93acb14430096c9dcdf57248afa2c0bfbc1590f9 Author: Christopher L. Shannon <christopher.l.shan...@gmail.com> AuthorDate: Fri Aug 12 07:44:57 2022 -0400 Adding ChangeSecret utility to the accumulo admin command (#2814) Issue #2807 --- .../src/main/java/org/apache/accumulo/server/util/Admin.java | 12 ++++++++++++ .../java/org/apache/accumulo/server/util/ChangeSecret.java | 11 ++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java index b7fe030f5c..053e0c197b 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java @@ -169,6 +169,13 @@ public class Admin implements KeywordExecutable { boolean verbose = false; } + /** + * @since 2.1.0 + */ + @Parameters( + commandDescription = "Changes the unique secret given to the instance that all servers must know.") + static class ChangeSecretCommand {} + public static void main(String[] args) { new Admin().execute(args); } @@ -200,6 +207,9 @@ public class Admin implements KeywordExecutable { CheckTabletsCommand checkTabletsCommand = new CheckTabletsCommand(); cl.addCommand("checkTablets", checkTabletsCommand); + ChangeSecretCommand changeSecretCommand = new ChangeSecretCommand(); + cl.addCommand("changeSecret", changeSecretCommand); + ListInstancesCommand listIntancesOpts = new ListInstancesCommand(); cl.addCommand("listInstances", listIntancesOpts); @@ -279,6 +289,8 @@ public class Admin implements KeywordExecutable { } else if (cl.getParsedCommand().equals("verifyTabletAssigns")) { VerifyTabletAssignments.verifyTableAssignments(opts.getClientProps(), verifyTabletAssignmentsOpts.verbose); + } else if (cl.getParsedCommand().equals("changeSecret")) { + ChangeSecret.changeSecret(context, conf); } else { everything = cl.getParsedCommand().equals("stopAll"); diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/ChangeSecret.java b/server/base/src/main/java/org/apache/accumulo/server/util/ChangeSecret.java index daa17c18fd..adfdc98321 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/ChangeSecret.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/ChangeSecret.java @@ -26,6 +26,7 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; +import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.SiteConfiguration; import org.apache.accumulo.core.data.InstanceId; import org.apache.accumulo.core.trace.TraceUtil; @@ -56,14 +57,18 @@ public class ChangeSecret { public static void main(String[] args) throws Exception { var siteConfig = SiteConfiguration.auto(); - var hadoopConf = new Configuration(); - ServerUtilOpts opts = new ServerUtilOpts(); opts.parseArgs(ChangeSecret.class.getName(), args); ServerContext context = opts.getServerContext(); + changeSecret(context, siteConfig); + } + + public static void changeSecret(final ServerContext context, final AccumuloConfiguration conf) + throws Exception { + try (var fs = context.getVolumeManager()) { - ServerDirs serverDirs = new ServerDirs(siteConfig, hadoopConf); + ServerDirs serverDirs = new ServerDirs(conf, new Configuration()); verifyHdfsWritePermission(serverDirs, fs); String oldPass = String.valueOf(System.console().readPassword("Old secret: "));