Skip to content

Commit 92f5bfc

Browse files
committed
Fix invalid use of #if within a macro, per Laurenz Albe. Also try to
make the LDAP code's error messages look like they were written by someone who had heard of our style guidelines.
1 parent 2316013 commit 92f5bfc

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/backend/libpq/auth.c

Lines changed: 17 additions & 12 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.135 2006/03/06 17:41:43 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.136 2006/03/16 18:11:17 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -712,6 +712,7 @@ CheckPAMAuth(Port *port, char *user, char *password)
712712

713713

714714
#ifdef USE_LDAP
715+
715716
static int
716717
CheckLDAPAuth(Port *port)
717718
{
@@ -774,7 +775,8 @@ CheckLDAPAuth(Port *port)
774775
if (r < 2)
775776
{
776777
ereport(LOG,
777-
(errmsg("Invalid LDAP url: '%s'", port->auth_arg)));
778+
(errmsg("invalid LDAP URL: \"%s\"",
779+
port->auth_arg)));
778780
return STATUS_ERROR;
779781
}
780782

@@ -783,26 +785,26 @@ CheckLDAPAuth(Port *port)
783785
passwd = recv_password_packet(port);
784786
if (passwd == NULL)
785787
return STATUS_EOF; /* client wouldn't send password */
786-
787788

788789
ldap = ldap_init(server, ldapport);
789790
if (!ldap)
790791
{
791-
ereport(LOG,
792-
(errmsg("Failed to initialize LDAP: %i",
793792
#ifndef WIN32
794-
errno
793+
ereport(LOG,
794+
(errmsg("could not initialize LDAP: error %d",
795+
errno)));
795796
#else
796-
(int)LdapGetLastError()
797+
ereport(LOG,
798+
(errmsg("could not initialize LDAP: error %d",
799+
(int) LdapGetLastError())));
797800
#endif
798-
)));
799801
return STATUS_ERROR;
800802
}
801803

802804
if ((r = ldap_set_option(ldap, LDAP_OPT_PROTOCOL_VERSION, &ldapversion)) != LDAP_SUCCESS)
803805
{
804806
ereport(LOG,
805-
(errmsg("Failed to set LDAP version: %i", r)));
807+
(errmsg("could not set LDAP protocol version: error %d", r)));
806808
return STATUS_ERROR;
807809
}
808810

@@ -815,12 +817,13 @@ CheckLDAPAuth(Port *port)
815817
#endif
816818
{
817819
ereport(LOG,
818-
(errmsg("Failed to start LDAP TLS session: %i", r)));
820+
(errmsg("could not start LDAP TLS session: error %d", r)));
819821
return STATUS_ERROR;
820822
}
821823
}
822824

823-
snprintf(fulluser, sizeof(fulluser)-1, "%s%s%s", prefix, port->user_name, suffix);
825+
snprintf(fulluser, sizeof(fulluser)-1, "%s%s%s",
826+
prefix, port->user_name, suffix);
824827
fulluser[sizeof(fulluser)-1] = '\0';
825828

826829
r = ldap_simple_bind_s(ldap, fulluser, passwd);
@@ -829,12 +832,14 @@ CheckLDAPAuth(Port *port)
829832
if (r != LDAP_SUCCESS)
830833
{
831834
ereport(LOG,
832-
(errmsg("LDAP login failed for user '%s' on server '%s': %i",fulluser,server,r)));
835+
(errmsg("LDAP login failed for user \"%s\" on server \"%s\": error %d",
836+
fulluser, server, r)));
833837
return STATUS_ERROR;
834838
}
835839

836840
return STATUS_OK;
837841
}
842+
838843
#endif /* USE_LDAP */
839844

840845
/*

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