Compare commits

..

No commits in common. 'dac63b29889e2b9f710c3d21fab3eb55ca3ce50f' and '5846157eedde59d137fea8283ff68a9fc745da09' have entirely different histories.

  1. 18
      CMakeLists.txt
  2. 1
      configs/f2b.conf.in
  3. 6
      debian/changelog
  4. 1
      docs/install.md
  5. 14
      src/log.c
  6. 2
      src/log.h
  7. 5
      src/sources/files.c

18
CMakeLists.txt

@ -1,9 +1,8 @@
cmake_minimum_required(VERSION 3.4)
set(CNAME "f2b")
set(VERSION "0.6.1")
set(VERSION "0.6")
project(${CNAME} C)
cmake_minimum_required(VERSION 2.6)
include(CTest)
@ -17,11 +16,14 @@ option(WITH_PCRE "Build pcre-compatible filter" ON)
option(WITH_REDIS "Build redis source/backend" OFF)
option(WITH_IPSET "Build native ipset backend" OFF)
set(INIT_SCRIPT "OFF") # valid variants: "off", "sysvinit", "openrc", "systemd"
if (NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr")
endif ()
# HACK: cmake >= 3.4 fixes this
if (CMAKE_INSTALL_PREFIX MATCHES "^/usr/?$")
set(CMAKE_INSTALL_SYSCONFDIR "/etc")
set(CMAKE_INSTALL_LOCALSTATEDIR "/var")
endif ()
include(GNUInstallDirs)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c99")
@ -78,12 +80,6 @@ install(DIRECTORY "configs/" DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/${CNAM
install(FILES "configs/f2b.conf" DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/${CNAME}"
RENAME "f2b.conf.sample")
if (INIT_SCRIPT STREQUAL "openrc")
install(FILES "contrib/init.openrc" DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/init.d" RENAME "f2b")
elseif (INIT_SCRIPT STREQUAL "systemd")
install(FILES "contrib/f2b.service" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/systemd/system")
endif ()
add_custom_target("dist" COMMAND
"git" "archive" "--format=tar.gz"
"--output=${CNAME}_v${VERSION}.tar.gz"

1
configs/f2b.conf.in

@ -2,7 +2,6 @@
includes = ${CMAKE_INSTALL_FULL_SYSCONFDIR}/f2b/conf-enabled
pidfile = /var/run/f2b.pid
statedir = ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/f2b
; valid destinations: stdout, stderr, syslog, file (logfile option should be set)
logdest = syslog
loglevel = info
logfile = /var/log/f2b.log

6
debian/changelog vendored

@ -1,9 +1,3 @@
f2b (0.6.1-1) unstable; urgency=medium
* bugfix version
-- Alex 'AdUser' Z <ad_user@runbox.com> Tue, 04 Jun 2024 09:48:18 +1000
f2b (0.6-1) unstable; urgency=medium
* new version

1
docs/install.md

@ -25,7 +25,6 @@ Other noticeable options are:
* `CMAKE_BUILD_TYPE` (Debug, Release or unset) -- sets compiler optimization level and debugging info. Set to "Release" for production code.
* `CMAKE_C_COMPILER` -- allows specify another compiler
* `CMAKE_INSTALL_PREFIX` -- set root of install dir ($DESTDIR also will be prefixed if set).
* `INIT_SCRIPT` -- install system init script (values: off/openrc/systemd, default: off)
After building you may type `sudo make install` to install compiled binaries and other files.
Default install layout is:

14
src/log.c

@ -10,12 +10,7 @@
#include <sys/syslog.h>
static log_msgtype_t minlevel = log_info;
static enum {
log_stderr = 0,
log_stdout = 1,
log_file = 2,
log_syslog = 3
} dest = log_stderr;
static enum { log_stderr = 0, log_file = 1, log_syslog = 2 } dest = log_stderr;
static FILE *logfile = NULL;
static const char *loglevels[] = {
@ -84,13 +79,6 @@ void f2b_log_set_level(const char *level) {
if (strcmp(level, "fatal") == 0) { minlevel = log_fatal; return; }
}
void f2b_log_to_stdout() {
if (logfile && logfile != stdout)
fclose(logfile);
dest = log_stdout;
logfile = stdout;
}
void f2b_log_to_stderr() {
if (logfile && logfile != stderr)
fclose(logfile);

2
src/log.h

@ -52,8 +52,6 @@ void f2b_log_set_level(const char *level);
* @param path Path for logfile
*/
void f2b_log_to_file (const char *path);
/** @brief Use logging to stdout */
void f2b_log_to_stdout();
/** @brief Use logging to stderr */
void f2b_log_to_stderr();
/** @brief Use logging to syslog */

5
src/sources/files.c

@ -215,9 +215,8 @@ next(cfg_t *cfg, char *buf, size_t bufsize, bool reset) {
for (f2b_file_t *file = cfg->current; file != NULL; file = file->next) {
if (file_rotated(cfg, file))
file_close(file);
if (file->fd == NULL) {
if (!file_open(file, NULL))
log_msg(cfg, error, "can't open file: %s", file->path);
if (file->fd == NULL && !file_open(file, NULL)) {
log_msg(cfg, error, "can't open file: %s", file->path);
continue;
}
if (file_getline(cfg, file, buf, bufsize))

Loading…
Cancel
Save