NationalSecurityAgency/ghidra · error · IOException
Error copying original connection file
Error message
Error copying original connection file
What it means
Thrown by initializeDataDirectory() when hbaFile.renameTo(hbaCopy) fails — pg_hba.conf could not be moved to pg_hba.conf.orig. BSim rewrites pg_hba.conf to enforce the chosen auth method (trust/password/cert), so a failed rename halts initialization.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java:928
}
File configCopy = new File(dataDirectory, POSTGRES_CONFIGFILE + ".orig");
if (hostAuthentication == AUTHENTICATION_PKI || localAuthentication == AUTHENTICATION_PKI) {
File rootCA = new File(dataDirectory, POSTGRES_ROOTCA);
FileUtilities.copyFile(certAuthorityFile, rootCA, false, null);
addCertificateName(connectingUserName);
}
// Move the original configuration file
if (!configFile.renameTo(configCopy)) {
throw new IOException("Error copying original configuration file");
}
File hbaCopy = new File(dataDirectory, POSTGRES_CONNECTFILE + ".orig");
// Move the original connection file
if (!hbaFile.renameTo(hbaCopy)) {
throw new IOException("Error copying original connection file");
}
// Patch the configuration
tuneConfig(configCopy, configFile, hbaCopy, hbaFile, serverConfigFile);
System.out.println("Generating servers SSL certificate");
generateSelfSignedCertificate(new File(dataDirectory, "server.crt"),
new File(dataDirectory, "server.key"));
}
/**
* Scan the PostgreSQL data directory from the command-line
* Make sure the directory exists and establish the File object -dataDirectory-
* @param params are the command-line arguments
* @param slot is the position to retrieve the data directory argument
* @throws IllegalArgumentException if the data directory is invalid
* @throws IOException if the canonical file cannot be retrieved
*/
private void scanDataDirectory(String[] params, int slot)
throws IllegalArgumentException, IOException {View on GitHub (pinned to d5f144c24d)
Solutions
- Verify pg_hba.conf exists in the data directory and is writable/owned by the running user.
- Ensure no postgres process is running against the data directory during init.
- Keep the data directory on one local filesystem.
- Clean up any half-applied .orig files from a previous failed run before retrying.
Defensive patterns
Strategy: try-catch
Validate before calling
File hba = new File(dataDir, "pg_hba.conf");
File hbaOrig = new File(dataDir, "pg_hba.conf.orig");
if (hba.exists() && !hba.canWrite()) {
throw new IllegalStateException("pg_hba.conf not writable; rename will fail");
} Type guard
public boolean hbaReadyForPatch(File dir) {
File hba = new File(dir, "pg_hba.conf");
return hba.isFile() && hba.canWrite() && dir.canWrite();
} Try / catch
try {
bsimControl.start(args);
} catch (IOException e) {
if ("Error copying original connection file".equals(e.getMessage())) {
throw new UserFacingException("Cannot move pg_hba.conf aside; check perms/fs", e);
}
throw e;
} Prevention
- Make sure no postgres is running against the dir during init.
- Avoid NFS/network filesystems for the data dir where rename semantics differ.
- Remove half-applied .orig files from prior failed inits.
When it happens
Trigger: Same renameTo() failure pattern as the config-file move, but for the connection/auth file pg_hba.conf, immediately after the postgresql.conf move.
Common situations: Cross-filesystem data directory; pg_hba.conf locked by a running postgres or monitoring tool; permission/ownership mismatch; leftover .orig from an interrupted init.
Related errors
- PKI authentication requested, but certificate authority file
- {} is not a valid certification authority
- Distinguished name option (--dn) required for {}
- Error copying original configuration file
- Missing ident file: {}
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/932cbc7d61caf0d3.
Report an issue: GitHub.