{"record":{"id":"abecdf035921c0f6","repo":"NationalSecurityAgency/ghidra","slug":"unable-to-obtain-password","errorCode":null,"errorMessage":"Unable to obtain password","messagePattern":"Unable to obtain password","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java","lineNumber":471,"sourceCode":"\t\tString protocol = \"postgresql\";\n\t\tString scheme = \"NO_NAME\";\n\t\treturn Authenticator\n\t\t\t\t.requestPasswordAuthentication(host, addr, port, protocol, prompt, scheme)\n\t\t\t\t.getPassword();\n\t}\n\n\t/**\n\t * (For a new postgres server) Establish an administrative password, by requesting the password\n\t * from the user, and then having the user re-enter the password. The password is stored in\n\t * the character array -adminPasswordData- and written to the file -passwordFile-\n\t * for access by the postgres \"init\" process\n\t * @throws IOException if there is a problem obtaining the password\n\t */\n\tprivate void establishAdminPassword() throws IOException {\n\t\tfor (;;) {\n\t\t\tadminPasswordData = requestPassword(\"Set admin(\" + connectingUserName + \") password:\");\n\t\t\tif (adminPasswordData == null) {\n\t\t\t\tthrow new IOException(\"Unable to obtain password\");\n\t\t\t}\n\t\t\tchar[] repeatPass = requestPassword(\"Please re-enter password:\");\n\t\t\tboolean match = comparePasswordData(adminPasswordData, repeatPass);\n\t\t\tclearPasswordData(repeatPass);\n\t\t\tif (match) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcleanupPasswordData();\n\t\t\tSystem.out.println(\"Passwords do not match\");\n\t\t}\n\t\tpasswordFile = Files\n\t\t\t\t.createTempFile(\"bsim\", \".dat\",\n\t\t\t\t\tPosixFilePermissions\n\t\t\t\t\t\t\t.asFileAttribute(PosixFilePermissions.fromString(\"rw-------\")))\n\t\t\t\t.toFile();\n\t\tFileWriter writer = new FileWriter(passwordFile);\n\t\twriter.write(adminPasswordData);\n\t\twriter.close();","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java#L453-L489","documentation":"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.","triggerScenarios":"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.","commonSituations":"CI/CD pipelines, daemon/service contexts, SSH non-TTY sessions, or stdin redirected from a file/pipe.","solutions":["Run the command in an interactive terminal with a real TTY.","Avoid piping or redirecting stdin so the prompt can read input.","For automation, pre-initialize the server interactively or use a supported non-interactive provisioning path."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Detect a TTY / readable console before attempting interactive password setup.\nif (System.console() == null) {\n    System.err.println(\"No interactive console available; cannot set admin password here.\");\n    System.err.println(\"Run this command from a real terminal.\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    launchable.establishAdminPassword();\n} catch (IOException e) {\n    if (e.getMessage().equals(\"Unable to obtain password\")) {\n        System.err.println(\"Password input unavailable. Run in an interactive terminal.\");\n    }\n    throw e;\n}","preventionTips":["Check System.console() != null before relying on interactive prompts.","Do not pipe/redirect stdin for commands that need passwords.","Initialize servers interactively first, then automate against them."],"tags":["cli","security","password","environment","postgresql"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}