NationalSecurityAgency/ghidra · error · IOException
Bad map field in pg_ident.conf entry
Error message
Bad map field in pg_ident.conf entry
What it means
Thrown by ServerConfig.IdentEntry.parse when the first non-whitespace character of a pg_ident.conf line is a double-quote. The map-name field must be an unquoted token; a leading quote is treated as malformed because the parser expects a bare map name here.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ServerConfig.java:378
public boolean matchRole(String mName, String rName) {
return mapName.equals(mName) && roleName.equals(rName);
}
/**
* Parse a single line from the pg_ident.conf file and recover the
* map name, system name, and role
* @param line is the incoming of text
* @return true if the line is an ident entry, false if it is a comment
* @throws IOException if the text cannot be parsed
*/
public boolean parse(String line) throws IOException {
int pos = 0;
pos = skipWhiteSpace(pos, line);
if (pos >= line.length()) {
return false; // Blank line, treat as comment
}
if (line.charAt(pos) == '"') {
throw new IOException("Bad map field in pg_ident.conf entry");
}
if (line.charAt(pos) == '#') {
return false; // Return false to indicate comment
}
int endpos = parseField(pos, line);
mapName = line.substring(pos, endpos);
pos = skipWhiteSpace(endpos, line);
if (pos >= line.length()) {
throw new IOException("Missing system-name in pg_ident.conf entry");
}
else if (line.charAt(pos) == '"') {
systemNameIsQuoted = true;
endpos = parseDoubleQuote(pos, line);
if (line.charAt(endpos - 1) != '"') {
throw new IOException("Entry missing ending quote in pg_ident.conf");
}
systemName = line.substring(pos + 1, endpos - 1); // Strip quotesView on GitHub (pinned to d5f144c24d)
Solutions
- Remove the leading quote from the map-name field; the map name must be an unquoted token.
- Use the form: mapname systemname username (only system-name and role may be quoted if they contain spaces).
- Validate that the first field does not start with '"' before saving the file.
Example fix
// before (pg_ident.conf line) "mymap" myuser myrole // after mymap myuser myrole
Defensive patterns
Strategy: validation
Validate before calling
// Reject a quoted map-name before parsing pg_ident.conf entry
String trimmed = line.trim();
int i = 0;
while (i < trimmed.length() && Character.isWhitespace(trimmed.charAt(i))) i++;
if (i < trimmed.length() && trimmed.charAt(i) == '"') {
throw new IllegalArgumentException(
"pg_ident.conf map-name must be unquoted: " + line);
}
identEntry.parse(line); Try / catch
try {
identEntry.parse(line);
} catch (IOException e) {
if (e.getMessage().contains("Bad map field")) {
log.error("pg_ident.conf map-name must not be quoted: '{}'", line);
}
throw e;
} Prevention
- Keep the map-name field in pg_ident.conf as a bare unquoted token.
- Only the system-name and role fields may be quoted (and only when they contain spaces).
- Lint pg_ident.conf entries for unexpected leading quotes.
When it happens
Trigger: Parsing a pg_ident.conf entry line whose map-name field begins with '"' (e.g. '"mymap" system user'). The parser rejects quoting on the first field.
Common situations: Over-quoting fields when editing pg_ident.conf by hand. Copying a quoted format from another config style into pg_ident.conf. Misunderstanding which fields may be quoted in this file.
Related errors
- Missing system-name in pg_ident.conf entry
- Entry missing ending quote in pg_ident.conf
- Missing role in pg_ident.conf entry
- Parsing error
- PostgreSQL pg_ctl command not found: {}
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/e8892f02ff9a8b9f.
Report an issue: GitHub.