summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syslogd/syslogd.c
Commit message (Collapse)AuthorAgeFilesLines
* Also terminate program names if we hit a '/' - this is to be slightlydwmalone2004-05-301-1/+2
| | | | | | | more friendly to postfix log messages. PR: 50912 Submitted by: Stanislav Lapshansky <slapsh@slapsh.pp.ru>
* A log file name may now be prefixed by a '-' if it should not bedwmalone2004-05-301-2/+12
| | | | | | | | | | | | | explicitly fsynced after kernel messages are logged. This option should be syntax compatible with a similar option in Linux syslogd. I've made some small changes to Pekka's patch, hoepfully I haven't goofed anything. PR: 66790 Submitted by: Pekka Savola <pekkas@netcore.fi> Obtained from: Martin Schulze's syslogd MFC after: 1 month
* Try to be more careful about using using the file descriptor f_file.dwmalone2004-05-301-7/+13
| | | | | | | | | | | | | | | | | | | | | Syslogd should ensure that f_file is a valid file descriptor when f_type is FILE, CONSOLE, TTY and for a PIPE where f_pid > 0. If the descriptor is closed/invalid then the type should be set to UNUSED or the pid should be set to 0. To this end: 1) Don't close(f->f_file) if we can't send a message to a remote host because the file descriptor used for remote logging is stored in finet, not in f->f_file. f->f_file is probably uninitialised, so I guess we usually end up closing fd 0. 2) Don't close PIPE file descriptors if they are invalid. 3) If the call to p_open fails, don't set the pid. The OpenBSD patches in this area set f_file to -1 after the fd is closed and then avoids calling close if f_file < 0. I haven't done this, but it might be a good idea too. Inspired by: PR 67139/OpenBSD
* Some string fixes.dwmalone2004-05-291-4/+9
| | | | | | | | | | | 1) Use strncpy on strings out of utmp. 2) Avoid running off the start of one string while removing white space. (I've used slightly different code to OpenBSD here.) 3) Ignore trailing spaces in the priority. PR: 67139 Submitted by: Xin LI <delphij@FreeBSD.org.cn> Obtained from: OpenBSD
* Exit with a warning if the path to one of the logging sockets isdwmalone2004-05-291-0/+4
| | | | | | | too long, rather than silently truncating them. PR: 67139 Inspired by: OpenBSD
* Fix some bugs that don't manifest themselves in practice.dwmalone2004-05-291-3/+6
| | | | | | | | | | | | 1) Don't check for getopt returning '?', we have a default case. 2) Check if the priority is LOG_KERN correctly - in practice LOG_KERN is 0, so it makes no difference. OpenBSD fixed a different nearby bug that we don't have 'cos our definition of LOG_MAKEPRI is different to OpenBSD's. Copy a comment from OpenBSD, observing that LOG_KERN is 0. Inspired by PR: 67139
* Update a couple of comments.dwmalone2004-05-291-2/+2
| | | | | | PR: 67139 Submitted by: Xin LI <[3]delphij@FreeBSD.org.cn> Obtained from: OpenBSD
* Silence some constness and printf type warnings. Most of thedwmalone2004-05-261-12/+14
| | | | | const fixes are ugly 'cos the types in an iovec aren't quite right for a writev.
* Use strtol to parse the <%d> tags in printline() and printsys().iedowse2004-01-311-18/+18
| | | | | | Sort local variables declarations in these functions. Submitted by: bde
* Be much more strict about parsing tagged log messages from /dev/klog;iedowse2004-01-261-10/+20
| | | | | | | | | | | | if the line doesn't match ^<%d>, then treat it as a regular kernel printf line. Previously if a kernel printf message started with "<" it would be interpreted as a log message, often with LOG_EMERG level. This was triggered by some printfs in sys/dev/aic7xxx/, and can also happen with the partial lines that result if syslogd cannot keep up with the rate of arrival of kernel messages. Reviewed by: dwmalone MFC after: 1 week
* logerror is used in syslogd to log errors from syslogd itself. Itdwmalone2003-11-161-0/+6
| | | | | | | | | | | | is possible for an error to occur while trying to log an error, and this can result in infinite recursion (or at least until we run out of stack). Rather than this, we ignore requests to log an error while logging an error. PR: 51253 MFC after: 2 weeks
* Remove an argument to printf that is unused.dwmalone2003-11-161-1/+1
|
* Avoid a corrupt timestamp on the consolegshapiro2003-05-171-2/+6
| | | | | | | PR: 51587 Submitted by: Dmitry Sivachenko <mitya@cavia.pp.ru> Approved by: re (rwatson) MFC after: 3 days
* Avoid code duplication by using libutil's trimdomain() instead ofgshapiro2003-05-171-10/+4
| | | | | | | | | an incorrect re-implementation. PR: 52223, 52342 Submitted by: Dan Nelson <dnelson@allantgroup.com> Approved by: re (bmah/rwatson) MFC after: 2 days
* Cleanup hostname matching in syslogd:gshapiro2003-05-041-17/+24
| | | | | | | | | | | | | | | | | | | 1. Hostnames were not treated case insensitively in all cases. 2. The method for stripping hostnames when reading the syslog.conf differed from that when finding the hostname of an incoming request. This lead to a broken match check. In my case, it meant I had to have '@scooter.smi.example.com.example.com' to have 'logger.example.com' properly save messages from 'scooter.smi.sendmail.com'. 3. Add paranoia to cfline() such that it doesn't try to access memory outside of the bounds of the f_host string. 4. While I am here, get rid of an outdated comment, argv[{0,1,2}] are now checked for NULL after the strdup() calls. Reviewed by: dwmalone MFC after: 1 week
* Hostname specifications must allow commas in the value. They arethomas2003-02-211-1/+2
| | | | | | | used to separate multiple host names. Noted by: Dan Nelson <dnelson@allantgroup.com> Reviewed by: roberto
* Allow multiple hosts or programs to be named in programthomas2003-02-131-6/+27
| | | | | | | | | | | | | or host specifications, eg: !foo,bar *.* /var/log/only_foo_or_bar.log !-foo,bar *.* /var/log/all_except_foo_or_bar.log Reviewed by: roberto Not objected to by: arch@
* Factor out the code that determines whether a message must be skippedthomas2002-11-071-26/+27
| | | | | | | as a consequence of a host or program name specification into a common function, skip_pmessage. Reviewed by: roberto
* Add used #include <limits.h>.wollman2002-10-271-0/+1
|
* Sync usage() with reality and sort it alphabetically.tjr2002-10-181-4/+5
| | | | | | PR: 42620 Submitted by: Jeff Ito MFC after: 1 month
* Avoid referencing a removed (and freed) queue entry. This partially revertsdes2002-10-061-2/+4
| | | | | | | | revision 1.101 (which did not introduce the bug but made it harder to fix) PR: misc/40363 Submitted by: David Dunham <dwdunham@isilon.com> MFC after: 2 weeks
* Introduce to the !program specification a capability similar to the onedcs2002-09-231-2/+14
| | | | | | | | | | | | | | | | | | | | | | that already exists for hosts: being able to specify a section that applies to every program *except* the one in question. The normal syntax for program specification is still valid. For the new capability, one uses: !-program Since there is no way to specify a program beginning with a dash in the old syntax, as it would be interpreted as the case above, the following alternative syntax to the original capability is provided: !+program This shouldn't introduce incompatibilities with any syslogd configuration in production because -stable's syslogd does not support a dash anywhere in the program specification. MFC after: 2 weeks
* Make syslogd -u treat "*" as all levels by explictly setting pri_cmpdwmalone2002-09-041-5/+14
| | | | | | | | | | | for it. While I'm here, add a the ability to say "!level" in a way which should be compatible with Linux's syslogd. PR: 28935 No objections: audit MFC after: 2 weeks
* Don't give up on a remote log host when we get a EHOSTUNREACH orcjc2002-08-251-3/+20
| | | | | | | | | | | | | | | | EHOSTDOWN. These are often transient errors (when the remote host reboots, temporary network problems, etc.), and we'd rather err on the side of caution and keep trying send messages that never arrive than just give up. Note that this is not an implementation of the "back-off" methods given in the PR. Those just seem too complicated. Why not just keep trying each time? Trying and failing doesn't really consume significantly more resources than if we were successful for each message. PR: bin/31029 MFC after: 1 week
* When parsing the program name from the incoming log messagerobert2002-07-251-1/+1
| | | | | | from a client, accept all printable characters as being part of the program name, except ':' and '[', because each is a possible delimiter.
* When reading a program name from the syslog configuration file,robert2002-07-251-1/+1
| | | | | | | | | | do not stop copying it into a buffer when encountering a non-alphanumerical character. Only stop at unprintable characters. This makes syslogd work correctly with executables like `interp.bin', `httpd_old', etc. PR: misc/40941 MFC after: 1 week
* use IPV6_V6ONLY instead of non standard IPV6_BINDV6ONLY.ume2002-07-221-3/+1
| | | | MFC after: 1 week
* Remove spaces between (void) and function calls. Use TAILQ_FOREACHdes2002-03-241-30/+40
| | | | | instead of hand-rolled equivalent. Add curly braces for symmetry around else.
* Parenthesize return values and pull an orphaned { back into the fold.des2002-03-241-19/+18
|
* __FBSDID, ANSIfy function definitions, staticize functions and globals,des2002-03-241-148/+108
| | | | | don't initialize globals to 0, some reindentation of declarations, some comments added or reworded.
* Un-__P().des2002-03-241-27/+27
|
* Remove unnecessary setjmp.h.maxim2002-02-131-1/+0
| | | | | | | Reviewed by: ru Approved by: ru Obtained from: OpenBSD MFC after: 1 week
* Unlink all log sockets at startup.maxim2002-02-131-0/+1
| | | | | | | | PR: misc/34839 Reviewed by: ru Approved by: ru Obtained from: OpenBSD MFC after: 2 weeks
* Initialze a stack variable with NULL to unbreak buildworld with -Wall.deischen2002-01-091-1/+1
| | | | | I don't know about anyone else, but the compiler was always aborting on this stupid warning, and has been doing so for weeks.
* Add a new flag '-c' to disable repeated line compression when the outputarchie2002-01-051-2/+7
| | | | | | is a pipe to another program, or, if specified twice, in all cases. PR: bin/32420
* Make the default kernel prefix "kernel:" instead of the boot file,dd2001-11-271-2/+18
| | | | | | | | | | | | | with the old behavior available via the -o option (it might still be useful if one has many kernels and cares which messages came from which). If the boot file is not used as the prefix, it is still logged once at startup. This change is prompted by the fact that the boot file is now much longer ("/boot/kernel/kernel" vs. "/kernel"), which significanlty bloats the syslogd output. Reviewed by: peter
* If the mask length is zero, there is no need to convert it to aps2001-11-141-1/+4
| | | | | | | | netmask. PR: 31947 Submitted by: Aaron Scarisbrick <aaronsca@hotmail.com> MFC after: 1 week
* Check the return values from calls to malloc(), calloc(), strdup() etc.des2001-09-301-12/+33
| | | | | Submitted by: Philippe Charnier <charnier@xp11.frmug.org> MFC after: 2 weeks
* Add a strcasecmp() call I forgot in my hurry to commit the previous fix.des2001-09-131-1/+2
| | | | | | | Without this call, the hostname check would in some cases yield false positives. Pointed out by: ru
* The previous commit appeared to just shove the bug under the carpet ratherdes2001-09-131-5/+23
| | | | | | | | | | than really solve it. This approach (inspired by Ruslan's patch) solves the real problem by stripping the local domain off the host name in the config line structure. Also mark a bunch of code sections that either do not check the return value of a strdup(), malloc() or calloc() call, or do not properly handle a NULL return.
* Fix logging from remote hosts, which has been broken since (at least) revisiondes2001-09-131-2/+3
| | | | | | | | 1.64, i.e. July of last year. Also fix a minor style bug in the same code. PR: bin/28634 Pointy hat to: dwmalone Pointed out by: my buggy DSL router's remote logging facility
* Fixed the free(3) panic overlooked due to the -Wno-uninitialized.ru2001-09-111-1/+2
|
* - Silence warnings: apply `const' generously, mark some variablesdd2001-09-091-44/+48
| | | | | | | | | | | | | | | __unused, and change local variables named `sin' (struct sockaddr_in) to `sin4'. (`sin' conflicts with the definition of sin(3), which gcc assumes to be defined even if math.h isn't included (it's a builtin). This is probably a bug in gcc.) - Apply WARNS=1. WARNS=2 was not used because this program assigns string literals to (struct iovec).iov_base for writing, and the only clean way to silence -Wwrite-strings in that case would be to strdup() and consequently free() those literals, which I considered too disruptive. Reviewed by: bde (partially)
* Correct a last minute sizeof() bogon in my previous commit.kris2001-09-051-1/+1
|
* Introduce a -b option that allows the user to specify which address todd2001-09-011-5/+11
| | | | | | | bind to. This is useful for hosts running jails that need syslog to maintain an open socket to log to a remote host. Reviewed by: sheldonh
* Fix some unsafe signal handlers, and be careful not to overflow on fd_set.kris2001-09-011-102/+136
| | | | | | | | Fix some string buffer operations. Based on: OpenBSD Reviewed by: audit MFC after: 2 weeks
* Gives syslogd(8) the ability to refresh its idea of the hostname ofcjc2001-08-271-7/+27
| | | | | | | | | | | the system on which it is running. The hostname is reloaded when 'HUPped' and a log message generated to note a change (before anyone points it out, this is not an added security feature). PR: bin/24444 Reviewed by: freebsd-audit Approved by: ru MFC after: 2 weeks
* Handle snprintf() returning -1.brian2001-08-201-2/+5
| | | | MFC after: 2 weeks
* - `-a' option for IPv6 was not working correctly.ume2001-07-191-4/+9
| | | | | | | | - Lose any stray host bits that a user may have entered when providing a network number and netmask to the `-a' option for IPv6. This is corresponding to 1.79 that is for IPv4 only. MFC after: 1 week
* Lose any stray host bits that a user may have entered when providingcjc2001-07-021-1/+3
| | | | | | | a network number and netmask to the '-a' option. Approved by: ru MFC after: 1 week
OpenPOWER on IntegriCloud