Enabling of key exchange between progs, debug output

crypto.cpp:
- Added function to strip the header/footer off of the received key
- Added checks for exit within crypto threads
- Increased size of key generated to 2048

parcel.cpp:
- Added flag to determine master/minion
- Changed output to reflect thread #
- Added a routine that may handle state info
- Added transfer of key when minion is started
- Enabled use of key transferred between ends
- Changed handing of ssh call to use popen instead of fork/execvp
- Removed state vars and put them into other file

receiver/sender.cpp:
- Added errno output on bad read

udpipe_threads.cpp:
- Bunch of indentation formatting
- Removed auth, because it should be handled by key exchange (have to
check with josh)
debug output to new file, crypto moved from header, master/minion setup

debug_output.cpp/h:
- Moved output routines for debug into one file to more easily share

Makefile:
- Added new files
- Have it spitting out a map file as parcel.map

crypto.cpp/h:
- Moved class functions into the cpp file so that the Makefile properly
detects when they've changed (easier than make rules)
- Have most output using verb now (left pris)

files.cpp:
- removed debug output

parcel.cpp:
- pulled out verb/warn/etc to debug_output
- centralized master/minion transfer code into routines, so they aren't
changed in multiple places anymore, also slimmed down start_transfer
as a result
- added comments to function calls where they were missing

receiver.cpp:
- added debug output

sender.cpp/h:
- renamed handle_files to send_files for naming consistency
- added debug output

thread_manager.cpp/h:
- checking thread equality using pthread_equal re: documentation
- using new debug output

udpipe.h:
- changed for crypto.h changes

udpipe_client.cpp:
- added debug output/error checking

udpipe_server.cpp:
- changed another bzero to memset
- debug output to reflect function

util.h:
- using call to get verbosity
added code missed in merge for crypto, more debug output

crypto.cpp:
- removed pthread_mutexattr_settype
- adjusting debug output

files.cpp:
- added define to skip filelist check

parcel.cpp:
- added code that got lost to set the crypto classes in the args passed
to udpipe_thread
- Added code to create cryptos in the right place (I think) for master
and minion
- centralized master/minion setup
- debug output

receiver/sender.cpp:
- debug output

udpipe_client/server/threads.cpp:
- check for crypto class in args
- debug output
bugs squashed (yay!), generating symmetric key, encryption successfulall:

all:
- removed newlines wherever I saw them in verb output calls (it does it
internally)
- debugging output changes (where not specified)
- using new thread_manager method with thread types (see
thread_manager.cpp below)

crypto.cpp:
- fixed fun bug where class was being instanced on stack at wrong scope
- added destructor to class for clean exit
- changed wait_thread_ready to use pthread_mutex_trylock to prevent
blocking
- changed generate_session_key to use PBKCS5_PBKDF2_HMAC_SHA1, which is
the preferred method for symmetric key encryption

debug_output.cpp:
- fixed a bug where it wasn't tracking path properly, so it would
briefly write log to a few different places
- moved print_backtrace in

files.cpp:
- changed method to where verb outputs function name

parcel.cpp:
- deleting Crypto class instances on way out
- Crypto classes now instanced with new so they don't go out of scope
anymore
- Fixed output of remote/local sender/receiver (was printing it wrong
was all)
- g_opts.socket_ready now set properly in start_transfer

thread_manager.cpp:
- Changed handling of RegisterThread/GetThreadCount/CheckForExit to take
a threadType, which is now used to determine whether threads can exit.
Right now, THREAD_TYPE_1s will not exit if there are any THREAD_TYPE_2s
running, so we can have threads that wait for other ones that are
dependent on them to exit first. It's hard coded for those two types
right now, but could be refactored to handle more.

udpipe_threads.cpp:
- auth_peer put back in
Memory leak fixes, testing improvements

crypto.cpp:
- Added EVP_CIPHER_CTX_cleanup removing memory leak
- mutex_buf is now malloced and checked so it's not repeatedly
overwriting the global

debug_print.cpp:
- moved print_bytes into here so everyone can use it, have it pad output
to specified line length

files.cpp:
- filetype in file struct is now allocated instead of using static
char*, allowing for consistent cleanup
- checks added for free_file_object

parcel.cpp:
- nheader now mallocs the header and must be freed. This was done
because the struct was being padded, and valgrind was reporting it as a
possible problem with uninitialized data (could be exploited for
security).
- improved and reordered clean_exit

receiver/sender.cpp:
- changed to use malloced header, so it uses pointer and is freed

udpipe_client/server.cpp:
- added a bunch of frees on exit to better clean up
- renamed rcvargs to recv_args for consistency

udpipe_threads.cpp:
- debug output for when auth check fails

testParcel.py:
- now has trips arg, which will do N round trips on request
- supports encrypted testing as well
Debug output, some cleanup, refactor of testParcel

everywhere:
- Stripped trailing whitespace on lines
- Commented out some debug output
- Changed more output to use verb instead of fprintf

debug_output.cpp:
- Changed format of print_bytes to not print weird ASCII characters

parcel.cpp:
- Removed old run_ssh_command and #define to switch between the two

udpipe_threads.cpp:
- More details printed when auth_peer fails

testParcel.py:
- Changed behavior so that localhost is no longer hardcoded
- Allowed logging to be done with an arg
- Changed how crypto, logging, and verbose work, just as a switch
- Round trip check is done after both legs now, so that files are sent,
and pulled back into a separate directory from original.  Then original
and new are compared.
- Test app is smarter about figuring out local position of app, what IP
addresses are, and what username is
thread_manager fix/refactor, key handling fix, whitespace, race conditions

everywhere:
- fixing whitespace to use tabs again (editor fun)
- changed names of routines in thread_manager to be consistent
- added wrapper to pthread_create to unify thread tracking, everyone
uses new method to create threads
- removed more fprintfs and changed to verb

crypto.cpp:
- hardcoded key length (for now)

debug_output.cpp:
- set logging back to append to existing file as opposed to creating new

parcel.cpp/h:
- checking pipes on open, seeing if we have crap in them
- close handle opened with popen
- added a few control types (not using now)

postmaster.cpp/h:
- added variable for check to wait to send files in global_data_t

receiver.cpp:
- added routine to send control message to say receiver is ready (not
currently used)
- added routine to validate header (not currently used)

sender.cpp:
- added more cases to handling control messages

thread_manager.cpp/h:
- fixed bug in check for exit that could have been set off by improperly
closed threads
- changed naming convention of functions to be consistent with rest of
files
- encapsulated pthread_create within create_thread to centralize
handling

testParcel.py:
- round trip count is now 1 based
- added sleep between passes
- use wait to kill any threads after, after giving them time to exit
debug & fixing to test errors

everywhere:
- using get_socket_ready instead of setting global in g_opts
- using wrapped read/write for debugability

files.cpp/h:
- wrapped read/write so that they can more easily be tracked while
debugging
- added a set_socket_ready to centralize routines

parcel.cpp:
- fixed a few more cases where g_session_key was assumed to be a string
instead of binary
- moved early case of setting the socket ready to later

testParcel.py:
- started basic framework for unittest, including moving command line
execution into a main function
- added ability for test to generate test data (once or every loop)
- cleaned up some of the output
More crypto debugging, unit test python script

everywhere:
- Debug output
- Checks for both socket ready and encrypt ready

parcelUnitTest.py:
- Created unit test type to move unit testing on to jenkins

files.cpp/h:
- Created unified routine to log whether the encryption threads are all
ready

parcel.cpp:
- Remaining adjustments to length of g_session_key when created

udpipe_threads.cpp:
- shortened auth key length to debug (will put back to long when
finished)

testParcel.py:
- code refactored to create parcelUnitTest.py
thread fix, debug output

parcelUnitTest.py:
- changed generateTestData to generate a variable number of files
- increased the size & number of test files generated

crypto.cpp:
- added some debug output

debug_output:
- fixed output of address in print_bytes

files.cpp/h:
- Added routines to handle whether the peer and auth are finished and
the encryption is verified
- whitespace

parcel.cpp/h:
- added flag for master to xfer_t struct
- added a few waits for encryption to verify
- fixed crypto length to what it should be for 128 (might want to make
this detect encryption type)

receiver.cpp:
- commented out some debug output

udpipe.h:
- added flag for master to rs_args and thread_args structs

udpipe_client/server.cpp:
- pass along flag for master

udpipe_threads.cpp:
- re-lengthened key to send for authorization
- changed how auth check handles to serialize it

testParcel.cpp:
- Fixes after moving stuff into parcelUnitTest.py so it still works for
command line testing
minor bug fixes

Everywhere:
- commenting out use of print_bytes until I have time to figure out why
Ubuntu/gcc doesn't like it (debug code, so non-critical now)
- more whitespace

Makefiles:
- addition of -fstack-protector-strong (which apparently only is
supported under Fedora, despite Ubuntu's automagical use with gcc) to
better detect buffer overruns

parcel.cpp:
- added routine to get ip address of current machine, changed
run_ssh_command to use it to send proper username/IP back (not sure how
that ever worked)
- fixed handling of arguments so the case of no args is detected instead
of crashing

testParcel.py:
- debug output