Skip to content

Commit 85f4d63

Browse files
committed
Tweak some SCRAM error messages and code comments
Clarify/correct some error messages, fix up some code comments that confused SASL and SCRAM, and other minor fixes. No changes in functionality.
1 parent 580ddce commit 85f4d63

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

doc/src/sgml/protocol.sgml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1405,13 +1405,13 @@ ErrorMessage.
14051405
</para>
14061406

14071407
<para>
1408-
When SCRAM-SHA-256 is used in PostgreSQL, the server will ignore the username
1409-
that the client sends in the <structname>client-first-message</>. The username
1408+
When SCRAM-SHA-256 is used in PostgreSQL, the server will ignore the user name
1409+
that the client sends in the <structname>client-first-message</>. The user name
14101410
that was already sent in the startup message is used instead.
14111411
<productname>PostgreSQL</> supports multiple character encodings, while SCRAM
1412-
dictates UTF-8 to be used for the username, so it might be impossible to
1413-
represent the PostgreSQL username in UTF-8. To avoid confusion, the client
1414-
should use <literal>pg_same_as_startup_message</literal> as the username in the
1412+
dictates UTF-8 to be used for the user name, so it might be impossible to
1413+
represent the PostgreSQL user name in UTF-8. To avoid confusion, the client
1414+
should use <literal>pg_same_as_startup_message</literal> as the user name in the
14151415
<structname>client-first-message</>.
14161416
</para>
14171417

@@ -5274,7 +5274,7 @@ RowDescription (B)
52745274

52755275
<varlistentry>
52765276
<term>
5277-
SASLInitialresponse (F)
5277+
SASLInitialResponse (F)
52785278
</term>
52795279
<listitem>
52805280
<para>

src/backend/libpq/auth-scram.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ mock_scram_verifier(const char *username, int *iterations, char **salt,
573573
}
574574

575575
/*
576-
* Read the value in a given SASL exchange message for given attribute.
576+
* Read the value in a given SCRAM exchange message for given attribute.
577577
*/
578578
static char *
579579
read_attr_value(char **input, char attr)
@@ -585,15 +585,15 @@ read_attr_value(char **input, char attr)
585585
ereport(ERROR,
586586
(errcode(ERRCODE_PROTOCOL_VIOLATION),
587587
errmsg("malformed SCRAM message"),
588-
errdetail("Expected attribute '%c' but found %s.",
588+
errdetail("Expected attribute \"%c\" but found \"%s\".",
589589
attr, sanitize_char(*begin))));
590590
begin++;
591591

592592
if (*begin != '=')
593593
ereport(ERROR,
594594
(errcode(ERRCODE_PROTOCOL_VIOLATION),
595595
errmsg("malformed SCRAM message"),
596-
errdetail("Expected character = for attribute %c.", attr)));
596+
errdetail("Expected character \"=\" for attribute \"%c\".", attr)));
597597
begin++;
598598

599599
end = begin;
@@ -652,7 +652,7 @@ sanitize_char(char c)
652652
}
653653

654654
/*
655-
* Read the next attribute and value in a SASL exchange message.
655+
* Read the next attribute and value in a SCRAM exchange message.
656656
*
657657
* Returns NULL if there is attribute.
658658
*/
@@ -674,7 +674,7 @@ read_any_attr(char **input, char *attr_p)
674674
ereport(ERROR,
675675
(errcode(ERRCODE_PROTOCOL_VIOLATION),
676676
errmsg("malformed SCRAM message"),
677-
errdetail("Attribute expected, but found invalid character %s.",
677+
errdetail("Attribute expected, but found invalid character \"%s\".",
678678
sanitize_char(attr))));
679679
if (attr_p)
680680
*attr_p = attr;
@@ -684,7 +684,7 @@ read_any_attr(char **input, char *attr_p)
684684
ereport(ERROR,
685685
(errcode(ERRCODE_PROTOCOL_VIOLATION),
686686
errmsg("malformed SCRAM message"),
687-
errdetail("Expected character = for attribute %c.", attr)));
687+
errdetail("Expected character \"=\" for attribute \"%c\".", attr)));
688688
begin++;
689689

