RPM, tests, pointlist indexing and nlookup-ing, lint fixes #4

Merged
zx merged 15 commits from zx into master 2025-04-21 10:27:16 +03:00
67 changed files with 791 additions and 609 deletions

View File

@ -6,8 +6,9 @@ on:
if: ${{ github.ref }} == 'refs/head/master'
jobs:
build-alt:
runs-on: alt-latest
## runs-on: alt-latest
container:
image: prj.zxalexis.ru/zx/alt-rpmbuild
branches:
- 'master'
@ -17,12 +18,12 @@ jobs:
run: printenv
- name: Installing prerequisites - update apt
run: apt-get update
- name: Installing prerequisites - install nodejs for actions & git
run: apt-get install -y git nodejs su
- name: Installing build environment
continue-on-error: true
run: |
apt-get install -y gcc rpm-build rpmlint make python gear hasher fakeroot patch rpmdevtools
## - name: Installing prerequisites - install nodejs for actions & git
## run: apt-get install -y git nodejs su
## - name: Installing build environment
## continue-on-error: true
## run: |
## apt-get install -y gcc rpm-build rpmlint make python gear hasher fakeroot patch rpmdevtools
- name: Installing needed software
run: apt-get install -y bison tcl
- name: Adding build user
@ -53,7 +54,7 @@ jobs:
su - builder -c 'rpmbuild -bb /builder/bforce.spec --define "_topdir /builder/rpmbuild"'
- name: Constructing artifact name and version
run: |
echo "BFORCE_VERLONG=$(cat ${{ env.GITHUB_WORKSPACE }}/source/.version)-$(date +%Y%M%d)" >> $GITHUB_ENV
echo "BFORCE_VERLONG=$(cat ${{ env.GITHUB_WORKSPACE }}/source/.version)-$(date +%Y%m%d)" >> $GITHUB_ENV
- name: Retrieving artifact files
run: mkdir bforce && cp /builder/rpmbuild/RPMS/x86_64/bforce-*.rpm bforce
- name: Try to upload artifacts bin

View File

@ -32,7 +32,7 @@ jobs:
su - builder -c "ls -la"
- name: Constructing artifact name and version
run: |
echo "BFORCE_VER=$(cat /builder/src/bforce/source/.version)-$(date +%Y%M%d)" >> $GITHUB_ENV
echo "BFORCE_VER=$(cat /builder/src/bforce/source/.version)-$(date +%Y%m%d)" >> $GITHUB_ENV
- name: Retrieving artifact files
run: mkdir bforce && cp /builder/bforce-*.pkg.tar.zst bforce
- name: Try to upload artifacts
@ -40,3 +40,40 @@ jobs:
with:
name: bforce-${{ env.BFORCE_VER }}-Arch
path: bforce
make-test:
runs-on: arch-latest
branches:
- 'master'
steps:
- name: Checking environment
continue-on-error: true
run: printenv
- name: Installing prerequisites - update pacman
run: pacman -Sy
- name: Installing prerequisites - install nodejs for actions & git
run: pacman --disable-sandbox --noconfirm -v -S git nodejs socat
- name: Downloading source tree
continue-on-error: false
uses: actions/checkout@v3
- name: Constructing artifact name and version
run: |
echo "BFORCE_VER=$(cat ${{ github.workspace }}/source/.version)-$(date +%Y%m%d)" >> $GITHUB_ENV
- uses: actions/download-artifact@v3
with:
name: bforce-${{ env.BFORCE_VER }}-Arch
- name: Display structure of downloaded files
run: ls -R
- name: Installing archlinux package
run: |
ls -la
pacman --noconfirm -v -U bforce-*.pkg.tar.zst
cd ${{ github.workspace }}/tests
echo '-----------------------------------------'
ls -la
- name: Testing package in clean environment
run: |
cd ${{ github.workspace }}/tests
echo '------------>>> TESTING <<<--------------'
BFBIN=/usr/bin/bforce ./mktests.sh

View File

@ -29,7 +29,7 @@ jobs:
uses: actions/checkout@v4
- name: Getting version info
run: |
echo "BFORCE_VER=$(cat ${{ env.GITHUB_WORKSPACE }}/source/.version)-$(date +%Y%M%d)" >> $GITHUB_ENV
echo "BFORCE_VER=$(cat ${{ env.GITHUB_WORKSPACE }}/source/.version)-$(date +%Y%m%d)" >> $GITHUB_ENV
- name: Building package
continue-on-error: false
run: |

View File

@ -279,3 +279,10 @@ Alexey Khromov (zx@zxalexis.ru)
+ Fixed binkp stuck on overrides in config
+ ReDebianized
+ Added CI automation: builds for Archlinux and Ubuntu
0.26.2
+ Added tests with socat and integrate it with CI
+ Fixed some minor lint errors by PVS-Studio
+ Fixed RPM spec-file to make builds for AltLinux
+ Added fail2ban filter to contrib
+ Fixed node/point-lists indexing and parsing for points listed

33
INSTALL
View File

@ -1,4 +1,35 @@
Basic Installation
Prerequisites
====================
C compiler (GCC in linux and clang in BSD will work well)
make
yacc or it's GNU's recreation named bison
Tcl optional for a couple of scripts
Installing with packages
=
Debian-based systesms (Debian, *buntu, Mint, Astra)
====================
Install build system for packaging:
apt install build-essential fakeroot devscripts debhelper pkg-config
apt install bison tcl
Use debuild to make deb-s:
cd <SRCDIR>/debian
debuild -us -uc -b
RPM-based systems (RHEL, CentOS, Altlinux, SimplyLinux, RedOS)
=====================
mkdir -p ./rpmbuild/{RPMS,BUILD}
rpmbuild -bb <SRCDIR>/rpm/bforce.spec --define "_topdir $( pwd )/rpmbuild" --define "_builddir <SRCDIR>/source"
Manual Installation
==================
These are generic installation instructions.

View File

@ -3,21 +3,42 @@
В данном документе приняты следующие обозначения:
<SRCDIR> - путь, куда вы распаковали тарболл с исходными
текстами bforce 0.xx (далее bforce)
<SRCDIR> - путь, куда вы распаковали тарболл с исходными текстами
bforce 0.xx (далее bforce)
Тарболл - файл с расширением tar.gz, или tar.bz2
Требования к системе
====================
Для компиляции bforce вам потребуется компилятор (для
gnu/bsd-систем gcc), так же GNU make (make для линукс,
gmake для bsd).
Для компиляции bforce вам потребуется компилятор с языка С,
так же GNU make (make для линукс, gmake для bsd) и yacc (в linux -
bison). Опционально - tcl
Обратитесь к документации по вашей системе того, что бы
узнать как установить вышеперечисленное программное обеспечение.
Создание пакета
=
Debian-based системы (Debian, *buntu, Mint, Astra)
====================
Установка программ и набора скриптов для сборки пакетов:
apt install build-essential fakeroot devscripts debhelper pkg-config
apt install bison tcl
Для создания пакета из скачанных исходников достаточно воспользоваться
командой debuild:
cd <SRCDIR>/debian
debuild -us -uc -b
RPM-based системы (RHEL, CentOS, Altlinux, SimplyLinux, RedOS)
=====================
mkdir -p ./rpmbuild/{RPMS,BUILD}
rpmbuild -bb <SRCDIR>/rpm/bforce.spec --define "_topdir $( pwd )/rpmbuild" --define "_builddir <SRCDIR>/source"
Установка вручную
=
Процесс компиляции
==================
@ -160,29 +181,29 @@ ifc 60179/tcp # fidonet EMSI over TCP
======================
Дополнительные утилиты для bforce находятся в <SRCDIR>/contrib:
bflan - bforce log analyzer
callout.sh - скрипт для отзвонки на аплинков
outman - скрипт outman
timesync.tcl - скрипт для синхорнизации времени с узлами ftn.
init.d/bforce - init-скрипт для RedHat
bfha - bforce history analyzer (bfha)
bfha/README - bfha README
bfha/bfha.pl - собственно, bfha
bflan - bforce log analyzer
callout.sh - скрипт для отзвонки на аплинков
outman - скрипт outman
timesync.tcl - скрипт для синхорнизации времени с узлами ftn.
init.d/bforce - init-скрипт для RedHat
bfha - bforce history analyzer (bfha)
bfha/README - bfha README
bfha/bfha.pl - собственно, bfha
legacy-part.conf - файл для донастройки прав на /run/lock в systemd
u-srif - продвинутый freq-процессор
u-srif - продвинутый freq-процессор
u-srif/u-srif-index.py \ с поддержой отчетов,
u-srif/u-srif-lookup.py \ ограничений,
u-srif/u-srif.py \ индексации файловой базы,
u-srif/conf \ что значительно ускоряет
u-srif/u-srif.py \ индексации файловой базы,
u-srif/conf \ что значительно ускоряет
u-srif/conf/report.footer \ работу.
u-srif/conf/report.header \ Написан на python.
u-srif/conf/u-srif.aliases \ --------------------
u-srif/conf/u-srif.conf \ -------------------
u-srif/conf/u-srif.dirs \ ------------------
u-srif/lib / ------------------
u-srif/lib/uconfig.py / -------------------
u-srif/lib/udbase.py / --------------------
u-srif/lib/ufido.py / ---------------------
u-srif/conf/u-srif.aliases \ --------------------
u-srif/conf/u-srif.conf \ -------------------
u-srif/conf/u-srif.dirs \ ------------------
u-srif/lib / ------------------
u-srif/lib/uconfig.py / -------------------
u-srif/lib/udbase.py / --------------------
u-srif/lib/ufido.py / ---------------------
u-srif/lib/unodestat.py / ----------------------
u-srif/lib/utmpl.py / -----------------------
u-srif/lib/uutil.py / ------------------------
u-srif/lib/utmpl.py / -----------------------
u-srif/lib/uutil.py / ------------------------

View File

@ -0,0 +1,25 @@
# Fail2Ban filter for bforce bf-log.tcpip log file
# Detecting unauthorized access
# Typically logged in /var/log/bforce/bf-debug
# Apr 10 17:34:20 [944134] TCP/IP connect from 72.138.46.4 on port 5590
# Apr 10 17:34:21 [944134] Session ended up, rc=21, inetd=1
# Apr 10 17:34:21 [944134] session rc = 21 ("Cannot handshake with remote")
# Apr 10 17:34:21 [944135] Answering TCPIP call...
# Apr 10 17:34:21 [944135] TCP/IP connect from 72.138.46.4 on port 7714
# Apr 10 17:34:21 [944135] Session ended up, rc=21, inetd=1
# Apr 10 17:34:21 [944135] session rc = 21 ("Cannot handshake with remote")
[INCLUDES]
# Read common prefixes. If any customizations available -- read them from
# common.local
before = common.conf
[Init]
maxlines = 5
[Definition]
prefregex = \[<F-MLFID>\d+</F-MLFID>\] TCP/IP connect from <HOST> on port \d+$
failregex = session rc \= 21
ignoreregex =

View File

@ -0,0 +1,8 @@
[bforce]
enabled = true
port = 24554,60179
filter = bforce
logpath = /opt/fidonms/logs/bf-log.tcpip
maxretry = 5
findtime = 60
bantime = 600

View File

@ -6,7 +6,7 @@ Type=forking
PIDFile=/tmp/bforce.pid
User=fido
Group=fido
ExecStart=/usr/bin/bforce -d -C /opt/fidonms/etc/bforce.conf
ExecStart=/usr/bin/bforce -d -C /etc/bforce/bforce.conf
ExecStop=/usr/bin/bforce -q
[Install]

