NationalSecurityAgency/ghidra · error · IOException
Error copying original configuration file
Error message
Error copying original configuration file
What it means
Thrown by initializeDataDirectory() when configFile.renameTo(configCopy) fails — i.e. postgresql.conf could not be moved to postgresql.conf.orig so BSim can write its tailored config. Java's renameTo fails across filesystems, on missing files, or on permission/lock issues.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java:921
checkCertAuthorityFile();
}
command.add("-D");
command.add(dataDirectory.getAbsolutePath());
int res = runCommand(null, command, loadLibraryVar, loadLibraryValue);
if (res != 0) {
throw new IOException("Error initializing postgres database");
}
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-View on GitHub (pinned to d5f144c24d)
Solutions
- Check filesystem permissions and ownership of postgresql.conf in the data directory.
- Ensure the data directory is on a single local filesystem (avoid NFS rename pitfalls).
- If a previous run left postgresql.conf.orig, restore the original layout before retrying.
- Free any process holding the file open and retry the command.
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight filesystem suitability for the rename BSim performs.
File conf = new File(dataDir, "postgresql.conf");
File copy = new File(dataDir, "postgresql.conf.orig");
if (conf.exists() && copy.exists()) {
throw new IllegalStateException("Stale postgresql.conf.orig already present; clean up first");
} Type guard
public boolean canAtomicallyRenameIn(File dir) {
return dir != null && dir.isDirectory()
&& dir.toPath().getFileSystem().equals(dir.toPath().toAbsolutePath().getFileSystem());
} Try / catch
try {
bsimControl.start(args);
} catch (IOException e) {
if ("Error copying original configuration file".equals(e.getMessage())) {
throw new UserFacingException("Cannot move postgresql.conf aside; check perms/fs", e);
}
throw e;
} Prevention
- Keep the BSim data directory on a single local filesystem.
- Ensure the running user owns the data directory and its files.
- Clean up .orig files from interrupted runs before retrying.
When it happens
Trigger: After a successful pg_ctl init, BSim moves postgresql.conf aside; the rename returns false and BSim aborts the whole initialization.
Common situations: Data directory on a filesystem where rename crosses mount boundaries; postgresql.conf held open/locked by another process; permissions changed between init and rename; antivirus/SAN/NFS rename semantics; the file was already moved by a previous interrupted run.
Related errors
- Error copying original connection file
- PKI authentication requested, but certificate authority file
- {} is not a valid certification authority
- Distinguished name option (--dn) required for {}
- Missing ident file: {}
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/fe3fd2eb57049c46.
Report an issue: GitHub.