Skip to content

Commit 1ccb385

Browse files
committed
Fix build breakage on Solaris-alikes with late-model GCC.
Solaris has never bothered to add "const" to the second argument of PAM conversation procs, as all other Unixen did decades ago. This resulted in an "incompatible pointer" compiler warning when building --with-pam, but had no more serious effect than that, so we never did anything about it. However, as of GCC 14 the case is an error not warning by default. To complicate matters, recent OpenIndiana (and maybe illumos in general?) *does* supply the "const" by default, so we can't just assume that platforms using our solaris template need help. What we can do, short of building a configure-time probe, is to make solaris.h #define _PAM_LEGACY_NONCONST, which causes OpenIndiana's pam_appl.h to revert to the traditional definition, and hopefully will have no effect anywhere else. Then we can use that same symbol to control whether we include "const" in the declaration of pam_passwd_conv_proc(). Bug: #18995 Reported-by: Andrew Watkins <awatkins1966@gmail.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/18995-82058da9ab4337a7@postgresql.org Backpatch-through: 13
1 parent c934d56 commit 1ccb385

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/backend/libpq/auth.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,16 @@ static int auth_peer(hbaPort *port);
9494

9595
#define PGSQL_PAM_SERVICE "postgresql" /* Service name passed to PAM */
9696

97+
/* Work around original Solaris' lack of "const" in the conv_proc signature */
98+
#ifdef _PAM_LEGACY_NONCONST
99+
#define PG_PAM_CONST
100+
#else
101+
#define PG_PAM_CONST const
102+
#endif
103+
97104
static int CheckPAMAuth(Port *port, const char *user, const char *password);
98-
static int pam_passwd_conv_proc(int num_msg, const struct pam_message **msg,
105+
static int pam_passwd_conv_proc(int num_msg,
106+
PG_PAM_CONST struct pam_message **msg,
99107
struct pam_response **resp, void *appdata_ptr);
100108

101109
static struct pam_conv pam_passw_conv = {
@@ -2041,7 +2049,7 @@ auth_peer(hbaPort *port)
20412049
*/
20422050

20432051
static int
2044-
pam_passwd_conv_proc(int num_msg, const struct pam_message **msg,
2052+
pam_passwd_conv_proc(int num_msg, PG_PAM_CONST struct pam_message **msg,
20452053
struct pam_response **resp, void *appdata_ptr)
20462054
{
20472055
const char *passwd;

src/include/port/solaris.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
#include <sys/isa_defs.h>
2626
#endif
2727

28+
/*
29+
* On original Solaris, PAM conversation procs lack a "const" in their
30+
* declaration; but recent OpenIndiana versions put it there by default.
31+
* The least messy way to deal with this is to define _PAM_LEGACY_NONCONST,
32+
* which causes OpenIndiana to declare pam_conv per the Solaris tradition,
33+
* and also use that symbol to control omitting the "const" in our own code.
34+
*/
35+
#define _PAM_LEGACY_NONCONST 1
36+
2837
/*
2938
* Many versions of Solaris have broken strtod() --- see bug #4751182.
3039
* This has been fixed in current versions of Solaris:

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