* fix freeze problems (#742624)

This commit is contained in:
Jose Pedro Oliveira 2011-12-14 18:11:37 +00:00
parent 4f524921bb
commit 2e987763ca
3 changed files with 101 additions and 4 deletions

View File

@ -0,0 +1,88 @@
From: Balazs Scheidler <bazsi@balabit.hu>
Date: Wed, 14 Dec 2011 14:21:05 +0000 (+0100)
Subject: afunix: clarified error messages in case of a failure
X-Git-Url: http://git.balabit.hu/?p=bazsi%2Fsyslog-ng-3.3.git;a=commitdiff_plain;h=606c8cc0b10aa4e877f70726b707402d100bb0f9
afunix: clarified error messages in case of a failure
On Fedora systems, syslog-ng was configured to use unix-stream() /dev/log
whereas systemd supplied a unix-dgram() one, which caused difficult to
diagnose problems.
This patch adds further logging to this case and causes syslog-ng to fail
with an error message if it finds that /dev/log is using an incorrect
socket type.
Reported-By: Michal Schmidt <mschmidt@redhat.com>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
---
diff --git a/modules/afsocket/afunix.c b/modules/afsocket/afunix.c
index cd86798..8145f1a 100644
--- a/modules/afsocket/afunix.c
+++ b/modules/afsocket/afunix.c
@@ -75,7 +75,7 @@ static gboolean
afunix_sd_acquire_socket(AFSocketSourceDriver *s, gint *result_fd)
{
AFUnixSourceDriver *self = (AFUnixSourceDriver *) s;
- gint fd, fds, t, r;
+ gint fd, fds;
*result_fd = -1;
fd = -1;
@@ -100,13 +100,40 @@ afunix_sd_acquire_socket(AFSocketSourceDriver *s, gint *result_fd)
{
for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + fds; fd++)
{
- t = (self->super.flags & AFSOCKET_STREAM) ? SOCK_STREAM : SOCK_DGRAM;
- r = sd_is_socket_unix(fd, t, -1, self->filename, 0);
- if (r == 1)
+ /* check if any type is available */
+ if (sd_is_socket_unix(fd, 0, -1, self->filename, 0))
{
- *result_fd = fd;
- break;
- }
+ int type = (self->super.flags & AFSOCKET_STREAM) ? SOCK_STREAM : SOCK_DGRAM;
+
+ /* check if it matches our idea of the socket type */
+ if (sd_is_socket_unix(fd, type, -1, self->filename, 0))
+ {
+ *result_fd = fd;
+ break;
+ }
+ else
+ {
+ msg_error("The systemd supplied UNIX domain socket is of a different type, check the configured driver and the matching systemd unit file",
+ evt_tag_str("filename", self->filename),
+ evt_tag_int("systemd-sock-fd", fd),
+ evt_tag_str("expecting", type == SOCK_STREAM ? "unix-stream()" : "unix-dgram()"),
+ NULL);
+ return FALSE;
+ }
+ }
+ else
+ {
+
+ /* systemd passed an fd we didn't really care about. This is
+ * not an error, but might be worth mentioning it at the debug
+ * level.
+ */
+
+ msg_debug("Ignoring systemd supplied fd as it is not a UNIX domain socket",
+ evt_tag_str("filename", self->filename),
+ evt_tag_int("systemd-sock-fd", fd),
+ NULL);
+ }
}
}
else
@@ -123,7 +150,7 @@ afunix_sd_acquire_socket(AFSocketSourceDriver *s, gint *result_fd)
}
else
{
- msg_debug("Failed to acquire systemd socket, opening nevertheless",
+ msg_debug("Failed to acquire systemd socket, trying to open ourselves",
evt_tag_str("filename", self->filename),
NULL);
}

View File

@ -21,7 +21,7 @@ options {
source s_sys {
file ("/proc/kmsg" program_override("kernel: "));
unix-stream ("/dev/log");
unix-dgram ("/dev/log");
internal();
# udp(ip(0.0.0.0) port(514));
};

View File

@ -5,7 +5,7 @@
Name: syslog-ng
Version: 3.2.5
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Next-generation syslog server
Group: System Environment/Daemons
@ -19,6 +19,7 @@ Source4: syslog-ng.logrotate
Patch0: syslog-ng-3.2.4-disable-ssl-tests.patch
Patch1: syslog-ng-3.2.5-syslog-ng.service.patch
Patch2: syslog-ng-3.3.4-afunix.c-diagnostic-messages.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -83,6 +84,7 @@ developing applications that use %{name}.
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
# fix perl path
%{__sed} -i 's|^#!/usr/local/bin/perl|#!%{__perl}|' contrib/relogger.pl
@ -244,6 +246,9 @@ fi
%{_datadir}/%{name}/syslog-ng.vim
%ghost %{_datadir}/vim/
# scl files
%{_datadir}/%{name}/include/
# uhm, some better places for those?
%{_datadir}/%{name}/xsd/
@ -260,11 +265,15 @@ fi
%defattr(-,root,root,-)
%{_libdir}/libsyslog-ng.so
%{_includedir}/%{name}/
# scl files
%{_datadir}/%{name}/include/
%changelog
* Wed Dec 14 2011 Jose Pedro Oliveira <jpo at di.uminho.pt> - 3.2.5-2
- Fix the freeze problems caused by the /dev/log unix socket type mismatch (#742624)
+ syslog-ng.conf: change /dev/log from unix-stream to unix-dgram
+ upstream patch syslog-ng-3.3.4-afunix.c-diagnostic-messages.patch
- Move the SCL files to the main RPM (#742624 comments >= 28)
* Tue Nov 1 2011 Jose Pedro Oliveira <jpo at di.uminho.pt> - 3.2.5-1
- Update to 3.2.5