Quote usernames in the sshd_log if necessary

If the incoming username contains a space it would throw off any
program reading the log file.  Instead quote the value so that a
parser could detect the quoted entry and recover.

Change-Id: If74e8c1f6820df9ba9369b039e6285fefff62549
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-01-02 17:19:26 -08:00
parent d6c0cc1069
commit ab8cc2a743

View File

@@ -308,7 +308,12 @@ class SshLog implements LifecycleListener {
Object val = event.getMDC(key);
buf.append(' ');
if (val != null) {
buf.append(val);
String s = val.toString();
if (0 <= s.indexOf(' ')) {
buf.append(QuotedString.BOURNE.quote(s));
} else {
buf.append(val);
}
} else {
buf.append('-');
}