Bug 742 - Newline missing from sudo.log output
Newline missing from sudo.log output
Status: RESOLVED FIXED
Product: Sudo
Classification: Unclassified
Component: Sudo
1.8.15
All FreeBSD
: low low
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-04-25 11:18 MDT by Alan
Modified: 2016-06-18 06:00 MDT (History)
0 users

See Also:


Attachments
Write a newline to log file entries when line wrapping is disabled (505 bytes, patch)
2016-04-25 11:30 MDT, Todd C. Miller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alan 2016-04-25 11:18:43 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!
Comment 1 Todd C. Miller 2016-04-25 11:29:02 MDT
Thanks for the report and the analysis.  There is indeed a newline missing when logfile wrapping is disabled.
Comment 2 Todd C. Miller 2016-04-25 11:30:03 MDT
Created attachment 474 [details]
Write a newline to log file entries when line wrapping is disabled
Comment 3 Todd C. Miller 2016-06-18 06:00:33 MDT
Fixed in sudo 1.8.17 which is now available.