summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syslogd/syslogd.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Early daemons like dhcpleased(8), slaacd(8), unwind(8), resolvd(8)bluhm2021-03-091-1/+5
| | | | | | | | | | | | | are started before syslogd(8). This resulted in ugly sendsyslog(2) dropped logs and the real message was lost. Create a temporary stash for log messages within the kernel. It has a limited size of 100 messages, and each message is truncated to 8192 bytes. When the stash is exhausted, the well-known dropped message is generated with a counter. After syslogd(8) has setup everything, it sends a debug line through libc to flush the kernel stash. Then syslogd receives all messages from the kernel before the usual logs. OK deraadt@ visa@
* Established TCP and TLS sockets of syslogd did stay open foreverbluhm2020-09-141-2/+14
| | | | | | | | | if a client aborted the connection silently. As syslogd does not write anything into incoming connections, it will not recognize failure. Setting TCP keep alive on the listen socket does prevent that for accecpted sockets. Note that outgoing connections do not need it as syslogd will write data into them. noticed by dhill@; OK millert@ beck@ deraadt@
* When DNS lookup of an UDP loghost failed, syslogd(8) did close thebluhm2020-05-251-19/+24
| | | | | | | UDP sockets for sending messages. Keep the sockets open if the config allows to send UDP. Then they can be used to send if DNS is working during the next SIGHUP. bug reported and fix tested by sven falempin; OK millert@
* When syslogd(8) parent process terminates, the file cleanup codebluhm2019-07-051-5/+4
| | | | | | | | | | did not work anymore. unveil(2) prevented removal. Cleaning the UNIX domain sockets is not necessary. They are harmless and unlinked before a new bind. So delete that functionality and convert global to local variables. Providing /var/run/syslog.pid is a common feature that should be kept. A stale pid file is confusing. So add a constant path to unveil(2) to allow pid file removal. OK deraadt@
* React properly to the very unlikely cases where snprintf(3) maybluhm2019-07-021-13/+35
| | | | | | fail. Log the message without formating, that is the best syslogd(8) can do. OK deraadt@
* When system calls indicate an error they return -1, not some arbitraryderaadt2019-06-281-6/+6
| | | | | | value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
* Increase the socket buffer size for sendsyslog(2) to 1 MB. Duringbluhm2019-01-181-8/+22
| | | | | | | bursts it is possible that syslogd(8) cannot process messages fast enough. The larger kernel buffer allows to work them off in more time. Then fewer dropped messages are reported. problem found by millert@; OK claudio@ deraadt@
* When parsing log lines in order to select syslog.conf(5) line blocks, supportschwarze2019-01-131-2/+3
| | | | | | | program names containing period ('.') and underscore ('_') ASCII characters. Missing feature reported by and patch tested by Kawashima underscore James at yahoo dot co dot jp. "Makes sense." deraadt@
* Honor SIGINT/QUIT when running in foregroundkn2018-11-291-2/+2
| | | | | | Allows stopping `syslogd -F' with ^C. OK bluhm
* Unsetting Initialized during syslogd die() is a relic from the timebluhm2018-08-311-4/+1
| | | | | | when we had real signal handlers. But now we use libevent, so remove the old logic. OK deraadt@ millert@
* allow shell globs to match program and hostname selector tags viadjm2018-07-171-3/+4
| | | | fnmatch(3); ok sthen@ bluhm@
* Revert my change to ignore EIO errors when writing to log files.bluhm2017-11-241-2/+2
| | | | | | | | | Syslogd continued logging messages to a file that had an EIO error. This could slow down the whole system. File system errors may cause huge delays at every access. This prevented debugging the issue. Now syslogd will log a warning and shut down logging to this file until restart or SIGHUP. OK deraadt@ espie@ millert@
* When the partition of /var/log was full, syslogd(8) stopped writingbluhm2017-10-231-14/+45
| | | | | | | | to files located there. It did this permanently, so cleaning /var without SIGHUP to syslogd did not help. Better retry, write an error message to other log hosts, and write a summary of dropped messages after it works again. OK millert@ friehm@
* When syslogd writes some startup errors to stderr or console, theybluhm2017-10-051-16/+27
| | | | | | | | never appear in any log file. After initialization, write a summary into log files and to remote log host. So the problem shows up, when someone is looking at the persistent messages. Print the "dropped message" warning in a common function. OK sthen@ millert@
* I have touched more than half the source code lines of syslogd(8).bluhm2017-10-051-1/+17
| | | | Add my copyright explicitly.
* Also ignore "Can't assign requested address" error when sendto(2)bluhm2017-10-021-1/+2
| | | | | | to UDP loghost fails. Otherwise syslogd(8) would no longer send to this destination after the error occured once. tested by Rivo Nurges; OK millert@ benno@ deraadt@
* Document how ioctl(2) LIOCSFD on /dev/klog registers a socket pairbluhm2017-09-271-1/+2
| | | | | to receive sendsyslog(2) messages. discussed with martijn@; OK jmc@ deraadt@
* syslogd has special code to report errors before it has beenbluhm2017-09-171-6/+8
| | | | | | | | initialized. For every message it did reopen the console with file descriptor passing from the privsep parent. Now preopen the console, so writing the message out works in more cases. If the console has been revoked, a reopen via privsep and write again is tried anyway. OK brynet@ deraadt@ jca@
* When writing local output, syslogd ignores EAGAIN. Unfortunatelybluhm2017-09-171-3/+5
| | | | | | | | | it has closed the file descriptor before checking the errno. So f_file contained a bad file descriptor that could be reused at the next open. Keep the file open if errno is EAGAIN. Move the close(2) down where the old file descriptor in f_file is overwritten in all cases. OK deraadt@ jca@
* In the default configuration syslogd(8) kept two *:514 UDP socketsbluhm2017-09-121-2/+18
| | | | | | | | | | | open. These sockets are used for sending UDP packets if there is a UDP loghost in syslog.conf(5). If syslogd is started with -u, they can receive packets, otherwise they are disabled with shutdown(SHUT_RD). In case syslogd does neither send nor receive, close the sockets after reading the configuration file. This gives us a cleaner netstat output, and the ports are not reported by port scanners. This has no security implication. OK benno@ jca@ sthen@ deraadt@
* Kernel sendsyslog(2), libc syslog(3), and syslogd(8) restrict andbluhm2017-08-081-17/+19
| | | | | | truncate the length of a syslog message to 8192 bytes. Use one global define LOG_MAXLINE for all of them. OK deraadt@ millert@
* When syslogd(8) failed to open a logfile, the error message couldbluhm2017-04-281-4/+12
| | | | | | | | | | | get lost. Remove log_setdebug() as it adds too much abstraction, use the global variable Started instead. Set the Started value before the init() function. Then errors during config file processing will be logged to the console as Initialize is still 0. This is better than stderr as the latter may be redirected to /dev/null. Print the timestamp and hostname also for direct messages to console, so that they look like all others. bug report jung@; OK benno@
* Allow syslogd(8) to listen on multiple addresses for incomming TLSbluhm2017-04-251-26/+47
| | | | | | connections. This expands the feature from UDP and TCP to syslog over TLS. input jmc@; OK millert@
* Add syslogd(8) option -r to suppress the summary line for pipe andbluhm2017-04-171-8/+16
| | | | | | | remote loghost as they are most commonly used for automated log processing. With -rr the "last message repeated" feature can be disabled completely. OK sthen@ deraadt@ jmc@
* Incoming TCP connections from clients fill the files of a log server.bluhm2017-04-071-6/+5
| | | | | | | | | A log client reconnects at every SIGHUP. Write these accept and close messages with debug priority, then they can be turned on in syslog.conf. Default is off. While there, move a debug message and set the priority of the exit message explicitly to error. OK mpf@ millert@
* The global variable Startup is not used anymore and can be deleted.bluhm2017-04-051-3/+1
| | | | | The functionality has moved into log_setdebug(). OK millert@
* As we did not have nice log functions before, ttymsg() had to returnbluhm2017-04-051-6/+4
| | | | | | the error string. Log the message when the error happens and make the function void. OK millert@
* The function logmsg() was used to generate local messages and tobluhm2017-04-051-46/+24
| | | | | | | process incoming messages. Split this functionality into log_info() and logline(). Sort the parameters like they appear in the syslog line. OK millert@
* Replace logerror() functions with generic log_warn() from log.c.bluhm2017-04-051-197/+116
| | | | | | Make messages a bit more consistent. Note that the new function supports format strings. Replace some log_debug() with log_warn(). OK millert@
* Replace all combinations of logerror() and die() with log.c fatal().bluhm2017-04-051-28/+16
| | | | | | Internally syslogd's fatal() calls die() to do cleanup if necessary. Also replace all err(3) after log_init() with fatal(). OK millert@
* Replace logdebug() with generic log_debug() from log.c. Implementbluhm2017-04-051-86/+74
| | | | | log_debugadd() to construct debug message incrementally. OK deraadt@
* Do not print a warning if closing the control socket fails. Itbluhm2017-04-051-3/+2
| | | | | cannot happen and there is nothing that could be done about it. OK deraadt@
* fix semicolon after if statement in currently uncalled codejsg2017-03-281-2/+2
| | | | ok bluhm@ deraadt@
* After my previous commit, file descriptor fd_sendsys may be -1 ifbluhm2017-03-261-3/+4
| | | | | socketpair(2) has failed. Do not call ioctl(LIOCSFD) in this case. OK millert@
* Keep syslogd(8) running as long as possible. Regular programsbluhm2017-03-241-30/+17
| | | | | | | | should terminate early in case of an error. But if syslogd dies, no messages can be seen at all. Except from command line parsing and memory shortage during statup, report errors and run all working subsystems, but do not die. OK millert@ dreaadt@
* Start to replace the home grown syslogd(8) internal debug and loggingbluhm2017-03-161-5/+19
| | | | | | | | | | functions with a more common log.c implementation. Of course openlog(3) cannot be used, so adapt the log.[ch] initially copied from ospfd(8) to syslogd's special needs. As the messages are limited to ERRBUFSIZE anyway, malloc(3) in the error logging code can be avoided. Changing all log calls to the new API will be done in a separate step. OK millert@
* Convert the global variable fd_tls to a local one. Use separatebluhm2017-03-161-5/+19
| | | | | | callbacks for TCP and TLS accept(2) instead of looking at the value of the listen file descriptor. OK millert@
* KNF spacing is more important than long linesderaadt2017-03-141-4/+4
|
* Syslogd accepted network input only for either IPv4 or IPv6. Tobluhm2017-01-021-42/+67
| | | | | | overcome this limitation, allow to specify more than one listen address for UDP and TCP. input jmc@; OK deraadt@ millert@
* When syslogd received a SIGHUP during startup, it died instead ofbluhm2016-12-301-1/+12
| | | | | | | reloading its config. This could happen when multiple signals were sent during a short interval. So block SIGHUP until signal handlers are installed. OK deraadt@ jca@
* If syslogd was started with a relative path, the program could notbluhm2016-12-271-3/+1
| | | | | | | | re-exec itself. This exec is done during startup of the privsep parent or when syslogd restarts after a SIGHUP. Convert a relative path in argv[0] to an absolute one with realpath(3) before chdir(2). Do all the path handling in priv_init(). suggested by millert@; OK jca@
* When the kernel message buffer overflows, a message is printed bybluhm2016-12-231-2/+3
| | | | | | | | | syslogd(8) and the buffer is overwritten. But after a complete message buffer was read, we got a split line. This happened as syslogd did a partial read which ended within a line. To avoid the latter, syslogd has to reserve space for the kernel message buffer plus 64 chars for the buffer full message. OK millert@
* Wrap lines earlier on tls_config_set_protocols(3)mestre2016-11-301-5/+5
| | | | Feedback and OK jsing@
* Check return value of tls_config_set_protocols(3) and log if it failsmestre2016-11-211-3/+9
| | | | OK bluhm@
* Remove the artificial maximum number of unix domain sockets inbluhm2016-10-171-6/+14
| | | | | | syslogd(8). Just malloc(3) them dynamically which also gives a more random address space layout. OK deraadt@
* Fix trailing whitespace and shorten long lines.bluhm2016-10-161-8/+10
| | | | No binary change.
* Use closefrom(4) in privsep parent and avoid some global filebluhm2016-10-161-4/+5
| | | | | descriptor variables in syslogd(8) this way. OK rzalamena@
* Do an exec on itself in the privileged syslogd(8) parent processbluhm2016-10-061-5/+13
| | | | | to reshuffle its memory layout. Input rzalamena@; OK deraadt@
* Syslog RFC 5424 says you should add 1 to 6 digits with fractionsbluhm2016-10-061-16/+25
| | | | | | of a second to each syslog timestamp. As we do not measure the time in syslog(3), use only 3 digits with millisecond precision. OK dlg@
* When doing global remote logging and archiving, it is inconvenientbluhm2016-10-041-21/+90
| | | | | | | | | that the syslog timestamp does not contain the year and the timezone, but has local time with daylight saving time. Now with -Z syslogd(8) switches to RFC 5424 ISO format for timestamps. Then all logging is also done in UTC. Default is to keep local time and BSD syslog RFC 3164 format. BIG BIG BIG OK for the feature ajacoutot@; OK deraadt@