From 65c2272dc04f1a55f97b567dcef61e6ca53297b4 Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Wed, 24 Aug 2011 00:01:56 +0400 Subject: [PATCH] PostgreSQL: unbreak GSSAPI support The problem with GSSAPI without Kerberos is that configure.in has very funny logics of choosing GSSAPI libraries: {{{ if test "$with_gssapi" = yes ; then if test "$PORTNAME" != "win32"; then AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [], [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])]) else LIBS="$LIBS -lgssapi32" fi fi }}} This makes configure to happily choose -lgssapi_krb5 when the system has Kerberos support (NO_KERBEROS is absent), but ld's '--as-needed' will throw this library away when no Kerberos functions are used and linker won't produce 'postgres' binary whining about unresolved symbols: {{{ cc -O2 -pipe -fno-strict-aliasing -Wall -Wmissing-prototypes \ -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels \ -fno-strict-aliasing -fwrapv -L../../src/port -L/usr/local/lib \ -rpath=/usr/lib:/usr/local/lib -L/usr/local/lib -L/usr/local/lib \ -Wl,--as-needed -Wl,-R'/usr/local/lib' -Wl,-export-dynamic \ [... a bunch of *.o files was stripped ...] ../../src/timezone/pgtz.o ../../src/port/libpgport_srv.a -lintl -lssl \ -lcrypto -lgssapi_krb5 -lcrypt -lm -o postgres libpq/auth.o: In function `pg_GSS_error': auth.c:(.text+0x6e): undefined reference to `gss_display_status' auth.c:(.text+0x8e): undefined reference to `gss_release_buffer' auth.c:(.text+0xc5): undefined reference to `gss_display_status' auth.c:(.text+0xe5): undefined reference to `gss_release_buffer' libpq/auth.o: In function `ClientAuthentication': auth.c:(.text+0x82d): undefined reference to `gss_delete_sec_context' auth.c:(.text+0x941): undefined reference to `gss_accept_sec_context' auth.c:(.text+0x9f1): undefined reference to `gss_release_buffer' auth.c:(.text+0xaf3): undefined reference to `gss_release_cred' auth.c:(.text+0xb10): undefined reference to `gss_display_name' auth.c:(.text+0xbc8): undefined reference to `gss_release_buffer' auth.c:(.text+0x10b0): undefined reference to `gss_release_buffer' auth.c:(.text+0x111e): undefined reference to `gss_release_buffer' libpq/pqcomm.o: In function `pq_close': pqcomm.c:(.text+0x105a): undefined reference to `gss_delete_sec_context' pqcomm.c:(.text+0x107d): undefined reference to `gss_release_cred' gmake: *** [postgres] Error 1 }}} Also, ports for PostgreSQL 8.4 and 9.0 had their misplaced: OPTIONS came after it, so WITH_/WITHOUT_ knobs will not be really activated. Signed-off-by: Eygene Ryabinkin --- databases/postgresql84-server/Makefile | 12 ++++++++---- databases/postgresql90-server/Makefile | 12 ++++++++---- databases/postgresql91-server/Makefile | 7 +++++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/databases/postgresql84-server/Makefile b/databases/postgresql84-server/Makefile index 9226da7..0fa0021 100644 --- a/databases/postgresql84-server/Makefile +++ b/databases/postgresql84-server/Makefile @@ -83,8 +83,6 @@ USE_OPENSSL= yes CONFIGURE_ARGS+=--with-openssl .endif -.include - .if !defined(SLAVE_ONLY) OPTIONS+= PAM "Build with PAM support (server only)" off OPTIONS+= LDAP "Build with LDAP authentication support" off @@ -103,6 +101,8 @@ OPTIONS+= ICU "Use ICU for unicode collation (server)" off # (requires dump/restore if modified.) OPTIONS+= INTDATE "Builds with 64-bit date/time type (server)" on +.include + . if (defined(SERVER_ONLY) && defined(WITH_ICU)) || make(makesum) USE_AUTOTOOLS= autoconf CONFIGURE_ARGS+=--with-icu @@ -161,8 +161,12 @@ INSTALL_TARGET= install-strip .if defined(WITH_GSSAPI) CONFIGURE_ARGS+=--with-gssapi -.if ${OSVERSION} >= 900000 -BROKEN= does not link on FreeBSD 9.X +.if !defined(WITH_MIT_KRB5) && !defined(WITH_HEIMDAL_KRB5) +# Kerberos libraries will pull the proper GSSAPI library +# via linker dependencies, but otherwise we must specify +# it explicitely: ld --as-needed is used for compilation, +# so configure's -lgssapi_krb5 won't go. +LDFLAGS+= -lgssapi .endif .else CONFIGURE_ARGS+=--without-gssapi diff --git a/databases/postgresql90-server/Makefile b/databases/postgresql90-server/Makefile index 7e7f3d6..b75905a 100644 --- a/databases/postgresql90-server/Makefile +++ b/databases/postgresql90-server/Makefile @@ -82,8 +82,6 @@ USE_OPENSSL= yes CONFIGURE_ARGS+=--with-openssl .endif -.include - .if !defined(SLAVE_ONLY) OPTIONS+= DTRACE "Build with DTrace probes (server only)" off OPTIONS+= PAM "Build with PAM support (server only)" off @@ -103,6 +101,8 @@ OPTIONS+= ICU "Use ICU for unicode collation (server)" off # (requires dump/restore if modified.) OPTIONS+= INTDATE "Builds with 64-bit date/time type (server)" on +.include + . if (defined(SERVER_ONLY) && defined(WITH_ICU)) || make(makesum) USE_AUTOTOOLS= autoconf CONFIGURE_ARGS+=--with-icu @@ -168,8 +168,12 @@ INSTALL_TARGET= install-strip .if !defined(WITHOUT_GSSAPI) CONFIGURE_ARGS+=--with-gssapi -.if ${OSVERSION} >= 900000 -BROKEN= does not link on FreeBSD 9.X +.if !defined(WITH_MIT_KRB5) && !defined(WITH_HEIMDAL_KRB5) +# Kerberos libraries will pull the proper GSSAPI library +# via linker dependencies, but otherwise we must specify +# it explicitely: ld --as-needed is used for compilation, +# so configure's -lgssapi_krb5 won't go. +LDFLAGS+= -lgssapi .endif .else CONFIGURE_ARGS+=--without-gssapi diff --git a/databases/postgresql91-server/Makefile b/databases/postgresql91-server/Makefile index e040444..db54db7 100644 --- a/databases/postgresql91-server/Makefile +++ b/databases/postgresql91-server/Makefile @@ -178,6 +178,13 @@ INSTALL_TARGET= install-strip .if (${OSVERSION} >= 700000) && !defined(WITHOUT_GSSAPI) CONFIGURE_ARGS+=--with-gssapi +.if !defined(WITH_MIT_KRB5) && !defined(WITH_HEIMDAL_KRB5) +# Kerberos libraries will pull the proper GSSAPI library +# via linker dependencies, but otherwise we must specify +# it explicitely: ld --as-needed is used for compilation, +# so configure's -lgssapi_krb5 won't go. +LDFLAGS+= -lgssapi +.endif .endif . if defined(WITH_MIT_KRB5) -- 1.7.3.4