Re: Parsing of pg_hba.conf and authentication inconsistencies - Mailing list pgsql-hackers
| From | Magnus Hagander | 
|---|---|
| Subject | Re: Parsing of pg_hba.conf and authentication inconsistencies | 
| Date | |
| Msg-id | 48CE9DC4.9020508@hagander.net Whole thread Raw | 
| In response to | Re: Parsing of pg_hba.conf and authentication inconsistencies (Tom Lane <tgl@sss.pgh.pa.us>) | 
| Responses | Re: Parsing of pg_hba.conf and authentication inconsistencies | 
| List | pgsql-hackers | 
Tom Lane wrote:
> "Brendan Jurd" <direvus@gmail.com> writes:
>> Or perhaps the DETAIL portion would be more appropriate as a CONTEXT?
>
> +1
Is this the proper syntax for errcontext() messags?
//Magnus
Index: hba.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/libpq/hba.c,v
retrieving revision 1.167
diff -c -r1.167 hba.c
*** hba.c    15 Sep 2008 12:32:56 -0000    1.167
--- hba.c    15 Sep 2008 17:38:01 -0000
***************
*** 660,666 ****
                      (errcode(ERRCODE_CONFIG_FILE_ERROR),
                       errmsg("invalid IP address \"%s\": %s",
                              token, gai_strerror(ret)),
!                      errdetail("In file \"%s\", line %d",
                                 HbaFileName, line_num)));
              if (cidr_slash)
                  *cidr_slash = '/';
--- 660,666 ----
                      (errcode(ERRCODE_CONFIG_FILE_ERROR),
                       errmsg("invalid IP address \"%s\": %s",
                              token, gai_strerror(ret)),
!                      errcontext("File \"%s\", line %d",
                                 HbaFileName, line_num)));
              if (cidr_slash)
                  *cidr_slash = '/';
***************
*** 697,703 ****
                          (errcode(ERRCODE_CONFIG_FILE_ERROR),
                           errmsg("invalid IP mask \"%s\": %s",
                                  token, gai_strerror(ret)),
!                          errdetail("In file \"%s\", line %d",
                                 HbaFileName, line_num)));
                  if (gai_result)
                      pg_freeaddrinfo_all(hints.ai_family, gai_result);
--- 697,703 ----
                          (errcode(ERRCODE_CONFIG_FILE_ERROR),
                           errmsg("invalid IP mask \"%s\": %s",
                                  token, gai_strerror(ret)),
!                          errcontext("File \"%s\", line %d",
                                 HbaFileName, line_num)));
                  if (gai_result)
                      pg_freeaddrinfo_all(hints.ai_family, gai_result);
***************
*** 773,779 ****
                  (errcode(ERRCODE_CONFIG_FILE_ERROR),
                   errmsg("invalid authentication method \"%s\"",
                          token),
!                  errdetail("In file \"%s\" line %d",
                          HbaFileName, line_num)));
          goto hba_other_error;
      }
--- 773,779 ----
                  (errcode(ERRCODE_CONFIG_FILE_ERROR),
                   errmsg("invalid authentication method \"%s\"",
                          token),
!                  errcontext("File \"%s\" line %d",
                          HbaFileName, line_num)));
          goto hba_other_error;
      }
***************
*** 784,790 ****
                  (errcode(ERRCODE_CONFIG_FILE_ERROR),
                   errmsg("invalid authentication method \"%s\": not supported on this platform",
                          token),
!                  errdetail("In file \"%s\" line %d",
                          HbaFileName, line_num)));
          goto hba_other_error;
      }
--- 784,790 ----
                  (errcode(ERRCODE_CONFIG_FILE_ERROR),
                   errmsg("invalid authentication method \"%s\": not supported on this platform",
                          token),
!                  errcontext("File \"%s\" line %d",
                          HbaFileName, line_num)));
          goto hba_other_error;
      }
***************
*** 796,802 ****
          ereport(LOG,
                  (errcode(ERRCODE_CONFIG_FILE_ERROR),
                   errmsg("krb5 authentication is not supported on local sockets"),
!                  errdetail("In file \"%s\" line %d",
                          HbaFileName, line_num)));
          goto hba_other_error;
      }
--- 796,802 ----
          ereport(LOG,
                  (errcode(ERRCODE_CONFIG_FILE_ERROR),
                   errmsg("krb5 authentication is not supported on local sockets"),
!                  errcontext("File \"%s\" line %d",
                          HbaFileName, line_num)));
          goto hba_other_error;
      }
***************
*** 840,852 ****
      if (line_item)
          ereport(LOG,
                  (errcode(ERRCODE_CONFIG_FILE_ERROR),
!                  errmsg("invalid entry in file \"%s\" at line %d, token \"%s\"",
!                         HbaFileName, line_num,
!                         (char *) lfirst(line_item))));
      else
          ereport(LOG,
                  (errcode(ERRCODE_CONFIG_FILE_ERROR),
!                  errmsg("missing field in file \"%s\" at end of line %d",
                          HbaFileName, line_num)));
      /* Come here if suitable message already logged */
--- 840,855 ----
      if (line_item)
          ereport(LOG,
                  (errcode(ERRCODE_CONFIG_FILE_ERROR),
!                  errmsg("invalid token \"%s\"",
!                         (char *) lfirst(line_item)),
!                     errcontext("File %s, line %d",
!                         HbaFileName, line_num)));
      else
          ereport(LOG,
                  (errcode(ERRCODE_CONFIG_FILE_ERROR),
!                  errmsg("missing field at end of line %d",
!                         line_num),
!                  errcontext("File %s, line %d",
                          HbaFileName, line_num)));
      /* Come here if suitable message already logged */
		
	pgsql-hackers by date: