Commit Graph

309 Commits

Author SHA1 Message Date
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Enji Cooper
15f0eea574 Parameterize out the length of struct filed->f_lasttime as MAXDATELEN
This removes the hardcoded value for the field (16) and the equivalent
hardcoded lengths in logmsg(..).

This change is being done to help stage future work to add RFC5424/RFC5434
support to syslogd(8).

Obtained from:	Isilon OneFS (dcd33d13da) (as part of a larger change)
Submitted by:	John Bauman <john.bauman@isilon.com>
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-02-25 00:12:29 +00:00
Enji Cooper
8fe70bb8f2 Use SRCTOP instead of .CURDIR relative paths with ".."
This simplifies pathing in make/displayed output

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-02-24 21:35:59 +00:00
Enji Cooper
916aa57754 Sort sys/ #includes some more
MFC after:	1 week
X-MFC with:	r313358
Sponsored by:	Dell EMC Isilon
2017-02-07 01:28:55 +00:00
Enji Cooper
688e4de4e7 Sort sys/ #includes and zap an unnecessary trailing space nearby
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-02-07 00:47:33 +00:00
Enji Cooper
72e282471c Use a flexible array for TypeNames instead of hardcoding the array length
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-02-07 00:42:55 +00:00
Enji Cooper
bc64f428ad Fix typos in comments (returing -> returning)
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-02-07 00:09:48 +00:00
Hiroki Sato
2f1c643658 Fix a bug which caused not to create AF_LOCAL sockets when family
is specified.

Spotted by:	Alex Deiter
2017-01-28 13:09:18 +00:00
Hiroki Sato
b4d60f9802 Add more #ifdef INET and INET6. 2017-01-11 07:21:59 +00:00
Hiroki Sato
8ffb87bf8c - Use more descriptive names for variables.
- Set O_CLOEXEC to the signal pipe and /dev/klog.
- Use a single signal handler to catch both SIGHUP and SIGCHLD.
- Fix a bug which did FD_SET() the writer-end of the pipe.
2016-12-31 13:15:52 +00:00
Hiroki Sato
00f6082b98 Remove extra NULL-check before free(3). 2016-12-31 09:52:00 +00:00
Hiroki Sato
34694ebe05 Replace two fat signal handlers with function calls in
the main I/O multiplex loop.  select() now watches
a pipe which is written by the new skinny signal
handlers and the received signals are handled inside
the loop sequencially.

This eliminates a complex signal mask to guarantee
async-signal safety.
2016-12-31 06:23:05 +00:00
Hiroki Sato
407cd97826 Retry to open an F_PIPE process when it dies unexpectedly.
Reported by:	Eugene Grosbein
PR:		215335
2016-12-31 03:07:48 +00:00
Hiroki Sato
77e315c975 - Fix -N flag (NoBind) for AF_LOCAL sockets.
- Do setsockopt(SO_RCVBUF) for AF_LOCAL sockets regardless of -s flag.
2016-12-24 23:29:50 +00:00
Enji Cooper
d97b8afd73 Unbreak syslogd after r310494
Don't close all file descriptors greater than STDERR_FILENO (2) in
waitdaemon(..) -- only close fd (file descriptor for /dev/null used in
subsequent calls to dup2) if it's greater than STDERR_FILENO.

Reported by:	subbsd@gmail.com, danny@cs.huji.ac.il
Pointyhat to:	hrs
X-MFC with:	r310494
2016-12-24 12:50:17 +00:00
Hiroki Sato
4c06e939f8 - Remove unused code.
- Use closefrom().
2016-12-24 07:13:33 +00:00
Hiroki Sato
acdd9d6a0d - More ifdef INET and INET6.
- Use STDERR_FILENO + 1 instead of "3".
- Fix dprintf() in cvthname().
2016-12-23 06:29:24 +00:00
Hiroki Sato
a3dc138e75 mdoc and style fixes. 2016-12-23 04:59:22 +00:00
Hiroki Sato
732c7a256c - Fix a use-after-free bug when dq_timeout == 1 and
sending SIGTERM to the process failed.  It is an
  unusual situation but it can happen.
- Split deadq_remove() into deadq_remove() and
  deadq_removebypid().
- Normalize variable names of struct deadq_entry *.
2016-12-22 13:46:17 +00:00
Hiroki Sato
066f8db8f3 Add a missing "default:" case. 2016-12-22 05:57:45 +00:00
Hiroki Sato
dd87e05952 Initialize a structure by using a compound literal to avoid forgetting
to zero unspecified members.
2016-12-22 05:55:44 +00:00
Hiroki Sato
1ef75d66c8 Fix debug log in the case of AF_INET6. 2016-12-22 05:28:30 +00:00
Hiroki Sato
cb7c842281 - Simplify masklen->netmask conversion for AF_INET6.
- Use iov[N] by array index instead of using pointer v = &iov[0] to
  make the compiler catch an out-of-range access of the array.
2016-12-22 05:23:38 +00:00
Hiroki Sato
bbe85c3834 Simplify type casting of struct sockaddr_in. 2016-12-21 07:05:34 +00:00
Hiroki Sato
e46b059e46 - Initialize deadq_head statically.
- Fix indent.
- Add missing -S flag into usage().
- Use nitems() for an iov array instead of a macro.
2016-12-21 06:49:21 +00:00
Hiroki Sato
e5610451b2 - Add fklog into struct socklist. Files and local/remote sockets are
now processed in struct socklist in a consistent manner.
- Add helper functions to add a new entry of struct socklist, filed, or peer.
- Use the same routine for -l, -p, and -S.
- Close /dev/klog when read(2) failed.
2016-12-21 06:42:30 +00:00
Hiroki Sato
c532386291 - Use fnmatch(3) for domanname matching of -a options.
- Document the patten matching.
- Document -S flag in SYNOPSIS.
2016-12-21 05:45:59 +00:00
Hiroki Sato
97456b7413 Escape punctuation characters. 2016-12-20 08:49:13 +00:00
Hiroki Sato
2e0ef629ee Add a NULL check. 2016-12-20 04:05:21 +00:00
Hiroki Sato
27efdcd869 Add a default socket bound to *:514 when no -b option is specified.
This was accidentally removed at r309933.

Spotted by:	Michael Butler
2016-12-20 03:41:40 +00:00
Hiroki Sato
a5636d2a3e Add a missing STAILQ_INSERT_TAIL() for allowaddr rule. 2016-12-19 17:10:30 +00:00
Hiroki Sato
442f3ba311 Remove an extra "break" which could incorrectly terminate an
STAILQ_FOREACH() loop when an AF_INET6 rule matched.

Spotted by:	cem
2016-12-13 20:55:46 +00:00
Hiroki Sato
dc96a41b44 - Refactor listening socket list. All of the listening sockets are
now maintained in a single linked-list in a transport-independent manner.
- Use queue.h for linked-list structure.
- Use linked-list for AllowedPeers.
- Use getaddrinfo(8) even for Unix Domain sockets.
- Use macros to type-casting from/to struct sockaddr{,_in,_in6}.
- Define fu_* macro for union f_un to shorten the member names.
- Remove an extra #include <sys/type.h>.
- Add "static" to non-exported symbols.
- !INET support is still incomplete but will be fixed later.

There is no functional change except for some minor debug messages.
2016-12-12 19:33:40 +00:00
Hiroki Sato
8555a6e0a4 Temporarily backout the previous commit because it was totally broken due to
unresolved merge conflicts.

Pointy hat to:	hrs
2016-12-12 19:24:52 +00:00
Hiroki Sato
783e461c73 - Refactor listening socket list. All of the listening sockets are
now maintained in a single linked-list in a transport-independent manner.
- Use queue.h for linked-list structure.
- Use linked-list for AllowedPeers.
- Use getaddrinfo(8) even for Unix Domain sockets.
- Use macros to type-casting from/to struct sockaddr{,_in,_in6}.
- Define fu_* macro for union f_un to shorten the member names.
- Remove an extra #include <sys/type.h>.
- Add "static" to non-exported symbols.
- !INET support is still incomplete but will be fixed later.

