Package ghidra.features.bsim.query
Class ServerConfig
java.lang.Object
ghidra.features.bsim.query.ServerConfig
Class for modifying the PostgreSQL configuration files describing
the main server settings (postgresql.conf)
the connection settings (pg_hba.conf)
the identification map (pg_ident.conf)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a key/value pair directly into the configuration fileRetrieve the value associated with a particular key from a (parsed) configuration filevoid
patchConfig
(File inFile, File outFile) Given a set of key/value pairs, established via restoreXml or manually entered via addKey, read in an existing configuration file, and write out an altered form, where: 1) Keys matching something in the keyValue map have their value altered to match the map 2) Keys that don't match anything in the map, are output unaltered 3) Comments, both entire line and those coming after key/value pairs, are preservedvoid
patchConnect
(File inFile, File outFile) Read in a connection file and write out an altered version of the file where: 1) Any entry that matches something in connectSet, has its authentication method altered 2) Any entry that does not match into connectSet is commented out in the output 3) Entire line comments are preservedstatic void
patchIdent
(File inFile, File outFile, String mapName, String systemName, String roleName, boolean addUser) Add/remove an identify entry to pg_ident.confvoid
restoreXml
(XmlPullParser parser) Read a set of key/value pairs and connection entries to use for patching, from an XML filevoid
scanConfig
(File inFile) Parse a configuration filevoid
scanConnect
(File inFile) Read in all the entries of the connection filevoid
setHostAuthentication
(String val, String options) void
setLocalAuthentication
(String val, String options)
-
Constructor Details
-
ServerConfig
public ServerConfig()
-
-
Method Details
-
restoreXml
Read a set of key/value pairs and connection entries to use for patching, from an XML file- Parameters:
parser
- the XML parser
-
patchConfig
Given a set of key/value pairs, established via restoreXml or manually entered via addKey, read in an existing configuration file, and write out an altered form, where: 1) Keys matching something in the keyValue map have their value altered to match the map 2) Keys that don't match anything in the map, are output unaltered 3) Comments, both entire line and those coming after key/value pairs, are preserved- Parameters:
inFile
- the file to readoutFile
- the new file to write- Throws:
IOException
- if the files cannot be read from or written to
-
patchConnect
Read in a connection file and write out an altered version of the file where: 1) Any entry that matches something in connectSet, has its authentication method altered 2) Any entry that does not match into connectSet is commented out in the output 3) Entire line comments are preserved- Parameters:
inFile
- the file to readoutFile
- the new file to write- Throws:
IOException
- if the files cannot be read from or written to
-
patchIdent
public static void patchIdent(File inFile, File outFile, String mapName, String systemName, String roleName, boolean addUser) throws IOException Add/remove an identify entry to pg_ident.conf- Parameters:
inFile
- is a copy of pg_ident.conf to modifyoutFile
- becomes the modified copy of pg_ident.confmapName
- is the map being modifiedsystemName
- is the system name (map from)roleName
- is the database role (map to)addUser
- is true if the map entry is to be added, false if the entry should be removed- Throws:
IOException
- if the file cannot be read from or written to
-
addKey
Add a key/value pair directly into the configuration file- Parameters:
key
- the key to add/updatevalue
- the value to insert
-
getValue
Retrieve the value associated with a particular key from a (parsed) configuration file- Parameters:
key
- identifies the value to return- Returns:
- the value
-
scanConfig
Parse a configuration file- Parameters:
inFile
- is the path to the file- Throws:
IOException
- if the file cannot be read
-
scanConnect
Read in all the entries of the connection file- Parameters:
inFile
- the file to read in- Throws:
IOException
- if the file cannot be read/parsed
-
getLocalAuthentication
-
setLocalAuthentication
-
getHostAuthentication
-
setHostAuthentication
-