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

Commita5c6b8f

Browse files
committed
libpq: Trace responses to SSLRequest and GSSENCRequest
Since these are single bytes instead of v2 or v3 messages they needcustom tracing logic. These "messages" don't even have official namesin the protocol specification, so I (Jelte) called them SSLResponse andGSSENCResponse here.Author: Jelte Fennema-Nio <postgres@jeltef.nl>Discussion:https://postgr.es/m/CAGECzQSoPHtZ4xe0raJ6FYSEiPPS+YWXBhOGo+Y1YecLgknF3g@mail.gmail.com
1 parent5304fec commita5c6b8f

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3493,11 +3493,17 @@ PQconnectPoll(PGconn *conn)
34933493
}
34943494
if (SSLok=='S')
34953495
{
3496+
if (conn->Pfdebug)
3497+
pqTraceOutputCharResponse(conn,"SSLResponse",
3498+
SSLok);
34963499
/* mark byte consumed */
34973500
conn->inStart=conn->inCursor;
34983501
}
34993502
elseif (SSLok=='N')
35003503
{
3504+
if (conn->Pfdebug)
3505+
pqTraceOutputCharResponse(conn,"SSLResponse",
3506+
SSLok);
35013507
/* mark byte consumed */
35023508
conn->inStart=conn->inCursor;
35033509

@@ -3635,6 +3641,10 @@ PQconnectPoll(PGconn *conn)
36353641

36363642
if (gss_ok=='N')
36373643
{
3644+
if (conn->Pfdebug)
3645+
pqTraceOutputCharResponse(conn,"GSSENCResponse",
3646+
gss_ok);
3647+
36383648
/*
36393649
* The connection is still valid, so if it's OK to
36403650
* continue without GSS, we can proceed using this
@@ -3648,6 +3658,10 @@ PQconnectPoll(PGconn *conn)
36483658
gss_ok);
36493659
gotoerror_return;
36503660
}
3661+
3662+
if (conn->Pfdebug)
3663+
pqTraceOutputCharResponse(conn,"GSSENCResponse",
3664+
gss_ok);
36513665
}
36523666

36533667
/* Begin or continue GSSAPI negotiation */

‎src/interfaces/libpq/fe-trace.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,3 +840,23 @@ pqTraceOutputNoTypeByteMessage(PGconn *conn, const char *message)
840840

841841
fputc('\n',conn->Pfdebug);
842842
}
843+
844+
/*
845+
* Trace a single-byte backend response received for a known request
846+
* type the frontend previously sent. Only useful for the simplest of
847+
* FE/BE interaction workflows such as SSL/GSS encryption requests.
848+
*/
849+
void
850+
pqTraceOutputCharResponse(PGconn*conn,constchar*responseType,
851+
charresponse)
852+
{
853+
if ((conn->traceFlags&PQTRACE_SUPPRESS_TIMESTAMPS)==0)
854+
{
855+
chartimestr[128];
856+
857+
pqTraceFormatTimestamp(timestr,sizeof(timestr));
858+
fprintf(conn->Pfdebug,"%s\t",timestr);
859+
}
860+
861+
fprintf(conn->Pfdebug,"B\t1\t%s\t %c\n",responseType,response);
862+
}

‎src/interfaces/libpq/libpq-int.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,8 @@ extern ssize_t pg_GSS_read(PGconn *conn, void *ptr, size_t len);
889889
externvoidpqTraceOutputMessage(PGconn*conn,constchar*message,
890890
booltoServer);
891891
externvoidpqTraceOutputNoTypeByteMessage(PGconn*conn,constchar*message);
892+
externvoidpqTraceOutputCharResponse(PGconn*conn,constchar*responseType,
893+
charresponse);
892894

893895
/* === miscellaneous macros === */
894896

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp