Kevin Day [Tue, 30 Jul 2019 01:53:17 +0000 (20:53 -0500)]
Update: add build_libraries_fll build setting
Add a new parameter to make it easier to switch between individual compilation, level compilation, and monolithic compilation.
This parameter will only be used for fll-specific libraries.
For programs (aka: "level 3") commented out examples for linking against level-based and monolithic are provided.
The configurations can then be easily swapped out by a couple of simple sed statements, such as:
- sed -i -e 's|^build_libraries_fll\>|#&|g' data/build/settings
- sed -i -e 's|^#build_libraries_fll-level\>|build_libraries_fll|g' data/build/settings
The above example will switch to the level based compiling, while disabling the individual compiling.
The level based compiling compiles each of the levels 0, 1, and 2 as a single library for each level, resulting in libraries such as:
- libfll_0-0.5.0.so
- libfll_1-0.5.0.so
- libfll_2-0.5.0.so
The monolithic based compiling compiles all of the levels 0, 1, and 2 as a single library, resulting in libraries such as:
- libfll-0.5.0.so
The standard names of individual, level, and monolithic do not overlap by default and can therefoe be installed side-by-side.
Kevin Day [Mon, 29 Jul 2019 04:01:42 +0000 (23:01 -0500)]
Feature: work directory support
Work Directory provides an easier way for developers to compile and test a particular set of FLL libraries and programs without conflicting with the host system.
If the host system has some version of the FLL project installed, the versions in the work directory will be used instead of the system directories.
Specifying the work directory is done via the '-w' or '--work_directory' commands.
To better achieve this functionality in the install.sh script, four new additional parameters were created:
- --libraries-static
- --libraries-shared
- --programs-static
- --programs-shared
These provide additional relative or absolute paths for installing the programs and libraries into.
The relative paths for --libraries-static and --libraries-shared is the library directory (which can be specified via --libdir).
The relative paths for --programs-static and --programs-shared is the program directory (which can be specified via --bindir).
Kevin Day [Sun, 28 Jul 2019 22:02:49 +0000 (17:02 -0500)]
Bugfix: install script destination parameters not being respected
I used the wrong name in the grab_next variable when designating to grab the next includedir and libdir.
There is also a mistake where I was copying the destination_prefix onto itself.
Kevin Day [Sun, 28 Jul 2019 21:48:42 +0000 (16:48 -0500)]
Update: always return 1 on failure
There were some cases where exit is not being called and other cases where exit 0 is being called.
Make sure that exit 1 is called on error so that this script can then be scriptable.
Kevin Day [Sat, 27 Jul 2019 21:31:09 +0000 (16:31 -0500)]
Security: set default policy to DROP after deleting chains
Performing numerous syscalls can by slow.
During this time, if the default behavior is open, then unwanted packets may make it through.
By dropping by default, these packets will not go through.
Kevin Day [Fri, 26 Jul 2019 01:49:29 +0000 (20:49 -0500)]
Bugfix: bash/linux does not support setting high bits on return codes
These bits are generally reserved for process-specific behavior.
Explicitly return 0 for success and 1 for failure.
The firewall program already does this.
The return codes from the main functions of each project will continue to utilize all of the bits as designed.
This will allow for projects that link to the library to get the actual return codes while simultaneously being compatible with Linux and Bash.
Later versions may provide alternative ways to get the error code from within the shell.
For example, if a specific return code environment variable is set, then the program could populate that environment variable on exit (clearing it on start).
This was originally defined online, but I had lost the data at some point.
The internet archive didn't cache the page and the data lost happened during the time I was changing the website.
The specifications were simple enough to be rewritten, but I have done so in haste.
Some of the specifications will be documented at a later date.
I do not remember what advanced reverse mapping was intended to be, so I replaced it with the custom json-like specification.
The goal of the json-like specification is to write it such that it is still valid json (minus any comments).
It is currently added to preserve the idea but there are no immediate plans to implement this specification.
Kevin Day [Thu, 25 Jul 2019 04:43:28 +0000 (23:43 -0500)]
Cleanup: fix comments and remove commented out memset
According to the standards that I have read, calloc() guarantees zero'd memory, so memset is not needed.
It so happens that the memset was commented out already, so just remove it.
There are some memset related comments that incorrectly use the word 'bool' when the word 'char' should be used.
Kevin Day [Tue, 23 Jul 2019 03:58:01 +0000 (22:58 -0500)]
Update: Add additional options, fix minor problems, and other miscellaneous fixes in regards to generate.sh and package.sh scripts
Add functionality provided in install.sh, such as configure based system compatible options: --enable-statuc, --disable-static, --enable-shared, and --disable-shared.
Fix some typos (such as failire which should instead be failure).
Tweak highlight colors used.
Use a separate "operation_failure" variable instead of recycling "operation" for parameter operation problems.
Add -S/--path_s parameter option for specifying a custom settings path.
If paths have a leading slash (/), remove duplicate slashes (such as "///bin/" -> "/bin/").
Make sure the new install.sh script gets added by the package.sh script.
The variable "sources_settings" is using the wrong source path (which was "path_c").
Instead, use the newly added "path_s".
Kevin Day [Tue, 23 Jul 2019 03:55:51 +0000 (22:55 -0500)]
Feature: add install.sh helper script
Provide a very basic install helper script for systems (or users) that do not have or do not want to use their package system to install the compiled files.
This is only intended to help someone install.
It is still recommended that a distribution or packager should povide their own tools to perform the installation.
Kevin Day [Sun, 21 Jul 2019 21:06:13 +0000 (16:06 -0500)]
Update: fix firewall utility and utilize recently added functionality
There were a few logic flaws in regards to the processing and memory management.
Switch to new logic where f_new_* and f_clear_* is utilized.
Update accodingly to the fll_execute changes.
Update the default configuration files.
Update the debugging code to work as expected.
Replace string cuntions with memory functions, such as replacing strncat with memcpy.
Add some new helper macros.
Delete all custom chains when rewriting rules to prevent problems.
Iptables unfortunately does not provide a way to check and see if a chain already exists.
Kevin Day [Sun, 21 Jul 2019 20:59:30 +0000 (15:59 -0500)]
Update: rewrite fll_execute, ensuring f_eol are properly added (and auto-add progam name where possible)
Previously, the f_eol was added but it assumed that there was actual room at the end of the allocated buffer to do so.
This now explicilty allocates a new buffer with room for the terminating f_eol.
The progam name is already provided, so do not require it to be added to the arguments (auto-add it).
Kevin Day [Fri, 19 Jul 2019 03:38:41 +0000 (22:38 -0500)]
Bugfix: firewall show command operating as lock
The debug parameters is conditionally enabled/disabled but the enum is not.
Make the enum conditionally enable/disable the debug option to prevent the wrong id from being used when debug is disabled.
Fix the alignment of the debug message.
Conditionally enable/disable displaying the debug in the help.
Kevin Day [Fri, 19 Jul 2019 03:12:16 +0000 (22:12 -0500)]
Bugfix: project compiled libraries are not being found
This is the result of an oversight when I converted the libraries directory to have static and shared into subdirectories.
The explicit link path was not updated accordingly.
Kevin Day [Fri, 19 Jul 2019 01:14:38 +0000 (20:14 -0500)]
Feature: add package generation helper scrript
There are four intended package design modes:
1) individual - each package is separated into their own individual directory and version.
2) level - Each of the three levels (level 0, level 1, and level 2) are put into their own directory and version.
3) monolothic - All three levels (level 0, level 1, and level 2) are put into a single directory and version.
Monolithic is not currently implemented due to design limitations in the generate.sh script and build settings files.
Kevin Day [Thu, 18 Jul 2019 01:11:17 +0000 (20:11 -0500)]
Security: use signed integers for string lengths and array lenghts by default
Standard functions, such as strnlen(), appear to operate on signed integers instead of unsigned.
Not being able to handle unsigned integers provides unknown behavior that could lead to potential security vulnerabilities.
Future versions of this project will likely need to abandon these methods for more flexible alternatives.
Example problem:
sources/c/console.c:36:23: warning: 'strnlen' specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
36 | string_length = strnlen(argv[location], f_console_max_size);
That is 2^63 instead of the expected 2^64.
The array lengths were converted to signed as well.
Kevin Day [Wed, 17 Jul 2019 03:07:13 +0000 (22:07 -0500)]
Bugfix: variables not being stored in array
Do not directly use string in bash array arguments.
More recent versions of bash do not handle this as expected.
Move explicit string to a variable and then use that variable to access the array.
Kevin Day [Wed, 14 Jan 2015 10:19:01 +0000 (04:19 -0600)]
Bugfix: direction option was confusing because it was mixed with chains
- Separate direction command into two separate commands: direction, and chain.
- The chain command mimics iptables chains and is automatically populated by the custom lists (aka: custom chains).
- When direction is set to something other than none, then the active ethernet device is used.
- Code cleanup and changes were performed while working on this.
- Added basic support for debugging, define _en_firewall_debug_ to enable custom debugging parameter.
Kevin Day [Wed, 14 Jan 2015 04:21:34 +0000 (22:21 -0600)]
Update: improve the contents firewall settings files
- Add more information to the example firewall settings.
- Improve/fix dhcp client/server rules
- Block/Blackhole unicasts, multicasts, and broadcasts.
- Add some examples rules on conntrack and some security rules.
Kevin Day [Fri, 9 Jan 2015 03:17:48 +0000 (21:17 -0600)]
Bugfix: reverse order of library links
It seems I got the order backwards.
I was using -lc and all the lowest level libraries on the left of the libraries that depend on it.
This caused unobvious linkage errors down the road.
Reversing the order prevented the problem and allowed for static libraries to link.
It is possible the order issue is with ar and not with gcc.
Kevin Day [Fri, 9 Jan 2015 00:55:55 +0000 (18:55 -0600)]
Bugfix: fix order of library linkage for firewall build settings
The ar command is sensitive to the order in which libraries are added.
Prior to this change, building a static library could have dependencies used before they are defined due to the order in which libraries were added.
Change the order so that libraries are to the right of their dependencies in the command line argument order
Kevin Day [Fri, 9 Jan 2015 00:51:57 +0000 (18:51 -0600)]
Bugfix: fix order of library linkage
The ar command is sensitive to the order in which libraries are added.
Prior to this change, building a static library could have dependencies used before they are defined due to the order in which libraries were added.
Change the order so that libraries are to the right of their dependencies in the command line argument order.
Kevin Day [Fri, 9 Jan 2015 00:34:06 +0000 (18:34 -0600)]
Bugfix: revert compiler workaround 5bdaa0b, place arguments after source
The problem turns out to be that, for gcc at the very least, linker options such as -lc are not properly passed to the linker when it is before the source files.
Using the examples:
1) gcc -lc main.c
2) gcc main.c -lc
In case of #1, the -lc is not passed to the linker.
In case of #2, the -lc is passed to the linker.
All arguments are now being moved after the source parts.
see: 5bdaa0b Workaround: compilers on some systems seem to be sensitive to the order of arguments
see: http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
Kevin Day [Thu, 8 Jan 2015 03:14:41 +0000 (21:14 -0600)]
Update: f_error changes and more signals
- Added more signal commands.
- Added more signal codes for up to 64 signals.
- Replaced f_error_unmask with f_error_set_fine to be more consistent with the other f_error_set_* names.
- The signal bit is intended to be both the error and warning bit set so it is mathematically the same as the mask bit.
- Change f_none starting point to 197 to handle all possible 64 signals.
Kevin Day [Wed, 31 Dec 2014 02:37:46 +0000 (20:37 -0600)]
Update: add signal code support to f_errors and move error code starting point to 166
Signals are used as the high order bits in a process that exits, which is where I provide error and similar return codes.
For this reason I am adding wrappers to the x86 signal codes in f_errors instead of a separate custom project such as the non-existant f_signals.
It looks like bash mixes the exit codes and signals into the numbers 129 to 165, so start with 166 as well.
Kevin Day [Thu, 16 Oct 2014 04:23:11 +0000 (23:23 -0500)]
Feature: add support for -p, --project in generate.sh
This adds support for defining a custom name for the use of preparing and building a project.
The files will be called .built-$project and .prepare-$project.
This allows for building multiple projects in the same directory path back to back.
Kevin Day [Fri, 8 Aug 2014 00:55:00 +0000 (19:55 -0500)]
Bugfix: add missing required library link dependencies
It seems I got away with forgetting some important libraries that were required by some libraries.
This makes me wonder if this is the cause of the bug that forced me to create the build_alt option.
Kevin Day [Sun, 3 Aug 2014 22:40:35 +0000 (17:40 -0500)]
Bugfix: programs incorrectly reporting version
I noticed, unfortunately after the release and not before, that the proper version number was not being reported.
This seems to have been an oversight.
To reduce the chances of this happening, I decided to make the next version number be the default.
I will make a release after a month or two fixing this.
Kevin Day [Thu, 26 Jun 2014 03:29:51 +0000 (22:29 -0500)]
Workaround: compilers on some systems seem to be sensitive to the order of arguments
As far as I can tell, some systems (in my case, it was on linuxmint, either debian or ubuntu) the compiler interprets the following differently:
1) gcc -lc main.c
2) gcc main.c -lc
The should be the same, but they are not for some compilers.
This is also not as obvious, some programs or libraries compile while others do not.
In my case, I ran the entire compilation of the f_* fl_* and fll_* libraries using the approach from (1).
Everything compiled and worked, up until I tried to compile my firewall program.
It complained that firewall_main was not found, despite all of the libraries in the path being valid.
I had to recompile the entire f_* fl_* and fll_* libraries using (2) for the firewall program to compile.
No functional changes were made, simply the order of compile arguments.
Therefore, I have implemented an alternative version of the build command, called build_alt.
This should be used if you are using a system where (2) is required over (1).
Kevin Day [Tue, 27 Aug 2013 00:27:33 +0000 (19:27 -0500)]
Release: FLL 0.4.0
On second thought, 0.3.1 does not need to be released because there is no further development going on in the 0.3.x branch.
Instead, make a stable release (0.4.0).
Kevin Day [Sat, 7 Jul 2012 23:40:04 +0000 (18:40 -0500)]
Update: Report total number of content parts when doing a total
This is uneeded for basic and basic list, but extended supports multiple content parts.
When -t is passed while doing a selection using -c, report the total number of content parts instead of the total number found.
Kevin Day [Sun, 17 Jun 2012 23:40:05 +0000 (18:40 -0500)]
Bugfix: fl_execute is now fll_execute
At some point fl_execute and level_1/execute.h where moved to level 2: fll_execute and level_2/execute.h.
This corrects files that did not get updated to reflect this change.
Kevin Day [Sun, 10 Jun 2012 19:41:20 +0000 (14:41 -0500)]
Bugfix: ipv6 icmp is different than ipv4 icmp, adjust rules accordingly
The ipv6 in iptables uses a separate command called icmpv6, with the parameter called icmpv6-type.
Adjust the default settings files to use ipv4 icmp only with iptables and ipv6 icmp only with ip6tables.
This also updates the icmp types for ipv6, adding comments on what each type is.
Kevin Day [Sun, 10 Jun 2012 18:31:20 +0000 (13:31 -0500)]
Bugfix: Fix usage of rule_contents for protocol none option
The if condition that is checking for the existing of the protocol option 'none' was improperly setup.
It was using the rule_objects instead of the rule_contents and therefore would never validate.
Kevin Day [Sat, 9 Jun 2012 19:48:41 +0000 (14:48 -0500)]
Cleanup: move color context structure from level 2 to level 1
Nothing in it depends on level 2.
Move it to level 1, making it available to all level 2 projects.
This renames the structure from fll_color_context to fl_color_context.
Appropriate initializers and memory related macros are renamed accordingly.
Kevin Day [Sat, 9 Jun 2012 16:21:09 +0000 (11:21 -0500)]
Cleanup: rename/move f_output to f_print
Be consinstent with the project+names wherever possible.
In this case, it is very much possible.
The functions area already called f_print*, so change the name of the project to f_print.
Kevin Day [Sat, 9 Jun 2012 04:49:36 +0000 (23:49 -0500)]
Update: remove *_initialize for specific types
Data types that are numeric, non-pointer, and non-structure should not need an *_initializer macros.
It has been decided for simplicity purposes that these will be left alone.
All other data types that are either non-numeric, pointers, or structures will continue to require *_initialize macros.
Kevin Day [Sat, 9 Jun 2012 04:25:40 +0000 (23:25 -0500)]
Update: return f_unknown at end of f_is_digit
If for some reason the end of the function is reached, f_unknown is returned.
This should be impossible and if compilers give an error, then that line can be removed.
Kevin Day [Sat, 9 Jun 2012 04:19:00 +0000 (23:19 -0500)]
Update: redesign error codes
This is a major rewrite of the error code system.
Previously, the error system did the following:
- used an unsigned short data type
- allowed for all 16 bits to be used
- because it was unsigned short, different architectures might have different size.
- it is rather inefficient and ugly to check for errors when there may be as many as 30 different error codes to compare against.
The new error system does the following:
- enforce exactly 16-bit unsigned integer by using uint16_t.
- reserves the first two high order bits in the following manner:
- bit 1 = error bit (1000 0000 0000 0000)
- bit 2 = warning bit (0100 0000 0000 0000)
- (note setting both bit 1 and bit 2 is unsupported)
- provide a series of macros to quickly detect and manage the new bits
- limits the total available number of error codes to 14-bits instead of 16-bits
The advantage of the new system is that what the status code is can be detected in one or two conditionals (using bitwise operations).
This should speed up performance and make the code easier to read.
Kevin Day [Fri, 8 Jun 2012 00:39:11 +0000 (19:39 -0500)]
Update: add the new default/example firewall setting files
I forgot to add this with one of the previous commits.
This is the rewrite of the setting rules using custom chains.
This also utilizes the newly added protocol support.
Kevin Day [Fri, 8 Jun 2012 00:36:34 +0000 (19:36 -0500)]
Feature: add support for 'protocol' option
The protocol option adds support for mass adding things like '-p tcp' in front of every rule.
This reduces repetition of the -p * commands.
The 'protocol' option accepts any single parameter or the reserved parameter 'none'.
Using 'none' will turn off the protocol option.
Other than 'none', this poses no restrictions on what the protocol may be.
Instead, that is left to iptables.
Kevin Day [Thu, 7 Jun 2012 23:06:57 +0000 (18:06 -0500)]
Update: rewrite firewall, adding support for custom chains
This is a major redesign of the firewall program.
Iptables chains are now supported automatically.
Each new basic list is itself a chain.
Reserved words not allowed for custom chains are:
- main
- stop
- lock
The 'main' chain signifies use of the default iptables chain.
The layout and structure of the files have been rewritten to utilize chains.
The default-firewall file has been removed and replaced with the following files:
- firewall-first
- firewall-last
- firewall-other
The newly written rules defines default firewall rules and chains such that there the following self-explanatory chains:
- input-tcp
- input-udp
- input-icmp
- output-tcp
- output-udp
- output-firewall
In addition to the above changes, the base functionality has been broken up into smaller functions to improve code quality.
Kevin Day [Thu, 7 Jun 2012 05:33:03 +0000 (00:33 -0500)]
Update: add support for array_length arrays
Because this uses memory operations it was moved to a separate file called types_arrays.h
This adds a dependency on f_memory.
While the dependency is circular, f_types will never provide source files.
Therefore chicken and the egg issues should not be a problem (f_types is always installed before f_memory).
Kevin Day [Thu, 7 Jun 2012 00:45:00 +0000 (19:45 -0500)]
Bugfix: reset position on back to back lists
If two lists are back to back such that one does not have content, then make sure that the position resets to the start.
If this does not happen, then the next object will be skipped.
Kevin Day [Wed, 6 Jun 2012 23:11:55 +0000 (18:11 -0500)]
Update: remove used vs size parameter checking
Remove this so that non-dynamic strings can be placed in a dynamic string data type.
In such cases, the dynamic string has a used but not a size.
This means allocations should not be performed on the string.
Kevin Day [Tue, 3 Apr 2012 23:16:40 +0000 (18:16 -0500)]
Cleanup: Move private functions into its own source and header files
It has become painfully apparent that much of the firewall main function needs to be broken down into smaller functions for managability and readability purposes.
The first step in doing such is to create a privte header and source files and move all internal functions there.
Everything in the private-* files are intended to never be exposed in the library.
Its only purpose is to make programming large projects more managable and readable.
As such, none of the functions should ever be considered part of the libraries/programs api.
Kevin Day [Sun, 1 Apr 2012 20:54:28 +0000 (15:54 -0500)]
Update: add support for custom user chains
Users should now be able to add their own custom chains.
Chains can be created by creating a new fss object that is not one of the following: first, last, stop, lock, or main.