From d74764ebf5f1cb941525f62a96ac56b83ff60caa Mon Sep 17 00:00:00 2001 From: Andras Gemes Date: Thu, 24 Oct 2024 11:47:54 +0200 Subject: [PATCH 1/2] BSim: Enable stderr display on console in runCommand() --- .../java/ghidra/features/bsim/query/BSimControlLaunchable.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java index 9b8e7137aa..49afad38e9 100644 --- a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java +++ b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java @@ -691,8 +691,9 @@ public class BSimControlLaunchable implements GhidraLaunchable { Process process = processBuilder.start(); new IOThread(process.getInputStream(), true).start(); - IOThread errThread = new IOThread(process.getErrorStream(), true); + IOThread errThread = new IOThread(process.getErrorStream(), false); errThread.start(); + errThread.join(); // Ensure all stderr output is processed to avoid mixed-up console output int retval = process.waitFor(); return retval; From 1e0df782b5bc09de4135802a3f285ea9d7424b0d Mon Sep 17 00:00:00 2001 From: James <49045138+ghidracadabra@users.noreply.github.com> Date: Thu, 7 Nov 2024 18:08:29 +0000 Subject: [PATCH 2/2] GP-5029 added space --- .../bsim/query/BSimControlLaunchable.java | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java index 49afad38e9..b5d872835d 100644 --- a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java +++ b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -98,7 +98,7 @@ public class BSimControlLaunchable implements GhidraLaunchable { private static final Set DROPUSER_OPTIONS = Set.of(); private static final Set CHANGEAUTH_OPTIONS = Set.of( AUTH_OPTION, NO_LOCAL_AUTH_OPTION, CAFILE_OPTION); - + //@formatter:on private static final Map> ALLOWED_OPTION_MAP = new HashMap<>(); static { @@ -670,8 +670,7 @@ public class BSimControlLaunchable implements GhidraLaunchable { /** * Invoke an external executable/command, display the output and error streams on the console, - * the exit condition of the command is returned. If the exit condition indicates and error, - * but a line of the error stream matches a provided String, the error is suppressed + * and return the exit value of the command. * @param directory is the working directory for the command * @param command is the command-line (including arguments) * @param envvar if non-null, is an environment variable to set for the command @@ -1430,21 +1429,21 @@ public class BSimControlLaunchable implements GhidraLaunchable { private static void printUsage() { //@formatter:off System.err.println("\n" + - "USAGE: bsim_ctl [command] required-args... [OPTIONS...}\n\n" + - " start [--auth|-a pki|password|trust] [--noLocalAuth] [--cafile \"\"] [--dn \"\"]\n" + - " stop [--force]\n" + - " adduser [--dn \"\"]\n" + - " dropuser \n" + - " changeauth [--auth|-a pki|password|trust] [--noLocalAuth] [--cafile \"\"]\n" + - " resetpassword \n" + - " changeprivilege admin|user\n" + - "\n" + - "Global options:\n" + - " --port|-p \n" + - " --user|-u \n" + - " --cert \n" + - "\n" + - "NOTE: Options with values may also be specified using the form: --option=value\n"); + "USAGE: bsim_ctl [command] required-args... [OPTIONS...}\n\n" + + " start [--auth|-a pki|password|trust] [--noLocalAuth] [--cafile \"\"] [--dn \"\"]\n" + + " stop [--force]\n" + + " adduser [--dn \"\"]\n" + + " dropuser \n" + + " changeauth [--auth|-a pki|password|trust] [--noLocalAuth] [--cafile \"\"]\n" + + " resetpassword \n" + + " changeprivilege admin|user\n" + + "\n" + + "Global options:\n" + + " --port|-p \n" + + " --user|-u \n" + + " --cert \n" + + "\n" + + "NOTE: Options with values may also be specified using the form: --option=value\n"); //@formatter:on } @@ -1521,7 +1520,7 @@ public class BSimControlLaunchable implements GhidraLaunchable { try { while ((line = shellOutput.readLine()) != null) { if (!suppressOutput) { - System.out.println(line); + System.out.println(" " + line); } } }