Accepting request 59829 from Base:System

Accepted submit request 59829 from user mtomaschewski

OBS-URL: https://build.opensuse.org/request/show/59829
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/rsyslog?expand=0&rev=20
This commit is contained in:
Ruediger Oertel 2011-02-03 00:48:49 +00:00 committed by Git OBS Bridge
commit 344129b694
5 changed files with 188 additions and 81 deletions

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:df96d0a1e31c79367b7c3ab29806515b2d5ea8acd2c184615897ea821506b118
size 1846314

3
rsyslog-5.6.3.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:160d000a5200b4ef6451330d2f30509ef2c974f1850b834221ad8704c21c71d3
size 1846846

View File

@ -1,9 +1,10 @@
commit c5132c84fc1a678b5d93fcc430871c141110b82c
Merge: c4026ec f9a4091
commit 020e414396b9ed4d005b6b0f6fb6567fe954230c
Author: Marius Tomaschewski <mt@suse.de>
Date: Fri Dec 3 18:07:40 2010 +0100
Date: Thu Jan 20 15:08:08 2011 +0100
Merge branch 'v5.6.1-systemd1' into v5.6.2-systemd1
Improved systemd socket activation support
Support for multiple unix sockets and activation in forking mode
commit f9a409137bdcd04ebf4851a23f573c436a14e5b2
Author: Rainer Gerhards <rgerhards@adiscon.com>
@ -30,15 +31,15 @@ Date: Tue Sep 7 13:06:04 2010 +0200
[skipped whitespace-only changes -- mt@suse.de]
diff --git a/ChangeLog b/ChangeLog
index ca13d48..1ea95b2 100644
index 72e2946..8b7c7b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+- acquire /dev/log socket optionally from systemd
+ thanks to Lennart Poettering for this patch
---------------------------------------------------------------------------
Version 5.6.2 [V5-STABLE] (rgerhards), 2010-11-30
- bugfix: compile failed on systems without epoll_create1()
Version 5.6.3 [V5-STABLE] (rgerhards), 2011-01-26
- bugfix: action processor released mememory too early, resulting in
diff --git a/plugins/imuxsock/Makefile.am b/plugins/imuxsock/Makefile.am
index a2fe0ba..28f9f9e 100644
--- a/plugins/imuxsock/Makefile.am
@ -53,7 +54,7 @@ index a2fe0ba..28f9f9e 100644
-imuxsock_la_LIBADD =
+imuxsock_la_LIBADD = $(RSRT_LIBS)
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index 046f12f..89bb50b 100644
index 046f12f..fc6b1e7 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -47,6 +47,7 @@
@ -64,63 +65,70 @@ index 046f12f..89bb50b 100644
MODULE_TYPE_INPUT
@@ -190,6 +191,40 @@ static int create_unix_socket(const char *path, int bCreatePath)
@@ -86,6 +87,7 @@ static prop_t *funixHName[MAXFUNIX] = { NULL, }; /* host-name override - if set,
static int funixFlowCtl[MAXFUNIX] = { eFLOWCTL_NO_DELAY, }; /* flow control settings for this socket */
static int funix[MAXFUNIX] = { -1, }; /* read-only after startup */
static int nfunix = 1; /* number of Unix sockets open / read-only after startup */
+static int sd_fds = 0; /* number of systemd activated sockers */
/* config settings */
static int bOmitLocalLogging = 0;
@@ -190,6 +192,20 @@ static int create_unix_socket(const char *path, int bCreatePath)
if (path[0] == '\0')
return -1;
+ if (strcmp(path, _PATH_LOG) == 0) {
+ int r;
+
+ /* Check whether an FD was passed in from systemd. If
+ * so, it's the /dev/log socket, so use it. */
+
+ r = sd_listen_fds(0);
+ if (r < 0) {
+ errmsg.LogError(-r, NO_ERRCODE, "Failed to acquire systemd socket");
+ return -1;
+ }
+
+ if (r > 1) {
+ errmsg.LogError(EINVAL, NO_ERRCODE, "Wrong number of systemd sockets passed");
+ return -1;
+ }
+
+ if (r == 1) {
+ fd = SD_LISTEN_FDS_START;
+ r = sd_is_socket_unix(fd, SOCK_DGRAM, -1, _PATH_LOG, 0);
+ if (r < 0) {
+ errmsg.LogError(-r, NO_ERRCODE, "Failed to verify systemd socket type");
+ return -1;
+ }
+
+ if (!r) {
+ errmsg.LogError(EINVAL, NO_ERRCODE, "Passed systemd socket of wrong type");
+ return -1;
+ }
+
+ return fd;
+ }
+ }
+ if (sd_fds > 0) {
+ for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + sd_fds; fd++) {
+ if( sd_is_socket_unix(fd, SOCK_DGRAM, -1, path, 0) == 1) {
+ /* ok, it matches -- just use as is */
+ return fd;
+ }
+ /*
+ * otherwise it either didn't matched *this* socket and
+ * we just continue to check the next one or there were
+ * an error and we will recreate it bellow.
+ */
+ }
+ }
+
unlink(path);
memset(&sunx, 0, sizeof(sunx));
@@ -395,8 +430,13 @@ CODESTARTafterRun
@@ -371,6 +387,11 @@ CODESTARTwillRun
if(pLogSockName != NULL)
funixn[0] = pLogSockName;
+ sd_fds = sd_listen_fds(0);
+ if (sd_fds < 0) {
+ errmsg.LogError(-sd_fds, NO_ERRCODE, "Failed to acquire systemd sockets");
+ }
+
/* initialize and return if will run or not */
for (i = startIndexUxLocalSockets ; i < nfunix ; i++) {
if ((funix[i] = create_unix_socket((char*) funixn[i], funixCreateSockPath[i])) != -1)
@@ -395,10 +416,19 @@ CODESTARTafterRun
if (funix[i] != -1)
close(funix[i]);
- /* Clean-up files. */
- for(i = startIndexUxLocalSockets; i < nfunix; i++)
+ /* Clean-up files. If systemd passed us a socket it is
+ * systemd's job to clean it up.*/
+ if (sd_listen_fds(0) > 0)
+ i = 1;
+ else
+ i = startIndexUxLocalSockets;
+ for(; i < nfunix; i++)
if (funixn[i] && funix[i] != -1)
- if (funixn[i] && funix[i] != -1)
+ /* Clean-up files. If systemd passed us a socket it is
+ * systemd's job to clean it up.*/
+ for(i = startIndexUxLocalSockets; i < nfunix; i++) {
+ if (funixn[i] && funix[i] != -1) {
+ if (sd_fds > 0 &&
+ funix[i] >= SD_LISTEN_FDS_START &&
+ funix[i] < SD_LISTEN_FDS_START + sd_fds)
+ continue;
+
unlink((char*) funixn[i]);
+ }
+ }
+
/* free no longer needed string */
free(pLogSockName);
free(pLogHostName);
diff --git a/runtime/Makefile.am b/runtime/Makefile.am
index b700eae..27c56a2 100644
--- a/runtime/Makefile.am
@ -862,7 +870,7 @@ index 0000000..45aac8b
+
+#endif
diff --git a/tools/syslogd.c b/tools/syslogd.c
index 2e4ea5d..245ebe3 100644
index ffcaa27..37c3848 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -135,6 +135,7 @@
@ -873,12 +881,49 @@ index 2e4ea5d..245ebe3 100644
/* definitions for objects we access */
DEFobjCurrIf(obj)
@@ -2431,6 +2432,8 @@ doGlblProcessInit(void)
@@ -2428,10 +2429,44 @@ doGlblProcessInit(void)
*/
exit(1); /* "good" exit - after forking, not diasabling anything */
}
+
num_fds = getdtablesize();
close(0);
/* we keep stdout and stderr open in case we have to emit something */
- for (i = 3; i < num_fds; i++)
+ i = 3;
+
+ if (sd_listen_fds(0) <= 0)
for (i = 3; i < num_fds; i++)
+ /* if (sd_booted()) */ {
+ const char *e;
+ char buf[24] = { '\0' };
+ char *p = NULL;
+ unsigned long l;
+ int sd_fds;
+
+ /* fork & systemd socket activation:
+ * fetch listen pid and update to ours,
+ * when it is set to pid of our parent.
+ */
+ if ( (e = getenv("LISTEN_PID"))) {
+ errno = 0;
+ l = strtoul(e, &p, 10);
+ if (errno == 0 && l > 0 && (!p || !*p)) {
+ if (getppid() == (pid_t)l) {
+ snprintf(buf, sizeof(buf), "%d",
+ getpid());
+ setenv("LISTEN_PID", buf, 1);
+ }
+ }
+ }
+
+ /*
+ * close only all further fds, except
+ * of the fds provided by systemd.
+ */
+ sd_fds = sd_listen_fds(0);
+ if (sd_fds > 0)
+ i = SD_LISTEN_FDS_START + sd_fds;
+ }
+ for ( ; i < num_fds; i++)
(void) close(i);
untty();
}

