@@ -2792,21 +2792,21 @@ parse_ident_line(TokenizedAuthLine *tok_line, int elevel)
27922792token = linitial (tokens );
27932793
27942794/* Copy the ident user token */
2795- parsedline -> token = copy_auth_token (token );
2795+ parsedline -> system_user = copy_auth_token (token );
27962796
27972797/* Get the PG rolename token */
27982798field = lnext (tok_line -> fields ,field );
27992799IDENT_FIELD_ABSENT (field );
28002800tokens = lfirst (field );
28012801IDENT_MULTI_VALUE (tokens );
28022802token = linitial (tokens );
2803- parsedline -> pg_role = pstrdup (token -> string );
2803+ parsedline -> pg_user = pstrdup (token -> string );
28042804
28052805/*
28062806 * Now that the field validation is done, compile a regex from the user
28072807 * token, if necessary.
28082808 */
2809- if (regcomp_auth_token (parsedline -> token ,file_name ,line_num ,
2809+ if (regcomp_auth_token (parsedline -> system_user ,file_name ,line_num ,
28102810err_msg ,elevel ))
28112811{
28122812/* err_msg includes the error to report */
@@ -2819,12 +2819,12 @@ parse_ident_line(TokenizedAuthLine *tok_line, int elevel)
28192819/*
28202820 *Process one line from the parsed ident config lines.
28212821 *
2822- *Compare input parsed ident line to the needed map,pg_role andident_user .
2822+ *Compare input parsed ident line to the needed map,pg_user andsystem_user .
28232823 **found_p and *error_p are set according to our results.
28242824 */
28252825static void
28262826check_ident_usermap (IdentLine * identLine ,const char * usermap_name ,
2827- const char * pg_role ,const char * ident_user ,
2827+ const char * pg_user ,const char * system_user ,
28282828bool case_insensitive ,bool * found_p ,bool * error_p )
28292829{
28302830* found_p = false;
@@ -2835,7 +2835,7 @@ check_ident_usermap(IdentLine *identLine, const char *usermap_name,
28352835return ;
28362836
28372837/* Match? */
2838- if (token_has_regexp (identLine -> token ))
2838+ if (token_has_regexp (identLine -> system_user ))
28392839{
28402840/*
28412841 * Process the system username as a regular expression that returns
@@ -2845,27 +2845,27 @@ check_ident_usermap(IdentLine *identLine, const char *usermap_name,
28452845int r ;
28462846regmatch_t matches [2 ];
28472847char * ofs ;
2848- char * regexp_pgrole ;
2848+ char * expanded_pg_user ;
28492849
2850- r = regexec_auth_token (ident_user ,identLine -> token ,2 ,matches );
2850+ r = regexec_auth_token (system_user ,identLine -> system_user ,2 ,matches );
28512851if (r )
28522852{
28532853char errstr [100 ];
28542854
28552855if (r != REG_NOMATCH )
28562856{
28572857/* REG_NOMATCH is not an error, everything else is */
2858- pg_regerror (r ,identLine -> token -> regex ,errstr ,sizeof (errstr ));
2858+ pg_regerror (r ,identLine -> system_user -> regex ,errstr ,sizeof (errstr ));
28592859ereport (LOG ,
28602860(errcode (ERRCODE_INVALID_REGULAR_EXPRESSION ),
28612861errmsg ("regular expression match for \"%s\" failed: %s" ,
2862- identLine -> token -> string + 1 ,errstr )));
2862+ identLine -> system_user -> string + 1 ,errstr )));
28632863* error_p = true;
28642864}
28652865return ;
28662866}
28672867
2868- if ((ofs = strstr (identLine -> pg_role ,"\\1" ))!= NULL )
2868+ if ((ofs = strstr (identLine -> pg_user ,"\\1" ))!= NULL )
28692869{
28702870int offset ;
28712871
@@ -2875,7 +2875,7 @@ check_ident_usermap(IdentLine *identLine, const char *usermap_name,
28752875ereport (LOG ,
28762876(errcode (ERRCODE_INVALID_REGULAR_EXPRESSION ),
28772877errmsg ("regular expression \"%s\" has no subexpressions as requested by backreference in \"%s\"" ,
2878- identLine -> token -> string + 1 ,identLine -> pg_role )));
2878+ identLine -> system_user -> string + 1 ,identLine -> pg_user )));
28792879* error_p = true;
28802880return ;
28812881}
@@ -2884,18 +2884,18 @@ check_ident_usermap(IdentLine *identLine, const char *usermap_name,
28842884 * length: original length minus length of \1 plus length of match
28852885 * plus null terminator
28862886 */
2887- regexp_pgrole = palloc0 (strlen (identLine -> pg_role )- 2 + (matches [1 ].rm_eo - matches [1 ].rm_so )+ 1 );
2888- offset = ofs - identLine -> pg_role ;
2889- memcpy (regexp_pgrole ,identLine -> pg_role ,offset );
2890- memcpy (regexp_pgrole + offset ,
2891- ident_user + matches [1 ].rm_so ,
2887+ expanded_pg_user = palloc0 (strlen (identLine -> pg_user )- 2 + (matches [1 ].rm_eo - matches [1 ].rm_so )+ 1 );
2888+ offset = ofs - identLine -> pg_user ;
2889+ memcpy (expanded_pg_user ,identLine -> pg_user ,offset );
2890+ memcpy (expanded_pg_user + offset ,
2891+ system_user + matches [1 ].rm_so ,
28922892matches [1 ].rm_eo - matches [1 ].rm_so );
2893- strcat (regexp_pgrole ,ofs + 2 );
2893+ strcat (expanded_pg_user ,ofs + 2 );
28942894}
28952895else
28962896{
28972897/* no substitution, so copy the match */
2898- regexp_pgrole = pstrdup (identLine -> pg_role );
2898+ expanded_pg_user = pstrdup (identLine -> pg_user );
28992899}
29002900
29012901/*
@@ -2904,15 +2904,15 @@ check_ident_usermap(IdentLine *identLine, const char *usermap_name,
29042904 */
29052905if (case_insensitive )
29062906{
2907- if (pg_strcasecmp (regexp_pgrole , pg_role )== 0 )
2907+ if (pg_strcasecmp (expanded_pg_user , pg_user )== 0 )
29082908* found_p = true;
29092909}
29102910else
29112911{
2912- if (strcmp (regexp_pgrole , pg_role )== 0 )
2912+ if (strcmp (expanded_pg_user , pg_user )== 0 )
29132913* found_p = true;
29142914}
2915- pfree (regexp_pgrole );
2915+ pfree (expanded_pg_user );
29162916
29172917return ;
29182918}
@@ -2921,14 +2921,14 @@ check_ident_usermap(IdentLine *identLine, const char *usermap_name,
29212921/* Not regular expression, so make complete match */
29222922if (case_insensitive )
29232923{
2924- if (pg_strcasecmp (identLine -> pg_role , pg_role )== 0 &&
2925- pg_strcasecmp (identLine -> token -> string ,ident_user )== 0 )
2924+ if (pg_strcasecmp (identLine -> pg_user , pg_user )== 0 &&
2925+ pg_strcasecmp (identLine -> system_user -> string ,system_user )== 0 )
29262926* found_p = true;
29272927}
29282928else
29292929{
2930- if (strcmp (identLine -> pg_role , pg_role )== 0 &&
2931- strcmp (identLine -> token -> string ,ident_user )== 0 )
2930+ if (strcmp (identLine -> pg_user , pg_user )== 0 &&
2931+ strcmp (identLine -> system_user -> string ,system_user )== 0 )
29322932* found_p = true;
29332933}
29342934}
@@ -2938,20 +2938,20 @@ check_ident_usermap(IdentLine *identLine, const char *usermap_name,
29382938/*
29392939 *Scan the (pre-parsed) ident usermap file line by line, looking for a match
29402940 *
2941- *See if the user with ident username "auth_user " is allowed to act
2942- *as Postgres user "pg_role " according to usermap "usermap_name".
2941+ *See if thesystem user with ident username "system_user " is allowed to act as
2942+ *Postgres user "pg_user " according to usermap "usermap_name".
29432943 *
29442944 *Special case: Usermap NULL, equivalent to what was previously called
29452945 *"sameuser" or "samerole", means don't look in the usermap file.
2946- *That's an implied map wherein "pg_role " must be identical to
2947- *"auth_user " in order to be authorized.
2946+ *That's an implied map wherein "pg_user " must be identical to
2947+ *"system_user " in order to be authorized.
29482948 *
29492949 *Iff authorized, return STATUS_OK, otherwise return STATUS_ERROR.
29502950 */
29512951int
29522952check_usermap (const char * usermap_name ,
2953- const char * pg_role ,
2954- const char * auth_user ,
2953+ const char * pg_user ,
2954+ const char * system_user ,
29552955bool case_insensitive )
29562956{
29572957bool found_entry = false,
@@ -2961,17 +2961,17 @@ check_usermap(const char *usermap_name,
29612961{
29622962if (case_insensitive )
29632963{
2964- if (pg_strcasecmp (pg_role , auth_user )== 0 )
2964+ if (pg_strcasecmp (pg_user , system_user )== 0 )
29652965return STATUS_OK ;
29662966}
29672967else
29682968{
2969- if (strcmp (pg_role , auth_user )== 0 )
2969+ if (strcmp (pg_user , system_user )== 0 )
29702970return STATUS_OK ;
29712971}
29722972ereport (LOG ,
29732973(errmsg ("provided user name (%s) and authenticated user name (%s) do not match" ,
2974- pg_role , auth_user )));
2974+ pg_user , system_user )));
29752975return STATUS_ERROR ;
29762976}
29772977else
@@ -2981,7 +2981,7 @@ check_usermap(const char *usermap_name,
29812981foreach (line_cell ,parsed_ident_lines )
29822982{
29832983check_ident_usermap (lfirst (line_cell ),usermap_name ,
2984- pg_role , auth_user ,case_insensitive ,
2984+ pg_user , system_user ,case_insensitive ,
29852985& found_entry ,& error );
29862986if (found_entry || error )
29872987break ;
@@ -2991,7 +2991,7 @@ check_usermap(const char *usermap_name,
29912991{
29922992ereport (LOG ,
29932993(errmsg ("no match in usermap \"%s\" for user \"%s\" authenticated as \"%s\"" ,
2994- usermap_name ,pg_role , auth_user )));
2994+ usermap_name ,pg_user , system_user )));
29952995}
29962996return found_entry ?STATUS_OK :STATUS_ERROR ;
29972997}
@@ -3073,7 +3073,7 @@ load_ident(void)
30733073foreach (parsed_line_cell ,new_parsed_lines )
30743074{
30753075newline = (IdentLine * )lfirst (parsed_line_cell );
3076- free_auth_token (newline -> token );
3076+ free_auth_token (newline -> system_user );
30773077}
30783078MemoryContextDelete (ident_context );
30793079return false;
@@ -3085,7 +3085,7 @@ load_ident(void)
30853085foreach (parsed_line_cell ,parsed_ident_lines )
30863086{
30873087newline = (IdentLine * )lfirst (parsed_line_cell );
3088- free_auth_token (newline -> token );
3088+ free_auth_token (newline -> system_user );
30893089}
30903090}
30913091if (parsed_ident_context != NULL )