Bugzilla – Bug 742
Newline missing from sudo.log output
Last modified: 2016-06-18 06:00:33 MDT
This actually affects v1.8.16, but Bugzilla doesn't list that version as an option. It does also seem to affect v1.8.15, though. When using options like Defaults logfile = /var/log/sudo.log Defaults loglinelen = 0 the output is not properly terminated at the ends of a line. Output looks like this: Apr 25 11:39:52 2016 : [REDACTED] : HOST=[REDACTED : TTY=pts/0 ; PWD=/usr/ports/security/sudo/work/sudo-1.8.16 ; USER=root ; COMMAND=/bin/cat /usr/local/etc/sudoersApr 25 12:08:03 2016 : [REDACTED] : HOST=[REDACTED] : TTY=pts/0 ; PWD=/usr/ports/security/sudo/work/sudo-1.8.16 ; USER=root ; COMMAND=/usr/bin/fgrep log /usr/local/etc/sudoers When loglinelen is set to a large number (e.g., 5555), output looks like it should: Apr 25 12:10:15 2016 : [REDACTED] : HOST=[REDACTED] : TTY=pts/0 ; PWD=/usr/ports/security/sudo/work/sudo-1.8.16 ; USER=root ; COMMAND=validate Apr 25 12:10:22 2016 : [REDACTED] : HOST=[REDACTED] : TTY=pts/0 ; PWD=/usr/ports/security/sudo/work/sudo-1.8.16 ; USER=root ; COMMAND=/bin/cat /usr/local/etc/sudoers Apr 25 12:10:35 2016 : [REDACTED] : HOST=[REDACTED] : TTY=pts/0 ; PWD=/usr/ports/security/sudo/work/sudo-1.8.16 ; USER=root ; COMMAND=validate This is a regression that I believe happened sometime in the past six to nine months or so. I know the output logs used to be formatted correctly, but I can't pin down exactly when this started happening. I'm guessing it might have something to do with the change to logging.c that happened with the merge of 1.8.14 (changeset 10139:f93a3f006a69) around - (void) fprintf(fp, "%s : %s : HOST=%s : %s\n", - timestr, user_name, user_srunhost, msg); + if (def_log_host) { + len = asprintf(&full_line, "%s : %s : HOST=%s : %s", as that missing "\n" seems mighty suspicious to me. However, I am most certainly not a coder, so this is a guess on my part. Thanks in advance for looking into this!
Thanks for the report and the analysis. There is indeed a newline missing when logfile wrapping is disabled.
Created attachment 474 [details] Write a newline to log file entries when line wrapping is disabled
Fixed in sudo 1.8.17 which is now available.