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

Commite98ca4d

Browse files
committed
Make hba parsing error messages more specific.
1 parentb0169bb commite98ca4d

File tree

1 file changed

+66
-27
lines changed

1 file changed

+66
-27
lines changed

‎src/backend/libpq/hba.c

Lines changed: 66 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.170 2008/10/24 12:48:31 mha Exp $
13+
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.171 2008/10/27 20:04:45 mha Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -637,8 +637,13 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
637637
#ifdefUSE_SSL
638638
parsedline->conntype=ctHostSSL;
639639
#else
640-
/* We don't accept this keyword at all if no SSL support */
641-
gotohba_syntax;
640+
ereport(LOG,
641+
(errcode(ERRCODE_CONFIG_FILE_ERROR),
642+
errmsg("hostssl not supported on this platform"),
643+
errhint("compile with --enable-ssl to use SSL connections"),
644+
errcontext("line %d of configuration file \"%s\"",
645+
line_num,HbaFileName)));
646+
return false;
642647
#endif
643648
}
644649
#ifdefUSE_SSL
@@ -654,26 +659,55 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
654659
}
655660
}/* record type */
656661
else
657-
gotohba_syntax;
662+
{
663+
ereport(LOG,
664+
(errcode(ERRCODE_CONFIG_FILE_ERROR),
665+
errmsg("invalid connection type \"%s\"",
666+
token),
667+
errcontext("line %d of configuration file \"%s\"",
668+
line_num,HbaFileName)));
669+
return false;
670+
}
658671

659672
/* Get the database. */
660673
line_item=lnext(line_item);
661674
if (!line_item)
662-
gotohba_syntax;
675+
{
676+
ereport(LOG,
677+
(errcode(ERRCODE_CONFIG_FILE_ERROR),
678+
errmsg("end-of-line before database specification"),
679+
errcontext("line %d of configuration file \"%s\"",
680+
line_num,HbaFileName)));
681+
return false;
682+
}
663683
parsedline->database=pstrdup(lfirst(line_item));
664684

665685
/* Get the role. */
666686
line_item=lnext(line_item);
667687
if (!line_item)
668-
gotohba_syntax;
688+
{
689+
ereport(LOG,
690+
(errcode(ERRCODE_CONFIG_FILE_ERROR),
691+
errmsg("end-of-line before role specification"),
692+
errcontext("line %d of configuration file \"%s\"",
693+
line_num,HbaFileName)));
694+
return false;
695+
}
669696
parsedline->role=pstrdup(lfirst(line_item));
670697

671698
if (parsedline->conntype!=ctLocal)
672699
{
673700
/* Read the IP address field. (with or without CIDR netmask) */
674701
line_item=lnext(line_item);
675702
if (!line_item)
676-
gotohba_syntax;
703+
{
704+
ereport(LOG,
705+
(errcode(ERRCODE_CONFIG_FILE_ERROR),
706+
errmsg("end-of-line before ip address specification"),
707+
errcontext("line %d of configuration file \"%s\"",
708+
line_num,HbaFileName)));
709+
return false;
710+
}
677711
token=pstrdup(lfirst(line_item));
678712

679713
/* Check if it has a CIDR suffix and if so isolate it */
@@ -718,14 +752,29 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
718752
{
719753
if (pg_sockaddr_cidr_mask(&parsedline->mask,cidr_slash+1,
720754
parsedline->addr.ss_family)<0)
721-
gotohba_syntax;
755+
{
756+
ereport(LOG,
757+
(errcode(ERRCODE_CONFIG_FILE_ERROR),
758+
errmsg("invalid CIDR mask in address \"%s\"",
759+
token),
760+
errcontext("line %d of configuration file \"%s\"",
761+
line_num,HbaFileName)));
762+
return false;
763+
}
722764
}
723765
else
724766
{
725767
/* Read the mask field. */
726768
line_item=lnext(line_item);
727769
if (!line_item)
728-
gotohba_syntax;
770+
{
771+
ereport(LOG,
772+
(errcode(ERRCODE_CONFIG_FILE_ERROR),
773+
errmsg("end-of-line before netmask specification"),
774+
errcontext("line %d of configuration file \"%s\"",
775+
line_num,HbaFileName)));
776+
return false;
777+
}
729778
token=lfirst(line_item);
730779

731780
ret=pg_getaddrinfo_all(token,NULL,&hints,&gai_result);
@@ -759,7 +808,14 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
759808
/* Get the authentication method */
760809
line_item=lnext(line_item);
761810
if (!line_item)
762-
gotohba_syntax;
811+
{
812+
ereport(LOG,
813+
(errcode(ERRCODE_CONFIG_FILE_ERROR),
814+
errmsg("end-of-line before authentication method"),
815+
errcontext("line %d of configuration file \"%s\"",
816+
line_num,HbaFileName)));
817+
return false;
818+
}
763819
token=lfirst(line_item);
764820

765821
unsupauth=NULL;
@@ -937,23 +993,6 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
937993
}
938994

939995
return true;
940-
941-
hba_syntax:
942-
if (line_item)
943-
ereport(LOG,
944-
(errcode(ERRCODE_CONFIG_FILE_ERROR),
945-
errmsg("invalid token \"%s\"",
946-
(char*)lfirst(line_item)),
947-
errcontext("line %d of configuration file \"%s\"",
948-
line_num,HbaFileName)));
949-
else
950-
ereport(LOG,
951-
(errcode(ERRCODE_CONFIG_FILE_ERROR),
952-
errmsg("missing field at end of line"),
953-
errcontext("line %d of configuration file \"%s\"",
954-
line_num,HbaFileName)));
955-
956-
return false;
957996
}
958997

959998

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp