summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2009-03-22 18:06:35 +0000
committerTom Lane2009-03-22 18:06:35 +0000
commit8a700858a7fc1d5071b20f3c73a352bf45e1b7cf (patch)
tree4330dfea0ca1864f9cfa263490c561ea2cf10bfe
parenta66b07f020ead830579a1cbdf8c1c47f0b91af0d (diff)
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.
-rw-r--r--src/backend/libpq/auth.c12
-rw-r--r--src/interfaces/libpq/fe-auth.c16
2 files changed, 18 insertions, 10 deletions
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index 0853bfd330..e8eb2342f5 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -1084,11 +1084,12 @@ pg_GSS_recvauth(Port *port)
*/
#ifdef ENABLE_SSPI
static void
-pg_SSPI_error(int severity, char *errmsg, SECURITY_STATUS r)
+pg_SSPI_error(int severity, const char *errmsg, SECURITY_STATUS r)
{
char sysmsg[256];
- if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, r, 0, sysmsg, sizeof(sysmsg), NULL) == 0)
+ if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, r, 0,
+ sysmsg, sizeof(sysmsg), NULL) == 0)
ereport(severity,
(errmsg_internal("%s", errmsg),
errdetail("SSPI error %x", (unsigned int) r)));
@@ -1150,8 +1151,7 @@ pg_SSPI_recvauth(Port *port)
&sspicred,
&expiry);
if (r != SEC_E_OK)
- pg_SSPI_error(ERROR,
- gettext_noop("could not acquire SSPI credentials handle"), r);
+ pg_SSPI_error(ERROR, _("could not acquire SSPI credentials"), r);
/*
* Loop through SSPI message exchange. This exchange can consist of
@@ -1240,7 +1240,7 @@ pg_SSPI_recvauth(Port *port)
}
FreeCredentialsHandle(&sspicred);
pg_SSPI_error(ERROR,
- gettext_noop("could not accept SSPI security context"), r);
+ _("could not accept SSPI security context"), r);
}
if (sspictx == NULL)
@@ -1296,7 +1296,7 @@ pg_SSPI_recvauth(Port *port)
{
FreeLibrary(secur32);
pg_SSPI_error(ERROR,
- gettext_noop("could not get security token from context"), r);
+ _("could not get token from SSPI security context"), r);
}
FreeLibrary(secur32);
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index e9d3cba0e1..0453511e9c 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -472,13 +472,13 @@ pg_GSS_startup(PGconn *conn)
*/
static void
-pg_SSPI_error(PGconn *conn, char *mprefix, SECURITY_STATUS r)
+pg_SSPI_error(PGconn *conn, const char *mprefix, SECURITY_STATUS r)
{
char sysmsg[256];
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, r, 0,
sysmsg, sizeof(sysmsg), NULL) == 0)
- printfPQExpBuffer(&conn->errorMessage, "%s: sspi error %x",
+ printfPQExpBuffer(&conn->errorMessage, "%s: SSPI error %x",
mprefix, (unsigned int) r);
else
printfPQExpBuffer(&conn->errorMessage, "%s: %s (%x)",
@@ -623,10 +623,18 @@ pg_SSPI_startup(PGconn *conn, int use_negotiate)
return STATUS_ERROR;
}
- r = AcquireCredentialsHandle(NULL, use_negotiate ? "negotiate" : "kerberos", SECPKG_CRED_OUTBOUND, NULL, NULL, NULL, NULL, conn->sspicred, &expire);
+ r = AcquireCredentialsHandle(NULL,
+ use_negotiate ? "negotiate" : "kerberos",
+ SECPKG_CRED_OUTBOUND,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ conn->sspicred,
+ &expire);
if (r != SEC_E_OK)
{
- pg_SSPI_error(conn, "acquire credentials failed", r);
+ pg_SSPI_error(conn, libpq_gettext("could not acquire SSPI credentials"), r);
free(conn->sspicred);
conn->sspicred = NULL;
return STATUS_ERROR;