Skip to content

Commit 727ffa1

Browse files
committed
Clean up pg_SSPI_error() coding a little bit: make the messages more
consistent, translate where intended, const-ify declarations. Resolves a gripe from Alvaro as well as some stuff I didn't like.
1 parent 5698f6b commit 727ffa1

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/backend/libpq/auth.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.178 2009/01/09 10:13:18 mha Exp $
11+
* $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.179 2009/03/22 18:06:35 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1084,11 +1084,12 @@ pg_GSS_recvauth(Port *port)
10841084
*/
10851085
#ifdef ENABLE_SSPI
10861086
static void
1087-
pg_SSPI_error(int severity, char *errmsg, SECURITY_STATUS r)
1087+
pg_SSPI_error(int severity, const char *errmsg, SECURITY_STATUS r)
10881088
{
10891089
char sysmsg[256];
10901090

1091-
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, r, 0, sysmsg, sizeof(sysmsg), NULL) == 0)
1091+
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, r, 0,
1092+
sysmsg, sizeof(sysmsg), NULL) == 0)
10921093
ereport(severity,
10931094
(errmsg_internal("%s", errmsg),
10941095
errdetail("SSPI error %x", (unsigned int) r)));
@@ -1150,8 +1151,7 @@ pg_SSPI_recvauth(Port *port)
11501151
&sspicred,
11511152
&expiry);
11521153
if (r != SEC_E_OK)
1153-
pg_SSPI_error(ERROR,
1154-
gettext_noop("could not acquire SSPI credentials handle"), r);
1154+
pg_SSPI_error(ERROR, _("could not acquire SSPI credentials"), r);
11551155

11561156
/*
11571157
* Loop through SSPI message exchange. This exchange can consist of
@@ -1240,7 +1240,7 @@ pg_SSPI_recvauth(Port *port)
12401240
}
12411241
FreeCredentialsHandle(&sspicred);
12421242
pg_SSPI_error(ERROR,
1243-
gettext_noop("could not accept SSPI security context"), r);
1243+
_("could not accept SSPI security context"), r);
12441244
}
12451245

12461246
if (sspictx == NULL)
@@ -1296,7 +1296,7 @@ pg_SSPI_recvauth(Port *port)
12961296
{
12971297
FreeLibrary(secur32);
12981298
pg_SSPI_error(ERROR,
1299-
gettext_noop("could not get security token from context"), r);
1299+
_("could not get token from SSPI security context"), r);
13001300
}
13011301

13021302
FreeLibrary(secur32);

src/interfaces/libpq/fe-auth.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.140 2009/01/13 10:43:21 mha Exp $
10+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.141 2009/03/22 18:06:35 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -472,13 +472,13 @@ pg_GSS_startup(PGconn *conn)
472472
*/
473473

474474
static void
475-
pg_SSPI_error(PGconn *conn, char *mprefix, SECURITY_STATUS r)
475+
pg_SSPI_error(PGconn *conn, const char *mprefix, SECURITY_STATUS r)
476476
{
477477
char sysmsg[256];
478478

479479
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, r, 0,
480480
sysmsg, sizeof(sysmsg), NULL) == 0)
481-
printfPQExpBuffer(&conn->errorMessage, "%s: sspi error %x",
481+
printfPQExpBuffer(&conn->errorMessage, "%s: SSPI error %x",
482482
mprefix, (unsigned int) r);
483483
else
484484
printfPQExpBuffer(&conn->errorMessage, "%s: %s (%x)",
@@ -623,10 +623,18 @@ pg_SSPI_startup(PGconn *conn, int use_negotiate)
623623
return STATUS_ERROR;
624624
}
625625

626-
r = AcquireCredentialsHandle(NULL, use_negotiate ? "negotiate" : "kerberos", SECPKG_CRED_OUTBOUND, NULL, NULL, NULL, NULL, conn->sspicred, &expire);
626+
r = AcquireCredentialsHandle(NULL,
627+
use_negotiate ? "negotiate" : "kerberos",
628+
SECPKG_CRED_OUTBOUND,
629+
NULL,
630+
NULL,
631+
NULL,
632+
NULL,
633+
conn->sspicred,
634+
&expire);
627635
if (r != SEC_E_OK)
628636
{
629-
pg_SSPI_error(conn, "acquire credentials failed", r);
637+
pg_SSPI_error(conn, libpq_gettext("could not acquire SSPI credentials"), r);
630638
free(conn->sspicred);
631639
conn->sspicred = NULL;
632640
return STATUS_ERROR;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy