All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] logger: do not exit when socket errors are not enforced
@ 2015-07-19 20:19 Sami Kerola
  2015-07-20  8:55 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Sami Kerola @ 2015-07-19 20:19 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

The libc openlog(3) does not have error detection whether unix socket
could be opened.  As a side effect that made it possible to use logger
even if syslogd was not running.  Of course user message in these cases
were lost.  This change makes the logger do behave similar way again, so
that sysvinit scripts can successfully pipe messages to logger when ever.

Addresses: https://bugs.debian.org/787864
Addresses: https://bugs.debian.org/790875
Reported-by: Andreas Beckmann <anbe@debian.org>
Reported-by: Andreas Henriksson <andreas@fatal.se>
Tested-by: Robie Basak <robie.basak@ubuntu.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 misc-utils/logger.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 8908dfc..9947b75 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -242,9 +242,10 @@ static int unix_socket(struct logger_ctl *ctl, const char *path, const int socke
 		if (ctl->unix_socket_errors)
 			err(EXIT_FAILURE, _("socket %s"), path);
 		else
-			/* See --socket-errors manual page entry for
-			 * explanation of this strange exit.  */
-			exit(EXIT_SUCCESS);
+			/* openlog(3) compatibility, socket errors are
+			 * not reported, but ignored silently */
+			ctl->noact = 1;
+			return -1;
 	}
 	return fd;
 }
@@ -685,7 +686,7 @@ static void logger_stdin(struct logger_ctl *ctl)
 
 static void logger_close(const struct logger_ctl *ctl)
 {
-	if (close(ctl->fd) != 0)
+	if (ctl->fd != -1 && close(ctl->fd) != 0)
 		err(EXIT_FAILURE, _("close failed"));
 	free(ctl->hdr);
 }
-- 
2.4.6


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] logger: do not exit when socket errors are not enforced
  2015-07-19 20:19 [PATCH] logger: do not exit when socket errors are not enforced Sami Kerola
@ 2015-07-20  8:55 ` Karel Zak
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2015-07-20  8:55 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Sun, Jul 19, 2015 at 09:19:12PM +0100, Sami Kerola wrote:
> The libc openlog(3) does not have error detection whether unix socket
> could be opened.  As a side effect that made it possible to use logger
> even if syslogd was not running.  Of course user message in these cases
> were lost.  This change makes the logger do behave similar way again, so
> that sysvinit scripts can successfully pipe messages to logger when ever.

Applied, thanks 
-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-20  8:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-19 20:19 [PATCH] logger: do not exit when socket errors are not enforced Sami Kerola
2015-07-20  8:55 ` Karel Zak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.