diff --git a/configure.ac b/configure.ac index 323ed261..7c8356c7 100644 --- a/configure.ac +++ b/configure.ac @@ -49,6 +49,55 @@ AC_CHECK_HEADERS([sys/utsname.h]) # ?? LT_INIT([dlopen]) +# Identify platform +AC_CANONICAL_HOST + +case $host in + *-*-aix*) + echo "Checking platform... Identified as AIX" + AC_DEFINE([AIX], [1], [Define if the operating system is AIX]) + ;; + *-*-hpux*) + echo "Checking platform... Identified as HPUX" + AC_DEFINE([HPUX], [1], [Define if the operating system is HPUX]) + ;; + *-*-darwin*) + echo "Checking platform... Identified as Macintosh OS X" + AC_DEFINE([MACOSX], [1], [Define if the operating system is Macintosh OSX]) + ;; + *-*-linux*) + echo "Checking platform... Identified as Linux" + AC_DEFINE([LINUX], [1], [Define if the operating system is LINUX]) + ;; + *-*-solaris*) + echo "Checking platform... Identified as Solaris" + AC_DEFINE([SOLARIS], [1], [Define if the operating system is SOLARIS]) + ;; + *-*-freebsd*) + echo "Checking platform... Identified as FreeBSD" + AC_DEFINE([FREEBSD], [1], [Define if the operating system is FREEBSD]) + ;; + *-*-netbsd*) + echo "Checking platform... Identified as NetBSD" + AC_DEFINE([NETBSD], [1], [Define if the operating system is NETBSD]) + ;; + *-*-openbsd*) + echo "Checking platform... Identified as OpenBSD" + AC_DEFINE([OPENBSD], [1], [Define if the operating system is OPENBSD]) + ;; + *-*-kfreebsd*) + echo "Checking platform... Identified as kFreeBSD, treating as linux" + AC_DEFINE([FREEBSD], [1], [Define if the operating system is FREEBSD]) + ;; + *-*-gnu*.*) + echo "Checking platform... Identified as HURD, treating as linux" + AC_DEFINE([LINUX], [1], [Define if the operating system is LINUX]) + ;; + *) + echo "Unknown CANONICAL_HOST $host" + exit + ;; +esac # Variables to be used inside the Makefile.am files. MSC_BASE_DIR=`pwd` diff --git a/headers/modsecurity/modsecurity.h b/headers/modsecurity/modsecurity.h index e58ef7be..a2c70fa9 100644 --- a/headers/modsecurity/modsecurity.h +++ b/headers/modsecurity/modsecurity.h @@ -76,6 +76,7 @@ #ifdef __cplusplus #include #include +#include #endif @@ -94,14 +95,14 @@ typedef struct ModSecurity_t ModSecurity; #include "modsecurity/rules.h" - #define MODSECURITY_MAJOR "3" #define MODSECURITY_MINOR "0" #define MODSECURITY_PATCHLEVEL "0" - +#define MODSECURITY_TAG "-alpha" #define MODSECURITY_VERSION MODSECURITY_MAJOR "." \ - MODSECURITY_MINOR "." MODSECURITY_PATCHLEVEL + MODSECURITY_MINOR "." MODSECURITY_PATCHLEVEL \ + MODSECURITY_TAG #ifdef __cplusplus @@ -122,6 +123,8 @@ class ModSecurity { ModSecurity(); ~ModSecurity() { } + static std::string whoAmI(); + /** * * The Phases enumerator consists in mapping the different stages of a @@ -208,6 +211,8 @@ extern "C" { /** @ingroup ModSecurity_C_API */ ModSecurity *msc_init(); +/** @ingroup ModSecurity_C_API */ +const char *msc_who_am_i(ModSecurity *msc); #ifdef __cplusplus } diff --git a/src/modsecurity.cc b/src/modsecurity.cc index c8bb9cc9..4bca23f8 100644 --- a/src/modsecurity.cc +++ b/src/modsecurity.cc @@ -17,6 +17,7 @@ #include #include "modsecurity/modsecurity.h" +#include "src/config.h" #include "src/unique_id.h" @@ -43,6 +44,63 @@ ModSecurity::ModSecurity() { } +/** + * @name whoAmI + * @brief Return information about this ModSecurity version and platform. + * + * Platform and version are two questions that community will ask prior to + * provide support. Making it available internally and to the connector as + * well. + * + * @note This information maybe will be used by a log parser. If you want to + * update it, make it in a fashion that won't break the existent parsers. + * (e.g. adding extra information _only_ to the end of the string) + */ +std::string ModSecurity::whoAmI() { + std::string platform("Unknown platform"); + +#if AIX + platform = "AIX"; +#elif LINUX + platform = "Linux"; +#elif OPENBSD + platform = "OpenBSD"; +#elif SOLARIS + platform = "Solaris"; +#elif HPUX + platform = "HPUX"; +#elif MACOSX + platform = "MacOSX"; +#elif FREEBSD + platform = "FreeBSD"; +#elif NETBSD + platform = "NetBSD"; +#elif WIN32 + platform = "Windows"; +#endif + + return std::string("ModSecurity v" MODSECURITY_VERSION \ + " (" + platform + ")"); +} + + +/** + * @name msc_who_am_i + * @brief Return information about this ModSecurity version and platform. + * + * Platform and version are two questions that community will ask prior to + * provide support. Making it available internally and to the connector as + * well. + * + * @note This information maybe will be used by a log parser. If you want to + * update it, make it in a fashion that won't break the existent parsers. + * (e.g. adding extra information _only_ to the end of the string) + */ +extern "C" const char *msc_who_am_i(ModSecurity *msc) { + return msc->whoAmI().c_str(); +} + + /** * @name msc_init * @brief Initilizes ModSecurity C API @@ -62,6 +120,4 @@ extern "C" ModSecurity *msc_init() { return modsec; } - - } // namespace ModSecurity