Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f2b1b30

Browse files
committed
Standardize GetTokenInformation() error reporting.
Commit c22650c sparked a discussion about diverse interpretations of "token user" in error messages. Expel old and new specimens of that phrase by making all GetTokenInformation() callers report errors the way GetTokenUser() has been reporting them. These error conditions almost can't happen, so users are unlikely to observe this change. Reviewed by Tom Lane and Stephen Frost.
1 parent 33d3fc5 commit f2b1b30

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/backend/libpq/auth.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1242,8 +1242,8 @@ pg_SSPI_recvauth(Port *port)
12421242

12431243
if (!GetTokenInformation(token, TokenUser, NULL, 0, &retlen) && GetLastError() != 122)
12441244
ereport(ERROR,
1245-
(errmsg_internal("could not get token user size: error code %lu",
1246-
GetLastError())));
1245+
(errmsg_internal("could not get token information buffer size: error code %lu",
1246+
GetLastError())));
12471247

12481248
tokenuser = malloc(retlen);
12491249
if (tokenuser == NULL)
@@ -1252,8 +1252,8 @@ pg_SSPI_recvauth(Port *port)
12521252

12531253
if (!GetTokenInformation(token, TokenUser, tokenuser, retlen, &retlen))
12541254
ereport(ERROR,
1255-
(errmsg_internal("could not get token user: error code %lu",
1256-
GetLastError())));
1255+
(errmsg_internal("could not get token information: error code %lu",
1256+
GetLastError())));
12571257

12581258
CloseHandle(token);
12591259

src/port/win32security.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,14 @@ pgwin32_get_dynamic_tokeninfo(HANDLE token, TOKEN_INFORMATION_CLASS class,
248248
if (GetTokenInformation(token, class, NULL, 0, &InfoBufferSize))
249249
{
250250
snprintf(errbuf, errsize,
251-
"could not get token information: got zero size\n");
251+
"could not get token information buffer size: got zero size\n");
252252
return FALSE;
253253
}
254254

255255
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
256256
{
257257
snprintf(errbuf, errsize,
258-
"could not get token information: error code %lu\n",
258+
"could not get token information buffer size: error code %lu\n",
259259
GetLastError());
260260
return FALSE;
261261
}

src/test/regress/pg_regress.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -904,15 +904,15 @@ current_windows_user(const char **acct, const char **dom)
904904
if (!GetTokenInformation(token, TokenUser, NULL, 0, &retlen) && GetLastError() != 122)
905905
{
906906
fprintf(stderr,
907-
_("%s: could not get token user size: error code %lu\n"),
907+
_("%s: could not get token information buffer size: error code %lu\n"),
908908
progname, GetLastError());
909909
exit(2);
910910
}
911911
tokenuser = malloc(retlen);
912912
if (!GetTokenInformation(token, TokenUser, tokenuser, retlen, &retlen))
913913
{
914914
fprintf(stderr,
915-
_("%s: could not get token user: error code %lu\n"),
915+
_("%s: could not get token information: error code %lu\n"),
916916
progname, GetLastError());
917917
exit(2);
918918
}

0 commit comments

Comments
 (0)