Commit 150679a2 authored by Russ Allbery's avatar Russ Allbery
Browse files

Imported Upstream version 1.0.7

parent 7b631881
PortSystem 1.0
name log4shib
version 1.0.6
version 1.0.7
categories sysutils shibboleth devel
maintainers snc scantor
description configurable logging for C++, fork of log4cpp
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for log4shib 1.0.6.
# Generated by GNU Autoconf 2.69 for log4shib 1.0.7.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
......@@ -587,8 +587,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='log4shib'
PACKAGE_TARNAME='log4shib'
PACKAGE_VERSION='1.0.6'
PACKAGE_STRING='log4shib 1.0.6'
PACKAGE_VERSION='1.0.7'
PACKAGE_STRING='log4shib 1.0.7'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
 
......@@ -1338,7 +1338,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures log4shib 1.0.6 to adapt to many kinds of systems.
\`configure' configures log4shib 1.0.7 to adapt to many kinds of systems.
 
Usage: $0 [OPTION]... [VAR=VALUE]...
 
......@@ -1408,7 +1408,7 @@ fi
 
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of log4shib 1.0.6:";;
short | recursive ) echo "Configuration of log4shib 1.0.7:";;
esac
cat <<\_ACEOF
 
......@@ -1520,7 +1520,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
log4shib configure 1.0.6
log4shib configure 1.0.7
generated by GNU Autoconf 2.69
 
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -2002,11 +2002,57 @@ fi
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
} # ac_fn_c_check_header_mongrel
# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
# ---------------------------------------------
# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
# accordingly.
ac_fn_c_check_decl ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
as_decl_name=`echo $2|sed 's/ *(.*//'`
as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
#ifndef $as_decl_name
#ifdef __cplusplus
(void) $as_decl_use;
#else
(void) $as_decl_name;
#endif
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext 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_decl
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
 
It was created by log4shib $as_me 1.0.6, which was
It was created by log4shib $as_me 1.0.7, which was
generated by GNU Autoconf 2.69. Invocation command line was
 
$ $0 $@
......@@ -2366,7 +2412,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# ? :+1 : ? == just some internal changes, nothing breaks but might work
# better
# CURRENT : REVISION : AGE
LT_VERSION=1:6:0
LT_VERSION=1:7:0
 
 
 
......@@ -2852,7 +2898,7 @@ fi
 
# Define the identity of the package.
PACKAGE='log4shib'
VERSION='1.0.6'
VERSION='1.0.7'
 
 
cat >>confdefs.h <<_ACEOF
......@@ -15287,6 +15333,63 @@ fi
done
 
 
# Checks close-on-exec functionality
# ----------------------------------------------------------------------------
ac_fn_c_check_decl "$LINENO" "O_CLOEXEC" "ac_cv_have_decl_O_CLOEXEC" "#include <fcntl.h>
"
if test "x$ac_cv_have_decl_O_CLOEXEC" = xyes; then :
$as_echo "#define HAVE_O_CLOEXEC 1" >>confdefs.h
fi
ac_fn_c_check_decl "$LINENO" "FD_CLOEXEC" "ac_cv_have_decl_FD_CLOEXEC" "#include <fcntl.h>
"
if test "x$ac_cv_have_decl_FD_CLOEXEC" = xyes; then :
$as_echo "#define HAVE_FD_CLOEXEC 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SOCK_CLOEXEC support" >&5
$as_echo_n "checking for SOCK_CLOEXEC support... " >&6; }
if ${log_cv_sock_cloexec+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
log_cv_sock_cloexec=no
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
#include <sys/socket.h>
int main()
{
return socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0) == -1;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
log_cv_sock_cloexec=yes
else
log_cv_sock_cloexec=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $log_cv_sock_cloexec" >&5
$as_echo "$log_cv_sock_cloexec" >&6; }
if test "$log_cv_sock_cloexec" = "yes"; then
$as_echo "#define HAVE_SOCK_CLOEXEC 1" >>confdefs.h
fi
# Checks local idioms
# ----------------------------------------------------------------------------
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for int64_t" >&5
......@@ -16963,7 +17066,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by log4shib $as_me 1.0.6, which was
This file was extended by log4shib $as_me 1.0.7, which was
generated by GNU Autoconf 2.69. Invocation command line was
 
CONFIG_FILES = $CONFIG_FILES
......@@ -17029,7 +17132,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
log4shib config.status 1.0.6
log4shib config.status 1.0.7
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
 
......
AC_INIT(log4shib, 1.0.6)
AC_INIT(log4shib, 1.0.7)
# autoconf 2.50 or higher to rebuild aclocal.m4, because the
# AC_CREATE_PREFIX_CONFIG_H macro needs the AS_DIRNAME macro.
......@@ -11,7 +11,7 @@ AC_PREREQ(2.50)
# ? :+1 : ? == just some internal changes, nothing breaks but might work
# better
# CURRENT : REVISION : AGE
LT_VERSION=1:6:0
LT_VERSION=1:7:0
AC_SUBST(LT_VERSION)
......@@ -69,6 +69,29 @@ AC_LANG(C)
AC_CHECK_HEADERS([unistd.h])
AC_CHECK_HEADERS([io.h])
# Checks close-on-exec functionality
# ----------------------------------------------------------------------------
AC_CHECK_DECL([O_CLOEXEC],
[AC_DEFINE([HAVE_O_CLOEXEC],[1],[Define to 1 if open supports O_CLOEXEC flag.])],,
[#include <fcntl.h>])
AC_CHECK_DECL([FD_CLOEXEC],
[AC_DEFINE([HAVE_FD_CLOEXEC],[1],[Define to 1 if fcntl supports FD_CLOEXEC flag.])],,
[#include <fcntl.h>])
AC_CACHE_CHECK([for SOCK_CLOEXEC support], [log_cv_sock_cloexec],
[AC_TRY_RUN([
#include <sys/types.h>
#include <sys/socket.h>
int main()
{
return socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0) == -1;
}], [log_cv_sock_cloexec=yes], [log_cv_sock_cloexec=no], [log_cv_sock_cloexec=no])])
if test "$log_cv_sock_cloexec" = "yes"; then
AC_DEFINE([HAVE_SOCK_CLOEXEC], 1, [Define if the SOCK_CLOEXEC flag is supported])
fi
# Checks local idioms
# ----------------------------------------------------------------------------
AC_C_INT64_T
......
......@@ -3,6 +3,9 @@
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if fcntl supports FD_CLOEXEC flag. */
#undef HAVE_FD_CLOEXEC
/* Define to 1 if you have the `ftime' function. */
#undef HAVE_FTIME
......@@ -33,6 +36,9 @@
/* define if the compiler implements namespaces */
#undef HAVE_NAMESPACES
/* Define to 1 if open supports O_CLOEXEC flag. */
#undef HAVE_O_CLOEXEC
/* Define if you have POSIX threads libraries and header files. */
#undef HAVE_PTHREAD
......@@ -42,6 +48,9 @@
/* define if the C library has snprintf */
#undef HAVE_SNPRINTF
/* Define if the SOCK_CLOEXEC flag is supported */
#undef HAVE_SOCK_CLOEXEC
/* define if the compiler has stringstream */
#undef HAVE_SSTREAM
......
Name: log4shib
Version: 1.0.6
Version: 1.0.7
Release: 1
Summary: Log for C++, Shibboleth Edition
License: LGPL
Group: Development/Libraries
Vendor: Shibboleth Consortium
URL: http://shibboleth.net/downloads/log4shib/1.0.6
URL: http://shibboleth.net/downloads/log4shib/1.0.7
Source: %name-%version.tar.gz
BuildRoot: %_tmppath/%name-%version-root
BuildRequires: gcc-c++
......
AC_DEFUN(BB_ENABLE_DOXYGEN,
AC_DEFUN([BB_ENABLE_DOXYGEN],
[
AC_ARG_ENABLE(doxygen, [ --enable-doxygen enable documentation generation with doxygen (auto)])
AC_ARG_ENABLE(dot, [ --enable-dot use 'dot' to generate graphs in doxygen (auto)])
......
......@@ -10,8 +10,8 @@
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,6,0
PRODUCTVERSION 1,0,6,0
FILEVERSION 1,0,7,0
PRODUCTVERSION 1,0,7,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
......@@ -30,7 +30,7 @@ BEGIN
VALUE "CompanyName", "Internet2\0"
VALUE "ContributingAuthors", "Cedric Le Goater, Marc Welz, others. See documentation for complete list\0"
VALUE "FileDescription", "Log library for C++ DLL\0"
VALUE "FileVersion", "1.0.6\0"
VALUE "FileVersion", "1.0.7\0"
VALUE "InternalName", "log4shib\0"
VALUE "LegalCopyright", "Copyright 2000-2013 the Log4cpp Project, others\0"
VALUE "LegalTrademarks", "\0"
......@@ -41,7 +41,7 @@ BEGIN
#endif
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "Log library for C++\0"
VALUE "ProductVersion", "1.0.6\0"
VALUE "ProductVersion", "1.0.7\0"
VALUE "SpecialBuild", "\0"
END
END
......
......@@ -15,6 +15,7 @@
# include <unistd.h>
#endif
#include <fcntl.h>
#include <stdio.h>
#include <time.h>
#include <log4shib/FileAppender.hh>
......@@ -32,9 +33,19 @@ namespace log4shib {
_mode(mode) {
if (!append)
_flags |= O_TRUNC;
#ifdef LOG4SHIB_HAVE_O_CLOEXEC
_flags |= O_CLOEXEC;
#endif
_fd = ::open(_fileName.c_str(), _flags, _mode);
if (_fd == -1)
throw std::runtime_error(std::string("failed to open log file (") + _fileName + ')');
#if !defined(LOG4SHIB_HAVE_O_CLOEXEC) && defined(LOG4SHIB_HAVE_FD_CLOEXEC)
int fdflags = ::fcntl(_fd, F_GETFD);
if (fdflags != -1) {
fdflags |= FD_CLOEXEC;
::fcntl(_fd, F_SETFD, fdflags);
}
#endif
}
FileAppender::FileAppender(const std::string& name, int fd) :
......@@ -43,6 +54,16 @@ namespace log4shib {
_fd(fd),
_flags(O_CREAT | O_APPEND | O_WRONLY),
_mode(00644) {
#ifdef LOG4SHIB_HAVE_O_CLOEXEC
_flags |= O_CLOEXEC;
#endif
#if !defined(LOG4SHIB_HAVE_O_CLOEXEC) && defined(LOG4SHIB_HAVE_FD_CLOEXEC)
int fdflags = ::fcntl(_fd, F_GETFD);
if (fdflags != -1) {
fdflags |= FD_CLOEXEC;
::fcntl(_fd, F_SETFD, fdflags);
}
#endif
}
FileAppender::~FileAppender() {
......@@ -50,9 +71,9 @@ namespace log4shib {
}
void FileAppender::close() {
if (_fd!=-1) {
if (_fd != -1) {
::close(_fd);
_fd=-1;
_fd = -1;
}
}
......@@ -91,9 +112,16 @@ namespace log4shib {
if (fd < 0)
return false;
else {
if (_fd != -1)
if (_fd != -1)
::close(_fd);
_fd = fd;
#if !defined(LOG4SHIB_HAVE_O_CLOEXEC) && defined(LOG4SHIB_HAVE_FD_CLOEXEC)
int fdflags = ::fcntl(_fd, F_GETFD);
if (fdflags != -1) {
fdflags |= FD_CLOEXEC;
::fcntl(_fd, F_SETFD, fdflags);
}
#endif
return true;
}
} else {
......
......@@ -60,12 +60,12 @@ namespace log4shib {
int portNumber) :
LayoutAppender(name),
_syslogName(syslogName),
_relayer(relayer),
_relayer(relayer),
_facility((facility == -1) ? LOG_USER : facility),
_portNumber((portNumber == -1) ? 514 : portNumber),
_socket (0),
_ipAddr (0),
_cludge (0)
_portNumber((portNumber == -1) ? 514 : portNumber),
_socket (0),
_ipAddr (0),
_cludge (0)
{
open();
}
......@@ -81,54 +81,65 @@ namespace log4shib {
}
void RemoteSyslogAppender::open() {
if (!_ipAddr) {
struct hostent *pent = gethostbyname (_relayer.c_str ());
if (!_ipAddr) {
struct hostent *pent = gethostbyname (_relayer.c_str ());
#ifdef WIN32
if (pent == NULL) {
if (WSAGetLastError () == WSANOTINITIALISED) {
WSADATA wsaData;
int err;
err = WSAStartup (0x101, &wsaData );
if (err) {
// loglog("RemoteSyslogAppender: WSAStartup returned %d", err);
if (pent == NULL) {
if (WSAGetLastError () == WSANOTINITIALISED) {
WSADATA wsaData;
int err;
err = WSAStartup (0x101, &wsaData );
if (err) {
// loglog("RemoteSyslogAppender: WSAStartup returned %d", err);
return; // fail silently
}
pent = gethostbyname (_relayer.c_str ());
_cludge = 1;
} else {
// loglog("RemoteSyslogAppender: gethostbyname returned error");
return; // fail silently
}
}
#endif
if (pent == NULL) {
in_addr_t ip = inet_addr (_relayer.c_str ());
pent = gethostbyaddr ((const char *) &ip, sizeof(in_addr_t), AF_INET);
if (pent == NULL) {
// loglog("RemoteSyslogAppender: failed to resolve host %s", _relayer.c_str());
return; // fail silently
}
pent = gethostbyname (_relayer.c_str ());
_cludge = 1;
} else {
// loglog("RemoteSyslogAppender: gethostbyname returned error");
return; // fail silently
}
}
#endif
if (pent == NULL) {
in_addr_t ip = inet_addr (_relayer.c_str ());
pent = gethostbyaddr ((const char *) &ip, sizeof(in_addr_t), AF_INET);
if (pent == NULL) {
// loglog("RemoteSyslogAppender: failed to resolve host %s", _relayer.c_str());
return; // fail silently
}
}
_ipAddr = *(pent->h_addr);
}
// Get a datagram socket.
if ((_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
_ipAddr = *(pent->h_addr);
}
// Get a datagram socket.
int type = SOCK_DGRAM;
#ifdef LOG4SHIB_HAVE_SOCK_CLOEXEC
type |= SOCK_CLOEXEC;
#endif
if ((_socket = socket(AF_INET, type, 0)) < 0) {
// loglog("RemoteSyslogAppender: failed to open socket");
return; // fail silently
}
}
#if !defined(LOG4SHIB_HAVE_SOCK_CLOEXEC) && defined(LOG4SHIB_HAVE_FD_CLOEXEC)
int fdflags = ::fcntl(_socket, F_GETFD);
if (fdflags != -1) {
fdflags |= FD_CLOEXEC;
::fcntl(_socket, F_SETFD, fdflags);
}
#endif
}
void RemoteSyslogAppender::close() {
if (_socket) {
if (_socket) {
#ifdef WIN32
closesocket (_socket);
closesocket (_socket);
#else
::close (_socket);
::close (_socket);
#endif
_socket = 0;
}
_socket = 0;
}
}
void RemoteSyslogAppender::_append(const LoggingEvent& event) {
......
......@@ -73,6 +73,13 @@ namespace log4shib {
::rename(_fileName.c_str(), oldName.str().c_str());
}
_fd = ::open(_fileName.c_str(), _flags, _mode);
#if !defined(LOG4SHIB_HAVE_O_CLOEXEC) && defined(LOG4SHIB_HAVE_FD_CLOEXEC)
int fdflags = ::fcntl(_fd, F_GETFD);
if (fdflags != -1) {
fdflags |= FD_CLOEXEC;
::fcntl(_fd, F_SETFD, fdflags);
}
#endif
}
void RollingFileAppender::_append(const LoggingEvent& event) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment