Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc196842

Browse files
committed
Refactor hba_authname
The previous implementation (from9afffcb) had an unnecessary checkon the boundaries of the enum which trigtered compile warnings. To cleanit up, move the pre-existing static assert to a central location andcall that.Reported-By: Erik RijkersReviewed-By: Michael PaquierDiscussion:https://postgr.es/m/1056399262.13159.1617793249020@webmailclassic.xs4all.nl
1 parent4560e0a commitc196842

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

‎src/backend/libpq/auth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ set_authn_id(Port *port, const char *id)
379379
ereport(LOG,
380380
errmsg("connection authenticated: identity=\"%s\" method=%s "
381381
"(%s:%d)",
382-
port->authn_id,hba_authname(port),HbaFileName,
382+
port->authn_id,hba_authname(port->hba->auth_method),HbaFileName,
383383
port->hba->linenumber));
384384
}
385385
}

‎src/backend/libpq/hba.c

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,14 +2607,8 @@ fill_hba_line(Tuplestorestate *tuple_store, TupleDesc tupdesc,
26072607
else
26082608
nulls[index++]= true;
26092609

2610-
/*
2611-
* Make sure UserAuthName[] tracks additions to the UserAuth enum
2612-
*/
2613-
StaticAssertStmt(lengthof(UserAuthName)==USER_AUTH_LAST+1,
2614-
"UserAuthName[] must match the UserAuth enum");
2615-
26162610
/* auth_method */
2617-
values[index++]=CStringGetTextDatum(UserAuthName[hba->auth_method]);
2611+
values[index++]=CStringGetTextDatum(hba_authname(hba->auth_method));
26182612

26192613
/* options */
26202614
options=gethba_options(hba);
@@ -3150,18 +3144,13 @@ hba_getauthmethod(hbaPort *port)
31503144
* should not be freed.
31513145
*/
31523146
constchar*
3153-
hba_authname(hbaPort*port)
3147+
hba_authname(UserAuthauth_method)
31543148
{
3155-
UserAuthauth_method;
3156-
3157-
Assert(port->hba);
3158-
auth_method=port->hba->auth_method;
3159-
3160-
if (auth_method<0||USER_AUTH_LAST<auth_method)
3161-
{
3162-
/* Should never happen. */
3163-
elog(FATAL,"port has out-of-bounds UserAuth: %d",auth_method);
3164-
}
3149+
/*
3150+
* Make sure UserAuthName[] tracks additions to the UserAuth enum
3151+
*/
3152+
StaticAssertStmt(lengthof(UserAuthName)==USER_AUTH_LAST+1,
3153+
"UserAuthName[] must match the UserAuth enum");
31653154

31663155
returnUserAuthName[auth_method];
31673156
}

‎src/include/libpq/hba.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ typedef struct Port hbaPort;
137137

138138
externboolload_hba(void);
139139
externboolload_ident(void);
140-
externconstchar*hba_authname(hbaPort*port);
140+
externconstchar*hba_authname(UserAuthauth_method);
141141
externvoidhba_getauthmethod(hbaPort*port);
142142
externintcheck_usermap(constchar*usermap_name,
143143
constchar*pg_role,constchar*auth_user,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp