unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCHES] Syslog produces no log (just for me?)
@ 2015-03-28 13:24 Alex Kost
  2015-03-29 14:03 ` Ludovic Courtès
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Kost @ 2015-03-28 13:24 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 641 bytes --]

Hello, I noticed that my /var/log/messages (and other log files and
tty12) were not filled anymore.  I found that the problem is in
"syslog.conf": when the "rule" lines begin with spaces, they are
ignored, so I'm attaching a patch to fix it.¹

The strange thing is it worked earlier (with the same config) and since
nobody noticed that before, I have a feeling that it might be the
problem on my computer.  So I appreciate if someone confirms that the
problem really exists.

Also I think it would be good to allow a user to specify his own
configuration file for syslogd (a patch is also attached²).  WDYT?

Thanks, Alex.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-services-syslog-service-Fix-syslog-configuration.patch --]
[-- Type: text/x-patch, Size: 2233 bytes --]

From 2292c9edd1747cda4f0b3f3b964698d3961dfc5d Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Sat, 28 Mar 2015 15:29:55 +0300
Subject: [PATCH 1/2] services: syslog-service: Fix syslog configuration.

* gnu/services/base.scm (syslog-service): Remove leading spaces from the
contents of syslog configuration.
---
 gnu/services/base.scm | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 24e6d32..f5ee8f5 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -531,24 +531,24 @@ given @var{config}---an @code{<nscd-configuration>} object.  Optionally,
 
   ;; Snippet adapted from the GNU inetutils manual.
   (define contents "
-     # Log all error messages, authentication messages of
-     # level notice or higher and anything of level err or
-     # higher to the console.
-     # Don't log private authentication messages!
-     *.alert;auth.notice;authpriv.none       /dev/console
+# Log all error messages, authentication messages of
+# level notice or higher and anything of level err or
+# higher to the console.
+# Don't log private authentication messages!
+*.alert;auth.notice;authpriv.none       /dev/console
 
-     # Log anything (except mail) of level info or higher.
-     # Don't log private authentication messages!
-     *.info;mail.none;authpriv.none          /var/log/messages
+# Log anything (except mail) of level info or higher.
+# Don't log private authentication messages!
+*.info;mail.none;authpriv.none          /var/log/messages
 
-     # Same, in a different place.
-     *.info;mail.none;authpriv.none          /dev/tty12
+# Same, in a different place.
+*.info;mail.none;authpriv.none          /dev/tty12
 
-     # The authpriv file has restricted access.
-     authpriv.*                              /var/log/secure
+# The authpriv file has restricted access.
+authpriv.*                              /var/log/secure
 
-     # Log all the mail messages in one place.
-     mail.*                                  /var/log/maillog
+# Log all the mail messages in one place.
+mail.*                                  /var/log/maillog
 ")
 
   (mlet %store-monad
-- 
2.2.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-services-syslog-service-Add-config-file-argument.patch --]
[-- Type: text/x-patch, Size: 2089 bytes --]

From f66520181a65566b1f191583c3e1344c1af93ecc Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Sat, 28 Mar 2015 15:42:23 +0300
Subject: [PATCH 2/2] services: syslog-service: Add 'config-file' argument.

* gnu/services/base.scm (syslog-service): Add 'config-file' keyword
argument.
* doc/guix.texi (Base Services): Document it.
---
 doc/guix.texi         | 5 +++--
 gnu/services/base.scm | 8 +++++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 3c72e65..73d79e3 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4489,8 +4489,9 @@ external name servers do not even need to be queried.
 @end defvr
 
 
-@deffn {Monadic Procedure} syslog-service
-Return a service that runs @code{syslogd} with reasonable default
+@deffn {Monadic Procedure} syslog-service [#:config-file #f]
+Return a service that runs @code{syslogd}.  If configuration file name
+@var{config-file} is not specified, use some reasonable default
 settings.
 @end deffn
 
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index f5ee8f5..d752948 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -526,8 +526,10 @@ given @var{config}---an @code{<nscd-configuration>} object.  Optionally,
 
              (respawn? #f)))))
 
-(define (syslog-service)
-  "Return a service that runs @code{syslogd} with reasonable default settings."
+(define* (syslog-service #:key config-file)
+  "Return a service that runs @code{syslogd}.
+If configuration file name @var{config-file} is not specified, use some
+reasonable default settings."
 
   ;; Snippet adapted from the GNU inetutils manual.
   (define contents "
@@ -561,7 +563,7 @@ mail.*                                  /var/log/maillog
       (start
        #~(make-forkexec-constructor
           (list (string-append #$inetutils "/libexec/syslogd")
-                "--no-detach" "--rcfile" #$syslog.conf)))
+                "--no-detach" "--rcfile" #$(or config-file syslog.conf))))
       (stop #~(make-kill-destructor))))))
 
 (define* (guix-build-accounts count #:key
-- 
2.2.1


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

* Re: [PATCHES] Syslog produces no log (just for me?)
  2015-03-28 13:24 [PATCHES] Syslog produces no log (just for me?) Alex Kost
@ 2015-03-29 14:03 ` Ludovic Courtès
  2015-03-30  7:23   ` Alex Kost
  0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2015-03-29 14:03 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Hello, I noticed that my /var/log/messages (and other log files and
> tty12) were not filled anymore.  I found that the problem is in
> "syslog.conf": when the "rule" lines begin with spaces, they are
> ignored, so I'm attaching a patch to fix it.¹
>
> The strange thing is it worked earlier (with the same config) and since
> nobody noticed that before, I have a feeling that it might be the
> problem on my computer.  So I appreciate if someone confirms that the
> problem really exists.

If definitely works on my machine.  Could it be that your in-store
syslog.conf has actually been altered or something?  Does syslogd print
an error message in the console when it starts?

> Also I think it would be good to allow a user to specify his own
> configuration file for syslogd (a patch is also attached²).  WDYT?

> From f66520181a65566b1f191583c3e1344c1af93ecc Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Sat, 28 Mar 2015 15:42:23 +0300
> Subject: [PATCH 2/2] services: syslog-service: Add 'config-file' argument.
>
> * gnu/services/base.scm (syslog-service): Add 'config-file' keyword
> argument.
> * doc/guix.texi (Base Services): Document it.

Sure, please push!

Thanks,
Ludo’.

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

* Re: [PATCHES] Syslog produces no log (just for me?)
  2015-03-29 14:03 ` Ludovic Courtès
@ 2015-03-30  7:23   ` Alex Kost
  2015-03-30 21:20     ` Ludovic Courtès
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Kost @ 2015-03-30  7:23 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courtès (2015-03-29 17:03 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> Hello, I noticed that my /var/log/messages (and other log files and
>> tty12) were not filled anymore.  I found that the problem is in
>> "syslog.conf": when the "rule" lines begin with spaces, they are
>> ignored, so I'm attaching a patch to fix it.¹
>>
>> The strange thing is it worked earlier (with the same config) and since
>> nobody noticed that before, I have a feeling that it might be the
>> problem on my computer.  So I appreciate if someone confirms that the
>> problem really exists.
>
> If definitely works on my machine.  Could it be that your in-store
> syslog.conf has actually been altered or something?  Does syslogd print
> an error message in the console when it starts?

Nope, syslog.conf in store is fine.  The problem can be definitely
solved for me by removing leading spaces.  Actually never mind, as I'm
going to use my config for syslog-service, but anyway here is what
happens when I start syslogd with the conf-file of the same contents as
provided by 'syslog-service':

--8<---------------cut here---------------start------------->8---
# /run/current-system/profile/libexec/syslogd --debug --rcfile /tmp/syslog-with-leading-spaces.conf
init
cfline(*.aauth.noth.notice;authpriv.none       /dev/console)
syslogd: unknown priority name "aauth.noth.notice"
(logmsg): syslog.err (43), flags 4, from localhost, msg syslogd: unknown priority name "aauth.noth.notice"
Logging to CONSOLE /dev/console
cfline(*.iail.none.none;authpriv.none          /var/log/messages)
syslogd: unknown priority name "iail.none.none"
(logmsg): syslog.err (43), flags 4, from localhost, msg syslogd: unknown priority name "iail.none.none"
Logging to CONSOLE /dev/console
cfline(*.iail.none.none;authpriv.none          /dev/tty12)
syslogd: unknown priority name "iail.none.none"
(logmsg): syslog.err (43), flags 4, from localhost, msg syslogd: unknown priority name "iail.none.none"
Logging to CONSOLE /dev/console
cfline(aut.*                                   /var/log/secure)
syslogd: unknown facility name "aut"
(logmsg): syslog.err (43), flags 4, from localhost, msg syslogd: unknown facility name "aut"
Logging to CONSOLE /dev/console
cfline(mai                                     /var/log/maillog)
syslogd: unknown priority name ""
(logmsg): syslog.err (43), flags 4, from localhost, msg syslogd: unknown priority name ""
Logging to CONSOLE /dev/console
cannot open /gnu/store/9i6q97ixp1ndrwq06b8b5y7mdy0ii4lz-inetutils-1.9.2/etc/syslog.d
 X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X UNUSED: 
 X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X UNUSED: 
 X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X UNUSED: 
 X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X UNUSED: 
 X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X UNUSED: 
(logmsg): syslog.info (46), flags 4, from localhost, msg syslogd (GNU inetutils 1.9.2): restart
syslogd: restarted
Klog open /proc/kmsg
Opened UNIX socket `/dev/log'.
off & running....
Debugging is disabled. Send SIGUSR1 to PID=354 to turn on debugging.
--8<---------------cut here---------------end--------------->8---

\f
And here is the output when the same conf file but without leading
spaces is used:
--8<---------------cut here---------------start------------->8---
# /run/current-system/profile/libexec/syslogd --debug --rcfile /tmp/syslog-without-leading-spaces.conf
init
cfline(*.alert;auth.notice;authpriv.none       /dev/console)
cfline(*.info;mail.none;authpriv.none          /var/log/messages)
cfline(*.info;mail.none;authpriv.none          /dev/tty12)
cfline(authpriv.*                              /var/log/secure)
cfline(mail.*                                  /var/log/maillog)
cannot open /gnu/store/9i6q97ixp1ndrwq06b8b5y7mdy0ii4lz-inetutils-1.9.2/etc/syslog.d
 X  X ff  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X FILE: /var/log/maillog
 X  X  X  X  X  X  X  X  X  X ff  X  X  X  X  X  X  X  X  X  X  X  X  X  X FILE: /var/log/secure
7f 7f  X 7f 7f 7f 7f 7f 7f 7f  X 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f TTY: /dev/tty12
7f 7f  X 7f 7f 7f 7f 7f 7f 7f  X 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f FILE: /var/log/messages
 3  3  3  3 3f  3  3  3  3  3  X  3  3  3  3  3  3  3  3  3  3  3  3  3  3 CONSOLE: /dev/console
(logmsg): syslog.info (46), flags 4, from localhost, msg syslogd (GNU inetutils 1.9.2): restart
Logging to TTY /dev/tty12
Logging to FILE /var/log/messages
syslogd: restarted
Klog open /proc/kmsg
Opened UNIX socket `/dev/log'.
off & running....
Debugging is disabled. Send SIGUSR1 to PID=355 to turn on debugging.
--8<---------------cut here---------------end--------------->8---

>> Also I think it would be good to allow a user to specify his own
>> configuration file for syslogd (a patch is also attached²).  WDYT?
>
>> From f66520181a65566b1f191583c3e1344c1af93ecc Mon Sep 17 00:00:00 2001
>> From: Alex Kost <alezost@gmail.com>
>> Date: Sat, 28 Mar 2015 15:42:23 +0300
>> Subject: [PATCH 2/2] services: syslog-service: Add 'config-file' argument.
>>
>> * gnu/services/base.scm (syslog-service): Add 'config-file' keyword
>> argument.
>> * doc/guix.texi (Base Services): Document it.
>
> Sure, please push!

Thanks!

-- 
Alex

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

* Re: [PATCHES] Syslog produces no log (just for me?)
  2015-03-30  7:23   ` Alex Kost
@ 2015-03-30 21:20     ` Ludovic Courtès
  2015-04-01  9:54       ` Syslog bug Alex Kost
  0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2015-03-30 21:20 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1932 bytes --]

Alex Kost <alezost@gmail.com> skribis:

> Nope, syslog.conf in store is fine.  The problem can be definitely
> solved for me by removing leading spaces.  Actually never mind, as I'm
> going to use my config for syslog-service, but anyway here is what
> happens when I start syslogd with the conf-file of the same contents as
> provided by 'syslog-service':
>
> # /run/current-system/profile/libexec/syslogd --debug --rcfile /tmp/syslog-with-leading-spaces.conf
> init
> cfline(*.aauth.noth.notice;authpriv.none       /dev/console)
> syslogd: unknown priority name "aauth.noth.notice"
> (logmsg): syslog.err (43), flags 4, from localhost, msg syslogd: unknown priority name "aauth.noth.notice"
> Logging to CONSOLE /dev/console
> cfline(*.iail.none.none;authpriv.none          /var/log/messages)
> syslogd: unknown priority name "iail.none.none"

Ooh, you found a genuine bug, as evidenced by the corrupt strings above.

Confirmed with Valgrind:

--8<---------------cut here---------------start------------->8---
$ valgrind ./src/syslogd --debug --rcfile /gnu/store/cz9n7s884mlr5y4x2bk8kq9hq44nnmaz-syslog.conf
==29582== Memcheck, a memory error detector
==29582== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==29582== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==29582== Command: ./src/syslogd --debug --rcfile /gnu/store/cz9n7s884mlr5y4x2bk8kq9hq44nnmaz-syslog.conf
==29582== 
init
==29582== Source and destination overlap in strcpy(0x55ebc00, 0x55ebc05)
==29582==    at 0x4C29C02: strcpy (in /gnu/store/13dzn85z8yhh6i977lwsii4wd7zjzyka-valgrind-3.10.1/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==29582==    by 0x405D1B: load_conffile.constprop.5 (syslogd.c:1974)
==29582==    by 0x4060CF: init (syslogd.c:2109)
==29582==    by 0x402BAC: main (syslogd.c:601)
--8<---------------cut here---------------end--------------->8---

This patch placates Valgrind and seems to do the job:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 403 bytes --]

diff --git a/src/syslogd.c b/src/syslogd.c
index 7af10f3..1db4455 100644
--- a/src/syslogd.c
+++ b/src/syslogd.c
@@ -1971,7 +1971,7 @@ load_conffile (const char *filename, struct filed **nextp)
       if (*p == '\0' || *p == '#')
 	continue;
 
-      strcpy (cline, p);
+      bcopy (p, cline, strlen (p));
 
       /* Cut the trailing spaces.  */
       for (p = strchr (cline, '\0'); isspace (*--p);)

[-- Attachment #3: Type: text/plain, Size: 125 bytes --]


Could you confirm that it solves the problem for you?  Just add it
locally to the inetutils recipe.

Thanks,
Ludo’.

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

* Re: Syslog bug
  2015-03-30 21:20     ` Ludovic Courtès
@ 2015-04-01  9:54       ` Alex Kost
  2015-04-01 19:51         ` Ludovic Courtès
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Kost @ 2015-04-01  9:54 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 4622 bytes --]

Ludovic Courtès (2015-03-31 00:20 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> Nope, syslog.conf in store is fine.  The problem can be definitely
>> solved for me by removing leading spaces.  Actually never mind, as I'm
>> going to use my config for syslog-service, but anyway here is what
>> happens when I start syslogd with the conf-file of the same contents as
>> provided by 'syslog-service':
>>
>> # /run/current-system/profile/libexec/syslogd --debug --rcfile /tmp/syslog-with-leading-spaces.conf
>> init
>> cfline(*.aauth.noth.notice;authpriv.none       /dev/console)
>> syslogd: unknown priority name "aauth.noth.notice"
>> (logmsg): syslog.err (43), flags 4, from localhost, msg syslogd: unknown priority name "aauth.noth.notice"
>> Logging to CONSOLE /dev/console
>> cfline(*.iail.none.none;authpriv.none          /var/log/messages)
>> syslogd: unknown priority name "iail.none.none"
>
> Ooh, you found a genuine bug, as evidenced by the corrupt strings above.
>
> Confirmed with Valgrind:
>
>
> $ valgrind ./src/syslogd --debug --rcfile /gnu/store/cz9n7s884mlr5y4x2bk8kq9hq44nnmaz-syslog.conf
> ==29582== Memcheck, a memory error detector
> ==29582== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
> ==29582== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
> ==29582== Command: ./src/syslogd --debug --rcfile /gnu/store/cz9n7s884mlr5y4x2bk8kq9hq44nnmaz-syslog.conf
> ==29582== 
> init
> ==29582== Source and destination overlap in strcpy(0x55ebc00, 0x55ebc05)
> ==29582==    at 0x4C29C02: strcpy (in /gnu/store/13dzn85z8yhh6i977lwsii4wd7zjzyka-valgrind-3.10.1/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==29582==    by 0x405D1B: load_conffile.constprop.5 (syslogd.c:1974)
> ==29582==    by 0x4060CF: init (syslogd.c:2109)
> ==29582==    by 0x402BAC: main (syslogd.c:601)
>
> This patch placates Valgrind and seems to do the job:
>
>
> diff --git a/src/syslogd.c b/src/syslogd.c
> index 7af10f3..1db4455 100644
> --- a/src/syslogd.c
> +++ b/src/syslogd.c
> @@ -1971,7 +1971,7 @@ load_conffile (const char *filename, struct filed **nextp)
>        if (*p == '\0' || *p == '#')
>  	continue;
>  
> -      strcpy (cline, p);
> +      bcopy (p, cline, strlen (p));
>  
>        /* Cut the trailing spaces.  */
>        for (p = strchr (cline, '\0'); isspace (*--p);)
>
> Could you confirm that it solves the problem for you?  Just add it
> locally to the inetutils recipe.

Wow, I admire how deep you dig!  Your patch does some funny thing, it
"moves" corruption to another place.  Here is the output:

--8<---------------cut here---------------start------------->8---
# ./syslogd --debug --rcfile /tmp/syslog-with-leading-spaces.conf
init
cfline(*.alert;auth.notice;authpriv.none       /dev/console
sole)
cfline(*.info;mail.none;authpriv.none          /var/log/messages
ages)
cfline(*.info;mail.none;authpriv.none          /dev/tty12
ty12)
cfline(authpriv.*                              /var/log/secure
cure)
cfline(mail.*                                  /var/log/maillog
llog)
cannot open /gnu/store/2k3qc6lff23y0kq51rw5b0kwpq4x7q54-inetutils-1.9.2/etc/syslog.d
 X  X ff  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X FILE: /var/log/maillog
llog
 X  X  X  X  X  X  X  X  X  X ff  X  X  X  X  X  X  X  X  X  X  X  X  X  X FILE: /var/log/secure
cure
7f 7f  X 7f 7f 7f 7f 7f 7f 7f  X 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f FILE: /dev/tty12
ty12
7f 7f  X 7f 7f 7f 7f 7f 7f 7f  X 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f FILE: /var/log/messages
ages
 3  3  3  3 3f  3  3  3  3  3  X  3  3  3  3  3  3  3  3  3  3  3  3  3  3 FILE: /dev/console
sole
(logmsg): syslog.info (46), flags 4, from localhost, msg syslogd (GNU inetutils 1.9.2): restart
Logging to FILE /dev/tty12
ty12
Logging to FILE /var/log/messages
ages
syslogd: restarted
Klog open /proc/kmsg
Opened UNIX socket `/dev/log'.
off & running....
Debugging is disabled. Send SIGUSR1 to PID=21422 to turn on debugging.
--8<---------------cut here---------------end--------------->8---

Look *close* at the file names :-)  This version of syslogd created the
following files on my system:

- "/var/log/maillog
llog",

- "/var/log/messages
ages", etc.

With a line feed character inside (i.e., "/var/log/messages^Jages").

The following modified patch fixes the issue for me.  However my C fu is
almost absent, so I'm not sure about side effects and if there is a
better way (perhaps, it would be better just to write a null character
after moving 'p' to 'cline').


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: syslog-fix.patch --]
[-- Type: text/x-patch, Size: 336 bytes --]

--- a/src/syslogd.c
+++ b/src/syslogd.c
@@ -1971,7 +1971,7 @@ load_conffile (const char *filename, struct filed **nextp)
       if (*p == '\0' || *p == '#')
 	continue;
 
-      strcpy (cline, p);
+      strncpy (cline, p, strlen (cline));
 
       /* Cut the trailing spaces.  */
       for (p = strchr (cline, '\0'); isspace (*--p);)

[-- Attachment #3: Type: text/plain, Size: 174 bytes --]


A side note: compilation of inetutils failed for me complaining about
missing "help2man".  It finished successfully after I had added
"help2man" to native-inputs.

-- 
Alex

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

* Re: Syslog bug
  2015-04-01  9:54       ` Syslog bug Alex Kost
@ 2015-04-01 19:51         ` Ludovic Courtès
  2015-04-01 20:34           ` Alex Kost
  0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2015-04-01 19:51 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 491 bytes --]

Alex Kost <alezost@gmail.com> skribis:

> Wow, I admire how deep you dig!  Your patch does some funny thing, it
> "moves" corruption to another place.  Here is the output:
>
> # ./syslogd --debug --rcfile /tmp/syslog-with-leading-spaces.conf
> init
> cfline(*.alert;auth.notice;authpriv.none       /dev/console
> sole)

Oops, indeed, I had it too but hadn’t noticed.  :-)

This is because the bcopy call didn’t copy the trailing zero, which is
fixed by adding “+ 1”:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 407 bytes --]

diff --git a/src/syslogd.c b/src/syslogd.c
index 7af10f3..aaf02a4 100644
--- a/src/syslogd.c
+++ b/src/syslogd.c
@@ -1971,7 +1971,7 @@ load_conffile (const char *filename, struct filed **nextp)
       if (*p == '\0' || *p == '#')
 	continue;
 
-      strcpy (cline, p);
+      bcopy (p, cline, strlen (p) + 1);
 
       /* Cut the trailing spaces.  */
       for (p = strchr (cline, '\0'); isspace (*--p);)

[-- Attachment #3: Type: text/plain, Size: 753 bytes --]


> --- a/src/syslogd.c
> +++ b/src/syslogd.c
> @@ -1971,7 +1971,7 @@ load_conffile (const char *filename, struct filed **nextp)
>        if (*p == '\0' || *p == '#')
>  	continue;
>  
> -      strcpy (cline, p);
> +      strncpy (cline, p, strlen (cline));

I guess this worked by chance: it does not copy the trailing zero, and
it doesn’t address the overlapping-memory-regions issue.

> A side note: compilation of inetutils failed for me complaining about
> missing "help2man".  It finished successfully after I had added
> "help2man" to native-inputs.

That’s because the patch modifies the source of an executable for which
a man page is generated.

Thanks for your feedback!  I’ll report the issue upstream.

Ludo’.

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

* Re: Syslog bug
  2015-04-01 19:51         ` Ludovic Courtès
@ 2015-04-01 20:34           ` Alex Kost
  0 siblings, 0 replies; 7+ messages in thread
From: Alex Kost @ 2015-04-01 20:34 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courtès (2015-04-01 22:51 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> Wow, I admire how deep you dig!  Your patch does some funny thing, it
>> "moves" corruption to another place.  Here is the output:
>>
>> # ./syslogd --debug --rcfile /tmp/syslog-with-leading-spaces.conf
>> init
>> cfline(*.alert;auth.notice;authpriv.none       /dev/console
>> sole)
>
> Oops, indeed, I had it too but hadn’t noticed.  :-)
>
> This is because the bcopy call didn’t copy the trailing zero, which is
> fixed by adding “+ 1”:
>
>
> diff --git a/src/syslogd.c b/src/syslogd.c
> index 7af10f3..aaf02a4 100644
> --- a/src/syslogd.c
> +++ b/src/syslogd.c
> @@ -1971,7 +1971,7 @@ load_conffile (const char *filename, struct filed **nextp)
>        if (*p == '\0' || *p == '#')
>  	continue;
>  
> -      strcpy (cline, p);
> +      bcopy (p, cline, strlen (p) + 1);
>  
>        /* Cut the trailing spaces.  */
>        for (p = strchr (cline, '\0'); isspace (*--p);)

OK, btw the manual (info "(libc) Copying and Concatenation") says
'bcopy' «is a partially obsolete alternative for 'memmove'».

>> --- a/src/syslogd.c
>> +++ b/src/syslogd.c
>> @@ -1971,7 +1971,7 @@ load_conffile (const char *filename, struct filed **nextp)
>>        if (*p == '\0' || *p == '#')
>>  	continue;
>>  
>> -      strcpy (cline, p);
>> +      strncpy (cline, p, strlen (cline));
>
> I guess this worked by chance: it does not copy the trailing zero, and
> it doesn’t address the overlapping-memory-regions issue.

By chance?  I thought it's reliable as it would fill the redundant part
of 'cline' (the rest part after copying 'p') with null characters.

>> A side note: compilation of inetutils failed for me complaining about
>> missing "help2man".  It finished successfully after I had added
>> "help2man" to native-inputs.
>
> That’s because the patch modifies the source of an executable for which
> a man page is generated.

Ah, thanks for the explanation.

> Thanks for your feedback!  I’ll report the issue upstream.

Great, thank you!

-- 
Alex

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

end of thread, other threads:[~2015-04-01 20:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-28 13:24 [PATCHES] Syslog produces no log (just for me?) Alex Kost
2015-03-29 14:03 ` Ludovic Courtès
2015-03-30  7:23   ` Alex Kost
2015-03-30 21:20     ` Ludovic Courtès
2015-04-01  9:54       ` Syslog bug Alex Kost
2015-04-01 19:51         ` Ludovic Courtès
2015-04-01 20:34           ` Alex Kost

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).