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

Commit b8f2980

Browse files
committed
Fix broken IDENT support for FreeBSD (appears to have been broken by
ill-considered conditional logic in getpeereid patch of 3-Dec-2002). Per bug #1021.
1 parent d75b2ec commit b8f2980

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

src/backend/libpq/auth.c

+13-14
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.113 2003/11/29 19:51:49 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.114 2003/12/20 18:24:52 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -471,32 +471,31 @@ ClientAuthentication(Port *port)
471471
break;
472472

473473
case uaIdent:
474-
#if defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || \
475-
(defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS)) && \
476-
!defined(HAVE_GETPEEREID) && !defined(SO_PEERCRED)
477-
478474
/*
479475
* If we are doing ident on unix-domain sockets, use SCM_CREDS
480476
* only if it is defined and SO_PEERCRED isn't.
481477
*/
482-
#if defined(HAVE_STRUCT_FCRED) || defined(HAVE_STRUCT_SOCKCRED)
483-
484-
/*
485-
* Receive credentials on next message receipt, BSD/OS,
486-
* NetBSD. We need to set this before the client sends the
487-
* next packet.
488-
*/
478+
#if !defined(HAVE_GETPEEREID) && !defined(SO_PEERCRED) && \
479+
(defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || \
480+
(defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS)))
481+
if (port->raddr.addr.ss_family == AF_UNIX)
489482
{
483+
#if defined(HAVE_STRUCT_FCRED) || defined(HAVE_STRUCT_SOCKCRED)
484+
/*
485+
* Receive credentials on next message receipt, BSD/OS,
486+
* NetBSD. We need to set this before the client sends the
487+
* next packet.
488+
*/
490489
int on = 1;
491490

492491
if (setsockopt(port->sock, 0, LOCAL_CREDS, &on, sizeof(on)) < 0)
493492
ereport(FATAL,
494493
(errcode_for_socket_access(),
495494
errmsg("could not enable credential reception: %m")));
496-
}
497495
#endif
498-
if (port->raddr.addr.ss_family == AF_UNIX)
496+
499497
sendAuthRequest(port, AUTH_REQ_SCM_CREDS);
498+
}
500499
#endif
501500
status = authident(port);
502501
break;

src/interfaces/libpq/fe-auth.c

+11-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.86 2003/11/29 19:52:11 pgsql Exp $
13+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.87 2003/12/20 18:24:52 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -447,12 +447,19 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, const char *hostname)
447447
}
448448
#endif /* KRB5 */
449449

450+
/*
451+
* Respond to AUTH_REQ_SCM_CREDS challenge.
452+
*
453+
* Note: the backend will not use this challenge if HAVE_GETPEEREID
454+
* or SO_PEERCRED is defined, so we don't bother to compile any code
455+
* in that case, even if the facility is available.
456+
*/
450457
static int
451458
pg_local_sendauth(char *PQerrormsg, PGconn *conn)
452459
{
453-
#if defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || \
454-
(defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS)) && \
455-
!defined(HAVE_GETPEEREID) && !defined(SO_PEERCRED)
460+
#if !defined(HAVE_GETPEEREID) && !defined(SO_PEERCRED) && \
461+
(defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || \
462+
(defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS)))
456463
char buf;
457464
struct iovec iov;
458465
struct msghdr msg;

0 commit comments

Comments
 (0)