NationalSecurityAgency/ghidra · error · IOException

Unable to obtain password

Error message

Unable to obtain password

What it means

Thrown by establishAdminPassword when requestPassword returns null while setting up a new postgres admin password. A null return means the password prompt could not read input (no console, EOF, or cancellation), so setup cannot proceed.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java:471

		String protocol = "postgresql";
		String scheme = "NO_NAME";
		return Authenticator
				.requestPasswordAuthentication(host, addr, port, protocol, prompt, scheme)
				.getPassword();
	}

	/**
	 * (For a new postgres server) Establish an administrative password, by requesting the password
	 * from the user, and then having the user re-enter the password. The password is stored in
	 * the character array -adminPasswordData- and written to the file -passwordFile-
	 * for access by the postgres "init" process
	 * @throws IOException if there is a problem obtaining the password
	 */
	private void establishAdminPassword() throws IOException {
		for (;;) {
			adminPasswordData = requestPassword("Set admin(" + connectingUserName + ") password:");
			if (adminPasswordData == null) {
				throw new IOException("Unable to obtain password");
			}
			char[] repeatPass = requestPassword("Please re-enter password:");
			boolean match = comparePasswordData(adminPasswordData, repeatPass);
			clearPasswordData(repeatPass);
			if (match) {
				break;
			}
			cleanupPasswordData();
			System.out.println("Passwords do not match");
		}
		passwordFile = Files
				.createTempFile("bsim", ".dat",
					PosixFilePermissions
							.asFileAttribute(PosixFilePermissions.fromString("rw-------")))
				.toFile();
		FileWriter writer = new FileWriter(passwordFile);
		writer.write(adminPasswordData);
		writer.close();

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Run the command in an interactive terminal with a real TTY.
  2. Avoid piping or redirecting stdin so the prompt can read input.
  3. For automation, pre-initialize the server interactively or use a supported non-interactive provisioning path.
Defensive patterns

Strategy: validation

Validate before calling

// Detect a TTY / readable console before attempting interactive password setup.
if (System.console() == null) {
    System.err.println("No interactive console available; cannot set admin password here.");
    System.err.println("Run this command from a real terminal.");
    return;
}

Try / catch

try {
    launchable.establishAdminPassword();
} catch (IOException e) {
    if (e.getMessage().equals("Unable to obtain password")) {
        System.err.println("Password input unavailable. Run in an interactive terminal.");
    }
    throw e;
}

Prevention

When it happens

Trigger: Running the new-server admin password setup in a non-interactive context (no TTY), piping EOF into stdin, or the user cancelling the prompt. The null check fires at line 471.

Common situations: CI/CD pipelines, daemon/service contexts, SSH non-TTY sessions, or stdin redirected from a file/pipe.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/abecdf035921c0f6. Report an issue: GitHub.