hba-keywords.diff
text/plain
Filename: hba-keywords.diff
Type: text/plain
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: context
| File | + | − |
|---|---|---|
| src/backend/libpq/hba.c | 30 | 0 |
*** a/src/backend/libpq/hba.c
--- b/src/backend/libpq/hba.c
***************
*** 855,861 **** parse_hba_line(List *line, int line_num, HbaLine *parsedline)
line_num, HbaFileName)));
return false;
}
! parsedline->database = pstrdup(lfirst(line_item));
/* Get the role. */
line_item = lnext(line_item);
--- 855,873 ----
line_num, HbaFileName)));
return false;
}
! token = pstrdup(lfirst(line_item));
!
! /* Filter out inapplicable keywords for the database field. */
! if (token[strlen(token) - 1] == '\n'
! && strcmp(token, "all\n") != 0
! && strcmp(token, "sameuser\n") != 0
! && strcmp(token, "samerole\n") != 0
! && strcmp(token, "samegroup\n") != 0
! && strcmp(token, "replication\n") != 0)
! {
! token[strlen(token) - 1] = '\0';
! }
! parsedline->database = token;
/* Get the role. */
line_item = lnext(line_item);
***************
*** 868,874 **** parse_hba_line(List *line, int line_num, HbaLine *parsedline)
line_num, HbaFileName)));
return false;
}
! parsedline->role = pstrdup(lfirst(line_item));
if (parsedline->conntype != ctLocal)
{
--- 880,894 ----
line_num, HbaFileName)));
return false;
}
! token = pstrdup(lfirst(line_item));
!
! /* Filter out inapplicable keywords for the role field. */
! if (token[strlen(token) - 1] == '\n'
! && strcmp(token, "all\n") != 0)
! {
! token[strlen(token) - 1] = '\0';
! }
! parsedline->role = token;
if (parsedline->conntype != ctLocal)
{
***************
*** 904,909 **** parse_hba_line(List *line, int line_num, HbaLine *parsedline)
--- 924,937 ----
/* need a modifiable copy of token */
token = pstrdup(token);
+ /*
+ * Filter out any remaining keywords, as the only valid keywords
+ * for this context ('samehost' and 'samenet') have already been
+ * handled above.
+ */
+ if (token[strlen(token) - 1] = '\n')
+ token[strlen(token) - 1] = '\0';
+
/* Check if it has a CIDR suffix and if so isolate it */
cidr_slash = strchr(token, '/');
if (cidr_slash)