Skip to content

Commit

Permalink
Work with postgres library versions < 8.4 Closes #609
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Apr 25, 2014
1 parent ea2941e commit f052c72
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/modules/rlm_sql/drivers/rlm_sql_postgresql/config.h.in
Expand Up @@ -6,6 +6,12 @@
/* Whether the PGRES_SINGLE_TUPLE constant is defined */
#undef HAVE_PGRES_SINGLE_TUPLE

/* Define to 1 if you have the `PQinitOpenSSL' function. */
#undef HAVE_PQINITOPENSSL

/* Define to 1 if you have the `PQinitSSL' function. */
#undef HAVE_PQINITSSL

/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT

Expand Down
81 changes: 81 additions & 0 deletions src/modules/rlm_sql/drivers/rlm_sql_postgresql/configure
Expand Up @@ -1428,6 +1428,73 @@ fi
as_fn_set_status $ac_retval
} # ac_fn_c_try_link
# ac_fn_c_check_func LINENO FUNC VAR
# ----------------------------------
# Tests whether FUNC exists, setting the cache variable VAR accordingly
ac_fn_c_check_func ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define $2 innocuous_$2
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $2 (); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
#undef $2
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char $2 ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_$2 || defined __stub___$2
choke me
#endif
int
main ()
{
return $2 ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_func
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
Expand Down Expand Up @@ -3007,6 +3074,20 @@ fi
if test "x$ac_cv_lib_pq_PQconnectdb" != "xyes"; then
fail="$fail libpq"
fi
for ac_func in \
PQinitOpenSSL \
PQinitSSL \
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
targetname=rlm_sql_postgresql
else
Expand Down
5 changes: 4 additions & 1 deletion src/modules/rlm_sql/drivers/rlm_sql_postgresql/configure.ac
Expand Up @@ -81,7 +81,10 @@ if test x$with_[]modname != xno; then
if test "x$ac_cv_lib_pq_PQconnectdb" != "xyes"; then
fail="$fail libpq"
fi

AC_CHECK_FUNCS(\
PQinitOpenSSL \
PQinitSSL \
)
targetname=modname
else
targetname=
Expand Down
Expand Up @@ -169,11 +169,15 @@ static int sql_init_socket(rlm_sql_handle_t *handle, rlm_sql_config_t *config) {
char *dbstring;
rlm_sql_postgres_conn_t *conn;

#ifdef HAVE_OPENSSL_CRYPTO_H
#if defined(HAVE_OPENSSL_CRYPTO_H) && (defined(HAVE_PQINITOPENSSL) || defined(HAVE_PQINITSSL))
static bool ssl_init = false;

if (!ssl_init) {
#ifdef HAVE_PQINITOPENSSL
PQinitOpenSSL(0, 0);
#else
PQinitSSL(0);
#endif
ssl_init = true;
}
#endif
Expand Down

0 comments on commit f052c72

Please sign in to comment.