Commit Graph

32 Commits

Author SHA1 Message Date
Nicholas J. Kain
3640c5bbf0 Ifchd: Print out log messages when commands are successfully dispatched. 2013-05-08 06:36:20 -04:00
Nicholas J. Kain
b7e6f59fc7 Use a Ragel-generated DFA parser for ifchd command dispatch. 2013-05-08 06:27:22 -04:00
Nicholas J. Kain
958a57d819 Convert to using strnkc(at|py). 2013-05-06 07:07:54 -04:00
Nicholas J. Kain
483ca6752d Whitelist syscalls provided by vDSO. 2012-07-22 09:49:51 -04:00
Nicholas J. Kain
7d5b6ddc7e Whitelist clock_gettime() for seccomp. Not necessary so long as vdso
is enabled, but otherwise...
2012-07-21 19:46:50 -04:00
Nicholas J. Kain
b53b8585d5 Use clock_gettime(CLOCK_MONOTONIC) instead of time() in ifchd.
Standardize license/copyright and version prints.
2012-07-21 14:02:42 -04:00
Nicholas J. Kain
87db9c70fd Enforce minimum physical MTU in ifchd.
Skip zero-length commands in execute_buffer().
2012-07-20 20:37:41 -04:00
Nicholas J. Kain
2bf7306bb9 Add some more syscalls to the ndhc permit filter. Netlink sockets were
broken before because of too-strict filters.

Move setup_signals under the seccomp filter to give it more testing coverage.

Make the UDP datagram length check much more strict.  If the read buffer
does not match up with the header lengths exactly, it is discarded.

Print a warning to syslog/stdout when ifchd execute_buffer() returns an
error.

Fix a regression introduced in ifchd that would cause the epoll handler to
spin when a client connection closed.
2012-07-20 18:48:26 -04:00
Nicholas J. Kain
f9c2059d37 Quit using malloc entirely in ifchd and reduce buffer copies.
This change also modifies the ndhc/ifchd wire protocol slightly.  The
new protocol doesn't overload the ':' character as a key:value separator
and a statement separator.  Instead ';' is now used as a statement separator.
The new format allows for more robust error-checking and reporting, and it
greatly simplifies the parser.  Old versions of ndhc/ifchd will not work
properly with ones compiled after this commit.

The 'domain' and 'search' keywords in resolv.conf updates are now used
more precisely.  The first domain in an update is the 'domain', and the
subsequent 5 domains are 'search' domains.

There are also supporting cleanups that pass struct ifchd_client pointers
to functions instead of passing index values.

This commit is large, but it cannot really be broken up into smaller
chunks since the changes are dependent on each other.
2012-07-20 17:31:15 -04:00
Nicholas J. Kain
6e9d856a9d Code cleanup. Create struct ifchd_client and pull all of the global
static arrays that are indexed by the socket slot index into an array
of struct ifchd_clients.
2012-07-20 14:56:17 -04:00
Nicholas J. Kain
c3272f07f4 Update copyright and license print spam. 2012-07-20 09:37:41 -04:00
Nicholas J. Kain
f4f9d02afd Enforce seccomp syscall restrictions when kernel support exists. 2012-07-20 07:05:56 -04:00
Nicholas J. Kain
ed2ffbb862 Constify some invariant structures. 2011-09-17 02:30:52 -04:00
Nicholas J. Kain
8caf9e7d7a Remove support for RFC868 Time Server options. Totally obsolete, and
ifchd just had empty hooks that never received work messages anyway.

Shorten the names of ifchd commands.  This breaks wire protocol, but
thankfully I haven't released yet!
2011-07-25 03:39:17 -04:00
Nicholas J. Kain
2cb0b9227d Consolidate DHCP option code numbers. 2011-07-25 03:11:47 -04:00
Nicholas J. Kain
77af1d81fe Relicense under New BSD (2-clause) license. I don't see any advantage to
restricting use unnecessarily, and simple attribution is fine.
2011-07-25 02:30:57 -04:00
Nicholas J. Kain
7e1e902b34 Share ifchd command defines between ifchd and ndhc. 2011-07-25 02:01:38 -04:00
Nicholas J. Kain
2aff36a274 Provide a gmake Makefile for distro builds and packagers.
Define _GNU_SOURCE in the CFLAGS.
Update the README.
Remove the duplicate Gentoo init script ndhc.sh that is in the root.
Remove DESIGN -- it's outdated.
2011-07-12 04:09:05 -04:00
Nicholas J. Kain
7ee0001e97 Constant correctness: socket(PF_*, ...) -> socket(AF_*, ...) 2011-06-25 11:11:48 -04:00
Nicholas J. Kain
d72b24a2fe Theoretical correctness fix:
Handle EAGAIN and EWOULDBLOCK more gracefully when dealing with safe_read().
All occurrences of safe_read() should only be invoked on fds that have signaled
ready-to-read state via the epoll() mechanism, so this change should not
result in any observable difference, but it is best to be safe.

Additionally, a constant stack variable is converted to an equivalent
macro define for cleanliness.

Finally, print the error type encountered if reading data from an ARP response
fails with a read error.
2011-05-30 10:54:05 -04:00
Nicholas J. Kain
59beb159d3 Place the ifchange socket in /var/state/ifchange within the chroot
jail and change configuration instructions as well.

Change default configuration instructions to specify setting root
of the chroot jail as owned by root.root.
2011-05-01 20:43:29 -04:00
Nicholas J. Kain
b3f9115689 Add a -V --verbose flag to enable the overly verbose list reciept logging.
Update interface flags only if it would provoke an actual change.
2011-04-30 07:30:07 -04:00
Nicholas J. Kain
f2b4527179 Use epoll() and signalfd() in ifchd. 2010-12-01 12:22:08 -05:00
Nicholas J. Kain
a43e69c7ae Factor out safe_write() into ncmlib and use it in ndhc as well. 2010-11-13 08:18:23 -05:00
Nicholas J. Kain
eb6009a5ee Make write() and sendto() properly handle short writes and errors in ndhc.
Make ndhc write a pidfile.
Clean up defines.h and split out ifchd and ndhc specifics.
2010-11-12 18:44:49 -05:00
Nicholas J. Kain
9d7ad2f11c Fix some strlcpy() misuse that cuts off the last character of the copied
string.
Clean up some log messages.
2010-11-12 17:24:54 -05:00
Nicholas J. Kain
f4a00f3826 Whitespace and indentation normalization. 2010-11-12 14:33:17 -05:00
Nicholas J. Kain
8aa6d9a320 Fix file_exists() to deal with modern variant.
Update README.
2010-11-12 12:05:37 -05:00
Nicholas J. Kain
b2daf09c10 Move set_cap() to ncmlib/cap.[ch]. 2010-11-12 09:04:43 -05:00
Nicholas J. Kain
2bc86fad4e Clean whitespace in ifchd.c. 2010-11-12 06:05:46 -05:00
Nicholas J. Kain
b882669f85 Convert to using shared ncmlib. 2010-11-12 05:42:07 -05:00
Nicholas J. Kain
b42eeb8847 Move ifchd files to a subdirectory. 2010-11-12 04:51:49 -05:00