460 Commits

Author SHA1 Message Date
Michael Rash
a5a3c06ef2 consolidated several test functions into a single generic_exec() function 2011-11-04 23:46:31 -04:00
Michael Rash
f41a26b389 Fixed fwknopd memory leak, several other fixes and updates
This commit does several things.  First, a memory leak in fwknopd has been
fixed by ensuring to free access.conf stanzas.  This bug was found with the
new test suite running in --enable-valgrind mode.  Here is what some of the
valgrind output looked like to find the leak:

==19217== 11 bytes in 1 blocks are indirectly lost in loss record 3 of 5
==19217==    at 0x4C2815C: malloc (vg_replace_malloc.c:236)
==19217==    by 0x52F6B81: strdup (strdup.c:43)
==19217==    by 0x10FC8B: add_acc_string (access.c:49)
==19217==    by 0x1105C8: parse_access_file (access.c:756)
==19217==    by 0x10B79B: main (fwknopd.c:194)
==19217==
==19217== 16 bytes in 1 blocks are indirectly lost in loss record 4 of 5
==19217==    at 0x4C27480: calloc (vg_replace_malloc.c:467)
==19217==    by 0x10FEC0: add_source_mask (access.c:88)
==19217==    by 0x110100: expand_acc_source (access.c:191)
==19217==    by 0x1104B0: parse_access_file (access.c:500)
==19217==    by 0x10B79B: main (fwknopd.c:194)
==19217==
==19217== 183 (152 direct, 31 indirect) bytes in 1 blocks are definitely lost in loss record 5 of 5
==19217==    at 0x4C27480: calloc (vg_replace_malloc.c:467)
==19217==    by 0x1103E4: parse_access_file (access.c:551)
==19217==    by 0x10B79B: main (fwknopd.c:194)
==19217==
==19217== LEAK SUMMARY:
==19217==    definitely lost: 152 bytes in 1 blocks
==19217==    indirectly lost: 31 bytes in 3 blocks
==19217==      possibly lost: 0 bytes in 0 blocks
==19217==    still reachable: 8 bytes in 1 blocks
==19217==         suppressed: 0 bytes in 0 blocks

Second, this commit changes how fwknopd acquires packet data with
pcap_dispatch() - packets are now processed within the callback function
process_packet() that is provided to pcap_dispatch(), the global packet
counter is incremented by the return value from pcap_dispatch() (since this is
the number of packets processed per pcap loop), and there are two new
fwknopd.conf variables PCAP_DISPATCH_COUNT and PCAP_LOOP_SLEEP to control the
number of packets that pcap_dispatch() should process per loop and the number
of microseconds that fwknopd should sleep per loop respectively.  Without this
change, it was fairly easy to cause fwknopd to miss packets by creating bursts
of packets that would all be processed one at time with the usleep() delay
between each.  For fwknopd deployed on a busy network and with a permissive
pcap filter (i.e. something other than the default that causes fwknopd to look
at, say, TCP ACK's), this change should help.

Third, the criteria that a packet must reach before data copying into the
buffer designed for SPA processing has been tightened.  A packet less than
/greater than the minimum/maximum expected sizes is ignored before data is
copied, and the base64 check is done as well.
2011-11-03 22:15:19 -04:00
Michael Rash
97a8d751c1 added complete SPA cycle tests for tcp ports 23 and 9418 (git), and for udp 53 dns 2011-10-30 22:14:00 -04:00
Michael Rash
044ea54d93 updated client SPA verbose message to include the server IP/host 2011-10-29 23:49:29 -04:00
Michael Rash
8e4b45dd56 minor looping criteria update for valgrind tests 2011-10-29 23:48:42 -04:00
Michael Rash
ea3e817871 [test-suite] added the ability to run all fwknop tests through valgrind 2011-10-29 16:59:57 -04:00
Michael Rash
f999e2e672 bugfix to return preprocess_spa_data() result properly to calling function 2011-10-29 16:55:28 -04:00
Michael Rash
b1b830f744 update to remove packet direction requirement when sniffing on OpenBSD loopback interfaces 2011-10-28 23:01:06 -04:00
Michael Rash
cde71b1b27 minor whitespace removal 2011-10-28 23:00:26 -04:00
Michael Rash
dbbbe60fe4 added stack protection detection for OpenBSD systems 2011-10-28 22:59:52 -04:00
Michael Rash
2e96ece4b0 Update to ensure libfko.so path is detected properly on OpenBSD 2011-10-28 22:42:27 -04:00
Michael Rash
464dbe95d0 Update to print all firewall commands in --verbose mode
This commit makes it easier to determine exactly which commands fwknopd
runs in --verbose mode when interacting with the underlying firewall.
This commit also adds --verbose --verbose mode to the test suite.
2011-10-27 21:51:55 -04:00
Michael Rash
6388e8ac7f added 'const' to function prototype vars where possible
Added the 'const' qualifier to function prototype variables where possible.
In addition, reduced some functions to file-scope with 'static' where possible.

Also made a few minor changes to remove extra whitespace, and fixed a bug
in create_fwknoprc() to ensure the new fwknoprc filehandle is closed.
2011-10-25 21:00:40 -04:00
Michael Rash
85377267e2 compiler warning fix for sscanf() on freebsd
This commit fixes the following gcc warning on freebsd systems:

replay_cache.c: In function 'replay_file_cache_init':
replay_cache.c:312: warning: format '%ld' expects type 'long int *', but argument 9 has type 'time_t *'
2011-10-24 21:52:13 -04:00
Michael Rash
1c6fc0f3f8 update to detect loopback interface 2011-10-24 20:48:56 -04:00
Michael Rash
3299fb2581 minor whitespace removal 2011-10-24 20:48:20 -04:00
Michael Rash
c9860811f5 added LD_LIBRARY_PATH to all fwknop/fwknopd commands to make manual command execution easier 2011-10-22 22:29:27 -04:00
Michael Rash
50bcc537ee added digest cache validation after GPG tests 2011-10-22 22:06:00 -04:00
Michael Rash
1b8606461c minor update to match include/exclude criteria on the whole test message 2011-10-22 21:54:22 -04:00
Michael Rash
9e3a4b4c92 extended packet validity tests in GPG mode 2011-10-22 21:29:44 -04:00
Michael Rash
09e6ed1405 added first GPG complete cycle SPA test 2011-10-22 16:48:30 -04:00
Michael Rash
2d9dbe1fca minor whitespace removal 2011-10-22 15:19:54 -04:00
Michael Rash
e4f4ee7825 added test to validate digest.cache structure 2011-10-22 14:25:56 -04:00
Michael Rash
266150218a added -P bpf test for complete SPA cycle over non standard SPA port 2011-10-22 10:57:25 -04:00
Michael Rash
0ab39a64a5 added -P bpf filter test 2011-10-22 10:48:37 -04:00
Michael Rash
6848983b47 added Rijndael SPA validity tests 2011-10-21 23:43:08 -04:00
Michael Rash
081b58d951 added rule timeout detection 2011-10-21 23:13:24 -04:00
Michael Rash
9b816ed29a added replay attack detection test 2011-10-21 22:55:45 -04:00
Michael Rash
0bda4ee1e5 minor removal of whitespace 2011-10-21 22:54:49 -04:00
Michael Rash
caf458ad3f added first complete SPA cycle test 2011-10-20 23:33:41 -04:00
Michael Rash
44598fd7dd Added --digest-file and --pid-file args
Added --digest-file and --pid-file args so that the user can easily alter
these paths from the command line.
2011-10-20 23:31:59 -04:00
Michael Rash
6f699f7e5d added client/server interaction test capability 2011-10-20 00:06:58 -04:00
Michael Rash
b8571bcc05 Minor PID string length fix
Changed PID string length to 7 to accomodate an ending newline and NULL
char when writing to the fwknopd .pid file.  Without this fix, with a
5 digit PID the trailing newline would be truncated (no room for the
ending NULL char).
2011-10-18 21:28:38 -04:00
Michael Rash
0e7a0e9a37 Added --fw-list-all and --fw-flush
Added new command line options --fw-list-all and --fw-flush to allow all
firewall rules to be displayed including those not created by fwknopd, and
allow all firewall rules created by fwknopd to be deleted.

Also switched -D config dump output to stdout.
2011-10-17 23:03:28 -04:00
Michael Rash
e479e776db Added usage of sudo for recompilation test
The test suite now recompiles fwknop only if the --enable-recompile-check
option is used, and if so, uses sudo (if installed) to have the resulting
binaries own by the original user (instead of by root).  Also made a couple
of API changes to create test output files automatically if they don't
exist.
2011-10-17 22:55:01 -04:00
Michael Rash
11c240c41b minor update to allow fw rules to be dumped before parsing the access.conf file 2011-10-13 22:44:35 -04:00
Michael Rash
e36c833f55 minor whitespace fixes 2011-10-13 22:02:21 -04:00
Michael Rash
9962dc0808 minor wording update netfilter -> iptables 2011-10-13 20:59:30 -04:00
Michael Rash
45ecc6f399 minor bugfix to ensure that the proper firewall is used to collect system specs 2011-10-13 20:41:12 -04:00
Michael Rash
103cd2a8fb added the test/conf/ directory for config files use by the test suite 2011-10-13 20:30:05 -04:00
Michael Rash
6f0d2c5091 minor typo fix 2011-10-13 20:29:37 -04:00
Michael Rash
64160a0c57 started on basic SPA generation, updated to use LD_LIBRARY_PATH for local libfko instance 2011-10-13 20:29:19 -04:00
Michael Rash
a1f4a65f27 interim commit to add major functionality to the fwknop test suite 2011-10-12 23:37:28 -04:00
Michael Rash
4a41ecc955 removed 2011-10-12 23:36:51 -04:00
Michael Rash
88d8eb03b3 minor update to switch to stdout when exiting with success 2011-10-12 23:36:04 -04:00
Michael Rash
41c0be29b7 switched --help output to stdout from stderr 2011-10-06 23:02:29 -04:00
Michael Rash
26f58a705d minor update to account for hardening-check return values 2011-10-06 22:53:27 -04:00
Michael Rash
1a3e1caffe Initial start on a test suite
This commit begins development on a comprehensive test suite for fwknop.
The initial tests are focused on compilation correctness and security options
as determined by the "hardening-check" script from Kees Cook of the Debian
security team.
2011-10-04 23:15:04 -04:00
Michael Rash
05f3cec96a Added --help usage information
With the --help command line argument, the following information is printed:

$ ./fwknop-launcher-lsof.pl --help

Usage: fwknop-launcher-lsof.pl [options]

Options:

    -c,  --config     <file>   - Path to fwknop-launcher.conf config file.
    -l,  --lsof-cmd   <path>   - Path to lsof command.
    -f,  --fwknop-cmd <path>   - Path to fwknop client command.
    -s,  --sleep   <seconds>   - Specify sleep interval (default:
                                 1 seconds)
    -n   --no-daemon           - Run in foreground mode.
    -u,  --user   <username>   - Specify username (usually this is not
                                 needed).
         --home-dir <dir>      - Path to user's home directory (usually
                                 this is not needed).
    -v   --verbose             - Print verbose information to the terminal
                                 (requires --no-daemon).
         --help                - Print usage info and exit.
2011-09-25 21:12:30 -04:00
Michael Rash
71ea0c6bfd Merge branch 'master' into fwknop-launcher 2011-09-25 21:02:54 -04:00