* Use __func__ and define it to __FUNCTION__ if not defined.
it's the C99 standard.
* Tests for certain linking libraries (libnsl, libsocket, libresolv) (configure.ac)
* Defines INADDR_NONE if not defined
* Search for <ucred.h> in addition to <sys/ucred.h> (configure.ac)
* Changes include of <sys/errno.h> to <errno.h>.
I _think_ this should be safe on all platforms (and it's the standard)
* Changes local variable name s_addr to saddr in takeover.c.
s_addr is a Single Unix Specification defined name.
* Checks if LOG_AUTHPRIV exists (it does not in Solaris)
Original patch by Magne Mæhre, applied with minor changes
LDFLAGS="$old_LDFLAGS"])
fi
+dnl Check if compiler supports __func__
+AC_CACHE_CHECK([whether compiler supports __func__], pgac_cv_funcname_func,
+ [AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __func__);],
+ [pgac_cv_funcname_func=yes], [pgac_cv_funcname_func=no])])
+if test x"$pgac_cv_funcname_func" = xyes ; then
+ AC_DEFINE(HAVE_FUNCNAME__FUNC, 1,
+ [Define to 1 if your compiler understands __func__.])
+fi
+
dnl asciidoc >= 8.2
AC_CHECK_PROGS(ASCIIDOC, asciidoc)
if test -n "$ASCIIDOC"; then
dnl Checks for header files.
AC_CHECK_HEADERS([crypt.h sys/param.h sys/socket.h libgen.h])
+
dnl ucred.h may have prereqs
-AC_CHECK_HEADERS([sys/ucred.h], [], [], [
+AC_CHECK_HEADERS([ucred.h sys/ucred.h], [], [], [
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
AC_CHECK_FUNCS(strlcpy strlcat getpeereid getpeerucred basename)
AC_SEARCH_LIBS(crypt, crypt, [], AC_MSG_ERROR([crypt not found]))
AC_SEARCH_LIBS(clock_gettime, rt)
+AC_SEARCH_LIBS(getsockname, socket)
+AC_SEARCH_LIBS(gethostbyname, nsl)
+AC_SEARCH_LIBS(hstrerror, resolv)
dnl Find libevent
AC_MSG_CHECKING([for libevent])
#include "config.h"
#endif
-#include <sys/errno.h>
+#include <errno.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#define INT4OID 23
#define TEXTOID 25
+/*
+ * Make sure __func__ works.
+ */
+
+#ifndef HAVE_FUNCNAME__FUNC
+#define __func__ __FUNCTION__
+#endif
+
+/*
+ * Some systems (Solaris) does not define INADDR_NONE
+ */
+#ifndef INADDR_NONE
+#define INADDR_NONE ((unsigned long) -1)
+#endif
+
/*
* libc compat functions.
*/
void _fatal(const char *file, int line, const char *func, bool do_exit, const char *s, ...) _PRINTF(5, 6);
void _fatal_perror(const char *file, int line, const char *func, const char *s, ...) _PRINTF(4, 5);
#define fatal(args...) \
- _fatal(__FILE__, __LINE__, __FUNCTION__, true, ## args)
+ _fatal(__FILE__, __LINE__, __func__, true, ## args)
#define fatal_noexit(args...) \
- _fatal(__FILE__, __LINE__, __FUNCTION__, false, ## args)
+ _fatal(__FILE__, __LINE__, __func__, false, ## args)
#define fatal_perror(args...) \
- _fatal_perror(__FILE__, __LINE__, __FUNCTION__, ## args)
+ _fatal_perror(__FILE__, __LINE__, __func__, ## args)
/*
* non-interruptible operations
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
+#ifdef HAVE_UCRED_H
+#include <ucred.h>
+#endif
#ifdef HAVE_SYS_UCRED_H
#include <sys/ucred.h>
#endif
static void takeover_load_fd(MBuf *pkt, const struct cmsghdr *cmsg)
{
int fd;
- char *task, *s_addr, *user, *db;
+ char *task, *saddr, *user, *db;
char *client_enc, *std_string, *datestyle, *timezone;
int oldfd, port, linkfd;
int got;
/* parse row contents */
got = scan_text_result(pkt, "issssiqissss", &oldfd, &task, &user, &db,
- &s_addr, &port, &ckey, &linkfd,
+ &saddr, &port, &ckey, &linkfd,
&client_enc, &std_string, &datestyle, &timezone);
- if (task == NULL || s_addr == NULL)
+ if (task == NULL || saddr == NULL)
fatal("NULL data from old process");
log_debug("FD row: fd=%d(%d) linkfd=%d task=%s user=%s db=%s enc=%s",
client_enc ? client_enc : "NULL");
/* fill address */
- addr.is_unix = strcmp(s_addr, "unix") == 0 ? true : false;
+ addr.is_unix = strcmp(saddr, "unix") == 0 ? true : false;
if (addr.is_unix) {
addr.port = cf_listen_port;
} else {
- addr.ip_addr.s_addr = inet_addr(s_addr);
+ addr.ip_addr.s_addr = inet_addr(saddr);
addr.port = port;
}
struct FacName { const char *name; int code; };
static struct FacName facility_names [] = {
{ "auth", LOG_AUTH },
- { "authpriv", LOG_AUTHPRIV },
+#ifdef LOG_AUTHPRIV
+ { "authpriv", LOG_AUTHPRIV },
+#endif
{ "daemon", LOG_DAEMON },
{ "user", LOG_USER },
{ "local0", LOG_LOCAL0 },