mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
Merge remote-tracking branch
'origin/GP-5129_ghidracadabra_PR-7102_gemesa_bsim-ctl-status' (Closes #7102)
This commit is contained in:
commit
5aec99616a
2 changed files with 42 additions and 0 deletions
|
@ -41,6 +41,7 @@
|
||||||
<CODE class="computeroutput">
|
<CODE class="computeroutput">
|
||||||
bsim_ctl start </datadir-path> [--auth|-a pki|password|trust] [--noLocalAuth] [--cafile </cacert-path>] [--dn "<distinguished-name>"]
|
bsim_ctl start </datadir-path> [--auth|-a pki|password|trust] [--noLocalAuth] [--cafile </cacert-path>] [--dn "<distinguished-name>"]
|
||||||
bsim_ctl stop </datadir-path> [--force]
|
bsim_ctl stop </datadir-path> [--force]
|
||||||
|
bsim_ctl status </datadir-path>
|
||||||
bsim_ctl adduser </datadir-path> <username> [--dn "<distinguished-name>"]
|
bsim_ctl adduser </datadir-path> <username> [--dn "<distinguished-name>"]
|
||||||
bsim_ctl dropuser </datadir-path> <username>
|
bsim_ctl dropuser </datadir-path> <username>
|
||||||
bsim_ctl resetpassword <username>
|
bsim_ctl resetpassword <username>
|
||||||
|
@ -136,6 +137,13 @@
|
||||||
immediately.</P>
|
immediately.</P>
|
||||||
</DD>
|
</DD>
|
||||||
|
|
||||||
|
<DT><SPAN class="term"><SPAN class="bold"><STRONG>status</STRONG></SPAN></SPAN></DT>
|
||||||
|
|
||||||
|
<DD>
|
||||||
|
<P>Retrieves the status of a PostgreSQL server (running/down). The path to the
|
||||||
|
actively used data directory must be provided.</P>
|
||||||
|
</DD>
|
||||||
|
|
||||||
<DT><SPAN class="term"><SPAN class="bold"><STRONG>adduser</STRONG></SPAN></SPAN></DT>
|
<DT><SPAN class="term"><SPAN class="bold"><STRONG>adduser</STRONG></SPAN></SPAN></DT>
|
||||||
|
|
||||||
<DD>
|
<DD>
|
||||||
|
|
|
@ -52,6 +52,7 @@ public class BSimControlLaunchable implements GhidraLaunchable {
|
||||||
// bsim_ctl commands
|
// bsim_ctl commands
|
||||||
public final static String COMMAND_START = "start";
|
public final static String COMMAND_START = "start";
|
||||||
public final static String COMMAND_STOP = "stop";
|
public final static String COMMAND_STOP = "stop";
|
||||||
|
public final static String COMMAND_STATUS = "status";
|
||||||
public final static String COMMAND_RESET_PASSWORD = "resetpassword";
|
public final static String COMMAND_RESET_PASSWORD = "resetpassword";
|
||||||
public final static String COMMAND_CHANGE_PRIVILEGE = "changeprivilege";
|
public final static String COMMAND_CHANGE_PRIVILEGE = "changeprivilege";
|
||||||
public final static String COMMAND_ADDUSER = "adduser";
|
public final static String COMMAND_ADDUSER = "adduser";
|
||||||
|
@ -91,6 +92,7 @@ public class BSimControlLaunchable implements GhidraLaunchable {
|
||||||
Set.of(AUTH_OPTION, DN_OPTION, NO_LOCAL_AUTH_OPTION, CAFILE_OPTION);
|
Set.of(AUTH_OPTION, DN_OPTION, NO_LOCAL_AUTH_OPTION, CAFILE_OPTION);
|
||||||
private static final Set<String> STOP_OPTIONS =
|
private static final Set<String> STOP_OPTIONS =
|
||||||
Set.of(FORCE_OPTION);
|
Set.of(FORCE_OPTION);
|
||||||
|
private static final Set<String> STATUS_OPTIONS = Set.of();
|
||||||
private static final Set<String> RESET_PASSWORD_OPTIONS = Set.of();
|
private static final Set<String> RESET_PASSWORD_OPTIONS = Set.of();
|
||||||
private static final Set<String> CHANGE_PRIVILEGE_OPTIONS = Set.of();
|
private static final Set<String> CHANGE_PRIVILEGE_OPTIONS = Set.of();
|
||||||
private static final Set<String> ADDUSER_OPTIONS =
|
private static final Set<String> ADDUSER_OPTIONS =
|
||||||
|
@ -104,6 +106,7 @@ public class BSimControlLaunchable implements GhidraLaunchable {
|
||||||
static {
|
static {
|
||||||
ALLOWED_OPTION_MAP.put(COMMAND_START, START_OPTIONS);
|
ALLOWED_OPTION_MAP.put(COMMAND_START, START_OPTIONS);
|
||||||
ALLOWED_OPTION_MAP.put(COMMAND_STOP, STOP_OPTIONS);
|
ALLOWED_OPTION_MAP.put(COMMAND_STOP, STOP_OPTIONS);
|
||||||
|
ALLOWED_OPTION_MAP.put(COMMAND_STATUS, STATUS_OPTIONS);
|
||||||
ALLOWED_OPTION_MAP.put(COMMAND_RESET_PASSWORD, RESET_PASSWORD_OPTIONS);
|
ALLOWED_OPTION_MAP.put(COMMAND_RESET_PASSWORD, RESET_PASSWORD_OPTIONS);
|
||||||
ALLOWED_OPTION_MAP.put(COMMAND_CHANGE_PRIVILEGE, CHANGE_PRIVILEGE_OPTIONS);
|
ALLOWED_OPTION_MAP.put(COMMAND_CHANGE_PRIVILEGE, CHANGE_PRIVILEGE_OPTIONS);
|
||||||
ALLOWED_OPTION_MAP.put(COMMAND_ADDUSER, ADDUSER_OPTIONS);
|
ALLOWED_OPTION_MAP.put(COMMAND_ADDUSER, ADDUSER_OPTIONS);
|
||||||
|
@ -201,6 +204,9 @@ public class BSimControlLaunchable implements GhidraLaunchable {
|
||||||
case COMMAND_STOP:
|
case COMMAND_STOP:
|
||||||
scanDataDirectory(params, slot++);
|
scanDataDirectory(params, slot++);
|
||||||
break;
|
break;
|
||||||
|
case COMMAND_STATUS:
|
||||||
|
scanDataDirectory(params, slot++);
|
||||||
|
break;
|
||||||
case COMMAND_ADDUSER:
|
case COMMAND_ADDUSER:
|
||||||
scanDataDirectory(params, slot++);
|
scanDataDirectory(params, slot++);
|
||||||
scanUsername(params, slot++);
|
scanUsername(params, slot++);
|
||||||
|
@ -1060,6 +1066,30 @@ public class BSimControlLaunchable implements GhidraLaunchable {
|
||||||
System.out.println("Server shutdown complete");
|
System.out.println("Server shutdown complete");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the status of a PostgreSQL server.
|
||||||
|
* @throws IOException if server status can not be retrieved
|
||||||
|
* @throws InterruptedException if the status command is interrupted
|
||||||
|
*/
|
||||||
|
private void statusCommand() throws IOException, InterruptedException {
|
||||||
|
discoverPostgresInstall();
|
||||||
|
List<String> command = new ArrayList<String>();
|
||||||
|
command.add(postgresControl.getAbsolutePath());
|
||||||
|
command.add("status");
|
||||||
|
command.add("-D");
|
||||||
|
command.add(dataDirectory.getAbsolutePath());
|
||||||
|
int res = runCommand(null, command, loadLibraryVar, loadLibraryValue);
|
||||||
|
if (res == 0) {
|
||||||
|
System.out.println("Server running");
|
||||||
|
}
|
||||||
|
else if (res == 3) {
|
||||||
|
System.out.println("Server down");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new IOException("Error getting postgres server status");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trigger a server running on the local host to rescan its identity file to pickup
|
* Trigger a server running on the local host to rescan its identity file to pickup
|
||||||
* any changes to the user mapping
|
* any changes to the user mapping
|
||||||
|
@ -1398,6 +1428,9 @@ public class BSimControlLaunchable implements GhidraLaunchable {
|
||||||
case COMMAND_STOP:
|
case COMMAND_STOP:
|
||||||
stopCommand();
|
stopCommand();
|
||||||
break;
|
break;
|
||||||
|
case COMMAND_STATUS:
|
||||||
|
statusCommand();
|
||||||
|
break;
|
||||||
case COMMAND_ADDUSER:
|
case COMMAND_ADDUSER:
|
||||||
addUserCommand();
|
addUserCommand();
|
||||||
break;
|
break;
|
||||||
|
@ -1433,6 +1466,7 @@ public class BSimControlLaunchable implements GhidraLaunchable {
|
||||||
"USAGE: bsim_ctl [command] required-args... [OPTIONS...}\n\n" +
|
"USAGE: bsim_ctl [command] required-args... [OPTIONS...}\n\n" +
|
||||||
" start </datadir-path> [--auth|-a pki|password|trust] [--noLocalAuth] [--cafile \"</cacert-path>\"] [--dn \"<distinguished-name>\"]\n" +
|
" start </datadir-path> [--auth|-a pki|password|trust] [--noLocalAuth] [--cafile \"</cacert-path>\"] [--dn \"<distinguished-name>\"]\n" +
|
||||||
" stop </datadir-path> [--force]\n" +
|
" stop </datadir-path> [--force]\n" +
|
||||||
|
" status </datadir-path>\n" +
|
||||||
" adduser </datadir-path> <username> [--dn \"<distinguished-name>\"]\n" +
|
" adduser </datadir-path> <username> [--dn \"<distinguished-name>\"]\n" +
|
||||||
" dropuser </datadir-path> <username>\n" +
|
" dropuser </datadir-path> <username>\n" +
|
||||||
" changeauth </datadir-path> [--auth|-a pki|password|trust] [--noLocalAuth] [--cafile \"</cacert-path>\"] [--dn \"<distinguished-name>\"]\n" +
|
" changeauth </datadir-path> [--auth|-a pki|password|trust] [--noLocalAuth] [--cafile \"</cacert-path>\"] [--dn \"<distinguished-name>\"]\n" +
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue