aboutsummaryrefslogtreecommitdiffstats
path: root/sharkd_daemon.c
AgeCommit message (Collapse)AuthorFilesLines
2023-10-13docs: Make version option handling consistentJohn Thacker1-0/+1
Document the help and version option handling, including long option form, the same for all the command line tools, both in the their help output and in any manpages. Add version option to randpkt. Fix #15483
2023-09-26Fix misppellings in root and ui directoriesMoshe Kaplan1-1/+1
Fix misppellings in root and ui directories. Most of these are comments, but some are in error messages.
2023-02-07Move ui/version_info.[ch] to wsutilJoão Valverde1-1/+1
2023-01-14MinGW: Cast away a -Wincompatible-pointer-types warningJoão Valverde1-1/+1
extcap/androiddump.c:1712:36: warning: passing argument 2 of 'ws_inet_pton4' from incompatible pointer type [-Wincompatible-pointer-types] 1712 | ws_inet_pton4(bt_local_ip, &(server.sin_addr.s_addr)); | ^~~~~~~~~~~~~~~~~~~~~~~~~ | | | u_long * {aka long unsigned int *}
2022-12-23Add a routine to get the path of an executable given the program name.Guy Harris1-1/+1
That reduces the number of get_progfile_dir() calls, leaving only the calls that are done either to 1) get the pathname in order to display it or 2) get the pathname in order to reset the library path. That makes it easier to figure out which get_progfile_dir() calls are made to find the directory in which (non-extcap) binaries from Wireshark are installed and which - if any - are made to figure out the directory in which *the currently-running executable* are stored. (Currently, get_progfile_dir() attemps to get the former, not the latter, so extcaps in an extcap subdirectory, for example, will get the parent directory of that subdirectory, *not* the directory in which they weere installed.)
2022-08-16win32-utils: Explicitly list inherited handlesTomasz Moń1-1/+9
Windows processes inherit all inheritable handles when a new process is created using CreateProcess() with bInheritHandles set to TRUE. This can lead to undesired object lifetime extension. That is, the child process will keep ineritable handles alive even if it does not use them. Up to Windows Vista it was not possible explicitly list handles that should be inherited. Wireshark no longer works on Windows releases earlier than Vista, so use the new API without checking Windows version. Require all callers to win32_create_process() to pass in the list of handles to inherit. Set the listed handles as inheritable shortly before calling CreateProcess() and set them as not inheritable shortly after the process is created. This minimizes possibility for other callers (especially in 3rd party libraries) to inherit handles by accident. Do not terminate mmdbresolve process on exit. Instead rely on process exit when EOF is received on standard input. Previously the EOF was never received because mmdbresolve inherited both ends of standard input pipe, i.e. the fact that Wireshark closed the write end was not observed by mmdbresolve because mmdbresolve kept write handle the standard input pipe open.
2022-02-20Remove editor modelines and .editorconfig exceptions from root filesDavid Perry1-344/+331
2021-12-19Replace g_strdup_printf() with ws_strdup_printf()João Valverde1-1/+1
Use macros from inttypes.h.
2021-09-30ws_getopt: Rename struct and macrosJoão Valverde1-5/+5
This is part of the API and should also be renamed to avoid conflicts.
2021-09-17Use the musl in-tree getopt_long() everywhereJoão Valverde1-21/+10
Besides the obvious limitation of being unavailable on Windows, the standard is vague about getopt() and getopt_long() has many non-portable pitfalls and buggy implementations, that increase the maintainance cost a lot. Also the GNU libc code currently in the tree is not suited for embedding and is unmaintainable. Own maintainership for getopt_long() and use the musl implementation everywhere. This way we don't need to worry if optreset is available, or if the $OPERATING_SYSTEM version behaves in subtly different ways. The API is under the Wireshark namespace to avoid conflicts with system headers. Side-note, the Mingw-w64 9.0 getopt_long() implementation is buggy with opterr and known to crash. In my experience it's a headache to use the embedded getopt implementation if the system provides one.
2021-07-04Move version_info.[ch] to ui/João Valverde1-1/+1
Version info is an aspect of UI implementation so move it to a more appropriate place, such as ui/. This also helps declutter the top-level. A static library is appropriate to encapsulate the dependencies as private and it is better supported by CMake than object libraries. Also version_info.h should not be installed as a public header.
2021-06-16Replace g_log() calls with ws_log()João Valverde1-2/+4
2021-04-30sharkd_daemon: fix signed vs. unsigned comparison.Guy Harris1-1/+1
"int argc, char **argv". If you're looping from 1 to argc, the index should just be an int; there's no advantage to making it a size_t.
2021-04-30Cast away the return value of g_strlcpy() and g_strlcat().Guy Harris1-5/+5
Most of the time, the return value tells us nothing useful, as we've already decided that we're perfectly willing to live with string truncation. Hopefully this keeps Coverity from whining that those routines could return an error code (NARRATOR: They don't) and thus that we're ignoring the possibility of failure (as indicated, we've already decided that we can live with string truncation, so truncation is *NOT* a failure).
2021-02-20sharkd: squelch redundant decl warningsJoão Valverde1-0/+11
In file included from ../sharkd_daemon.c:31: ../wsutil/wsgetopt.h:38:21: warning: redundant redeclaration of ‘optarg’ [-Wredundant-decls] 38 | WS_DLL_PUBLIC char *optarg; | ^~~~~~ In file included from /usr/include/bits/getopt_posix.h:27, from /usr/include/unistd.h:883, from ../wsutil/socket.h:33, from ../sharkd_daemon.c:28: /usr/include/bits/getopt_core.h:36:14: note: previous declaration of ‘optarg’ was here 36 | extern char *optarg; | ^~~~~~ In file included from ../sharkd_daemon.c:31: ../wsutil/wsgetopt.h:52:19: warning: redundant redeclaration of ‘optind’ [-Wredundant-decls] 52 | WS_DLL_PUBLIC int optind; | ^~~~~~ In file included from /usr/include/bits/getopt_posix.h:27, from /usr/include/unistd.h:883, from ../wsutil/socket.h:33, from ../sharkd_daemon.c:28: /usr/include/bits/getopt_core.h:50:12: note: previous declaration of ‘optind’ was here 50 | extern int optind; | ^~~~~~ In file included from ../sharkd_daemon.c:31: ../wsutil/wsgetopt.h:57:19: warning: redundant redeclaration of ‘opterr’ [-Wredundant-decls] 57 | WS_DLL_PUBLIC int opterr; | ^~~~~~ In file included from /usr/include/bits/getopt_posix.h:27, from /usr/include/unistd.h:883, from ../wsutil/socket.h:33, from ../sharkd_daemon.c:28: /usr/include/bits/getopt_core.h:55:12: note: previous declaration of ‘opterr’ was here 55 | extern int opterr; | ^~~~~~ In file included from ../sharkd_daemon.c:31: ../wsutil/wsgetopt.h:61:19: warning: redundant redeclaration of ‘optopt’ [-Wredundant-decls] 61 | WS_DLL_PUBLIC int optopt; | ^~~~~~ In file included from /usr/include/bits/getopt_posix.h:27, from /usr/include/unistd.h:883, from ../wsutil/socket.h:33, from ../sharkd_daemon.c:28: /usr/include/bits/getopt_core.h:59:12: note: previous declaration of ‘optopt’ was here 59 | extern int optopt; | ^~~~~~ In file included from ../sharkd_daemon.c:31: ../wsutil/wsgetopt.h:131:19: warning: redundant redeclaration of ‘getopt’ [-Wredundant-decls] 131 | WS_DLL_PUBLIC int getopt (int ___argc, char *const *___argv, const char *__shortopts) | ^~~~~~ In file included from /usr/include/bits/getopt_posix.h:27, from /usr/include/unistd.h:883, from ../wsutil/socket.h:33, from ../sharkd_daemon.c:28: /usr/include/bits/getopt_core.h:91:12: note: previous declaration of ‘getopt’ was here 91 | extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) | ^~~~~~
2021-02-20sharkd_daemon: squelch unused parameter warning.Jim Young1-0/+4
Commit 69df23fc40951556d2f9f303944f943547c31ac0 refactored sharkd_loop() making the use of argv[] dependent on the #define _WIN32. Add _U_ for the #ifndef _WIN32 case. Suppresses: > [2005/2398] Building C object CMakeFiles/sharkd.dir/sharkd_daemon.c.o > /projects/wireshark/sharkd_daemon.c:357:33: warning: unused parameter 'argv' [-Wunused-parameter] > sharkd_loop(int argc _U_, char* argv[]) > ^ > 1 warning generated.
2021-02-08sharkd: Add configuration profile and other optionsPaul Offord1-32/+201
This change adds code to allow the selection of a configuration profile during sharkd start by adding a -C command line option. A new -a option has been added to specify the api service endpoint e.g. tcp:127.0.0.1:4446 The change also adds version display (-v) and help display (-h) options. These additions have been made in a way to ensure that the original command line options still work correctly to maintain backward compatibility. The new options have been added using the getopt_long(...) function that is used by tshark to simplify the addition of further command line options. Closes #17222
2019-07-26HTTPS (almost) everywhere.Guy Harris1-1/+1
Change all wireshark.org URLs to use https. Fix some broken links while we're at it. Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c Reviewed-on: https://code.wireshark.org/review/34089 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-21Remove ABI compliance checker code.João Valverde1-1/+1
It's broken, unmaintained, poorly implemented and obsoleted by saner debug-info methods. Note: To do the compliance check properly would require much more extensive work to clearly define public and private interfaces (without manual bookeeping of files or symbols either, of course, because who would want that...). Change-Id: Ib801f3c152ca2369f95ca1f4af4d37cd8cc7c47a Reviewed-on: https://code.wireshark.org/review/33928 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: João Valverde <j@v6e.pt>
2019-05-02Move the Winsock initialization and cleanup to wsutil routines.Guy Harris1-10/+9
Those routines exist on both Windows and UN*X, but they don't do anything on UN*X (they could if it were ever necessary). That eliminates some #ifdefs, and also means that the gory details of initializing Winsock, including the Winsock version being requested, are buried in one routine. The initialization routine returns NULL on success and a pointer to a g_malloc()ated error message on failure; report the error to the user, along with a "report this to the Wireshark developers" suggestion. That means including wsutil/socket.h, which obviates the need to include some headers for socket APIs, as it includes them for you. Change-Id: I9327bbf25effbb441e4217edc5354a4d5ab07186 Reviewed-on: https://code.wireshark.org/review/33045 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-05-01Windows: Modernize our WSAStartup usage.Gerald Combs1-1/+1
Make sure we link each application that calls WSAStartup with ws2_32.lib. Pass version 2.2 to WSAStartup. Wikipedia says it was introduced in 1996, so we should be OK. Ping-Bug: 15711 Change-Id: I431839e930e7c646669af7373789640b5180ec28 Reviewed-on: https://code.wireshark.org/review/33033 Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Tomasz Moń <desowin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-13Windows: Always assign newly-created processes to our job.Gerald Combs1-5/+3
Move ws_pipe_kill_child_on_exit to win32-utils. Add win32_create_process, which calls CreateProcess + AssignProcessToJobObject. Use win32_create_process instead of CreateProcess everywhere. Bug: 1419 Change-Id: I7a1f17dddf6a73f6973d54621f271b69311400d1 Reviewed-on: https://code.wireshark.org/review/26448 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.Dario Lombardo1-1/+1
The first is deprecated, as per https://spdx.org/licenses/. Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed Reviewed-on: https://code.wireshark.org/review/25661 Petri-Dish: Anders Broman <a.broman58@gmail.com> Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-11-09Start using SPDX license identifiers.Gerald Combs1-13/+1
A while back Graham pointed out the SPDX project (spdx.org), which is working on standardizing license specifications: https://www.wireshark.org/lists/wireshark-dev/201509/msg00119.html Appendix V of the specification describes a short identifier (SPDX-License-Identifier) that you can use in place of boilerplate in your source files: https://spdx.org/spdx-specification-21-web-version#h.twlc0ztnng3b Start the conversion process with our top-level C and C++ files. Change-Id: Iba1d835776714deb6285e2181e8ca17f95221878 Reviewed-on: https://code.wireshark.org/review/24302 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Balint Reczey <balint@balintreczey.hu> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-11-09Replace inet_addr() with our inet_pton() wrapperJoão Valverde1-5/+2
Error checking omitted like in original code. Change-Id: If8b4181d30ddf5717951aaf7ec61db25c0bc5322 Reviewed-on: https://code.wireshark.org/review/24309 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2017-09-24sharkd: close server file descriptor in child.Jakub Zawadzki1-0/+1
Change-Id: I65713f6d49fccb2045a99636d0d2f1aa5be44b83 Reviewed-on: https://code.wireshark.org/review/23677 Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
2017-09-24sharkd: don't go to background when using stdin and stdout.Jakub Zawadzki1-10/+13
Patch will allow to use stdin/stdout on other than windows platforms. Change-Id: I729ebd4efaa1675956b085e74b413805125a7d7a Reviewed-on: https://code.wireshark.org/review/23676 Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
2017-03-27Check for return value of WSAStartup on all executables.Michael Mann1-1/+6
Windows vscodeanalysis complains even though the event is probably very unlikely. Change-Id: Iafe158eea5586908209d6bfe1e45540117558673 Reviewed-on: https://code.wireshark.org/review/20727 Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-12sharkd: fix a memory leak on Windows introduced in gfe06aadPascal Quantin1-0/+1
Change-Id: I907dbc924574b02d2f1b8d7668158b5b6d2c87cf Reviewed-on: https://code.wireshark.org/review/20073 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2017-02-03sharkd: fix warning C4090: 'function' : different 'const' qualifiersPascal Quantin1-2/+4
According to https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx the lpCommandLine argument must not be const as is may cause an access violation. Change-Id: Iedd77663cd21ca8df542595890fbc7023f2c9c2b Reviewed-on: https://code.wireshark.org/review/19922 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-01Use INVALID_SOCKET for an invalid socket handle.Guy Harris1-14/+14
-1 is fine on UN*X, but, on Windows, it's INVALID_SOCKET. We define INVALID_SOCKET as (-1) on UN*X, so it can be used on both platforms. Change-Id: Ib2269ddf98c352a1d3c85e44006cc49d80750a78 Reviewed-on: https://code.wireshark.org/review/19909 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-02-01Fix some more UN*X-vs-Windows issues.Guy Harris1-3/+3
Change-Id: Ie9ad31289f0572a7e7249fcb3305849673536f05 Reviewed-on: https://code.wireshark.org/review/19908 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-02-01sharkd: windows supportJakub Zawadzki1-23/+94
Change-Id: I6581bacdea49416cc26431f66b093f36b39c5a67 Reviewed-on: https://code.wireshark.org/review/19829 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-01-26Clean up some UN*X-vs-Windows socket issues.Guy Harris1-22/+3
Have a wsutil/socket.h file, for inclusion by everything that uses sockets, that contains the UN*X-vs-Windows #includes and #defines to hide some UN*X-sockets vs. Winsock API differences. That stuff mostly comes from from extcap/extcap-base.h; have that file just include wsutil/socket.h rather than defining that stuff itself. Include it in sharkd_daemon.c. Use socklen_t for the size of things to pass to bind() as the last argument; wsutil/socket.h defines it as int on Windows. Ignore sharkd in Git. Change-Id: I3f2171b7aa613717f52305f62bfd7d43e0172dc6 Reviewed-on: https://code.wireshark.org/review/19796 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-01-26Fix sharkd compiling on WindowsMichael Mann1-5/+40
Change-Id: I8c614189159f1263d9452d495cee34d1a2c1bfcb Reviewed-on: https://code.wireshark.org/review/19790 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-01-25Add sharkd - daemon variantJakub Zawadzki1-0/+223
sharkd listens on UNIX socket and allows external clients to run commands like: loading file, analysing frames or running TAP(s). Change-Id: I443b2865e4adfd1c11f4f57d09ff7fce6b1e8766 Reviewed-on: https://code.wireshark.org/review/18208 Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>