| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
| |
If the control socket is in non-blocking mode, there's no guarantee that
we can easily send an error message to the client - we *probably* can,
but let's not rely on it, especially given that there are "shouldn't
happen" errors. Log them instead.
While we're at it, fix a copy-and-pasteo and fix indentation.
(cherry picked from commit 40b4666b567b234a5d8c2ae802c290d49758834a)
|
|
|
|
|
|
|
|
|
|
|
| |
C copmilers *really* shouldn't complain about unreachable break
statements, given that they're used as case separators. *Maybe*
complain if they're immediately preceded by a return or break statement,
but not if they're preceded by calls to functions that don't return.
While we're at it, use the same style for all NOTREACHED comments.
(cherry picked from commit 69b2b73b57863b270ca9479c136b158242dd08df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We now depend on the *full* semantics of those routines, including the
return value being usable for truncation checks.
If we're building for a UN*X that has them, define pcap_strl{cpy,cat} to
be strl{cpy,cat}.
If we're building for Windows using MSVC, define pcap_strl{cpy,cat}, not
strl{cpy,cat}.
Otherwise, build our won versions of pcap_strl{cpy,cat} from BSD-derived
source code.
(cherry picked from commit 017c240336a375aebd52ec30cf341a207f1c12a4)
|
| |
|
|
|
|
| |
https://www.winpcap.org/docs/docs_412/html/group__remote.html
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
FD_SETSIZE might be defined as an unsigned, but sock_info->sock will be
an int on UN*Xes. It's not going to be negative (that's used for errors
from calls that return FDs, and if we got an error we wouldn't have an
FD on which to select), so just cast both sides to unsigned int.
|
|
|
|
| |
Signed-off-by: Joerg Mayer <jmayer@loplof.de>
|
|\
| |
| | |
Declare some variables static (found via -Wmissing-variable-declarations)
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
That makes it
#ifdef _WIN32
Windows-only stuff
#else
UN*X-only stuff
#endif
|
| |
| |
| |
| |
| |
| |
| | |
This emphasizes that it's for *debugging* messages, not for errors sent
to the peer or logged to a daemon log file. Any message that would be
useful if printed/logged in a production environment should *not* be
reported with SOCK_DEBUG_MESSAGE().
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When run from inetd and programs that support inetd-style program
launching (xinetd, launchd, systemd, ...), we don't do a
connection-accept loop; we're handed the input side of the connection as
the standard input and the output side of the connection as the standard
output, and should dive right into the service loop.
We extract the initial connection initialization and cleanup stuff from
daemon_serviceloop() and put it into the code that calls the service
loop, in rpcapd.c; it's different in the four cases where we start a
service loop (accepted connection on UN*X, accepted connection on
Windows, run from inetd, active mode), so that cleans up
daemon_serviceloop() a bit.
Supply a sample launchd plist; we could also supply examples of inetd
and xinetd config file entries, and systemd units.
|
| |
| |
| |
| |
| | |
SOCK_ASSERT was always called with a true expression ("1") thus only ever executing the message part.
Rename the macro, remove the assert part and remove the "1" parameter.
|
| |
| |
| |
| |
| |
| |
| | |
We don't need to make it a manual-reset event, explicitly check it with
WaitForSingleObject(), and reset it; it's the first event in the event
set, so if it's set, WSAWaitForMultipleEvents() will return
WSA_WAIT_EVENT_0, otherwise it'll return some other value.
|
|/
|
|
|
|
|
|
| |
That's what we do on UN*X; it should keep us from changing configuration
information out from under that loop.
While we're at it, indicate that we'll accept "parameter change"
controls, because we have code to process them.
|
|
|
|
|
|
|
|
|
| |
Call send_shutdown_event() on a SERVICE_CONTROL_STOP opcode.
Handle the SERVICE_CONTROL_PARAMCHANGE opcode as well.
Also, close all the listen sockets and clean up the socket mechanism
before accept_connections() returns.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Doing WSAEventSelect() on a socket turns on non-blocking mode on that
socket. accept(), on a non-blocking socket, returns a non-blocking
socket and, if the listen socket is non-blocking because
WSAEventSelect() was done on it, returns a non-blocking socket *with
WSAEventSelect() in effect*, so you have to remove the events and then
turn off non-blocking mode.
Thanks, Microsoft.
|
|
|
|
|
|
|
| |
ISO C doesn't say it can have that argument, and the argument isn't
used. The Single UNIX Specification says a pointer to the environment
is available as an external variable, and says nothing about a third
envp argument.
|
|
|
|
|
|
|
|
|
|
| |
Instead, have the SIGHUP handler set a flag indicating that the
configuration file should be re-read, and have the main loop check that
flag and, if it's set, clear the flag and call fileconf_read().
Don't set the handler in fileconf_read() - we're using sigaction() and
telling it that the handler shouldn't be reset, so there's no need to
set it, and setting it might clear the "don't reset" indication.
|
|
|
|
|
| |
Behavior, if a variable is set in a signal handler, is undefined unless
the variable is of type volatile sig_atomic_t.
|
|
|
|
|
|
|
| |
We don't want to rely on signal() not resetting the signal handler. The
Single UNIX Specification says it's implementation-defined whether that
happens. Use sigaction(), instead, where, if you don't request that the
signal handler be reset, it's not reset.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Have the main thread wait on all of the sockets on which we're
listening, using select() on UN*X and WSAWaitForMultipleEvents() on
Windows, rather than having separate threads or processes for each of
the sockets.
On UN*X, have "shut down" signals just set a flag, and have the select()
check for EINTR and, if it got EINTR, check the flag, and leave the main
event loop if it's set.
On Windows, set a console control event handler and, for all the "shut
down" events, set an event on which the main thread waits, in addition
to the socket events, and, if that event is signaled, leave the main
event loop.
|
|
|
|
|
| |
Again, the "decl" in "__declspec()" appears to mean it's for use only in
declarations, not definitions.
|
|
|
|
|
|
|
|
| |
Also suppress the one non-fixable warning:
build/scanner.c:5020:1: warning: function 'yy_fatal_error' could be
declared with attribute 'noreturn' [-Wmissing-noreturn]
Signed-off-by: Joerg Mayer <jmayer@loplof.de>
|
|
|
|
| |
Use for (;;) rather than while (1).
|
|
|
|
|
|
|
|
| |
If we have the SO_NOSIGPIPE socket option, set it on all sockets created
with sock_open().
Ignore SIGPIPE in rpcapd, in case we're on a platform where we *can't*
disable SIGPIPE on a socket.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If we're using threads, free it if the attempt to create the thread
fails.
If we're using subprocesses, free it in the parent process, which isn't
using it.
(We don't really teed the socket temporary if we're using subprocesses,
as the socket value won't be overwritten - the multiple socket opens are
done in separate processes.)
This should fix Coverity CID 1418994.
|
|
|
|
| |
This should fix Coverity CID 1418993.
|
|
|
|
| |
It's just a version of getopt() to use on Windows.
|
|
|
|
| |
That squelches some warnings.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
That routine will use strerror_s() or strerror_r() if available, in a
fashion that's thread-safe. Otherwise, it falls back on
pcap_strerror().
Use it in both libpcap and rpcapd.
Given that we check for errors in strerror_r(), hopefully this will
squelch warnings with newer version of GCC and GNU libc; whilst the
macOS (and other BSD-flavored?) strerror_r() always fills in a message,
that's not required by the Single UNIX Specification, as far as I can
tell, so we apparently really *do* need to check for errors.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Have separate handlers for SIGINT/SIGTERM, for which we just want to
kill off subprocesses on UN*X and exit on all platforms (just exit,
don't muck with sockets, as that could cause random errors in threads
handling connections), and SIGABRT, which is for Windows services and
which probably needs more cleanup.
Change signal handler names to better felect what they (now) do, and add
and update comments.
No need to export the handlers from rpcapd/rpcapd.c
|
|
|
|
|
| |
If we're not checking whether a sock_close() fails, we don't need an
error message.
|
| |
|
|
|
|
|
| |
These threads just run in the background; we don't need to wait for them
to finish, so close the handle as soon as we've gotten it.
|
| |
|
|
|
|
| |
That way, we get the same semantics on Windows and UN*X.
|
|
|
|
|
| |
That's one fewer tool you have to go run out and get in order to
assemble the motorocycle engine you picked up from Ikea.
|
|
|
|
|
|
|
|
| |
To block a thread forever (or, on UN*X, until a signal), use
Sleep(INFINITE) on Windows and pause() on UN*X.
To block a thread for N seconds, use Sleep(N*1000) on Windows and
sleep(N) on UN*X.
|
| |
|
|
|
|
|
|
| |
Currently, we only have one protocol version, but the code should be
able to handle multiple versions in the future - and to be able to work
with older code that doesn't do negotiation.
|
| |
|
| |
|
|
|
|
| |
Fixes Coverity CID 1419001.
|
|
|
|
|
|
|
|
|
|
| |
On Windows, you're supposed to check against INVALID_SOCKET. On UN*X,
you're supposed to check against -1, but, on UN*X, we define
INVALID_SOCKET to be -1 so you can compare against INVALID_SOCKET on
both platforms.
That means that sock_open() should return INVALID_SOCKET on errors as
well.
|