Class ServerConfig

java.lang.Object
ghidra.features.bsim.query.ServerConfig

public class ServerConfig extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addKey(String key, String value)
    Add a key/value pair directly into the configuration file
     
     
    Retrieve the value associated with a particular key from a (parsed) configuration file
    void
    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 preserved
    void
    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 preserved
    static void
    patchIdent(File inFile, File outFile, String mapName, String systemName, String roleName, boolean addUser)
    Add/remove an identify entry to pg_ident.conf
    void
    Read a set of key/value pairs and connection entries to use for patching, from an XML file
    void
    scanConfig(File inFile)
    Parse a configuration file
    void
    scanConnect(File inFile)
    Read in all the entries of the connection file
    void
     
    void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ServerConfig

      public ServerConfig()
  • Method Details

    • restoreXml

      public void restoreXml(XmlPullParser parser)
      Read a set of key/value pairs and connection entries to use for patching, from an XML file
      Parameters:
      parser - the XML parser
    • patchConfig

      public void patchConfig(File inFile, File outFile) throws IOException
      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 read
      outFile - the new file to write
      Throws:
      IOException - if the files cannot be read from or written to
    • patchConnect

      public void patchConnect(File inFile, File outFile) throws IOException
      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 read
      outFile - 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 modify
      outFile - becomes the modified copy of pg_ident.conf
      mapName - is the map being modified
      systemName - 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

      public void addKey(String key, String value)
      Add a key/value pair directly into the configuration file
      Parameters:
      key - the key to add/update
      value - the value to insert
    • getValue

      public String getValue(String key)
      Retrieve the value associated with a particular key from a (parsed) configuration file
      Parameters:
      key - identifies the value to return
      Returns:
      the value
    • scanConfig

      public void scanConfig(File inFile) throws IOException
      Parse a configuration file
      Parameters:
      inFile - is the path to the file
      Throws:
      IOException - if the file cannot be read
    • scanConnect

      public void scanConnect(File inFile) throws IOException
      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

      public String getLocalAuthentication()
    • setLocalAuthentication

      public void setLocalAuthentication(String val, String options)
    • getHostAuthentication

      public String getHostAuthentication()
    • setHostAuthentication

      public void setHostAuthentication(String val, String options)