690690
end = begin;
@@ -703,7 +703,7 @@ read_any_attr(char **input, char *attr_p)
703703
}
704704

705705
/*
706-
* Read and parse the first message from client in the context of a SASL
706+
* Read and parse the first message from client in the context of a SCRAM
707707
* authentication exchange message.
708708
*
709709
* At this stage, any errors will be reported directly with ereport(ERROR).
@@ -802,14 +802,14 @@ read_client_first_message(scram_state *state, char *input)
802802
ereport(ERROR,
803803
(errcode(ERRCODE_PROTOCOL_VIOLATION),
804804
errmsg("malformed SCRAM message"),
805-
errdetail("Unexpected channel-binding flag %s.",
805+
errdetail("Unexpected channel-binding flag \"%s\".",
806806
sanitize_char(*input))));
807807
}
808808
if (*input != ',')
809809
ereport(ERROR,
810810
(errcode(ERRCODE_PROTOCOL_VIOLATION),
811811
errmsg("malformed SCRAM message"),
812-
errdetail("Comma expected, but found character %s.",
812+
errdetail("Comma expected, but found character \"%s\".",
813813
sanitize_char(*input))));
814814
input++;
815815

@@ -824,7 +824,7 @@ read_client_first_message(scram_state *state, char *input)
824824
ereport(ERROR,
825825
(errcode(ERRCODE_PROTOCOL_VIOLATION),
826826
errmsg("malformed SCRAM message"),
827-
errdetail("Unexpected attribute %s in client-first-message.",
827+
errdetail("Unexpected attribute \"%s\" in client-first-message.",
828828
sanitize_char(*input))));
829829
input++;
830830

@@ -929,7 +929,7 @@ verify_client_proof(scram_state *state)
929929
}
930930

931931
/*
932-
* Build the first server-side message sent to the client in a SASL
932+
* Build the first server-side message sent to the client in a SCRAM
933933
* communication exchange.
934934
*/
935935
static char *

src/interfaces/libpq/fe-auth-scram.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ pg_fe_scram_exchange(void *opaq, char *input, int inputlen,
228228
{
229229
*success = false;
230230
printfPQExpBuffer(errorMessage,
231-
libpq_gettext("invalid server signature\n"));
231+
libpq_gettext("incorrect server signature\n"));
232232
}
233233
*done = true;
234234
state->state = FE_SCRAM_FINISHED;
@@ -249,7 +249,7 @@ pg_fe_scram_exchange(void *opaq, char *input, int inputlen,
249249
}
250250

251251
/*
252-
* Read value for an attribute part of a SASL message.
252+
* Read value for an attribute part of a SCRAM message.
253253
*/
254254
static char *
255255
read_attr_value(char **input, char attr, PQExpBuffer errorMessage)
@@ -260,7 +260,7 @@ read_attr_value(char **input, char attr, PQExpBuffer errorMessage)
260260
if (*begin != attr)
261261
{
262262
printfPQExpBuffer(errorMessage,
263-
libpq_gettext("malformed SCRAM message (%c expected)\n"),
263+
libpq_gettext("malformed SCRAM message (attribute \"%c\" expected)\n"),
264264
attr);
265265
return NULL;
266266
}
@@ -269,7 +269,7 @@ read_attr_value(char **input, char attr, PQExpBuffer errorMessage)
269269
if (*begin != '=')
270270
{
271271
printfPQExpBuffer(errorMessage,
272-
libpq_gettext("malformed SCRAM message (expected = in attr '%c')\n"),
272+
libpq_gettext("malformed SCRAM message (expected character \"=\" for attribute \"%c\")\n"),
273273
attr);
274274
return NULL;
275275
}
@@ -508,7 +508,7 @@ read_server_final_message(fe_scram_state *state, char *input,
508508
char *errmsg = read_attr_value(&input, 'e', errormessage);
509509

510510
printfPQExpBuffer(errormessage,
511-
libpq_gettext("error received from server in SASL exchange: %s\n"),
511+
libpq_gettext("error received from server in SCRAM exchange: %s\n"),
512512
errmsg);
513513
return false;
514514
}

0 commit comments

Comments
 (0)