[collectd] excessive syslog() definition with FORTIFY_SOURCE

Luboš Staněk lubek at users.sourceforge.net
Tue Nov 21 14:37:54 CET 2006


Hi,
I think that it was discussed in the forum but to no solution
(collectd-3.10.1-alt2: rebuild failed).

It worked right for glibc < 2.4, I think.
The syslog() is defined in glibc-2.4 in the include/bits/syslog.h (which
is included by the syslog.h -> sys/syslog.h) this way:

#define syslog(pri, ...) \
  __syslog_chk (pri, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)

Therefore the current collectd.h definition of syslog() is not working
for the newest glibc and FORTIFY_SOURCE.

The CFLAGS as defined by the RedHat/Fedora Core build farm:
CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m32
-fasynchronous-unwind-tables -march=i386 -mtune=generic"

What is FORTIFY_SOURCE?
In a nutshell, it is a buffer overflow blocking code.
See: http://fedoraproject.org/wiki/Security/Features


>From collectd.h:
---- snip -----
#if HAVE_SYSLOG_H
# include <syslog.h>
#endif
---- snip -----
---- snip -----
#if HAVE_SYSLOG
# define syslog(...) syslog(__VA_ARGS__)
---- snip -----

>From build log:
---- snip -----
In file included from apache.c:23:
collectd.h:132:1: error: "syslog" redefined
In file included from /usr/include/sys/syslog.h:207,
                 from /usr/include/syslog.h:1,
                 from collectd.h:82,
                 from apache.c:23:
/usr/include/bits/syslog.h:28:1: error: this is the location of the
previous definition
In file included from apcups.c:32:
collectd.h:132:1: error: "syslog" redefined
In file included from /usr/include/sys/syslog.h:207,
                 from /usr/include/syslog.h:1,
                 from collectd.h:82,
                 from apcups.c:32:
/usr/include/bits/syslog.h:28:1: error: this is the location of the
previous definition
---- snip -----


Could we change the definition this way?

#if HAVE_SYSLOG
#ifndef syslog
# define syslog(...) syslog(__VA_ARGS__)
#endif

Best regards,
Lubos




More information about the collectd mailing list