View File

@ -1,3 +1,26 @@
-------------------------------------------------------------------
Wed Feb 2 16:47:24 UTC 2011 - mt@suse.de
- update to 5.6.3 (v5-stable) with following bugfixes (digest):
* action processor released mememory too early, resulting in
potential issue in retry cases (very unlikely).
* batch processing flagged invalid message as "bad" under some
circumstances
* unitialized variable could cause issues under extreme
conditions plus some minor nits.
* batches which had actions in error were not properly retried
in all cases
* imfile did duplicate messages under some circumstances
- enabled plain tcp input, unix socket output, last message
parser and the libdbi module as separate package.
- disabled systemd patch for openSUSE <= 11.3
-------------------------------------------------------------------
Thu Jan 20 14:10:59 UTC 2011 - mt@suse.de
- Improved systemd socket activation support to allow multiple
unix sockets and activation in forking mode (bnc#656197).
-------------------------------------------------------------------
Fri Dec 3 16:49:41 UTC 2010 - mt@suse.de

View File

@ -1,5 +1,5 @@
#
# spec file for package rsyslog (Version 5.6.2)
# spec file for package rsyslog (Version 5.6.3)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@ -20,11 +20,10 @@
Name: rsyslog
Summary: The enhanced syslogd for Linux and Unix
Version: 5.6.2
Version: 5.6.3
Release: 1
%define upstream_version 5.6.2
# add %define build_with_relp 1 to enable relp on < 11.3, e.g.
# via <topadd>%define build_with_relp 1</topadd> in _link file.
%define upstream_version 5.6.3
%define with_dbi 0%{?suse_version} >= 1140 || 0%{?build_with_relp:1}
%define with_relp 0%{?suse_version} >= 1130 || 0%{?build_with_relp:1}
%define _sbindir /sbin
%define rsyslogdocdir %{_docdir}/%{name}
@ -42,29 +41,33 @@ BuildRequires: klogd
BuildRequires: dos2unix openssl-devel pcre-devel pkgconfig zlib-devel
BuildRequires: krb5-devel mysql-devel net-snmp-devel postgresql-devel
BuildRequires: libgnutls-devel
%if %{?with_relp}
%if 0%{?with_dbi}
BuildRequires: libdbi-devel
%endif
%if 0%{?with_relp}
# RELP support
BuildRequires: librelp-devel
%endif
# UDP spoof support
%if 0%{?suse_version} > 1130
%if 0%{?suse_version} >= 1140
BuildRequires: libnet-devel
#
#BuildRequires: systemd
#
# unresolvable: nothing provides fsck-with-dev-lock needed by systemd
#
# The systemd package provides
# /usr/share/doc/packages/systemd/sd-daemon.[ch]
# files instead of a lib ...
BuildRequires: systemd
%else
BuildRequires: libnet
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
#Source0: http://download.rsyslog.com/rsyslog/%{name}-%{upstream_version}.tar.gz
#Source0: http://download.rsyslog.com/rsyslog/rsyslog-<upstream_version>.tar.gz
Source0: %{name}-%{upstream_version}.tar.bz2
Source1: rsyslog.sysconfig
Source2: rsyslog.conf.in
Source3: rsyslog.early.conf.in
Source4: rsyslog.d.remote.conf.in
%if 0%{?suse_version} >= 1140
Patch1: rsyslog-systemd-integration.bnc656104.diff
%endif
%description
Rsyslog is an enhanced multi-threaded syslogd supporting, among others,
@ -138,6 +141,21 @@ package.
This module provides the support for logging into PostgreSQL databases.
%if 0%{?with_dbi}
%package module-dbi
License: GPLv3+
Group: System/Daemons
Requires: %{name} = %{version}
Summary: Database support via DBI
%description module-dbi
Rsyslog is an enhanced multi-threaded syslog daemon. See rsyslog
package.
This package provides a module with the support for logging into DBI
supported databases.
%endif
%package module-snmp
License: GPLv3+
Group: System/Daemons
@ -164,7 +182,7 @@ package.
This module provides the ability for TLS encrypted TCP logging (based
on current syslog-transport-tls internet drafts).
%if %{?with_relp}
%if 0%{?with_relp}
%package module-relp
License: GPLv3+
@ -194,7 +212,11 @@ This module provides a UDP forwarder that allows changing the sender address.
%prep
%setup -q -n %{name}-%{upstream_version}
%if 0%{?suse_version} >= 1140
%patch1 -p1
# install the files systemd provides rather than what we provide.
cp -a /usr/share/doc/packages/systemd/sd-daemon.[ch] runtime/
%endif
dos2unix doc/*.html
%build
@ -220,18 +242,24 @@ export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -W -Wall"
--enable-gssapi-krb5 \
--enable-mysql \
--enable-pgsql \
%if 0%{?with_dbi}
--enable-libdbi \
%endif
%if 0%{?with_relp}
--enable-relp \
%endif
--enable-snmp \
--enable-mail \
--enable-imfile \
--enable-imptcp \
--enable-imtemplate \
--enable-omprog \
--enable-omuxsock \
--enable-omtemplate \
--enable-diagtools \
%if %{?with_relp}
--enable-relp \
%endif
--enable-omudpspoof \
--enable-omstdout \
--enable-pmlastmsg \
--enable-diagtools \
--disable-static
make %{?_smp_mflags:%{_smp_mflags}} V=1
@ -241,12 +269,15 @@ make install DESTDIR="%{buildroot}" V=1
#
rm -f %{buildroot}%{rsyslog_module_dir_nodeps}/*.la
#
# move all modules linking libraries in /usr to /usr/%_lib
# move all modules linking libraries in /usr to /usr/lib[64]
# the user has to specify them with full path then...
install -d -m0755 %{buildroot}%{rsyslog_module_dir_withdeps}
for mod in omgssapi.so imgssapi.so lmgssutil.so ommysql.so \
ompgsql.so omsnmp.so lmnsd_gtls.so \
%if %{?with_relp}
%if 0%{?with_dbi}
omlibdbi.so \
%endif
%if 0%{?with_relp}
imrelp.so omrelp.so \
%endif
; do
@ -412,6 +443,7 @@ fi
%{rsyslog_module_dir_nodeps}/lmnet.so
%{rsyslog_module_dir_nodeps}/lmnetstrms.so
%{rsyslog_module_dir_nodeps}/lmnsd_ptcp.so
%{rsyslog_module_dir_nodeps}/imptcp.so
%{rsyslog_module_dir_nodeps}/lmregexp.so
%{rsyslog_module_dir_nodeps}/lmstrmsrv.so
%{rsyslog_module_dir_nodeps}/lmtcpclt.so
@ -420,9 +452,11 @@ fi
%{rsyslog_module_dir_nodeps}/ommail.so
%{rsyslog_module_dir_nodeps}/omprog.so
%{rsyslog_module_dir_nodeps}/omruleset.so
%{rsyslog_module_dir_nodeps}/omstdout.so
%{rsyslog_module_dir_nodeps}/omtemplate.so
%{rsyslog_module_dir_nodeps}/omtesting.so
%{rsyslog_module_dir_nodeps}/omstdout.so
%{rsyslog_module_dir_nodeps}/omuxsock.so
%{rsyslog_module_dir_nodeps}/pmlastmsg.so
%dir %{rsyslog_module_dir_withdeps}
%{_mandir}/man5/rsyslog.conf.5*
%{_mandir}/man8/rsyslogd.8*
@ -463,6 +497,12 @@ fi
%doc %{rsyslogdocdir}/pgsql-createDB.sql
%{rsyslog_module_dir_withdeps}/ompgsql.so
%if 0%{?with_dbi}
%files module-dbi
%defattr(-,root,root)
%{rsyslog_module_dir_withdeps}/omlibdbi.so
%endif
%files module-snmp
%defattr(-,root,root)
%{rsyslog_module_dir_withdeps}/omsnmp.so
@ -471,8 +511,7 @@ fi
%defattr(-,root,root)
%{rsyslog_module_dir_withdeps}/lmnsd_gtls.so
%if %{?with_relp}
%if 0%{?with_relp}
%files module-relp
%defattr(-,root,root)
%{rsyslog_module_dir_withdeps}/imrelp.so