View File

@ -9,5 +9,5 @@ service binkp
wait = no
user = fido
server = /usr/bin/bforce
server_args = -C /opt/fidonms/etc/bforce.conf -i binkp
server_args = -C /etc/bforce/bforce.conf -i binkp
}

View File

@ -9,5 +9,5 @@ service ifc
wait = no
user = fido
server = /usr/bin/bforce
server_args = -C /opt/fidonms/etc/bforce.conf -i auto
}
server_args = -C /etc/bforce/bforce.conf -i auto
}

263
debian/Makefile.in vendored
View File

@ -1,263 +0,0 @@
# Makefile.in generated by automake 1.8.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = ../debian
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES)
mkinstalldirs = $(mkdir_p)
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
CC = @CC@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
DEFS = @DEFS@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GROUP = @GROUP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
OBJEXT = @OBJEXT@
OWNER = @OWNER@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
SHELL = @SHELL@
YACC = @YACC@
ac_ct_CC = @ac_ct_CC@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
# $Id$
EXTRA_DIST = copyright changelog rules conffiles \
control dirs init.d
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ../debian/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu ../debian/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
uninstall-info-am:
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am
.PHONY: all all-am check check-am clean clean-generic distclean \
distclean-generic distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \
uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -1,6 +0,0 @@
bforce for Debian
-----------------
See CHANGES.ugenk
-- Evgeniy Kozhuhovskiy <e.kozhuhovskiy@gmail.com>, Thu Feb 10 23:54:48 2005

7
debian/changelog vendored
View File

@ -1,3 +1,10 @@
bforce (0.26.2) UNRELEASED; urgency=medium
* Added tests to CI actions
* Fixed nodelist indexing for points handling
-- Alexey Khromov <zx@zxalexis.ru> Sat, 19 Apr 2025 07:43:54 +0300
bforce (0.26.1) UNRELEASED; urgency=medium
* Fixed for ubuntu/debian builds and CI actions

View File

@ -2,7 +2,7 @@
.SH NAME
bfindex \- nodelist compiler for bforce
.SH SYNOPSYS
\fBbfindex [-fh]\fR
\fBbfindex [-fh] [-C\fIconfig\fB]\fR
.SH DESCRIPTION
\fBbfindex\fP is a nodelist compiler for BinkleyForce FTN mailer.

View File

@ -2,7 +2,7 @@
.SH NAME
bfstat \- binkley style outbound statistic
.SH SYNOPSYS
\fBbfstat [-afhprst] [-n \fInumber\fB]\fR
\fBbfstat [-afhprst] [-n \fInumber\fB] [-C\fIconfig\fB]\fR
.SH DESCRIPTION
\fBbfstat\fP help you to see your outbound statistic in human readable
form.

View File

@ -2,7 +2,7 @@
.SH NAME
Bnlookup \- Nodelist search tool for bforce
.SH SYNOPSYS
\fBnlookup [-rh]\fR
\fBnlookup [-rh] [-C\fIconfig\fB]\fR
.SH DESCRIPTION
\fBnlookup\fP is a nodelist search tool for BinkleyForce FTN mailer.

View File