There is no functional change except for some minor debug messages.
2016-12-12 19:10:14 +00:00
Baptiste Daroussin
8ecd7189a4 Properly initialize nextp
MFC after:	1 day
2016-11-27 19:27:13 +00:00
Baptiste Daroussin
dd83a7df85 initialize *nextp which could be left uninitialized in case the configuration
file cannot be open/read

Reported by:	Coverity via cem
MFC after:	2 days
CID:		1365665
2016-11-26 15:49:59 +00:00
Baptiste Daroussin
fdec22c37d syslogd(8): add an 'include' keyword
All the '.conf' files not beginning with a '.' contained int he directory
following the keyword will be included.

This keyword can only be used in the first level configuration files.

Modify the default syslogd.conf to 'include' /etc/syslog.d and
/usr/local/etc/syslog.d

It simplify a lot handling of syslog from automation tools.

Reviewed by:	markj, kib (via irc)
Approved by:	markj
MFC after:	2 weeks
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D8402
2016-11-01 01:41:24 +00:00
Baptiste Daroussin
fafe86ce27 Directly set the O_NONBLOCK flags via open(2) 2016-09-11 18:58:44 +00:00
Alan Somers
f32e43a6a8 syslogd: Enable repeated line compression for lines of any length.
Enable repeated line compression for lines of any length, instead of only
short lines. AFAICT repeated line compression was limited to short lines as
a RAM optimization, which made sense when karels added it in 1988, but no
longer.  The penalty is a paltry 904B of RAM per file logged.

Reviewed by:	rpaulo
MFC after:	32 days
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D4475
2016-01-27 16:17:15 +00:00
Kurt Lidl
247027652e Have syslogd honor 'mesg' status when logging to users.
PR:		bin/196742
Submitted by:	jef at mail acme com
Approved by:	rpaulo (mentor)
Differential Revision:	https://reviews.freebsd.org/D4270
2015-11-25 20:01:11 +00:00
Xin LI
e54569ecca die() would never return, mark it as so.
MFC after:	2 weeks
2015-08-27 18:11:00 +00:00
Enji Cooper
c1987c2852 Set f_file to -1/F_UNUSED when after closing when possible
This will help ensure we don't trash file descriptors that get used later on
in the daemon

Found via internal Coverity scan

MFC after: 2 weeks
Discussed with: cem, ed, markj
Differential Revision: https://reviews.freebsd.org/D3081
Submitted by: Miles Ohlrich <miles.ohlrich@isilon.com>
Sponsored by: EMC / Isilon Storage Division
2015-08-05 03:17:06 +00:00
Rui Paulo
baa557331e syslogd: re-read the timezone when receive a SIGHUP.
syslogd already re-reads the configuration file and the hostname when
receiving a SIGHUP, so it makes sense to reset the timezone.
Special care was taken to ensure we don't break installations running
with a custom TZ variable.

PR:		196905
Submitted by:	Kurt Lidl <lidl pix.net>
Sponsored by:	Pi-Coral, Inc.
2015-06-16 22:42:19 +00:00
Rui Paulo
e87161769c syslogd: don't leak finet0.
Submitted by:	Kurt Lidl <lidl pix.net>
Sponsored by:	Pi-Coral, Inc.
2015-06-16 22:31:38 +00:00
Rui Paulo
38076b4ba5 syslogd: support multiple -b options.
It's now possible to bind multiple sockets to different IP addresses.

PR:		159305
Submitted by:	Kurt Lidl <lidl pix.net>
Sponsored by:	Pi-Coral, Inc.
2015-06-16 22:26:22 +00:00
Simon J. Gerraty
ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty
44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty
98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Xin LI
e8a94f7104 path.h is not needed here. 2015-05-16 08:12:00 +00:00