Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.1'
Browse files Browse the repository at this point in the history
- the merge of #4567 needs additional changes because of ServiceLock
  data in ZooKeeper.  This will be done as a separate PR.
  • Loading branch information
Ed Coleman committed May 24, 2024
2 parents f2005ca + 4426b90 commit 8e5d967
Show file tree
Hide file tree
Showing 7 changed files with 1,232 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ public void execute(final String[] args) {
JCommander cl = new JCommander(opts);
cl.setProgramName("accumulo admin");

ServiceStatusCmd.Opts serviceStatusCommandOpts = new ServiceStatusCmd.Opts();
cl.addCommand("serviceStatus", serviceStatusCommandOpts);

ChangeSecretCommand changeSecretCommand = new ChangeSecretCommand();
cl.addCommand("changeSecret", changeSecretCommand);

Expand Down Expand Up @@ -375,6 +378,8 @@ public void execute(final String[] args) {
tServerLocksOpts.delete);
} else if (cl.getParsedCommand().equals("fate")) {
executeFateOpsCommand(context, fateOpsCommand);
} else if (cl.getParsedCommand().equals("serviceStatus")) {
printServiceStatus(context, serviceStatusCommandOpts);
} else {
everything = cl.getParsedCommand().equals("stopAll");

Expand Down Expand Up @@ -402,6 +407,11 @@ public void execute(final String[] args) {
}
}

private static void printServiceStatus(ServerContext context, ServiceStatusCmd.Opts opts) {
ServiceStatusCmd ssc = new ServiceStatusCmd();
ssc.execute(context, opts);
}

private static int ping(ClientContext context, List<String> args) {

InstanceOperations io = context.instanceOperations();
Expand Down Expand Up @@ -567,21 +577,11 @@ static String qualifyWithZooKeeperSessionId(String zTServerRoot, ZooCache zooCac
private Map<String,String> siteConfig, systemConfig;
private List<String> localUsers;

@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN",
justification = "code runs in same security context as user who provided input")
public void printConfig(ClientContext context, DumpConfigCommand opts) throws Exception {

File outputDirectory = null;
if (opts.directory != null) {
outputDirectory = new File(opts.directory);
if (!outputDirectory.isDirectory()) {
throw new IllegalArgumentException(
opts.directory + " does not exist on the local filesystem.");
}
if (!outputDirectory.canWrite()) {
throw new IllegalArgumentException(opts.directory + " is not writable");
}
}
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN",
justification = "app is run in same security context as user providing the filename")
File outputDirectory = getOutputDirectory(opts.directory);
defaultConfig = DefaultConfiguration.getInstance();
siteConfig = context.instanceOperations().getSiteConfiguration();
systemConfig = context.instanceOperations().getSystemConfiguration();
Expand Down Expand Up @@ -628,6 +628,22 @@ public void printConfig(ClientContext context, DumpConfigCommand opts) throws Ex
}
}

@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN",
justification = "app is run in same security context as user providing the filename")
private static File getOutputDirectory(final String directory) {
File outputDirectory = null;
if (directory != null) {
outputDirectory = new File(directory);
if (!outputDirectory.isDirectory()) {
throw new IllegalArgumentException(directory + " does not exist on the local filesystem.");
}
if (!outputDirectory.canWrite()) {
throw new IllegalArgumentException(directory + " is not writable");
}
}
return outputDirectory;
}

private String getDefaultConfigValue(String key) {
if (key == null) {
return null;
Expand Down
Loading

0 comments on commit 8e5d967

Please sign in to comment.