@ -1,6 +1,6 @@
Summary: Bforce, Fidonet mailer
Name: bforce
Version: 0.26.1
Version: 0.26.2
Release: %{_vendor}.1
Copyright: GPL
Group: Fidonet/mailer
@ -31,6 +31,7 @@ mkdir -p $RPM_BUILD_ROOT/etc/bforce
mkdir -p $RPM_BUILD_ROOT/usr/bin
mkdir -p $RPM_BUILD_ROOT/usr/sbin
mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1
mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/system/
mkdir -p $RPM_BUILD_ROOT/var/log/bforce
mkdir -p $RPM_BUILD_ROOT/var/spool/fido/bt/pin
mkdir -p $RPM_BUILD_ROOT/var/spool/fido/bt/in
@ -49,6 +50,7 @@ install %{_builddir}/%{name}/examples/bforce.subst $RPM_BUILD_ROOT/etc/bforce/bf
install %{_builddir}/%{name}/examples/freq.aliases $RPM_BUILD_ROOT/etc/bforce/freq.aliases.sample
install %{_builddir}/%{name}/examples/freq.dirs $RPM_BUILD_ROOT/etc/bforce/freq.dirs.sample
install %{_builddir}/%{name}/contrib/outman $RPM_BUILD_ROOT/usr/bin/outman
install %{_builddir}/%{name}/contrib/systemd/bforce.service $RPM_BUILD_ROOT/usr/lib/systemd/system/bforce.service
cp %{_builddir}/%{name}/man/*.1 $RPM_BUILD_ROOT/usr/share/man/man1/
cp %{_builddir}/%{name}/{README.md,CHANGES,COPYING,INSTALL,INSTALL.ru,SYSLOG,TODO} $RPM_BUILD_ROOT/$RPM_DOC_DIR/$RPM_PACKAGE_NAME-$RPM_PACKAGE_VERSION/

View File

@ -1 +1 @@
0.26.1
0.26.2

View File

@ -28,7 +28,8 @@ CONFDIR = @sysconfdir@
BINDIR = @bindir@
LOGDIR = @LOGDIR@
SPOOLDIR = @SPOOLDIR@
MANDIR = @MANDIR@
MANDIR = /usr/share/man/man1
SYSTEMDDIR = /var/lib/systemd/system
DAEMON_LOGFILE = $(LOGDIR)/bf-daemon
BFORCE_LOGFILE = $(LOGDIR)/bf-log
@ -208,6 +209,7 @@ install-man:
install-contrib:
$(INSTALL_PROGRAM) -o $(OWNER) -g $(GROUP) $(CONTRIBDIR)/outman $(BINDIR)/outman
$(INSTALL_DATA) -o $(OWNER) -g $(GROUP) $(CONTRIBDIR)/systemd/bforce.service $(SYSTEMDDIR)/bforce.service
@echo "Please, edit $(BINDIR)/outman"
install: install-bin install-config install-man

View File

@ -259,11 +259,15 @@ int main(int argc, char *argv[], char *envp[])
mainenv[0] = NULL;
i=0;
while (envp[i]) {
mainenv[i] = malloc(strlen(envp[i])+2);
strcpy(mainenv[i], envp[i]);
mainenv[++i] = NULL;
DEB((D_FREE, "Program ENV: %s\n", mainenv[(i-1)]));
if ( envp[0] ) {
while (envp[i]) {
mainenv[i] = malloc(strlen(envp[i])+2);
if ( mainenv[i] ) {
strcpy(mainenv[i], envp[i]);
mainenv[++i] = NULL;
DEB((D_FREE, "Program ENV: %s\n", mainenv[(i-1)]));
}
}
}
memset(&opts, '\0', sizeof(s_bforce_opts));

View File

@ -662,7 +662,7 @@ static int proc_domain(s_domain *dest, char *value)
if( p_path[strlen(p_path)-1] == DIRSEPCHR )
dest->path = xstrcpy(p_path);
else
dest->path = string_concat(p_path, DIRSEPSTR, NULL);
dest->path = string_concat(p_path, DIRSEPSTR, '\0');
return(PROC_RC_OK);
}
else
@ -751,7 +751,7 @@ static int proc_path(s_string *dest, char *value)
if( value[strlen(value)-1] == DIRSEPCHR )
dest->str = xstrcpy(value);
else
dest->str = string_concat(value, DIRSEPSTR, NULL);
dest->str = string_concat(value, DIRSEPSTR, '\0');
return(PROC_RC_OK);
}
@ -1004,7 +1004,7 @@ static int proc_filebox(s_filebox *dest, char *value)
if( p_path[strlen(p_path)-1] == DIRSEPCHR )
dest->path = xstrcpy(p_path);
else
dest->path = string_concat(p_path, DIRSEPSTR, NULL);
dest->path = string_concat(p_path, DIRSEPSTR, '\0');
dest->flavor = flavor;
return rc;
}

View File

@ -1035,7 +1035,7 @@ int daemon_run(const char *confname, const char *incname, bool quit)
/*
* Check rescan timer
*/
if( !timer_running(timer_rescan) || timer_expired(timer_rescan) )
if( timer_expired(timer_rescan) )
{
(void)daemon_rescan_sysqueue(&daemon_sys_queue,
daemon_queues);
@ -1045,7 +1045,7 @@ int daemon_run(const char *confname, const char *incname, bool quit)
/*
* Check alive timer
*/
if( !timer_running(timer_alive) || timer_expired(timer_alive) )
if( timer_expired(timer_alive) )
{
daemon_alive_message(&daemon_sys_queue);
timer_set(&timer_alive, DAEMON_ALIVE_TIMER);

View File

@ -955,7 +955,7 @@ yydestruct (char *yymsg,
{
YY_USE (yyvaluep);
if (!yymsg)
yymsg = "Deleting";
yymsg = "Deleting"; // cppcheck_suppress uselessAssignmentPtrArg
YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
@ -1067,8 +1067,9 @@ yysetstate:
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * YYSIZEOF (*yyssp),
&yyss1, yysize * YYSIZEOF (*yyssp), // cppcheck_suppress syntaxError
&yyvs1, yysize * YYSIZEOF (*yyvsp),
&yyls1, yysize * YYSIZEOF (*yylsp),
&yystacksize);
@ -1088,7 +1089,7 @@ yysetstate:
yy_state_t *yyss1 = yyss;
union yyalloc *yyptr =
YY_CAST (union yyalloc *,
YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); // cppcheck_suppress sizeofwithnumericparameter
if (! yyptr)
YYNOMEM;
YYSTACK_RELOCATE (yyss_alloc, yyss);
@ -1780,7 +1781,14 @@ static int expr_check_mailer(const char *str)
static int expr_check_addr(const char *str)
{
s_faddr addr;
s_faddr addr = {
.inetform = false,
.zone = 0,
.net = 0,
.node = 0,
.point = 0,
.domain = '\0' };
#ifdef DEBUG
char abuf1[BF_MAXADDRSTR+1];
char abuf2[BF_MAXADDRSTR+1];

View File

@ -360,7 +360,13 @@ static int expr_check_mailer(const char *str)
static int expr_check_addr(const char *str)
{
s_faddr addr = { 0, 0, 0, 0, 0, '\0' };
s_faddr addr = {
.inetform = false,
.zone = 0,
.net = 0,
.node = 0,
.point = 0,
.domain = '\0' };
#ifdef DEBUG
char abuf1[BF_MAXADDRSTR+1];

View File

@ -200,9 +200,18 @@ static void req_proc_ext(s_freq *freq, char *reqname)
char srfname[L_tmpnam+5];
char rspname[L_tmpnam+5];
char *comline = NULL;
char *chunk;
if( tmpnam(srfname) )
chunk = xmalloc(L_tmpnam+1);
if ( chunk )
{
getrandname(chunk, L_tmpnam);
chunk[L_tmpnam]='\0';
strnxcpy(srfname, chunk, L_tmpnam);
free(chunk);
//if( tmpnam(srfname) )
//{
strncpy(rspname, srfname, L_tmpnam+4);
rspname[L_tmpnam+4] = '\0';
strcat(srfname, ".srf");

View File

@ -116,7 +116,7 @@ static pid_t lock_read_pid(const char *lckname)
if( len == sizeof(pid) || sscanf(buf, "%d", &pid) != 1 || pid == 0 )
{
/* We found binary lock file? */
pid = *((int *)buf);
pid = *((u_int *)buf);
#ifndef LOCK_BINARY
log("warning: found binary lock file %s", lckname);
#endif
@ -197,12 +197,15 @@ static int lock_create(const char *lckname, const char *tmpname)
int rc, fd;
int tries;
#ifdef LOCK_BINARY
pid_t pid;
#else
char buf[32];
#endif
ASSERT(lckname != NULL && tmpname != NULL);
if( (fd = open(tmpname, O_CREAT | O_RDWR, 0644)) < 0 )
@ -299,8 +302,7 @@ int port_checklock(const char *lockdir, const s_modemport *modemport)
rc = lock_check(lckname);
if( lckname )
free(lckname);
free(lckname);
return rc;
}
@ -312,20 +314,24 @@ int port_lock(const char *lockdir, const s_modemport *modemport)
{
int rc;
char *lckname;
char *tmpname, *p_tmpname;
char *tmpname, *p_tmpname, *chunk;
if( *lockdir )
tmpname = xstrcpy(lockdir);
else
tmpname = xstrcpy(BFORCE_LOCK_DIR);
tmpname = xstrcat(tmpname, "bfXXXXXX");
//tmpname = xstrcat(tmpname, "bfXXXXXX");
if( (p_tmpname = mktemp(tmpname)) == NULL )
{
logerr("can't generate unique file name from \"%s\"", tmpname);
free(tmpname); return 1;
}
chunk = xmalloc(7);
getrandname(chunk,6);
p_tmpname = string_concat(tmpname, "bf", chunk, '\0');
//if( (p_tmpname = mktemp(tmpname)) == NULL )
//{
// logerr("can't generate unique file name from \"%s\"", tmpname);
// free(tmpname); return 1;
//}
if( (lckname = lock_getname(lockdir, modemport)) == NULL )
{
@ -340,8 +346,7 @@ int port_lock(const char *lockdir, const s_modemport *modemport)
if( tmpname )
free(tmpname);
if( lckname )
free(lckname);
free(lckname);
return rc;
}

View File

@ -58,6 +58,7 @@ struct debuglevel {
{ "Daemon", D_DAEMON },
{ "Free", D_FREE },
{ "24554", D_24554 },
{ "Index", D_INDEX },
// { "Daemon", D_DAEMON },
{ "Full", D_FULL },
{ NULL, 0 }
@ -144,7 +145,7 @@ int log_close(void)
ASSERT(log_fp);
if( log_fp )
if( log_fp != NULL )
{
rc = fclose(log_fp);
DEB((D_INFO,"Closing log file."));
@ -543,7 +544,7 @@ void debug(unsigned long what, const char *str, ...)
debug_open();
}
if( debug_fp )
if( debug_fp != NULL )
{
fprintf(debug_fp, "%s ", time_string_log(buf, sizeof(buf), 0));
va_start(args, str);

View File

@ -243,7 +243,8 @@ void netspool_acknowledge(s_netspool_state *state)
void netspool_end(s_netspool_state *state)
{
sendstr(state->socket, "END satisfied");
int i;
i = sendstr(state->socket, "END satisfied");
close(state->socket);
state->state = NS_NOTINIT;
}

View File

@ -198,6 +198,54 @@ int nodelist_parse_Txy(s_node *node, const char *xy)
return 0;
}
/*****************************************************************************
* Pointlist string parser
*
* Arguments:
* node put here all obtained information
* str pointer to the nodelist string
*
* Return value:
* zero value if string was parsed successfuly, and non-zero if wasn't
*/
int nodelist_parsepoint(s_node *node, char *str)
{
char *argv[NODELIST_POSFLAGS+1];
char *p;
int cnt;
DEB((D_NODELIST,"nodelist: parsepoint %s", str));
cnt = string_parse(argv, NODELIST_POSFLAGS+1, str, ',');
if( cnt < NODELIST_POSFLAGS-1 )
return -1;
DEB((D_NODELIST,"nodelist: parsepoint OK: %d", cnt));
strnxcpy(node->name, argv[NODELIST_POSNAME], sizeof(node->name));
DEB((D_NODELIST,"nodelist: parsepoint sys: %s", node->name));
strnxcpy(node->location, argv[NODELIST_POSLOCATION], sizeof(node->location));
DEB((D_NODELIST,"nodelist: parsepoint loc: %s", node->location));
strnxcpy(node->sysop, argv[NODELIST_POSSYSOP], sizeof(node->sysop));
DEB((D_NODELIST,"nodelist: parsepoint zyz: %s", node->sysop));
strnxcpy(node->phone, argv[NODELIST_POSPHONE], sizeof(node->phone));
DEB((D_NODELIST,"nodelist: parsepoint pho: %s", node->phone));
if (argv[NODELIST_POSFLAGS])
strnxcpy(node->flags, argv[NODELIST_POSFLAGS], sizeof(node->flags));
DEB((D_NODELIST,"nodelist: parsepoint fl: %s", node->flags));
if (argv[NODELIST_POSSPEED])
node->speed = atoi(argv[NODELIST_POSSPEED]);
DEB((D_NODELIST, "nodelist: Parsed common values SYS: %s, ZYZ: %s, LOC: %s, PHONE: %s", node->name, node->sysop, node->location, node->phone));
/*
* Replace all '_' by space character
*/
string_replchar(node->name, '_', ' ');
string_replchar(node->location, '_', ' ');
string_replchar(node->sysop, '_', ' ');
node->keyword = KEYWORD_POINT;
return 0;
}
/*****************************************************************************
* Nodelist string parser
*
@ -212,7 +260,7 @@ int nodelist_parsestring(s_node *node, char *str)
{
char *argv[NODELIST_POSFLAGS+1];
char *p;
DEB((D_NODELIST,"nodelist: parsestring %s", str));
if( string_parse(argv, NODELIST_POSFLAGS+1, str, ',') != NODELIST_POSFLAGS+1 )
return -1;
@ -671,6 +719,7 @@ int nodelist_lookup_string(char *buffer, size_t buflen, s_faddr addr)
*/
for( ptrl = conf_first(cf_nodelist); ptrl; ptrl = conf_next(ptrl) )
{
DEB((D_NODELIST,"nl_lookup_string: using %s",ptrl->d.falist.what));
if( ftn_addrcomp_mask(addr, ptrl->d.falist.addr) == 0 )
{
if( (nlp = nodelist_open(ndldir, ptrl->d.falist.what, NODELIST_READ)) )
@ -701,10 +750,24 @@ int nodelist_lookup(s_node *node, s_faddr addr)
if( nodelist_lookup_string(buf, sizeof(buf), addr) == 0 )
{
node->listed = TRUE;
if( nodelist_parsestring(node, buf) == -1 )
if (addr.point == 0)
{
log("invalid nodelist string for address %s",
ftn_addrstr(abuf, addr));
if( nodelist_parsestring(node, buf) == -1 )
{
DEB((D_NODELIST,"invalid nodelist string for address %s",
ftn_addrstr(abuf, addr)));
log("invalid nodelist string for address %s",
ftn_addrstr(abuf, addr));
}
} else {
if ( nodelist_parsepoint(node, buf) == -1 )
{
DEB((D_NODELIST,"invalid nodelist string for address %s",
ftn_addrstr(abuf, addr)));
log("invalid nodelist string for address %s",
ftn_addrstr(abuf, addr));
}
node->addr = addr;
}
return 0;
}

View File

@ -156,7 +156,7 @@ int exec_redirect_descriptor(int desc, const char *fname, int flags)
return -1;
}
return 0;
return 0; //cppcheck-suppress resourceLeak
}
int exec_command(s_exec_options *eopt)

View File

@ -46,7 +46,7 @@ char *out_getname_4d(s_faddr addr)
else
sprintf(buf, "%04x%04x.pnt/%08x", addr.net, addr.node, addr.point);
dest = string_concat(p_outbound, buf, NULL);
dest = string_concat(p_outbound, buf, '\0');
}
else
{
@ -55,7 +55,7 @@ char *out_getname_4d(s_faddr addr)
else
sprintf(buf, ".%03x/%04x%04x.pnt/%08x", addr.zone, addr.net, addr.node, addr.point);
dest = string_concat(out_root, out_main, buf, NULL);
dest = string_concat(out_root, out_main, buf, '\0');
}
}
@ -83,7 +83,7 @@ char *out_getname_domain(s_faddr addr)
else
sprintf(buf, "%04x%04x.pnt/%08x", addr.net, addr.node, addr.point);
dest = string_concat(cfptr->d.domain.path, buf, NULL);
dest = string_concat(cfptr->d.domain.path, buf, '\0');
break;
}
}
@ -102,7 +102,7 @@ char *out_getname_amiga(s_faddr addr)
if( p_amigaoutbound && *p_amigaoutbound )
{
sprintf(buf, "%d.%d.%d.%d", addr.zone, addr.net, addr.node, addr.point);
dest = string_concat(p_amigaoutbound, buf, NULL);
dest = string_concat(p_amigaoutbound, buf, '\0');
}
return dest;

View File

@ -155,7 +155,7 @@ static int out_scan_bso_dir(s_outbound_callback_data *callback,
if( alst || !fa_list )
{
p = string_concat(path, dirent->d_name, "/", NULL);
p = string_concat(path, dirent->d_name, "/", '\0');
out_scan_bso_dir(callback, fa_list, addr, p, 1);
if( p ) { free(p); p = NULL; }
}
@ -178,7 +178,7 @@ static int out_scan_bso_dir(s_outbound_callback_data *callback,
if( alst || !fa_list )
{
callback->path = string_concat(path, dirent->d_name, NULL);
callback->path = string_concat(path, dirent->d_name, '\0');
callback->addr = *addr;
callback->type = OUTB_TYPE_BSO;
callback->flavor = -1;
@ -250,7 +250,7 @@ static int out_scan_bso(s_outbound_callback_data *callback,
if( alst || mailfor == NULL )
{
newpath = string_concat(out_root, dirent->d_name, "/", NULL);
newpath = string_concat(out_root, dirent->d_name, "/", '\0');
out_scan_bso_dir(callback, mailfor, &addr, newpath, 0);
free(newpath);
}
@ -296,7 +296,7 @@ static int out_scan_fbox_dir(s_outbound_callback_data *callback,
while( (dirent = readdir(dir)) )
{
callback->path = string_concat(path, dirent->d_name, NULL);
callback->path = string_concat(path, dirent->d_name, '\0');
if( is_regfile(callback->path) )
{
callback->addr = addr;
@ -340,7 +340,7 @@ static int out_scan_lbox(s_outbound_callback_data *callback,
alst = alst->next );
if( alst )
{
newpath = string_concat(path, dirent->d_name, "/", NULL);
newpath = string_concat(path, dirent->d_name, "/", '\0');
(void)out_scan_fbox_dir(callback, newpath, addr, FLAVOR_HOLD);
free(newpath);
}
@ -348,7 +348,7 @@ static int out_scan_lbox(s_outbound_callback_data *callback,
else
{
/* Scan all fileboxes */
newpath = string_concat(path, dirent->d_name, "/", NULL);
newpath = string_concat(path, dirent->d_name, "/", '\0');
(void)out_scan_fbox_dir(callback, newpath, addr, FLAVOR_HOLD);
free(newpath);
}
@ -424,7 +424,7 @@ static int out_scan_aso(s_outbound_callback_data *callback,
if( alst || !mailfor )
{
callback->path = string_concat(path, dirent->d_name, NULL);
callback->path = string_concat(path, dirent->d_name, '\0');
callback->addr = addr;
callback->type = OUTB_TYPE_ASO;
callback->flavor = -1;

View File

@ -469,8 +469,10 @@ case 2:
case 3: // send password on outgoing or pw confirmation on incoming
// special empty password is sent if there is no password for the remote addr
if (bstate->mode==bmode_incoming_handshake) {
if (bstate->password_received) {
if (bstate->mode==bmode_incoming_handshake)
{
if (bstate->password_received)
{
DEB((D_24554, "send OK, password verified"));
buf[0] = BPMSG_OK;
*block_type = BINKP_BLK_CMD;
@ -481,45 +483,54 @@ case 3: // send password on outgoing or pw confirmation on incoming
DEB((D_24554, "waiting for password from remote"));
return 0; // nothing to send
}
else if (bstate->mode==bmode_outgoing_handshake) {
if (!bstate->address_established) {
DEB((D_24554, "address not received still"));
return 0;
}
DEB((D_24554, "send password"));
else
{
if (!bstate->address_established)
{
DEB((D_24554, "address not received still"));
return 0;
}
DEB((D_24554, "send password"));
buf[0] = BPMSG_PWD;
*block_type = BINKP_BLK_CMD;
buf[0] = BPMSG_PWD;
*block_type = BINKP_BLK_CMD;
if( bstate->local_data->passwd[0] == '\0' ) {
*block_length = 1 + sprintf(buf+1, "-");
}
else if( bstate->remote_data->options & BINKP_OPT_MD5 ) {
char digest_bin[16];
char digest_hex[33];
if(bstate->remote_data->challenge_length==0) {
DEB((D_24554, "waiting for challenge"));
return 0;
if( bstate->local_data->passwd[0] == '\0' )
{
*block_length = 1 + sprintf(buf+1, "-");
}
else
if( bstate->remote_data->options & BINKP_OPT_MD5 )
{
char digest_bin[16];
char digest_hex[33];
if(bstate->remote_data->challenge_length==0)
{
DEB((D_24554, "waiting for challenge"));
return 0;
}
md5_cram_get(bstate->local_data->passwd,
bstate->remote_data->challenge,
bstate->remote_data->challenge_length,
digest_bin);
/* Encode digest to the hex string */
string_bin_to_hex(digest_hex, digest_bin, 16);
*block_length = 1 + sprintf(buf+1,
"CRAM-MD5-%s", digest_hex);
}
else
{
*block_length = 1 + sprintf(buf+1, "%s", bstate->local_data->passwd);
}
bstate->phase += 1;
return 1;
}
md5_cram_get(bstate->local_data->passwd, bstate->remote_data->challenge,
bstate->remote_data->challenge_length, digest_bin);
/* Encode digest to the hex string */
string_bin_to_hex(digest_hex, digest_bin, 16);
*block_length = 1 + sprintf(buf+1, "CRAM-MD5-%s", digest_hex);
}
else {
*block_length = 1 + sprintf(buf+1, "%s", bstate->local_data->passwd);
}
bstate->phase += 1;
return 1;
}
else {
log("impossible mode");
return -1;
}
return -1;
case 4:
@ -593,7 +604,7 @@ else if (bstate->mode == bmode_transfer) {
case 1: //send M_FILE - M_GET forcibly sets this phase. M_GET must open needed file
DEB((D_24554, "send M_FILE"));
buf[0] = BPMSG_FILE;
*block_length = 1+sprintf(buf+1, "%s %ld %ld 0", bstate->pi->send->net_name,
*block_length = 1+sprintf(buf+1, "%s %zu %lu 0", bstate->pi->send->net_name,
bstate->pi->send->bytes_total, bstate->pi->send->mod_time);
DEB((D_24554, "M_FILE: %s", buf+1));
*block_type = BINKP_BLK_CMD;
@ -699,12 +710,11 @@ case BPMSG_ADR: /* List of addresses */
if (bstate->address_established) {
PROTO_ERROR("remote tries to change address");
}
if( bstate->extracmd[0] != (char)-1 ) return 0; // suspend !!!
if( bstate->extracmd[0] != (char)0xFF ) return 0; // suspend !!!
binkp_process_ADR(buf+1);
if( !state.n_remoteaddr ) {
log("error: remote did not supplied any addresses");
if( bstate->extracmd[0] != (char)-1 ) return 0; // suspend
bstate->extracmd[0] = BPMSG_BSY;
strcpy(bstate->extracmd+1, "No addresses was presented");
bstate->extraislast = true;
@ -783,7 +793,7 @@ case BPMSG_PWD: /* Session password */
// lock addresses
if( session_addrs_lock(state.remoteaddrs, state.n_remoteaddr) ) {
log("error locking addresses of the remote");
if( bstate->extracmd[0] != (char)-1 ) return 0; // suspend if extra is occupied
if( bstate->extracmd[0] != (char)0xFF ) return 0; // suspend if extra is occupied
bstate->extracmd[0] = BPMSG_BSY;
strcpy(bstate->extracmd+1, "All addresses are busy");
bstate->extraislast = true;
@ -823,7 +833,7 @@ case BPMSG_FILE: /* File information */
DEB((D_24554, "no, skipping; TODO: accept it"));
if( bstate->extracmd[0] != (char)-1 ) return 0;
bstate->extracmd[0] = BPMSG_SKIP;
sprintf(bstate->extracmd+1, "%s %ld %ld %ld", recvfi.fn, recvfi.sz, recvfi.tm, recvfi.offs);
sprintf(bstate->extracmd+1, "%s %zu %lu %zu", recvfi.fn, recvfi.sz, recvfi.tm, recvfi.offs);
bstate->extraislast = false;
return 1;
}
@ -870,7 +880,7 @@ case 2:
default:
PROTO_ERROR("p_rx_fopen_error");
}
PROTO_ERROR("never should get here");
// PROTO_ERROR("never should get here");
case BPMSG_OK: /* Password was acknowleged (data ignored) */
DEB((D_24554, "received M_OK len=%d", block_length));
@ -879,7 +889,7 @@ case BPMSG_OK: /* Password was acknowleged (data ignored) */
}
if (session_addrs_lock(state.remoteaddrs, state.n_remoteaddr)) {
log("error: unable to lock");
if (bstate->extracmd[0]!= (char)-1) return 0;
if (bstate->extracmd[0]!= (char)0xFF) return 0;
bstate->extracmd[0] = BPMSG_BSY;
strcpy(bstate->extracmd+1, "All addresses are busy");
bstate->extraislast = true;
@ -989,7 +999,7 @@ case BPMSG_GET: /* Get a file from offset */
}
DEB((D_24554, "M_GET file %s size %d time %d offset %d", getfi.fn, getfi.sz, getfi.tm, getfi.offs));
if (bstate->extracmd[0] != (char)-1) return 0;
if (bstate->extracmd[0] != (char)0xFF) return 0;
if (bstate->pi->send) if (p_compfinfo(bstate->pi->send, getfi.fn, getfi.sz, getfi.tm)==0) {
DEB((D_24554, "M_GET for currently transmitted file"));
@ -1079,7 +1089,7 @@ case BINKP_BLK_DATA:
return 1;
}
if (bstate->extracmd[0] != (char)-1) return 0;
if (bstate->extracmd[0] != (char)0xFF) return 0;
long int n;
n = p_rx_writefile(buf, block_length, bstate->pi);

View File

@ -43,11 +43,11 @@ const char *Protocols[] =
static int prot_get_next_file(s_filelist **dest, s_protinfo *pi)
{
DEB((D_OUTBOUND, "prot_get_next_file")); // %s %d", hint->fn, hint->sz);
DEB((D_OUTBOUND, "prot_get_next_file")); // %s %d", hint->fn, hint->sz);
s_filelist *ptrl = NULL;
s_filelist *best = NULL;
s_fsqueue *q = &state.queue;
s_filehint *hint = NULL; // M_GET hinting does not work good here as it spec net_name and it is unknown here (especially for PKTs)
s_filehint *hint = NULL; // M_GET hinting does not work good here as it spec net_name and it is unknown here (especially for PKTs)
*dest = NULL;
@ -296,10 +296,10 @@ get_next_file:
pi->send_left_num -= 1;
pi->send_left_size -= ptrl->size;
if( pi->send_left_size < 0 )
pi->send_left_size = 0;
//if( pi->send_left_size < 0 )
// pi->send_left_size = 0;
if( pi->send_left_num < 0 )
pi->send_left_num = 0;
pi->send_left_num = 0;
DEB((D_PROT, "p_tx_fopen: now opening \"%s\"", ptrl->fname));
@ -1053,7 +1053,7 @@ int p_rx_fopen(s_protinfo *pi, char *fn, size_t sz, time_t tm, mode_t mode)
/*
* Check, there is enough space in our inbound
*/
if (openmode == "a") needed_bytes_total = minfree + pi->recv->bytes_total - pi->recv->bytes_skipped;
if ( strcmp(openmode, "a") == 0 ) needed_bytes_total = minfree + pi->recv->bytes_total - pi->recv->bytes_skipped;
else needed_bytes_total = minfree + pi->recv->bytes_total;
if( minfree > 0 && getfreespace(state.inbound) < needed_bytes_total )

View File

@ -449,8 +449,8 @@ static int sm_rx_waitseq(s_rx_emsidat *d)
static int sm_rx_getdat(s_rx_emsidat *d)
{
int rc = 0;
int pos = 0;
int emsi_len = 0;
u_int pos = 0;
u_int emsi_len = 0;
short unsigned ourcrc;
short unsigned remcrc;
char *emsi_dat = NULL;
@ -599,7 +599,7 @@ void emsi_set_sysinfo(s_emsi *emsi, s_emsi *remote_emsi, int hrc,
s_cval_entry *hide_ptr;
s_faddr *primary = NULL;
char xdt[EMSI_MAXXDATETIME+1];
time_t xtm;
time_t xtm = 0;
const long options = conf_options(cf_options);
const long speed = conf_number(cf_max_speed);

View File

@ -65,7 +65,7 @@ static char *add_str(char *source, const char *add)
{
len += 2;
dest = (char *)xrealloc(dest, len);
sprintf(&dest[pos], "\\%02hd", *(unsigned char*)add);
sprintf(&dest[pos], "\\%02hhu", *(unsigned char*)add);
add += 1;
pos += 3;
}
@ -200,38 +200,12 @@ char *emsi_createdat(s_emsi *emsi)
if( emsi->compcodes.NCP ) tmp = add_str(tmp, "NCP,");
} else {
ord = xmalloc(4);
DEB((D_HSHAKE,"Protocol order found: %s", p_order));
ord = strncpy(ord, p_order,3);
ord[3] = '\0';
DEB((D_HSHAKE,"Protocol order chunk: %s", ord));
if ( ord == NULL )
DEB((D_HSHAKE,"EMSI create order error"));
if ( !strcmp(ord,"HYD") )
if ( emsi->compcodes.HYD) tmp = add_str(tmp, "HYD,");
if ( !strcmp(ord,"JAN") )
if ( emsi->compcodes.JAN) tmp = add_str(tmp, "JAN,");
if ( !strcmp(ord,"DZA") )
if ( emsi->compcodes.DZA) tmp = add_str(tmp, "DZA,");
if ( !strcmp(ord,"ZAP") )
if ( emsi->compcodes.ZAP) tmp = add_str(tmp, "ZAP,");
if ( !strcmp(ord,"ZMO") )
if ( emsi->compcodes.ZMO) tmp = add_str(tmp, "ZMO,");
if ( !strcmp(ord,"TZA") )
if ( emsi->compcodes.TZA) tmp = add_str(tmp, "TZA,");
if ( !strcmp(ord,"SLK") )
if ( emsi->compcodes.SLK) tmp = add_str(tmp, "SLK,");
if ( !strcmp(ord,"KER") )
if ( emsi->compcodes.KER) tmp = add_str(tmp, "KER,");
if ( !strcmp(ord,"NCP") )
if ( emsi->compcodes.NCP) tmp = add_str(tmp, "NCP,");
p_order = strchr(p_order, ',');
if ( p_order ) p_order = p_order+1; /* skip ',' */
while ( p_order ) {
if (ord)
{
DEB((D_HSHAKE,"Protocol order found: %s", p_order));
ord = strncpy(ord, p_order,3);
ord[3] = '\0';
DEB((D_HSHAKE,"Protocol order chunk: %s", ord));
if ( ord == NULL )
DEB((D_HSHAKE,"EMSI create order error"));
if ( !strcmp(ord,"HYD") )
if ( emsi->compcodes.HYD) tmp = add_str(tmp, "HYD,");
if ( !strcmp(ord,"JAN") )
@ -251,9 +225,34 @@ char *emsi_createdat(s_emsi *emsi)
if ( !strcmp(ord,"NCP") )
if ( emsi->compcodes.NCP) tmp = add_str(tmp, "NCP,");
p_order = strchr(p_order, ',');
if ( p_order ) p_order = p_order+1; /* skip ',' */
if ( p_order ) p_order = p_order+1; /* skip ',' */
while ( p_order ) {
ord = strncpy(ord, p_order,3);
ord[3] = '\0';
DEB((D_HSHAKE,"Protocol order chunk: %s", ord));
if ( !strcmp(ord,"HYD") )
if ( emsi->compcodes.HYD) tmp = add_str(tmp, "HYD,");
if ( !strcmp(ord,"JAN") )
if ( emsi->compcodes.JAN) tmp = add_str(tmp, "JAN,");
if ( !strcmp(ord,"DZA") )
if ( emsi->compcodes.DZA) tmp = add_str(tmp, "DZA,");
if ( !strcmp(ord,"ZAP") )
if ( emsi->compcodes.ZAP) tmp = add_str(tmp, "ZAP,");
if ( !strcmp(ord,"ZMO") )
if ( emsi->compcodes.ZMO) tmp = add_str(tmp, "ZMO,");
if ( !strcmp(ord,"TZA") )
if ( emsi->compcodes.TZA) tmp = add_str(tmp, "TZA,");
if ( !strcmp(ord,"SLK") )
if ( emsi->compcodes.SLK) tmp = add_str(tmp, "SLK,");
if ( !strcmp(ord,"KER") )
if ( emsi->compcodes.KER) tmp = add_str(tmp, "KER,");
if ( !strcmp(ord,"NCP") )
if ( emsi->compcodes.NCP) tmp = add_str(tmp, "NCP,");
p_order = strchr(p_order, ',');
if ( p_order ) p_order = p_order+1; /* skip ',' */
}
free(ord);
}
free(ord);
}
if( emsi->compcodes.FRQ ) tmp = add_str(tmp, "FRQ,");
@ -452,7 +451,7 @@ char *emsi_createdat(s_emsi *emsi)
static char *get_field(char **str, char from, char to)
{
char *dst, *src, *dest = NULL;
int ch;
u_int ch;
src = *str;
@ -555,7 +554,7 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
/* password */
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
if( p && *p ) strnxcpy(emsi->passwd, p, sizeof(emsi->passwd));
if( *p ) strnxcpy(emsi->passwd, p, sizeof(emsi->passwd));
/* link codes */
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
@ -670,21 +669,22 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
else if( !strcmp(p, "HFR") ) emsi->compcodes.HFR = 1;
}
/* Delete last comma from order list */
emsi->proto_order[strlen(emsi->proto_order)-1] = '\0';
if (strlen(emsi->proto_order) > 0)
emsi->proto_order[strlen(emsi->proto_order)-1] = '\0';
DEB((D_HSHAKE,"Ordered compcodes: %s",emsi->proto_order));
/* mailer information */
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
if( p && *p ) strnxcpy(emsi->m_pid, p, sizeof(emsi->m_pid));
if( *p ) strnxcpy(emsi->m_pid, p, sizeof(emsi->m_pid));
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
if( p && *p ) strnxcpy(emsi->m_name, p, sizeof(emsi->m_name));
if( *p ) strnxcpy(emsi->m_name, p, sizeof(emsi->m_name));
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
if( p && *p ) strnxcpy(emsi->m_ver, p, sizeof(emsi->m_ver));
if( *p ) strnxcpy(emsi->m_ver, p, sizeof(emsi->m_ver));
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
if( p && *p ) strnxcpy(emsi->m_reg, p, sizeof(emsi->m_reg));;
if( *p ) strnxcpy(emsi->m_reg, p, sizeof(emsi->m_reg));;
}
else if( strcmp(tmp, "IDENT") == 0 )
{
@ -692,17 +692,17 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
if( (tmp=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
if( (p=get_field(&tmp, '[', ']')) == NULL ) return(1);
if( p && *p ) strnxcpy(emsi->sname, p, sizeof(emsi->sname));
if( *p ) strnxcpy(emsi->sname, p, sizeof(emsi->sname));
if( (p=get_field(&tmp, '[', ']')) == NULL ) return(1);
if( p && *p ) strnxcpy(emsi->location, p, sizeof(emsi->location));
if( *p ) strnxcpy(emsi->location, p, sizeof(emsi->location));
if( (p=get_field(&tmp, '[', ']')) == NULL ) return(1);
if( p && *p ) strnxcpy(emsi->sysop, p, sizeof(emsi->sysop));
if( *p ) strnxcpy(emsi->sysop, p, sizeof(emsi->sysop));
if( (p=get_field(&tmp, '[', ']')) == NULL ) return(1);
if( p && *p ) strnxcpy(emsi->phone, p, sizeof(emsi->phone));;
if( *p ) strnxcpy(emsi->phone, p, sizeof(emsi->phone));;
if( (p=get_field(&tmp, '[', ']')) == NULL ) return(1);
if( p && *p ) sscanf(p, "%d", &emsi->speed);
if( *p ) sscanf(p, "%d", &emsi->speed);
if( (p=get_field(&tmp, '[', ']')) == NULL ) return(1);
if( p && *p ) strnxcpy(emsi->flags, p, sizeof(emsi->flags));
if( *p ) strnxcpy(emsi->flags, p, sizeof(emsi->flags));
}
else if( strcmp(tmp, "TRX#") == 0 )
{
@ -720,9 +720,9 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
else if( strcmp(tmp, "TRAF") == 0 )
{
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
if( p && *p )
if( *p )
{
if( sscanf(p, "%08X %08X", &emsi->netmail_size, &emsi->arcmail_size) == 2 )
if( sscanf(p, "%08zX %08zX", &emsi->netmail_size, &emsi->arcmail_size) == 2 )
{
emsi->have_traf = 1;
}
@ -736,9 +736,9 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
{
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
if( (p=get_field(&p, '[', ']')) == NULL ) return(1);
if( p && *p )
if( *p )
{
if( sscanf(p, "%08X", &emsi->files_size) == 1 )
if( sscanf(p, "%08zX", &emsi->files_size) == 1 )
{
emsi->have_moh = 1;
}
@ -781,21 +781,24 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
/* Parse EMSI TZUTC in fmt (+|-)HHMM */
if( *p ) {
tzc = malloc(2);
DEB((D_HSHAKE, "Got TZUTC=%s for parsing", p));
tzn = sscanf( p, "%1c%02u%02u", tzc, &tzh, &tzm);
tzc[1] = '\0';
if ( tzn == 3) {
DEB((D_HSHAKE, "Got TZC=%s , H=%u, M=%u", tzc, tzh,tzm));
emsi->have_tzutc = 1;
if ( strcmp(tzc, "-") == 0 ) {
emsi->tzutc = -(tzh*60 + tzm);
if (tzc)
{
DEB((D_HSHAKE, "Got TZUTC=%s for parsing", p));
tzn = sscanf( p, "%1c%02u%02u", tzc, &tzh, &tzm);
tzc[1] = '\0';
if ( tzn == 3) {
DEB((D_HSHAKE, "Got TZC=%s , H=%u, M=%u", tzc, tzh,tzm));
emsi->have_tzutc = 1;
if ( strcmp(tzc, "-") == 0 ) {
emsi->tzutc = -(tzh*60 + tzm);
} else {
emsi->tzutc = tzh*60 + tzm;
}
} else {
emsi->tzutc = tzh*60 + tzm;
DEB((D_HSHAKE,"TZUTC value not parsed!"));
}
} else {
DEB((D_HSHAKE,"TZUTC value not parsed!"));
free(tzc);
}
free(tzc);
}
}
else
@ -878,7 +881,7 @@ void emsi_logdat(s_emsi *emsi)
if( emsi->compcodes.HFR )
strcat(flags, "HFR,");
if( *flags )
if( *flags && (strlen(flags) > 0) )
{
flags[strlen(flags)-1] = '\0';
log(" Options : %s", flags);
@ -919,7 +922,7 @@ void emsi_logdat(s_emsi *emsi)
if( emsi->have_emsi )
{
if( emsi->m_name[0] || emsi->m_pid[0]
|| emsi->m_ver[0] || emsi->m_reg )
|| emsi->m_ver[0] || emsi->m_reg[0] )
{
log(" Mailer : %s [%s] %s/%s",
emsi->m_name[0] ? string_printable(emsi->m_name) : "?",

View File

@ -100,7 +100,8 @@ char *hydra_pkttype_names[] =
"HPKT_EOFACK",
"HPKT_END",
"HPKT_IDLE",
"HPKT_DEVDATA"
"HPKT_DEVDATA",
"HPKT_DEVDACK"
};
char *hydra_char_names[] =
@ -1049,8 +1050,8 @@ static int hydra_parse_init(s_hydrainfo *hi, char *pkt, size_t pktlen)
if( appinf && canopt && desopt && window && prefix )
{
char buf[256];
long txwindow = 0L;
long rxwindow = 0L;
unsigned long txwindow = 0UL;
unsigned long rxwindow = 0UL;
DEB((D_PROT, "hydra: revtime = \"%s\"", time_string_long(buf, sizeof(buf), revtime)));
DEB((D_PROT, "hydra: appinf = \"%s\"", appinf));
@ -1548,7 +1549,9 @@ int hydra_batch(s_hydrainfo *hi, s_protinfo *pi)
/*
* Check current CPS, session time limits, etc.
*/
if( (rc = p_info(pi, 1)) ) gotoexit(rc);
rc = p_info(pi, 1);
if( rc != PRC_NOERROR ) gotoexit(rc);
/*
* Send/receive as much data as possible, but without delays
@ -1637,7 +1640,7 @@ int hydra_batch(s_hydrainfo *hi, s_protinfo *pi)
char *p;
/* Get file modification time and size */
sscanf(hi->ibuf, "%08lx%08x%*08x%*08x%*08x",
sscanf(hi->ibuf, "%08lx%08zx%*08zx%*08zx%*08zx",
(unsigned long *)&modtime, &filesize);
/* Convert local time -> UTC */

View File

@ -85,13 +85,12 @@ static void yoohoo_put_hello(char *buffer, s_yoohoo_sysinfo *myhello)
* Add domain after the end of 'Node name'
* TODO: check it for buffer overflows %-I
*/
if( state.n_localaddr > 0 && state.localaddrs[0].addr.domain
&& *state.localaddrs[0].addr.domain )
if( state.n_localaddr > 0 && *state.localaddrs[0].addr.domain )
{
char *q;
if( strlen(myhello->system) + strlen(state.localaddrs[0].addr.domain) > 57 )
{
if( strlen(state.localaddrs[0].addr.domain) < 60 )
if( strlen(state.localaddrs[0].addr.domain) < 60 ) //PVS-Suppress V547
q = p + (60 - strlen(state.localaddrs[0].addr.domain));
else
q = p;

View File

@ -67,7 +67,7 @@ static const char *FrameTypes[] =
"ZCOMMAND",
"ZSTDERR",
"Unused"
#define FRTYPES 22 /* Total number of frame types in this array */
#define FRTYPES 20 /* Total number of frame types in this array */
/* not including psuedo negative entries */
};
#endif

View File

@ -548,7 +548,7 @@ static int zmodem_proc_ZFILE(s_protinfo *pi, char *blkptr, size_t blklen)
fileiptr = blkptr + strlen(blkptr) + 1;
if( fileiptr >= (blkptr + blklen) ||
sscanf(fileiptr, "%d%lo", &filesize, (unsigned long *)&filetime) < 1 )
sscanf(fileiptr, "%zu%lo", &filesize, (unsigned long *)&filetime) < 1 )
{
log("zmodem: got invalid ZFILE packet");
return 1;

View File

@ -47,14 +47,18 @@ static void zmodem_add_empty_packet(s_protinfo *pi)
s_filelist **ptrl;
s_packet pkt;
char tmpname[] = "/tmp/bfXXXXXX";
char *chunk;
char *p_tmpname;
if( (p_tmpname = mktemp(tmpname)) == NULL )
{
logerr("cannot generate temp. file name for packet from \"%s\"", tmpname);
chunk = xmalloc(7);
if (!chunk) {
logerr("cannot generate temp. file name for packet");
return;
}
getrandname(chunk, 6);
p_tmpname = string_concat("/tmp/bf", chunk, '\0');
free(chunk);
memset(&pkt, '\0', sizeof(s_packet));
pkt.dest = state.node.addr;

View File

@ -210,7 +210,7 @@ int call_system_quiet(const char *connstr, bool inet)
if( (exec_cmd = conf_string(cf_run_before_session)) != NULL )
{
exec_result = system(exec_cmd);
if( exec_result = 0 )
if( exec_result == 0 )
log("external application %s executed with zero return code (%i)", exec_cmd, exec_result);
else
logerr("external application %s executed with non-zero return code %i", exec_cmd, exec_result);
@ -378,7 +378,7 @@ int call_system_modem(void)
log("calling with modem %s (%s, %s)",
ftn_addrstr(abuf, state.node.addr),
(state.node.name && *state.node.name) ? state.node.name : "<none>",
( *state.node.name) ? state.node.name : "<none>",
string_printable(dialstring));
/*
@ -519,15 +519,15 @@ case CALL_TCPIP_TELNET:
state.session = SESSION_UNKNOWN;
target = xstrcpy("ITN");
break;
defalt:
default:
log("invalid protocol for TCP/IP module");
return BFERR_FATALERROR;
}
log("calling with internet %s (%s, %s)",
ftn_addrstr(abuf, state.node.addr),
(state.node.name && *state.node.name ) ? state.node.name : "<none>",
(state.node.host && *state.node.host) ? state.node.host : "<none>");
(*state.node.name ) ? state.node.name : "<none>",
( *state.node.host) ? state.node.host : "<none>");
memset(abuf, '\0', BF_MAXADDRSTR+1);
pbuf = xmalloc(1024);
@ -536,7 +536,7 @@ defalt:
if ( ! resflg )
{
char *p = string_casestr(pbuf, target);
const char *p = string_casestr(pbuf, target);
if ( p )
{
@ -568,7 +568,7 @@ defalt:
if( (rc = tcpip_connect(pbuf, state.tcpmode)) == 0
&& (rc = tcpip_init() == 0) )
&& ( (rc = tcpip_init()) == 0) )
{
TTYSTATUS(1);
rc = session();
@ -862,7 +862,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
}
if( NULL != state.override.run && strlen(state.override.run) > 0 )
{
if ( (runrc = system(state.override.run) != 0 ))
if ( (runrc = system(state.override.run)) != 0 )
{
logerr("run script \"%s\" executed with non-zero return value", state.override.run);
}
@ -872,7 +872,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
// try allowed methods and break if rc == 0
rc = -1;
if( rc && (call_mayuse & CALL_STDIO) )
if( call_mayuse & CALL_STDIO )
{
DEB((D_EVENT,"sess_call: calling stdio"));
rc = call_system_quiet(opts->connect, opts->inetd);

View File

@ -58,11 +58,11 @@ static char *session_stat_get_stsfile(s_faddr *addr, int linenum)
addr->zone, addr->net,
addr->node, addr->point);
else
sprintf(buf, "%u.%u.%u.%u-%u.sts",
sprintf(buf, "%u.%u.%u.%u-%d.sts",
addr->zone, addr->net,
addr->node, addr->point, linenum);
yield = string_concat(p_stsdir, buf, NULL);
yield = string_concat(p_stsdir, buf, '\0');
}
return yield;

View File

@ -109,6 +109,22 @@ int file_lock_wait(FILE *fp, bool exclusive)
return -1;
}
void getrandname(char * buf, u_int size)
{
srand((unsigned int)time(NULL));
char c;
int i;
for (i = 0; i<size; i++)
{
c = rand();
// Only ASCII 0..9A..Z
while ( (c > 90) || (c < 48) || ( ( c > 57) && ( c < 65 ) ) )
c = rand();
buf[i] = c;
}
buf[size]='\0';
}
bool file_name_issafe(int ch)
{
if( ch == '!' ) return TRUE;
@ -151,12 +167,22 @@ char *file_getname(char *filename)
char *file_gettmp(void)
{
char *tmp = xstrcpy("/tmp/bforce-XXXXXX");
char *res = mktemp(tmp);
if( !res )
free(tmp);
char *chunk = xmalloc(7);
char *res = NULL;
if (chunk)
{
getrandname(chunk,6);
chunk[6] = '\0';
char *tmp = xstrcpy("/tmp/bforce-");
res = string_concat(tmp, chunk, '\0');
if( chunk )
free(chunk);
if( !res )
free(tmp);
}
return res;
}

View File

@ -152,7 +152,13 @@ int plock_link(const char *lockname, const char *tmpname)
int plock_create(const char *lockname)
{
int rc;
char *tmpname, *p;
char *tmpname, *p, *chunk;
chunk = xmalloc(7);
if (!chunk) {
logerr("can't generate unique file name from \"%s\"", tmpname);
DEB((D_FREE, "plock freed"));
return PLOCK_ERROR;
}
ASSERT(lockname != NULL);
@ -166,16 +172,10 @@ int plock_create(const char *lockname)
DEB((D_FREE, "plock freed"));
return PLOCK_ERROR;
}
tmpname = xstrcat(tmpname, "bforce-XXXXXX");
if( (p = mktemp(tmpname)) == NULL )
{
logerr("can't generate unique file name from \"%s\"", tmpname);
DEB((D_FREE, "plock free"));
free(tmpname);
DEB((D_FREE, "plock freed"));
return PLOCK_ERROR;
}
tmpname = xstrcat(tmpname, "bforce-");
getrandname(chunk,6);
p = string_concat(tmpname,chunk,'\0');
if( (rc = plock_write(p)) == PLOCK_OK )
rc = plock_link(lockname, p);

View File

@ -598,6 +598,8 @@ int string_parse(char **dest, int items, char *str, int separator)
{
int count = 0;
char *p = str;
//if ( *((unsigned char *)p) == separator )
// p++;
dest[count++] = str;
@ -606,6 +608,7 @@ int string_parse(char **dest, int items, char *str, int separator)
if( *((unsigned char *)p) == separator )
{
*p++ = '\0';
// DEB((D_INDEX,"Parsed string: %s", dest[count]));
dest[count++] = p;
} else
++p;

View File

@ -29,11 +29,12 @@ bool eventexpr(s_expr *expr)
static void usage(void)
{
printf_usage("nodelist compiler",
"usage: bfindex [-fh]\n"
"usage: bfindex [-fh] [-C config]\n"
"\n"
"options:\n"
" -f force nodelist compiling\n"
" -h show this help message\n"
" -C config use config\n"
"\n"
);
}
@ -42,6 +43,7 @@ static int nodelist_makeindex(s_nodelist *nlp, s_faddr addr)
{
s_bni bni;
char buf[1024];
bool modepoint = FALSE;
long countnodes = 0L;
long countlines = 0L;
enum nodelist_keyword keyword;
@ -52,6 +54,9 @@ static int nodelist_makeindex(s_nodelist *nlp, s_faddr addr)
bni.node = addr.node;
bni.point = addr.point;
DEB((D_INDEX, "Start create index for addr: %u:%u/%u.%u", bni.zone,
bni.net, bni.node, bni.point));
if( nodelist_createheader(nlp) == -1 )
{
log("cannot create nodelist index header");
@ -80,13 +85,16 @@ static int nodelist_makeindex(s_nodelist *nlp, s_faddr addr)
if( (p = strchr(buf, ',')) )
{
//DEB((D_INDEX, "index: parse comma: %s", p ));
*p++ = '\0';
if( (q = strchr(p, ',')) ) *q = '\0';
}
if( p == NULL || *p == '\0' )
{
log("incorrect nodelist line %ld: Short line", countlines);
DEB((D_INDEX,"incorrect nodelist line %ld: Short line", countlines));
continue;
}
@ -94,20 +102,28 @@ static int nodelist_makeindex(s_nodelist *nlp, s_faddr addr)
{
log("incorrect nodelist line %d: Bad keyword \"%s\"",
countlines, buf);
DEB((D_INDEX,"incorrect nodelist line %d: Bad keyword \"%s\"",
countlines, buf));
continue;
}
//DEB((D_INDEX,"index: keyword=%d", keyword));
if( keyword == KEYWORD_BOSS )
{
s_faddr tmpaddr;
if( ftn_addrparse(&tmpaddr, p, FALSE) )
{
DEB((D_INDEX,"incorrect nodelist line %ld: Bad boss address \"%s\"",
countlines, p));
log("incorrect nodelist line %ld: Bad boss address \"%s\"",
countlines, p);
}
else
{
DEB((D_INDEX,"index: parsing Boss %u:%u/%u.0",
tmpaddr.zone, tmpaddr.net, tmpaddr.node));
if (addr.point == -1 )
modepoint = true;
bni.zone = tmpaddr.zone;
bni.net = tmpaddr.net;
bni.node = tmpaddr.node;
@ -131,36 +147,49 @@ static int nodelist_makeindex(s_nodelist *nlp, s_faddr addr)
bni.node = 0;
bni.point = 0;
bni.hub = 0;
modepoint = false;
break;
case KEYWORD_REGION:
bni.net = value;
bni.node = 0;
bni.point = 0;
bni.hub = 0;
modepoint = false;
break;
case KEYWORD_HOST:
bni.net = value;
bni.node = 0;
bni.point = 0;
bni.hub = 0;
modepoint = false;
break;
case KEYWORD_HUB:
bni.node = value;
bni.point = 0;
bni.hub = value;
modepoint = false;
break;
case KEYWORD_EMPTY:
if (modepoint)
{
//DEB((D_INDEX,"found empty value=%u",value ));
bni.point = value;
break;
}
case KEYWORD_PVT:
case KEYWORD_HOLD:
case KEYWORD_DOWN:
bni.node = value;
bni.point = 0;
modepoint = false;
break;
case KEYWORD_POINT:
DEB((D_INDEX,"index: kw point"));
bni.point = value;
break;
default:
ASSERT_MSG();
DEB((D_INDEX,"index: default assert"));
}
if( nodelist_putindex(nlp, &bni) == -1 )
@ -182,10 +211,12 @@ int main(int argc, char *argv[])
{
s_cval_entry *cfptr;
char *nodelistdir = NULL;
char *confname = NULL;
time_t starttime = 0L;
bool forcecompile = FALSE;
long countnodes = 0L;
char c;
int rc = 0;
/* Initialise random number generation */
(void)srand((unsigned)time(0));
@ -193,7 +224,7 @@ int main(int argc, char *argv[])
(void)setlocale(LC_ALL, "");
/* Set our name (for logging only) */
while( (c = getopt(argc, argv, "hf")) != (char)-1 )
while( (c = getopt(argc, argv, "hfC:")) != (char)-1 )
{
switch( c ) {
case 'f':
@ -202,15 +233,25 @@ int main(int argc, char *argv[])
case 'h':
usage();
exit(0);
case 'C':
if( confname || !optarg ) { usage(); exit(5); }
confname = (char *)xstrcpy(optarg);
break;
default:
usage();
exit(5);
}
}
if( conf_readconf(conf_getconfname(), 0, false) )
if( confname && *confname )
rc = conf_readconf(confname, 0, false);
else
rc = conf_readconf(conf_getconfname(), 0, false);
if( rc )
{
log("Can not find config");
exit(1);
}

View File

@ -44,7 +44,7 @@ bool eventexpr(s_expr *expr)
static void usage(void)
{
printf_usage("outbound viewer",
"usage: bfstat [-afhprst] [-n<number>]\n"
"usage: bfstat [-C config] [-afhprst] [-n<number>]\n"
"\n"
"options:\n"
" -a sort by FTN address (default)\n"
@ -56,6 +56,7 @@ static void usage(void)
" -r reverse order while sorting\n"
" -s sort by total files size\n"
" -t disable total sizes printing\n"
" -C config use config file\n"
"\n"
);
}
@ -248,8 +249,10 @@ int main(int argc, char *argv[])
s_opts opts;
s_sysqueue queue;
s_outbound_callback_data ocb;
char *confname = NULL;
char c;
int i;
int rc = 0;
bfstat_opts_default(&opts);
@ -288,6 +291,10 @@ int main(int argc, char *argv[])
if( ISDEC(optarg) )
opts.nodeslimit = atoi(optarg);
break;
case 'C':
if( confname || !optarg ) { usage(); exit(BFERR_FATALERROR); }
confname = (char *)xstrcpy(optarg);
break;
default:
usage();
exit(1);
@ -301,8 +308,16 @@ int main(int argc, char *argv[])
/* Initialise current locale */
(void)setlocale(LC_ALL, "");
if( conf_readconf(conf_getconfname(), 0, false) )
exit(1);
if( confname && *confname )
rc = conf_readconf(confname, 0, false);
else
rc = conf_readconf(conf_getconfname(), 0, false);
if( rc )
{
log("Can not find config");
exit(BFERR_FATALERROR);
}
memset(&ocb, '\0', sizeof(s_outbound_callback_data));
ocb.callback = out_handle_sysqueue;

View File

@ -28,12 +28,13 @@ bool eventexpr(s_expr *expr)
static void usage(void)
{
printf_usage("nodelist lookup utility",
"usage: nlookup [-rmh] <address>\n"
"usage: nlookup [-C config] [-rmh] <address>\n"
"\n"
"options:\n"
" -r show nodelist string\n"
" -m show email address\n"
" -h show this help message\n"
" -C config use config file\n"
"\n"
);
}
@ -82,7 +83,7 @@ void print_nodeinfo(const s_node *node)
timevec_check(&node->worktime, now) ? "false" : "true");
}
if( node->sysop && *node->sysop && strcmp(node->sysop, "<none>") )
if( (node->keyword != KEYWORD_POINT) && node->sysop && *node->sysop && strcmp(node->sysop, "<none>") )
{
char username[BNI_MAXSYSOP+1];
@ -127,6 +128,8 @@ int main(int argc, char *argv[])
s_node node;
s_faddr addr;
char ch;
int rc = 0;
char *confname = NULL;
bool rawstring = FALSE;
bool emailaddr = FALSE;
@ -135,7 +138,7 @@ int main(int argc, char *argv[])
/* Initialise current locale */
(void)setlocale(LC_ALL, "");
while( (ch=getopt(argc, argv, "hrm")) != (char)-1 )
while( (ch=getopt(argc, argv, "hdrmC:")) != (char)-1 )
{
switch( ch ) {
case 'h':
@ -147,6 +150,10 @@ int main(int argc, char *argv[])
case 'm':
emailaddr = TRUE;
break;
case 'C':
if( confname || !optarg ) { usage(); exit(BFERR_FATALERROR); }
confname = (char *)xstrcpy(optarg);
break;
default:
usage();
exit(BFERR_FATALERROR);
@ -159,8 +166,18 @@ int main(int argc, char *argv[])
exit(BFERR_FATALERROR);
}
if( conf_readconf(conf_getconfname(), 0, false) )
if( confname && *confname )
rc = conf_readconf(confname, 0, false);
else
rc = conf_readconf(conf_getconfname(), 0, false);
if( rc )
{
DEB((D_NODELIST,"nlookup: Can not find config"));
exit(BFERR_FATALERROR);
}
DEB((D_NODELIST,"Starting nlookup"));
if( rawstring )
{
@ -171,10 +188,16 @@ int main(int argc, char *argv[])
}
else if( nodelist_lookup(&node, addr) == 0 )
{
if( emailaddr )
print_nodemail(&node);
else
print_nodeinfo(&node);
if (addr.point == 0) {
if( emailaddr )
print_nodemail(&node);
else
print_nodeinfo(&node);
}
else
{
print_nodeinfo(&node);
}
}
deinit_conf();

11
source/configure vendored
View File

@ -580,12 +580,12 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='bforce'
PACKAGE_TARNAME='bforce'
PACKAGE_VERSION='0.24.1'
PACKAGE_STRING='bforce 0.24.1'
PACKAGE_VERSION='0.26.2'
PACKAGE_STRING='bforce 0.26.2'
PACKAGE_BUGREPORT='zx@zxalexis.ru'
PACKAGE_URL='https://prj.zxalexis.ru/gitea/zx/bforce.git'
ac_default_prefix=/usr/local/fido
ac_default_prefix=/usr
# Factoring default headers for most tests.
ac_includes_default="\
#include <stdio.h>
@ -1436,7 +1436,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
bforce configure 0.24
bforce configure 0.26
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -5792,7 +5792,7 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi
ac_config_files="$ac_config_files ../debian/Makefile"
ac_config_files="$ac_config_files"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@ -6486,7 +6486,6 @@ do
case $ac_config_target in
"include/config.h") CONFIG_HEADERS="$CONFIG_HEADERS include/config.h" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"../debian/Makefile") CONFIG_FILES="$CONFIG_FILES ../debian/Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac

View File

@ -3,7 +3,7 @@ dnl
dnl $Id$
dnl
#AC_INIT(bforce/bforce.c)
AC_INIT([bforce],[0.26.1],[zx@zxalexis.ru])
AC_INIT([bforce],[0.26.2],[zx@zxalexis.ru])
AC_CONFIG_HEADER(include/config.h)
AC_CANONICAL_SYSTEM
dnl # Minimum Autoconf version required.

View File

@ -48,6 +48,7 @@ enum { LOG_FILE_DAEMON, LOG_FILE_SESSION, LOG_FILE_DEBUG, LOG_FILE_HISTORY };
#define D_DAEMON 0x0001000L
#define D_24554 0x0002000L
#define D_FREE 0x0004000L
#define D_INDEX 0x0008000L
#define D_FULL 0xfffffffL
#endif

View File

@ -159,6 +159,7 @@ s_node;
int nodelist_checkflag(const char *nodeflags, const char *flag);
int nodelist_keywordval(const char *keyword);
int nodelist_parsepoint(s_node *node, char *str);
int nodelist_parsestring(s_node *node, char *str);
s_nodelist *nodelist_open(const char *dir, char *name, int mode);
int nodelist_checkheader(s_nodelist *nlp);

View File

@ -78,13 +78,13 @@ typedef struct {
} s_session_passwd;
typedef struct sendopts {
int fnc:1, /* Convert outgoing file names to 8+3 format */
holdreq:1, /* Hold .REQ files? (file requests) */
holdhold:1, /* Hold files with HOLD flavor? */
holdfiles:1, /* Hold all files except netmail + arcmail */
holdxt:1, /* Hold all except netmail? */
holdall:1, /* Hold ALL trafic!? */
hydraRH1; /* Hydra RH1 mode (EMSI only) */
unsigned int fnc:1, /* Convert outgoing file names to 8+3 format */
holdreq:1, /* Hold .REQ files? (file requests) */
holdhold:1, /* Hold files with HOLD flavor? */
holdfiles:1, /* Hold all files except netmail + arcmail */
holdxt:1, /* Hold all except netmail? */
holdall:1, /* Hold ALL trafic!? */
hydraRH1; /* Hydra RH1 mode (EMSI only) */
} s_sendopts;
/*

View File

@ -46,10 +46,10 @@ enum day
typedef struct faddr {
bool inetform; /* Is address in domain form? */
int zone; /* -1 value means any?! */
int net;
int node;
int point;
u_int zone; /* -1 value means any?! */
u_int net;
u_int node;
u_int point;
char domain[BF_MAXDOMAIN+1];
} s_faddr;
@ -83,7 +83,7 @@ typedef struct message {
typedef struct packet {
s_faddr orig;
s_faddr dest;
int baud;
u_int baud;
char password[8+1];
s_message *msgs;
int n_msgs;
@ -161,6 +161,7 @@ bool is_regfile(const char *filename);
int directory_create(const char *dirname, mode_t access_mode);
FILE *file_open(const char *path, const char *mode);
int file_close(FILE *stream);
void getrandname(char * buf, u_int size);
/* u_ftn.c */
int ftn_addrparse(s_faddr *addr, const char *s, bool wildcard);

View File

@ -6,7 +6,7 @@ proto_order %PROTO%
#domain schoolnet /var/spool/ftn/schoolnet/ 461
log_file %TESTZONE%/logsA/bf-log
debug_file %TESTZONE%/logsA/bf-debug
debug_level modem hshake event freq
debug_level info modem hshake event prot outbound override
nodial_flag %TESTZONE%/etc/nodial
inbound_directory (Protected) %TESTZONE%/inboundA
inbound_directory %TESTZONE%/inbound-unsecureA
@ -19,6 +19,7 @@ status_directory %TESTZONE%/logsA
history_file %TESTZONE%/logsA/history
password 99:1/2 testpwd1
override 99:1/2 flags INA:localhost,IFC:59999,IBN:59999
#min_speed_in 1200
#min_speed_out 1200
#session_limit_in 1800

View File

@ -6,7 +6,7 @@ proto_order %PROTO%
#domain schoolnet /var/spool/ftn/schoolnet/ 461
log_file %TESTZONE%/logsB/bf-log
debug_file %TESTZONE%/logsB/bf-debug
debug_level modem hshake event freq
debug_level info modem hshake event prot outbound override
nodial_flag %TESTZONE%/etc/nodial
inbound_directory (Protected) %TESTZONE%/inboundB
inbound_directory %TESTZONE%/inbound-unsecureB
@ -19,6 +19,7 @@ status_directory %TESTZONE%/logsB
history_file %TESTZONE%/logsB/history
password 99:1/1 testpwd1
override 99:1/1 flags INA:localhost,IFC:59999,IBN:59999
#min_speed_in 1200
#min_speed_out 1200
#session_limit_in 1800

0
tests/configs/genpkt.sh Executable file → Normal file
View File

View File

@ -1,52 +1,93 @@
#!/bin/bash
#!/usr/bin/env bash
# Making tests of BForce
CURDIR=$(pwd)
BFBIN=$(pwd)/../source/bin/bforce
CURDIR="${CURDIR:-$(pwd)}"
BFBIN=${BFBIN:-$(pwd)/../source/bin/bforce}
SOCATCMD=${SOCATCMD:-$(which socat)}
function prepconfig() {
echo "Preparing configs with $1 as protocol..."
cp ${CURDIR}/configs/bforceA.conf ${CURDIR}/etc/bforceA.conf
sed -i -e "s/%PROTO%/$1/" ${CURDIR}/etc/bforceA.conf
sed -i -e "s#%TESTZONE%#${CURDIR}#" ${CURDIR}/etc/bforceA.conf
if [[ ! -d "${CURDIR}/ftntest" ]] ;
then
echo -n "(o_O) "
else
echo "Dir exists!"
rm -rf ${CURDIR}/ftntest/{etc,inboundA,inboundB,inbound-unsecureA,inbound-unsecureB,logsA,logsB,outboundA,outboundB}
fi
cp ${CURDIR}/configs/bforceB.conf ${CURDIR}/etc/bforceB.conf
sed -i -e "s/%PROTO%/$1/" ${CURDIR}/etc/bforceB.conf
sed -i -e "s#%TESTZONE%#${CURDIR}#" ${CURDIR}/etc/bforceB.conf
mkdir -p "${CURDIR}"/ftntest/{etc,inbound-unsecureA,inbound-unsecureB,inboundA,inboundB,logsA,logsB,outboundA,outboundB}
cp -f ${CURDIR}/configs/bforceA.conf ${CURDIR}/ftntest/etc/bforceA.conf
sed -i -e "s/%PROTO%/$1/" ${CURDIR}/ftntest/etc/bforceA.conf
sed -i -e "s#%TESTZONE%#${CURDIR}/ftntest#" ${CURDIR}/ftntest/etc/bforceA.conf
cp ${CURDIR}/configs/00010002.cut ${CURDIR}/outboundA/00010002.cut
cp ${CURDIR}/configs/00010001.cut ${CURDIR}/outboundB/00010001.cut
cp -f ${CURDIR}/configs/bforceB.conf ${CURDIR}/ftntest/etc/bforceB.conf
sed -i -e "s/%PROTO%/$1/" ${CURDIR}/ftntest/etc/bforceB.conf
sed -i -e "s#%TESTZONE%#${CURDIR}/ftntest#" ${CURDIR}/ftntest/etc/bforceB.conf
cp -f ${CURDIR}/configs/00010002.cut ${CURDIR}/ftntest/outboundA/00010002.cut
cp -f ${CURDIR}/configs/00010001.cut ${CURDIR}/ftntest/outboundB/00010001.cut
}
function testcomm() {
rm -rf ${CURDIR}/inboundA/*
rm -rf ${CURDIR}/inboundB/*
rm -rf ${CURDIR}/ftntest/inboundA/*
rm -rf ${CURDIR}/ftntest/inboundB/*
echo " over ${1}"
# for V1 and V2
#mkfifo ${CURDIR}/bforceAtoB
#mkfifo ${CURDIR}/bforceBtoA
mkfifo ${CURDIR}/bforceAtoB
mkfifo ${CURDIR}/bforceBtoA
BFCFGA=${CURDIR}/etc/bforceA.conf
BFCFGB=${CURDIR}/etc/bforceB.conf
BFCFGA=${CURDIR}/ftntest/etc/bforceA.conf
BFCFGB=${CURDIR}/ftntest/etc/bforceB.conf
# Works for Linux
BFCONFIG=${BFCFGA}
BFCONFIG=${BFCFGA} ${BFBIN} -o 99:1/2 > ${CURDIR}/bforceAtoB < ${CURDIR}/bforceBtoA &
# Variant 1
#BFCONFIG=${BFCFGA}
#BFCONFIG=${BFCFGA} ${BFBIN} -o 99:1/2 > ${CURDIR}/bforceAtoB < ${CURDIR}/bforceBtoA &
#
BFCONFIG=${BFCFGB}
BFCONFIG=${BFCFGB} ${BFBIN} -S"CONNECT 9600" auto < ${CURDIR}/bforceAtoB > ${CURDIR}/bforceBtoA
#BFCONFIG=${BFCFGB}
#BFCONFIG=${BFCFGB} ${BFBIN} -S"CONNECT 9600" auto < ${CURDIR}/bforceAtoB > ${CURDIR}/bforceBtoA
# Variant 2
#${CURDIR}/runbfA.sh ${BFBIN} ${BFCFGA} > ${CURDIR}/bforceAtoB < ${CURDIR}/bforceBtoA &
#${CURDIR}/runbfB.sh ${BFBIN} ${BFCFGB} < ${CURDIR}/bforceAtoB > ${CURDIR}/bforceBtoA
# Variant 3 works with sockets and pipes - not pty
case ${1} in
"PSTN")
socat -ly -Wlock EXEC:"${CURDIR}/runbfB.sh ${BFBIN} ${BFCFGB}" EXEC:"${CURDIR}/runbfA.sh ${BFBIN} ${BFCFGA}"
sleep 2
;;
"IFC")
${CURDIR}/runbfC.sh ${BFBIN} ${BFCFGA} &
socat -ly -Wlock TCP4-LISTEN:59999 EXEC:"${CURDIR}/runbfD.sh ${BFBIN} ${BFCFGB}"
sleep 2
;;
"BKP")
${CURDIR}/runbfE.sh ${BFBIN} ${BFCFGA} &
socat -ly -Wlock TCP4-LISTEN:59999 EXEC:"${CURDIR}/runbfF.sh ${BFBIN} ${BFCFGB}"
sleep 2
;;
esac
# For [Free]BSD it need to be replaced - pipes are bidirectional:
# ./ping <&1 | ./pong >&0
rm ${CURDIR}/{bforceAtoB,bforceBtoA}
# for V1 and V2
#rm ${CURDIR}/{bforceAtoB,bforceBtoA}
## WE MUST CHECK THAT INBOUND ARE FULL!!! ##
FCNTA=$( find ${CURDIR}/inboundA -name *.pkt | wc -l )
FCNTB=$( find ${CURDIR}/inboundB -name *.pkt | wc -l )
DIFFA=$( diff ${CURDIR}/inboundA/*.pkt ${CURDIR}/configs/00010001.cut && echo $? )
DIFFB=$( diff ${CURDIR}/inboundB/*.pkt ${CURDIR}/configs/00010002.cut && echo $? )
FCNTA=$( find ${CURDIR}/ftntest/inboundA -name *.pkt | wc -l )
FCNTB=$( find ${CURDIR}/ftntest/inboundB -name *.pkt | wc -l )
if [[ "${FCNTA}" -eq "1" ]]
then
DIFFA=$( diff ${CURDIR}/ftntest/inboundA/*.pkt ${CURDIR}/configs/00010001.cut && echo $? )
fi
if [[ "${FCNTB}" -eq "1" ]]
then
DIFFB=$( diff ${CURDIR}/ftntest/inboundB/*.pkt ${CURDIR}/configs/00010002.cut && echo $? )
fi
if [[ "${DIFFA}" -eq "0" ]] && [[ "${FCNTA}" -eq "1" ]]
then
@ -55,48 +96,76 @@ function testcomm() {
echo "....Result: OK"
else
echo "....Failed DiffB"
RES=2
fi
else
echo "....Failed DiffA"
RES=1
fi
cat ${CURDIR}/logsA/bf-debug >> ${CURDIR}/debugA.log
cat ${CURDIR}/logsB/bf-debug >> ${CURDIR}/debugB.log
if [[ -f ${CURDIR}/ftntest/logsA/bf-debug ]]
then
cat ${CURDIR}/ftntest/logsA/bf-debug >> ${CURDIR}/debugA.log
fi
if [[ -f ${CURDIR}/ftntest/logsB/bf-debug ]]
then
cat ${CURDIR}/ftntest/logsB/bf-debug >> ${CURDIR}/debugB.log
fi
rm -rf ${CURDIR}/ftntest
}
if [[ ! -d "${CURDIR}/inboundA" ]]
then
echo "All clear to begin"
else
echo "Dir exists!"
rm -rf {etc,inboundA,inboundB,inbound-unsecureA,inbound-unsecureB,logsA,logsB,outboundA,outboundB}
fi
mkdir -p "${CURDIR}"/{etc,inbound-unsecureA,inbound-unsecureB,inboundA,inboundB,logsA,logsB,outboundA,outboundB}
if [[ ! -f "${BFBIN}" ]]
then
# No executable to test!
echo "No executable to run! Aborting..."
exit -1
else
if [[ ! -f "${SOCATCMD}" ]]
then
# No socat
echo "No socat cmd! Aborting..."
exit -1
fi
# All doing here
echo "Bforce executable found"
echo "Bforce executable found: ${BFBIN}"
RES=0
prepconfig "ZMO"
echo -n "--> Running ZMO test..."
testcomm
testcomm "PSTN"
prepconfig "ZAP"
echo -n "--> Running ZAP test..."
testcomm
testcomm "PSTN"
prepconfig "HYD"
echo -n "--> Running Hydra test..."
testcomm
testcomm "PSTN"
prepconfig "ZMO"
echo -n "--> Running ZMO test..."
testcomm "IFC"
prepconfig "ZAP"
echo -n "--> Running ZAP test..."
testcomm "IFC"
prepconfig "HYD"
echo -n "--> Running HYD test..."
testcomm "IFC"
prepconfig "ZMO"
echo -n "--> Running BINKP test..."
testcomm "BKP"
# TODO: make binkd test over netcat possibly
fi
rm -rf {etc,inboundA,inboundB,inbound-unsecureA,inbound-unsecureB,logsA,logsB,outboundA,outboundB}
# rm -rf ${CURDIR}/ftntest/{etc,inboundA,inboundB,inbound-unsecureA,inbound-unsecureB,logsA,logsB,outboundA,outboundB}
rm -rf ${CURDIR}/ftntest
# printf $RES
exit ${RES}

3
tests/runbfA.sh Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
BFCONFIG=${2} ${1} -C ${2} -o 99:1/2

2
tests/runbfB.sh Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
BFCONFIG=${2} ${1} -C ${2} -S"CONNECT 9600" -i auto

2
tests/runbfC.sh Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
BFCONFIG=${2} ${1} -C ${2} -a 127.0.0.1:59999 -u ifcico 99:1/2

2
tests/runbfD.sh Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
BFCONFIG=${2} ${1} -C ${2} -S"" -i auto

2
tests/runbfE.sh Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
BFCONFIG=${2} ${1} -C ${2} -a 127.0.0.1:59999 -u binkp 99:1/2

2
tests/runbfF.sh Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
BFCONFIG=${2} ${1} -C ${2} -i binkp