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

Commitb777be0

Browse files
committed
Un-break peer authentication.
Commit613c6d2 sloppily replaced alookup of the UID obtained from getpeereid() with a lookup of theserver's own user name, thus totally destroying peer authentication.Revert. Per report from Christoph Berg.In passing, make sure get_user_name() zeroes *errstr on success onWindows as well as non-Windows. I don't think any callers actuallydepend on this ATM, but we should be consistent across platforms.
1 parente5a452b commitb777be0

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

‎src/backend/libpq/auth.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include<arpa/inet.h>
2222
#include<unistd.h>
2323

24-
#include"common/username.h"
2524
#include"libpq/auth.h"
2625
#include"libpq/crypt.h"
2726
#include"libpq/ip.h"
@@ -1560,8 +1559,7 @@ auth_peer(hbaPort *port)
15601559
charident_user[IDENT_USERNAME_MAX+1];
15611560
uid_tuid;
15621561
gid_tgid;
1563-
constchar*user_name;
1564-
char*errstr;
1562+
structpasswd*pass;
15651563

15661564
errno=0;
15671565
if (getpeereid(port->sock,&uid,&gid)!=0)
@@ -1578,15 +1576,17 @@ auth_peer(hbaPort *port)
15781576
returnSTATUS_ERROR;
15791577
}
15801578

1581-
user_name=get_user_name(&errstr);
1582-
if (!user_name)
1579+
pass=getpwuid(uid);
1580+
1581+
if (pass==NULL)
15831582
{
1584-
ereport(LOG, (errmsg_internal("%s",errstr)));
1585-
pfree(errstr);
1583+
ereport(LOG,
1584+
(errmsg("local user with ID %d does not exist",
1585+
(int)uid)));
15861586
returnSTATUS_ERROR;
15871587
}
15881588

1589-
strlcpy(ident_user,user_name,IDENT_USERNAME_MAX+1);
1589+
strlcpy(ident_user,pass->pw_name,IDENT_USERNAME_MAX+1);
15901590

15911591
returncheck_usermap(port->hba->usermap,port->user_name,ident_user, false);
15921592
}

‎src/common/username.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ get_user_name(char **errstr)
5454
staticcharusername[256+1];
5555
DWORDlen=sizeof(username)-1;
5656

57+
*errstr=NULL;
58+
5759
if (!GetUserName(username,&len))
5860
{
5961
*errstr=psprintf(_("user name lookup failure: %s"),strerror(errno));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp