LWN.net Logo

Sanitizing log file output

Sanitizing log file output

Posted Jul 1, 2011 14:25 UTC (Fri) by geofft (subscriber, #59789)
Parent article: Sanitizing log file output

Is it actually unusual for people to run "dmesg" instead of e.g. "dmesg | cat -A"?

Should dmesg(1) be patched to sanitize output for the current terminal/locale settings? (Is it already?)

What format is the raw kernel buffer, anyway? UTF-8?


(Log in to post comments)

Sanitizing log file output

Posted Jul 1, 2011 19:06 UTC (Fri) by nix (subscriber, #2304) [Link]

I can safely say that I have never run dmesg | cat -A in my life, nor would I ever have thought of doing so had it not been for this thread. I don't think syslog-ng has any defence against this yet, either (though doubtless baszi has already added it by now!)

Sanitizing log file output

Posted Jul 1, 2011 20:09 UTC (Fri) by dlang (✭ supporter ✭, #313) [Link]

for what little it's worth, rsyslog does escape control characters by default.

this is a place that I think a bit of paranoia is good.

what does it hurt to change some characters to hex codes? the readability suffers a tiny bit, but this isn't a novel that you are reading, it's just a log message, and as long as the escaping is done consistantly, does it really matter if you see fooXbar (where X is something other than a ascii printable character) foo#xxxbar (or however you present the escaping)? in either case what you are really going to end up doing is searching or matching the string, and it really doesn't matter which you use for that purpose.

Sanitizing log file output

Posted Jul 1, 2011 20:06 UTC (Fri) by jrn (subscriber, #64214) [Link]

I would think the usual case is "dmesg | less".

Sanitizing log file output

Posted Jul 1, 2011 20:29 UTC (Fri) by nix (subscriber, #2304) [Link]

Indeed. This sanitizes things fine as long as you have the right things in $LESS.

Sanitizing log file output

Posted Jul 3, 2011 0:21 UTC (Sun) by mgedmin (subscriber, #34497) [Link]

I find myself doing "dmegs | tail" more often.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds