{"record":{"id":"27019eed22ce002d","repo":"NationalSecurityAgency/ghidra","slug":"cannot-modify-settings-on-running-server","errorCode":null,"errorMessage":"Cannot modify settings on running server","messagePattern":"Cannot modify settings on running server","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java","lineNumber":1281,"sourceCode":"\t * @throws InterruptedException if the postgres installation cannot be found\n\t * @throws SAXException if the {@link #tuneConfig(File, File, File, File, File)} call fails\n\t * @throws GeneralSecurityException if there is no Distinguished Name supplied\n\t */\n\tprivate void changeAuthCommand()\n\t\t\tthrows IOException, InterruptedException, SAXException, GeneralSecurityException {\n\t\tdiscoverPostgresInstall();\n\t\tFile configFile = new File(dataDirectory, POSTGRES_CONFIGFILE);\n\t\tFile hbaFile = new File(dataDirectory, POSTGRES_CONNECTFILE);\n\t\tif (!configFile.exists()) {\n\t\t\tthrow new IOException(\"Data directory not initialized: run \\\"bsim_ctl start\\\" first\");\n\t\t}\n\t\tint requestedLocalAuth = localAuthentication;\n\t\tint requestedHostAuth = hostAuthentication;\n\t\tint requestedPort = port;\n\t\tport = -1;\n\t\trecoverConfigurationParameters(configFile, hbaFile);\n\t\tif (isServerRunning()) {\n\t\t\tthrow new IOException(\"Cannot modify settings on running server\");\n\t\t}\n\t\tif ((!authConfigPresent || (requestedHostAuth == hostAuthentication &&\n\t\t\trequestedLocalAuth == localAuthentication)) &&\n\t\t\t(requestedPort == -1 || requestedPort == port)) {\n\t\t\tSystem.out.println(\"No changes to make\");\n\t\t\treturn;\n\t\t}\n\n\t\tFile serverConfigFile = Application.getModuleDataFile(\"serverconfig.xml\").getFile(false);\n\t\tFile configCopy = new File(dataDirectory, POSTGRES_CONFIGFILE + \".orig\");\n\t\tif (!configCopy.exists()) {\n\t\t\tthrow new IOException(\n\t\t\t\t\"Original configuration file not present: \" + configCopy.getAbsolutePath());\n\t\t}\n\t\tFile hbaCopy = new File(dataDirectory, POSTGRES_CONNECTFILE + \".orig\");\n\t\tif (!hbaCopy.exists()) {\n\t\t\tthrow new IOException(\n\t\t\t\t\"Original connection file not present: \" + hbaCopy.getAbsolutePath());","sourceCodeStart":1263,"sourceCodeEnd":1299,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java#L1263-L1299","documentation":"Thrown by changeAuthCommand() after recoverConfigurationParameters() if isServerRunning() returns true. BSim deliberately refuses to rewrite postgresql.conf and pg_hba.conf while the PostgreSQL server process is active, because changes would not take effect and could corrupt the live state. The IOException tells the operator to stop the server first.","triggerScenarios":"Running 'bsim_ctl changeauth <datadir>' while the PostgreSQL BSim server process for that datadir is still running.","commonSituations":"Operator forgets to stop the server before reconfiguring; a previous 'bsim_ctl stop' failed or was skipped; a background service manager auto-restarted the server.","solutions":["Stop the server with 'bsim_ctl stop <datadir>' and confirm it is down with 'bsim_ctl status <datadir>'.","If stop fails, use 'bsim_ctl stop <datadir> --force' to terminate the process.","Re-run 'bsim_ctl changeauth <datadir>' once status confirms the server is stopped."],"exampleFix":"# before (server still running)\nbsim_ctl changeauth /opt/bsim/data --auth password\n# after (stop first, verify, then change)\nbsim_ctl stop /opt/bsim/data\nbsim_ctl status /opt/bsim/data\nbsim_ctl changeauth /opt/bsim/data --auth password","handlingStrategy":"try-catch","validationCode":"// Confirm the server is stopped before reconfiguring:\nif (bsimControl.isServerRunning(dataDirectory)) {\n    throw new IllegalStateException(\"Stop the server before changing auth settings\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    bsimControl.run(new String[]{\"changeauth\", dataDir, \"--auth\", \"password\"});\n} catch (IOException e) {\n    if (e.getMessage().contains(\"running server\")) {\n        bsimControl.run(new String[]{\"stop\", dataDir});\n        bsimControl.run(new String[]{\"changeauth\", dataDir, \"--auth\", \"password\"});\n    } else {\n        throw e;\n    }\n}","preventionTips":["Always stop the BSim server before changeauth.","Verify server status with 'bsim_ctl status' as part of reconfiguration scripts.","Automate stop-before-change sequencing in deployment scripts."],"tags":["bsim","postgres","cli","configuration"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}