NetBSD & Google's Summer of Code: Martin Schuette - Improve syslogd (syslogd)

| & |

# NetBSD-SoC: Improve syslogd

## What is it?

The syslog daemon handles most log messages of a unixoid system. It receives messages from shell-scripts, applications, daemons, the kernel, or by network and then writes them into logfiles, on user's consoles or forwards them to some other logserver -- all depending on its configuration and the message properties.

implemented the upcoming IETF standards for NetBSD's syslog(3) and syslogd(8):

- transport-tls defines the network protocol to send syslog data over TLS (instead of UDP), thus providing a reliable and authenticated transport.
- syslog-protocol defines a new layout for syslog lines; the most important additions are full timestamps (with year and timezone) and structured data with name=value pairs. This enables all programs to declare semantic content (uid, client IP, return codes, etc), making automatic log-monitoring (or at least parsing) much easier.
- syslog-sign defines signature messages to assert authentication, integrity and correct sequencing of syslog messages.

To my knowledge this is one of the first implementations of these protocols. It will provide NetBSD (and hopefully the other BSDs as well) with an advanced, reliable, and secure syslogd; thus saving admins the time and effort to install custom logging solutions just to get secure transport to their central logserver.

## Current Status

### Functions

#### TLS

The TLS support is now working (tested with RSA and DSA keys). It will read its configuration from syslog.conf, accept incoming TLS connections to receive messages, establish connections to other TLS servers.

If a TLS server is temporarily not available then its messages will be buffered and sent after reconnection.

#### syslog-protocol

A command line option determines whether syslogd output is in BSD Syslog or in syslog-protocol format. All received messages are converted accordingly.

I also modified syslog(3) in libc to send syslog-protocol messages.

While syslog(3) can only use the message field, a new syslogp(3) call is provided to add a MSGID and structured data to a message.

#### syslog-sign

syslogd(8) is now able to digitally sign messages with syslog-sign.

### syslog.conf

I extended the traditional configuration file format to support additionally fields for TLS. A syslog.conf for TLS currently looks like this:

    # TLS options
    tls_ca="/etc/my.cacert"
    tls_cert="/etc/localhost.crt"
    tls_key="/etc/localhost.key"
    tls_verify="off"
    tls_bindhost="127.0.0.1"
    tls_bindport="13245"
    tls_server=on

    # file destination
    *.*      /home/mschuett/test.log
    # UDP destination
    *.*      @192.168.178.5
    # TLS destination
    *.*      @[127.0.0.1]:5555(fingerprint="SHA1:E4:E1:A6:1C:D4:31:D7:D4:9B:B8:DC:DF:DD:CE:30:71:46:00:92:C9")

### Source Code

To try syslogd fetch the latest .tar.gz archive (2008-08-18) (older versions: 2008-08-05, 2008-08-05).

The sources for syslogd, the libc functions, newsyslog, and logger are also available from the CVS on sourceforge.

For development I used an own SVN; a detailed timeline of code changes is available in the on my Trac.

The syslogd code needs and libevent. The only system-dependent function is wallmsg() to write messages to users's terminals.
It was developed and tested on NetBSD and FreeBSD. I heard it does not compile on OpenBSD (I do not know about DragonflyBSD), probably due to different files under /usr/include. I would be interested if someone tried to compile on Linux; this will be some more work, because one will also need additional functions from BSDs libc that are not in glibc (most notably strlcat()).

## Deliverables

I got all my mandatory components:

- Implement transport-tls in syslogd(8)
- Implement syslog-protocol in syslogd(8)
- Implement syslog-protocol in syslog(3)
- Implement syslog-sign in syslogd(8)

...and parts of my optional components:

- interoperability with other implementations: so far I could only test TLS-transport with rsyslog
- Extended API to use new functions: with syslogp() I wrote a new API; but it is not really the extended API I had in mind here.

## Documentation

New manpages and description:

- my syslogd(8)
- my syslog.conf(5)
- my syslog(3)/syslogp(3)
- How-To configure a TLS transport
- Overview of syslog-sign and its usage

Existing specifications and man-pages:

- RFC3164: The BSD syslog Protocol
- syslogd(8)
- syslog.conf(5)
- syslog(3)
- SUS on syslog.h
- SUS on syslog()

IETF documents:

- Transmission of syslog messages over UDP (draft-ietf-syslog-transport-udp)
- TLS Transport Mapping for Syslog (draft-ietf-syslog-transport-tls)
- The syslog Protocol (draft-ietf-syslog-protocol)
- Signed syslog Messages (draft-ietf-syslog-sign)

Martin Schütte <`info@mschuette.name`>
$Id: index.html,v 1.1 2008/10/31 16:12:19 christos Exp $