{"record":{"id":"183fc113e1ea7167","repo":"NationalSecurityAgency/ghidra","slug":"missing-ident-file","errorCode":null,"errorMessage":"Missing ident file: {}","messagePattern":"Missing ident file: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java","lineNumber":1123,"sourceCode":"\t\tcommand.add(dataDirectory.getAbsolutePath());\n\t\tcommand.add(\"-s\");\n\t\tint res = runCommand(null, command, loadLibraryVar, loadLibraryValue);\n\t\tif (res != 0) {\n\t\t\tthrow new IOException(\"Error creating new user\");\n\t\t}\n\t}\n\n\t/**\n\t * Update the PostgreSQL identity map (pg_ident.conf) adding a map from\n\t * the currently active -commonName- to -username-\n\t * @param username the user name to add\n\t * @throws IOException if the postgres ident file is invalid\n\t */\n\tprivate void addCertificateName(String username) throws IOException {\n\t\tFile identFile = new File(dataDirectory, POSTGRES_IDENTFILE);\n\t\tFile copyFile = new File(dataDirectory, POSTGRES_IDENTFILE + \".copy\");\n\t\tif (!identFile.isFile()) {\n\t\t\tthrow new IOException(\"Missing ident file: \" + identFile.getAbsolutePath());\n\t\t}\n\t\tServerConfig.patchIdent(identFile, copyFile, POSTGRES_MAP_IDENTIFIER, commonName, username,\n\t\t\ttrue);\n\t\tFileUtilities.copyFile(copyFile, identFile, false, null);\n\t}\n\n\t/**\n\t * Add a new user to the currently running server on the local host.\n\t * A connection is established, using the local interface, and the \"CREATE ROLE\" command\n\t * is executed. If the server is configured to require certificate authentication on\n\t * remote connections, the user must have provided a distinguished name associated with\n\t * the certificate, which is then mapped to the new username. \n\t * @throws GeneralSecurityException if using PKI and no Distinguished Name is found\n\t * @throws Exception if there's a problem initializing the Application of discovering the Postgres installation\n\t */\n\tprivate void addUserCommand() throws GeneralSecurityException, Exception {\n\t\tdiscoverPostgresInstall();\n\t\tinitializeDataDirectory();\t\t\t// Needed to pick up authentication settings","sourceCodeStart":1105,"sourceCodeEnd":1141,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java#L1105-L1141","documentation":"Thrown by addCertificateName() (init flow) when pg_ident.conf is not a regular file in the data directory. BSim patches pg_ident.conf to map the certificate's common name to the connecting user; without the file the mapping cannot be written.","triggerScenarios":"During initializeDataDirectory() PKI setup, `new File(dataDirectory, POSTGRES_IDENTFILE).isFile()` is false right after postgres init.","commonSituations":"Postgres version/config that does not generate pg_ident.conf by default; the file was deleted; permissions prevent seeing the file; partial/failed earlier init left the data directory incomplete.","solutions":["Confirm pg_ident.conf exists in the data directory; create an empty one if postgres didn't (`touch <dataDir>/pg_ident.conf`).","Re-initialize the data directory cleanly if it is incomplete.","Check read permissions on the data directory.","Ensure the postgres major version is one BSim expects (generates pg_ident.conf)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"File ident = new File(dataDir, \"pg_ident.conf\");\nif (!ident.isFile()) {\n    // create an empty map file so BSim can patch it, if appropriate for your setup\n    ident.createNewFile();\n}","typeGuard":"public boolean identFileExists(File dir) {\n    return new File(dir, \"pg_ident.conf\").isFile();\n}","tryCatchPattern":"try {\n    bsimControl.start(args);\n} catch (IOException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Missing ident file:\")) {\n        throw new UserFacingException(\"pg_ident.conf missing in data dir; (re)initialize the cluster\", e);\n    }\n    throw e;\n}","preventionTips":["Use a postgres version that generates pg_ident.conf on init.","Avoid deleting pg_ident.conf from the data directory.","Re-init the cluster if the data directory is incomplete."],"tags":["postgresql","pki","authentication","file-system","bsim","cli"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}