Merge pull request #1 from askovpen/master

crypt support
master
Sergey Dorofeev 10 years ago
commit d9cde2accc

263
debian/Makefile vendored

@ -1,263 +0,0 @@
# Makefile.in generated by automake 1.8.3 from Makefile.am.
# ../debian/Makefile. Generated from Makefile.in by configure.
# 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 = .
top_srcdir = ../..
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = /usr/bin/install -c
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 = i686-pc-linux-gnu
host_triplet = i686-pc-linux-gnu
target_triplet = i686-pc-linux-gnu
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 = gcc
CFLAGS = -g -O2
CPP = gcc -E
CPPFLAGS =
DEFS = -DHAVE_CONFIG_H
ECHO_C =
ECHO_N = -n
ECHO_T =
EGREP = /bin/grep -E
EXEEXT =
GROUP = sergey
INSTALL_DATA = ${INSTALL} -m 644
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = ${INSTALL}
LDFLAGS =
LIBOBJS =
LIBS = -lrt
LTLIBOBJS =
OBJEXT = o
OWNER = sergey
PACKAGE_BUGREPORT = sergey@fidoman.ru
PACKAGE_NAME = bforce
PACKAGE_STRING = bforce 0.24
PACKAGE_TARNAME = bforce
PACKAGE_VERSION = 0.24
PATH_SEPARATOR = :
SHELL = /bin/bash
YACC = byacc
ac_ct_CC = gcc
bindir = ${exec_prefix}/bin
build = i686-pc-linux-gnu
build_alias =
build_cpu = i686
build_os = linux-gnu
build_vendor = pc
datadir = ${prefix}/share
exec_prefix = ${prefix}
host = i686-pc-linux-gnu
host_alias =
host_cpu = i686
host_os = linux-gnu
host_vendor = pc
includedir = ${prefix}/include
infodir = ${prefix}/share/info
libdir = ${exec_prefix}/lib
libexecdir = ${exec_prefix}/libexec
localstatedir = ${prefix}/var
mandir = ${prefix}/share/man
oldincludedir = /usr/include
prefix = /home/sergey/bforce
program_transform_name = s,x,x,
sbindir = ${exec_prefix}/sbin
sharedstatedir = ${prefix}/com
sysconfdir = ${prefix}/etc
target = i686-pc-linux-gnu
target_alias =
target_cpu = i686
target_os = linux-gnu
target_vendor = pc
# $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:

@ -1,202 +0,0 @@
#
# Copyright (c) 1999-2000, Alexander Belkin <adb@newmail.ru>
#
# Copyright (c) 2004, Evgeniy Kozhuhovskiy <e.kozhuhovskiy@gmail.com>
#
# $Id$
#
prefix=/home/sergey/bforce
exec_prefix=${prefix}
CC = gcc
INCLUDES = -I./include
CFLAGS = -g -O2 -fno-builtin
LIBS = -lrt
YACC = byacc
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
SRCDIR = .
SRCDIRCONF = $(SRCDIR)/../examples
CONTRIBDIR = $(SRCDIR)/../contrib
OWNER = sergey
GROUP = sergey
CONFDIR = ${prefix}/etc
BINDIR = ${exec_prefix}/bin
LOGDIR = /var/log/bforce
SPOOLDIR = /var/spool/bforce
DAEMON_LOGFILE = $(LOGDIR)/bf-daemon
BFORCE_LOGFILE = $(LOGDIR)/bf-log
BFORCE_DEBFILE = $(LOGDIR)/bf-debug
BFORCE_DEBLEVEL = 0L
BFORCE_CFGFILE = $(CONFDIR)/bforce.conf
DEFINES = -DDAEMON_LOGFILE=\"$(DAEMON_LOGFILE)\" \
-DBFORCE_LOGFILE=\"$(BFORCE_LOGFILE)\" \
-DBFORCE_DEBFILE=\"$(BFORCE_DEBFILE)\" \
-DBFORCE_DEBLEVEL=$(BFORCE_DEBLEVEL) \
-DBFORCE_CFGFILE=\"$(BFORCE_CFGFILE)\" \
-DBF_OS=\"linux-gnu\" -DHAVE_CONFIG_H
SUBDIRS = bforce bfutil
BFINDEX_OBJS = bfutil/bfindex.o \
bforce/conf_deinit.o bforce/conf_proc.o \
bforce/conf_read.o bforce/conf_get.o \
bforce/logger.o bforce/nodelist.o \
bforce/u_file.o bforce/u_ftn.o \
bforce/u_misc.o bforce/u_string.o \
bforce/u_time.o
NLOOKUP_OBJS = bfutil/nlookup.o \
bforce/conf_deinit.o bforce/conf_proc.o \
bforce/conf_read.o bforce/conf_get.o \
bforce/logger.o bforce/nodelist.o \
bforce/u_file.o bforce/u_ftn.o \
bforce/u_misc.o bforce/u_string.o \
bforce/u_time.o
BFSTAT_OBJS = bfutil/bfstat.o \
bforce/conf_deinit.o bforce/conf_proc.o \
bforce/conf_read.o bforce/conf_get.o \
bforce/outb_flo.o bforce/outb_fsqueue.o \
bforce/sess_stat.o \
bforce/outb_getname.o bforce/outb_sysqueue.o \
bforce/outb_scan.o bforce/logger.o \
bforce/u_file.o \
bforce/u_ftn.o bforce/u_misc.o \
bforce/u_string.o bforce/u_time.o \
bforce/u_plock.o
BFORCE_OBJS = bforce/bforce.o \
bforce/daemon.o bforce/daemon_branch.o \
bforce/daemon_call.o bforce/daemon_lines.o \
bforce/conf_deinit.o \
bforce/conf_proc.o bforce/conf_read.o \
bforce/conf_get.o bforce/expression.o \
bforce/freq_bark.o bforce/freq_proc.o \
bforce/freq_srif.o bforce/freq_wazoo.o \
bforce/io_modem.o bforce/io_tcpip.o \
bforce/io_unix_lock.o bforce/io_unix_modem.o \
bforce/io_unix_tio.o bforce/io_unix_tty.o \
bforce/logger.o bforce/nodelist.o \
bforce/os_unix.o bforce/outb_bsy.o \
bforce/outb_flo.o bforce/outb_fsqueue.o \
bforce/outb_getname.o bforce/outb_sysqueue.o \
bforce/outb_scan.o bforce/prot_common.o \
bforce/prot_binkp.o bforce/prot_binkp_api.o \
bforce/prot_binkp_misc.o bforce/prot_hydra.o \
bforce/prot_xmrecv.o bforce/prot_xmsend.o \
bforce/prot_zmmisc.o bforce/prot_zmrecv.o \
bforce/prot_zmsend.o \
bforce/prot_yoohoo.o bforce/prot_yoohoo_api.o \
bforce/prot_emsi.o bforce/prot_emsi_misc.o \
bforce/prot_emsi_api.o \
bforce/sess_common.o bforce/sess_stat.o \
bforce/sess_call.o bforce/sess_answ.o \
bforce/sess_init.o bforce/sess_main.o \
bforce/u_crc.o bforce/u_ftn.o \
bforce/u_md5.o \
bforce/u_misc.o bforce/u_string.o \
bforce/u_time.o bforce/u_file.o \
bforce/u_pkt.o bforce/u_recode.o \
bforce/u_plock.o bforce/netspool.o
.c.o:
@echo Compiling $*.c
@$(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@
all: bin bin/bforce bin/bfindex bin/bfstat bin/nlookup
bin:
test -d bin || mkdir bin
bforce/expression.c: bforce/expression.y
$(YACC) bforce/expression.y
mv y.tab.c bforce/expression.c
bin/bforce: $(BFLIB_OBJS) $(BFORCE_OBJS)
@echo "Linking $@"
@$(CC) $(BFLIB_OBJS) $(BFORCE_OBJS) $(LIBS) -o $@
bin/bfindex: $(BFLIB_OBJS) $(BFINDEX_OBJS)
@echo "Linking $@"
@$(CC) $(BFLIB_OBJS) $(BFINDEX_OBJS) $(LIBS) -o $@
bin/nlookup: $(BFLIB_OBJS) $(NLOOKUP_OBJS)
@echo "Linking $@"
@$(CC) $(BFLIB_OBJS) $(NLOOKUP_OBJS) $(LIBS) -o $@
bin/bfstat: $(BFLIB_OBJS) $(BFSTAT_OBJS)
@echo "Linking $@"
@$(CC) $(BFLIB_OBJS) $(BFSTAT_OBJS) $(LIBS) -o $@
clean:
@for i in $(SUBDIRS); do (rm -f $$i/*.o || exit 1); done
rm -f ./bforce/expression.c
rm -f ./bin/bforce
rm -f ./bin/bfindex
rm -f ./bin/bfstat
rm -f ./bin/nlookup
rm -f ./bin/core
clean-am:
rm -f ./Makefile
rm -f ./include/config.h
rm -f ./config.log
rm -f ./config.status
clean-ac:
rm -f ./configure
distclean: clean clean-am
distclean-m: distclean clean-ac
ifnames:
@for i in $(SUBDIRS); do (ifnames $$i/*.c || exit 1); done
bforce/expression.y.o: bforce/expression.y.c bforce/expression.l.c
bforce/expression.l.o: bforce/expression.y.c bforce/expression.l.c
installdirs:
if [ ! -d $(CONFDIR) ]; then mkdir -p $(CONFDIR); fi
if [ ! -d $(BINDIR) ]; then mkdir -p $(BINDIR); fi
if [ ! -d $(LOGDIR) ]; then mkdir -p $(LOGDIR); fi
if [ ! -d $(SPOOLDIR) ]; then mkdir -p $(SPOOLDIR); fi
if [ ! -d $(SPOOLDIR)/bt/in ]; then mkdir -p $(SPOOLDIR)/bt/in; fi
if [ ! -d $(SPOOLDIR)/bt/pin ]; then mkdir -p $(SPOOLDIR)/bt/pin; fi
if [ ! -d $(SPOOLDIR)/bt/out ]; then mkdir -p $(SPOOLDIR)/bt/out; fi
if [ ! -d $(SPOOLDIR)/ndl ]; then mkdir -p $(SPOOLDIR)/ndl; fi
if [ ! -d $(SPOOLDIR)/bforce ]; then mkdir -p $(SPOOLDIR); fi
chown $(OWNER):$(GROUP) $(CONFDIR)
chown $(OWNER):$(GROUP) $(LOGDIR)
chown $(OWNER):$(GROUP) $(SPOOLDIR)/bt/in
chown $(OWNER):$(GROUP) $(SPOOLDIR)/bt/pin
chown $(OWNER):$(GROUP) $(SPOOLDIR)/bt/out
chown $(OWNER):$(GROUP) $(SPOOLDIR)/ndl
chown $(OWNER):$(GROUP) $(SPOOLDIR)
install-bin:
$(INSTALL_PROGRAM) -o $(OWNER) -g $(GROUP) $(SRCDIR)/bin/bforce $(BINDIR)/bforce
$(INSTALL_PROGRAM) -o $(OWNER) -g $(GROUP) $(SRCDIR)/bin/bfindex $(BINDIR)/bfindex
$(INSTALL_PROGRAM) -o $(OWNER) -g $(GROUP) $(SRCDIR)/bin/bfstat $(BINDIR)/bfstat
$(INSTALL_PROGRAM) -o $(OWNER) -g $(GROUP) $(SRCDIR)/bin/nlookup $(BINDIR)/nlookup
install-config:
$(INSTALL_DATA) -o $(OWNER) -g $(GROUP) $(SRCDIRCONF)/bforce.conf $(CONFDIR)/bforce.conf.sample
$(INSTALL_DATA) -o $(OWNER) -g $(GROUP) $(SRCDIRCONF)/bforce.subst $(CONFDIR)/bforce.subst.sample
$(INSTALL_DATA) -o $(OWNER) -g $(GROUP) $(SRCDIRCONF)/bforce.passwd $(CONFDIR)/bforce.passwd.sample
$(INSTALL_DATA) -o $(OWNER) -g $(GROUP) $(SRCDIRCONF)/freq.aliases $(CONFDIR)/freq.aliases.sample
$(INSTALL_DATA) -o $(OWNER) -g $(GROUP) $(SRCDIRCONF)/freq.dirs $(CONFDIR)/freq.dirs.sample
install-contrib:
$(INSTALL_PROGRAM) -o $(OWNER) -g $(GROUP) $(CONTRIBDIR)/outman $(BINDIR)/outman
@echo "Please, edit $(BINDIR)/outman"
install: install-bin install-config

@ -103,7 +103,8 @@ BFORCE_OBJS = bforce/bforce.o \
bforce/u_misc.o bforce/u_string.o \
bforce/u_time.o bforce/u_file.o \
bforce/u_pkt.o bforce/u_recode.o \
bforce/u_plock.o bforce/netspool.o
bforce/u_plock.o bforce/netspool.o \
bforce/prot_binkp_crypt.o
.c.o:
@echo Compiling $*.c

@ -1,976 +0,0 @@
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#endif
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define YYPATCH 20120115
#define YYEMPTY (-1)
#define yyclearin (yychar = YYEMPTY)
#define yyerrok (yyerrflag = 0)
#define YYRECOVERING() (yyerrflag != 0)
#define YYPREFIX "yy"
#define YYPURE 0
#line 49 "bforce/expression.y"
#include "includes.h"
#include "confread.h"
#include "util.h"
#include "logger.h"
#include "session.h"
#include "nodelist.h"
#include "io.h"
static struct tm *now = NULL;
static int expr_result = 0;
static char *expr_p_pos = NULL;
static char *expr_p_text = NULL;
/*
* These are expression element checkers (not only)
* Return values:
* 0 - FALSE
* 1 - TRUE
* -1 - cannot check, because some data is not available yet
* -2 - invalid element (we should not check this expression more)
*/
static int expr_check_incoming(void);
static int expr_check_outgoing(void);
static int expr_check_protected(void);
static int expr_check_listed(void);
static int expr_check_logic(int e1, int op, int e2);
static int expr_check_phone(const char *phone);
static int expr_check_arop(int num1, int op, int num2);
static int expr_check_flag(const char *str);
static int expr_check_exec(const char *str);
static int expr_check_exist(const char *str);
static int expr_check_port(const char *str);
static int expr_check_mailer(const char *str);
static int expr_check_addr(const char *str);
static int expr_check_time(const char *str);
static int yylex(void);
static int yyparse(void);
static int yyerror(const char *s);
#line 60 "y.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
#endif
/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
# ifdef YYPARSE_PARAM_TYPE
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
# else
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
# define YYPARSE_DECL() yyparse(void)
#endif
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
# define YYLEX yylex(YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(void)
# define YYLEX yylex()
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
#define COMMA 257
#define TEXT 258
#define NUMBER 259
#define INCOMING 260
#define OUTGOING 261
#define LISTED 262
#define PROTECTED 263
#define CONNSPEED 264
#define EXEC 265
#define EXIST 266
#define PORT 267
#define MAILER 268
#define TZ 269
#define FLAG 270
#define SPEED 271
#define PHONE 272
#define TIME 273
#define ADDRESS 274
#define EQ 275
#define NE 276
#define GT 277
#define GE 278
#define LT 279
#define LE 280
#define AND 281
#define OR 282
#define NOT 283
#define XOR 284
#define OPENB 285
#define CLOSEB 286
#define AROP 287
#define LOGOP 288
#define YYERRCODE 256
static const short yylhs[] = { -1,
0, 1, 1, 1, 1, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 4, 4,
};
static const short yylen[] = { 2,
1, 1, 2, 3, 3, 1, 1, 1, 1, 2,
3, 3, 3, 2, 2, 2, 2, 2, 2, 1,
1, 3, 1, 3,
};
static const short yydefred[] = { 0,
20, 6, 7, 8, 9, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
0, 16, 17, 18, 19, 0, 0, 10, 0, 14,
0, 15, 0, 0, 0, 11, 13, 0, 12, 0,
5, 0, 22, 24,
};
static const short yydgoto[] = { 18,
19, 20, 28, 32,
};
static const short yysindex[] = { -251,
0, 0, 0, 0, 0, -287, -255, -254, -250, -232,
-259, -229, -257, -227, -225, -251, -251, 0, -253, 0,
-223, 0, 0, 0, 0, -222, -219, 0, -220, 0,
-217, 0, -253, -261, -251, 0, 0, -229, 0, -225,
0, -253, 0, 0,
};
static const short yyrindex[] = { 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 41, 0,
0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
2, 0, 5, 0, 0, 0, 0, 0, 0, 0,
0, 6, 0, 0,
};
static const short yygindex[] = { 0,
7, 0, 8, 3,
};
#define YYTABLESIZE 292
static const short yytable[] = { 21,
21, 23, 22, 23, 3, 4, 1, 24, 2, 3,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 33, 34, 41, 25, 35, 26, 27, 29,
30, 16, 31, 17, 35, 36, 37, 38, 39, 40,
1, 42, 44, 0, 0, 43, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 21, 23, 21, 23,
3, 4,
};
static const short yycheck[] = { 287,
0, 0, 258, 258, 0, 0, 258, 258, 260, 261,
262, 263, 264, 265, 266, 267, 268, 269, 270, 271,
272, 273, 16, 17, 286, 258, 288, 287, 258, 287,
258, 283, 258, 285, 288, 259, 259, 257, 259, 257,
0, 35, 40, -1, -1, 38, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 286, 286, 288, 288,
286, 286,
};
#define YYFINAL 18
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 288
#if YYDEBUG
static const char *yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"COMMA","TEXT","NUMBER",
"INCOMING","OUTGOING","LISTED","PROTECTED","CONNSPEED","EXEC","EXIST","PORT",
"MAILER","TZ","FLAG","SPEED","PHONE","TIME","ADDRESS","EQ","NE","GT","GE","LT",
"LE","AND","OR","NOT","XOR","OPENB","CLOSEB","AROP","LOGOP",
};
static const char *yyrule[] = {
"$accept : fullline",
"fullline : expression",
"expression : elemexp",
"expression : NOT expression",
"expression : expression LOGOP expression",
"expression : OPENB expression CLOSEB",
"elemexp : INCOMING",
"elemexp : OUTGOING",
"elemexp : LISTED",
"elemexp : PROTECTED",
"elemexp : FLAG flagstring",
"elemexp : CONNSPEED AROP NUMBER",
"elemexp : SPEED AROP NUMBER",
"elemexp : TZ AROP NUMBER",
"elemexp : PHONE TEXT",
"elemexp : TIME timestring",
"elemexp : EXEC TEXT",
"elemexp : EXIST TEXT",
"elemexp : PORT TEXT",
"elemexp : MAILER TEXT",
"elemexp : TEXT",
"flagstring : TEXT",
"flagstring : TEXT COMMA flagstring",
"timestring : TEXT",
"timestring : TEXT COMMA timestring",
};
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
#define YYINITSTACKSIZE 500
typedef struct {
unsigned stacksize;
short *s_base;
short *s_mark;
short *s_last;
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 211 "bforce/expression.y"
#include "expression_lex.c"
static int expr_check_incoming(void)
{
if( !state.valid )
return -1;
return state.caller ? 0 : 1;
}
static int expr_check_outgoing(void)
{
if( !state.valid )
return -1;
return state.caller ? 1 : 0;
}
static int expr_check_protected(void)
{
if( !state.valid || !state.node.addr.zone )
return -1;
return state.protected ? 1 : 0;
}
static int expr_check_listed(void)
{
if( !state.valid || !state.node.addr.zone )
return -1;
return state.node.listed ? 1 : 0;
}
static int expr_check_logic(int e1, int op, int e2)
{
DEB((D_EVENT, "[yacc] logic: %d %d %d", e1, op, e2));
if( e1 < 0 ) e1 = 0;
if( e2 < 0 ) e2 = 0;
switch(op) {
case AND:
return (e1 && e2);
case OR:
return (e1 || e2);
case XOR:
return (e1 ^ e2);
}
log("invalid logical operator in expression");
return 0;
}
static int expr_check_phone(const char *phone)
{
DEB((D_EVENT, "[yacc] phone: is %s in %s",
phone, state.node.phone));
if( !state.valid )
return 0;
return strstr(state.node.phone, phone) ? 1 : 0;
}
static int expr_check_arop(int num1, int op, int num2)
{
DEB((D_EVENT, "[yacc] arop: %d %d %d", num1, op, num2));
switch(op) {
case EQ: return (num1 == num2);
case NE: return (num1 != num2);
case GT: return (num1 > num2);
case GE: return (num1 >= num2);
case LT: return (num1 < num2);
case LE: return (num1 <= num2);
}
log("invalid arithmetic operator in expression");
return 0;
}
static int expr_check_flag(const char *str)
{
DEB((D_EVENT, "[yacc] flag: \"%s\"", str));
if( !state.valid )
return 0;
return !nodelist_checkflag(state.node.flags, str);
}
static int expr_check_exec(const char *str)
{
DEB((D_EVENT, "[yacc] exec: \"%s\"", str));
return session_run_command(str) ? 0 : 1;
}
static int expr_check_exist(const char *str)
{
DEB((D_EVENT, "[yacc] exist: \"%s\"", str));
return access(str, F_OK) ? 1 : 0;
}
static int expr_check_port(const char *str)
{
DEB((D_EVENT, "[yacc] port: \"%s\"", str));
if( !state.valid )
return -1;
if( !strcasecmp(str, "tcpip") )
{
return state.inet ? 1 : 0;
}
else if( state.modemport && state.modemport->name )
{
return strstr(state.modemport->name, str) ? 1 : 0;
}
else if( isatty(0) )
{
return strstr(ttyname(0), str) ? 1 : 0;
}
return -1;
}
static int expr_check_mailer(const char *str)
{
char *p;
DEB((D_EVENT, "[yacc] mailer: \"%s\"", str));
if( !state.valid )
return -1;
if( state.handshake && state.handshake->remote_mailer )
p = state.handshake->remote_mailer(state.handshake);
else
return -1;
return (p && string_casestr(p, str)) ? 1 : 0;
}
static int expr_check_addr(const char *str)
{
s_faddr addr;
#ifdef DEBUG
char abuf1[BF_MAXADDRSTR+1];
char abuf2[BF_MAXADDRSTR+1];
DEB((D_EVENT, "[yacc] addr: \"%s\" (session with \"%s\")",
ftn_addrstr(abuf1, addr),
ftn_addrstr(abuf2, state.node.addr)));
#endif
if( !state.valid )
return -1;
if( ftn_addrparse(&addr, str, TRUE) )
{
log("invalid address \"%s\"", str);
return -2;
}
return !ftn_addrcomp_mask(state.node.addr, addr);
}
static int expr_check_time(const char *str)
{
DEB((D_EVENT, "[yacc] time: \"%s\"", str));
switch( time_check(str, now) ) {
case -1:
log("invalid time string \"%s\"", str);
return -2;
case 0:
return 1;
}
return 0;
}
bool eventexpr(s_expr *expr)
{
time_t tt;
char *tmp;
if( !expr || !expr->expr )
return 1;
if( expr->error )
return 0;
DEB((D_EVENT, "eventexpr: [yacc] check expression \"%s\"",
expr->expr));
tt = time(NULL);
now = localtime(&tt);
tmp = (char*)xstrcpy(expr->expr);
expr_p_pos = tmp;
expr_result = 0;
if( yyparse() )
{
expr->error = TRUE;
log("cannot parse expression \"%s\"", expr->expr);
DEB((D_EVENT, "eventexpr: [yacc] $yyparse return error"));
expr_result = 0;
}
free(tmp);
DEB((D_EVENT, "eventexpr: [yacc] checking result is \"%s\" (%d)",
(expr_result == 1) ? "TRUE" : "FALSE", expr_result));
return (expr_result == 1) ? TRUE : FALSE;
}
static int yyerror(const char *str)
{
log("expression check failure: %s", str);
return 0;
}
#line 548 "y.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
#endif
#include <stdlib.h> /* needed for malloc, etc */
#include <string.h> /* needed for memset */
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(YYSTACKDATA *data)
{
int i;
unsigned newsize;
short *newss;
YYSTYPE *newvs;
if ((newsize = data->stacksize) == 0)
newsize = YYINITSTACKSIZE;
else if (newsize >= YYMAXDEPTH)
return -1;
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = data->s_mark - data->s_base;
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
data->s_base = newss;
data->s_mark = newss + i;
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
if (newvs == 0)
return -1;
data->l_base = newvs;
data->l_mark = newvs + i;
data->stacksize = newsize;
data->s_last = data->s_base + newsize - 1;
return 0;
}
#if YYPURE || defined(YY_NO_LEAKS)
static void yyfreestack(YYSTACKDATA *data)
{
free(data->s_base);
free(data->l_base);
memset(data, 0, sizeof(*data));
}
#else
#define yyfreestack(data) /* nothing */
#endif
#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
YYPARSE_DECL()
{
int yym, yyn, yystate;
#if YYDEBUG
const char *yys;
if ((yys = getenv("YYDEBUG")) != 0)
{
yyn = *yys;
if (yyn >= '0' && yyn <= '9')
yydebug = yyn - '0';
}
#endif
yynerrs = 0;
yyerrflag = 0;
yychar = YYEMPTY;
yystate = 0;
#if YYPURE
memset(&yystack, 0, sizeof(yystack));
#endif
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
yystack.s_mark = yystack.s_base;
yystack.l_mark = yystack.l_base;
yystate = 0;
*yystack.s_mark = 0;
yyloop:
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
}
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
yychar = YYEMPTY;
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
yyn = yytable[yyn];
goto yyreduce;
}
if (yyerrflag) goto yyinrecovery;
yyerror("syntax error");
goto yyerrlab;
yyerrlab:
++yynerrs;
yyinrecovery:
if (yyerrflag < 3)
{
yyerrflag = 3;
for (;;)
{
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, error recovery shifting\
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
goto yyloop;
}
else
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: error recovery discarding state %d\n",
YYPREFIX, *yystack.s_mark);
#endif
if (yystack.s_mark <= yystack.s_base) goto yyabort;
--yystack.s_mark;
--yystack.l_mark;
}
}
}
else
{
if (yychar == 0) goto yyabort;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
yychar = YYEMPTY;
goto yyloop;
}
yyreduce:
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
if (yym)
yyval = yystack.l_mark[1-yym];
else
memset(&yyval, 0, sizeof yyval);
switch (yyn)
{
case 1:
#line 93 "bforce/expression.y"
{
DEB((D_EVENT, "[yacc] expression return %d", yystack.l_mark[0]));
expr_result = yystack.l_mark[0];
}
break;
case 2:
#line 99 "bforce/expression.y"
{
DEB((D_EVENT, "[yacc] elemexp return %d", yystack.l_mark[0]));
yyval = yystack.l_mark[0];
}
break;
case 3:
#line 104 "bforce/expression.y"
{
DEB((D_EVENT, "[yacc] not exprression %d", yystack.l_mark[0]));
if( (yystack.l_mark[0]) < 0 )
yyval = 0;
else
yyval = !(yystack.l_mark[0]);
}
break;
case 4:
#line 112 "bforce/expression.y"
{
yyval = expr_check_logic(yystack.l_mark[-2], yystack.l_mark[-1], yystack.l_mark[0]);
}
break;
case 5:
#line 116 "bforce/expression.y"
{
DEB((D_EVENT, "eventexp: [yacc] backeted.expr %d", yystack.l_mark[-1]));
yyval = yystack.l_mark[-1];
}
break;
case 6:
#line 122 "bforce/expression.y"
{
yyval = expr_check_incoming();
}
break;
case 7:
#line 126 "bforce/expression.y"
{
yyval = expr_check_outgoing();
}
break;
case 8:
#line 130 "bforce/expression.y"
{
yyval = expr_check_listed();
}
break;
case 9:
#line 134 "bforce/expression.y"
{
yyval = expr_check_protected();
}
break;
case 10:
#line 138 "bforce/expression.y"
{
yyval = yystack.l_mark[0];
}
break;
case 11:
#line 142 "bforce/expression.y"
{
if( state.valid && state.connspeed > 0 )
yyval = expr_check_arop(state.connspeed, yystack.l_mark[-1], yystack.l_mark[0]);
else
yyval = -1;
}
break;
case 12:
#line 149 "bforce/expression.y"
{
if( state.valid && state.node.speed > 0 )
yyval = expr_check_arop(state.node.speed, yystack.l_mark[-1], yystack.l_mark[0]);
else
yyval = -1;
}
break;
case 13:
#line 156 "bforce/expression.y"
{
yyval = expr_check_arop(time_gmtoffset(), yystack.l_mark[-1], yystack.l_mark[0]);
}
break;
case 14:
#line 160 "bforce/expression.y"
{
yyval = expr_check_phone(expr_p_text);
}
break;
case 15:
#line 164 "bforce/expression.y"
{
yyval = yystack.l_mark[0];
}
break;
case 16:
#line 168 "bforce/expression.y"
{
yyval = expr_check_exec(expr_p_text);
}
break;
case 17:
#line 172 "bforce/expression.y"
{
yyval = expr_check_exist(expr_p_text);
}
break;
case 18:
#line 176 "bforce/expression.y"
{
yyval = expr_check_port(expr_p_text);
}
break;
case 19:
#line 180 "bforce/expression.y"
{
yyval = expr_check_mailer(expr_p_text);
}
break;
case 20:
#line 184 "bforce/expression.y"
{
yyval = expr_check_addr(expr_p_text);
if( yyval == -2 )
YYABORT;
}
break;
case 21:
#line 191 "bforce/expression.y"
{
yyval = expr_check_flag(expr_p_text);
}
break;
case 22:
#line 195 "bforce/expression.y"
{
yyval = expr_check_logic(yystack.l_mark[-2], OR, yystack.l_mark[0]);
}
break;
case 23:
#line 200 "bforce/expression.y"
{
yyval = expr_check_time(expr_p_text);
if( yyval == -2 )
YYABORT;
}
break;
case 24:
#line 206 "bforce/expression.y"
{
yyval = expr_check_logic(yystack.l_mark[-2], OR, yystack.l_mark[0]);
}
break;
#line 915 "y.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
yystack.l_mark -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state 0 to\
state %d\n", YYPREFIX, YYFINAL);
#endif
yystate = YYFINAL;
*++yystack.s_mark = YYFINAL;
*++yystack.l_mark = yyval;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, YYFINAL, yychar, yys);
}
#endif
}
if (yychar == 0) goto yyaccept;
goto yyloop;
}
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
*++yystack.s_mark = (short) yystate;
*++yystack.l_mark = yyval;
goto yyloop;
yyoverflow:
yyerror("yacc stack overflow");
yyabort:
yyfreestack(&yystack);
return (1);
yyaccept:
yyfreestack(&yystack);
return (0);
}

@ -137,6 +137,8 @@ int binkp_loop(s_binkp_state *bstate) {
return PRC_ERROR;
}
writebuf[1] = block_length&0xff;
if (bstate->mode==bmode_transfer && bstate->remote_data->options&BINKP_OPT_CRYPT)
encrypt_buf(writebuf, have_to_write, bstate->remote_data->keys_out);
}
if (m==2 || m==3) {
DEB((D_24554, "no more to send"));
@ -204,6 +206,8 @@ int binkp_loop(s_binkp_state *bstate) {
log("read: remote socket shutdown");
return PRC_REMOTEABORTED;
}
if (bstate->mode==bmode_transfer && bstate->remote_data->options & BINKP_OPT_CRYPT)
decrypt_buf(readbuf+read_pos, n, bstate->remote_data->keys_in);
DEB((D_24554, "got %d bytes", n));
want_read -= n;
read_pos += n;
@ -266,6 +270,11 @@ int binkp_loop(s_binkp_state *bstate) {
int binkp_outgoing(s_binkp_sysinfo *local_data, s_binkp_sysinfo *remote_data)
{
char *p;
init_keys(remote_data->keys_out, local_data->passwd ? local_data->passwd : "-");
init_keys(remote_data->keys_in, "-");
for (p=local_data->passwd ? local_data->passwd : "-"; *p; p++)
update_keys(remote_data->keys_in, (int)*p);
s_binkp_state s;
s.mode = bmode_outgoing_handshake;
s.local_data = local_data;
@ -399,7 +408,7 @@ case 6:
case 7:
if (bstate->mode==bmode_outgoing_handshake) {
buf[0]=BPMSG_NUL;
strcpy(buf+1, "OPT MB");
strcpy(buf+1, "OPT MB CRYPT");
if (!nodelist_checkflag (state.node.flags, "NR"))
strcat(buf+1, " NR");
// ND is too complicated and have unclear gain
@ -506,6 +515,15 @@ case 4:
if (bstate->mode==bmode_incoming_handshake) {
DEB((D_24554, "incoming handshake is complete"));
bstate->complete = true;
char *p;
char pbuf[32];
for (i=0;i<state.n_remoteaddr;i++)
if( !session_get_password(state.remoteaddrs[i].addr, pbuf, sizeof(pbuf)) ){
init_keys(bstate->remote_data->keys_in, pbuf?pbuf:"-");
init_keys(bstate->remote_data->keys_out, "-");
for (p=pbuf?pbuf:"-"; *p; p++)
update_keys(bstate->remote_data->keys_out, (int)*p);
}
}
else {
DEB((D_24554, "outgoing handshake: everything is sent"));

@ -0,0 +1,148 @@
/*
* crypt.c -- crypt binkp traffic
*
* crypt.c is a part of binkd project
*
* Copyright (c) 1990-2000 Info-ZIP.
* Copyright (C) 2001 Pavel Gulchouck <gul@gul.kiev.ua> 2:463/68
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. See COPYING.
*
* This encryption code is a direct transcription of the algorithm from
* Roger Schlafly.
*/
/*
* $Id: crypt.c,v 2.4 2005/10/10 15:44:24 stas Exp $
*
* $Log: crypt.c,v $
* Revision 2.4 2005/10/10 15:44:24 stas
* Move CRC32's define into crypt.h
*
* Revision 2.3 2001/02/21 06:25:21 gul
* changed crlf to cr in the source file
*
* Revision 2.2 2001/02/20 12:01:50 gul
* rename encrypt to encrypt_buf to avoid conflict with unistd.h
*
* Revision 2.1 2001/02/15 16:05:59 gul
* crypt bugfix
*
* Revision 2.0 2001/02/15 11:02:16 gul
* Added crypt traffic possibility
*
*
*/
#include "includes.h"
#include "session.h"
#include "prot_common.h"
#include "prot_binkp.h"
unsigned long crc_32_tab[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
0x2d02ef8dL
};
int update_keys (unsigned long keys[3], int c)
{
int keyshift;
keys[0] = CRC32(keys[0], c);
keys[1] += keys[0] & 0xff;
keys[1] = keys[1] * 134775813L + 1;
keyshift = (int)(keys[1] >> 24);
keys[2] = CRC32(keys[2], keyshift);
return c;
}
void init_keys (unsigned long keys[3], const char *passwd)
{
keys[0] = 305419896L;
keys[1] = 591751049L;
keys[2] = 878082192L;
while (*passwd)
{
update_keys(keys, (int)*passwd);
passwd++;
}
}
int decrypt_byte (unsigned long keys[3])
{
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */
temp = ((unsigned)keys[2] & 0xffff) | 2;
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
}
void decrypt_buf (char *buf, unsigned int bufsize, unsigned long keys[3])
{
while (bufsize--)
update_keys(keys, *buf++ ^= decrypt_byte(keys));
}
void encrypt_buf (char *buf, unsigned int bufsize, unsigned long keys[3])
{
int t;
while (bufsize--)
{
t=decrypt_byte(keys);
update_keys(keys, *buf);
*buf++ ^= t;
}
}

@ -140,6 +140,7 @@ void binkp_log_options(s_binkp_sysinfo *remote)
{
if (remote->options & BINKP_OPT_MB) log ("We are in MB mode.");
if (remote->options & BINKP_OPT_NR) log ("We are in NR mode.");
if (remote->options & BINKP_OPT_CRYPT) log ("We are in CRYPT mode.");
}
/*****************************************************************************
@ -310,6 +311,9 @@ void binkp_parse_options(s_binkp_sysinfo *binkp, char *options)
if( !strcmp(p, "NR") ) {
binkp->options |= BINKP_OPT_NR;
} else
if( !strcmp(p, "CRYPT") ) {
binkp->options |= BINKP_OPT_CRYPT;
} else
if( !strcmp(p, "MB") )
binkp->options |= BINKP_OPT_MB;
else if( !strcmp(p, "MPWD") )

@ -1,154 +0,0 @@
/* include/config.h. Generated from config.h.in by configure. */
/* include/config.h.in. Generated automatically from configure.in by autoheader. */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define if the `getpgrp' function takes no argument. */
#define GETPGRP_VOID 1
/* Define if you don't have vprintf but do have _doprnt. */
/* #undef HAVE_DOPRNT */
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#define HAVE_SYS_WAIT_H 1
/* Define if you have the vprintf function. */
#define HAVE_VPRINTF 1
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef mode_t */
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef pid_t */
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define if the setvbuf function takes the buffering type as its second
argument and the buffer pointer as the third, as on System V
before release 3. */
/* #undef SETVBUF_REVERSED */
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/* #undef size_t */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define if your <sys/time.h> declares struct tm. */
/* #undef TM_IN_SYS_TIME */
/* Do you want debug code to be compiled? */
#define DEBUG 1
/* Do you want use DCD line control? */
#define MODEM_WATCH_CARRIER 1
/* Do you want hangup to watch for modem DCD line? */
#define MODEM_HANGUP_WATCH_CARRIER 1
/* Version string */
#define RELEASE_VERSION "0.23"
/* Disable passwords logging? */
#define BFORCE_LOG_PASSWD 1
/* Path to the UUCP lock files directory */
#define BFORCE_LOCK_DIR "/var/lock/"
/* Do you want to use syslog? */
#define USE_SYSLOG 1
/* Netspool */
#define NETSPOOL 1
/* Do you want use .csy locks? */
#define BFORCE_USE_CSY 1
/* Define if you have the mkdir function. */
#define HAVE_MKDIR 1
/* Define if you have the mktime function. */
#define HAVE_MKTIME 1
/* Define if you have the rename function. */
#define HAVE_RENAME 1
/* Define if you have the select function. */
#define HAVE_SELECT 1
/* Define if you have the setproctitle function. */
/* #undef HAVE_SETPROCTITLE */
/* Define if you have the socket function. */
#define HAVE_SOCKET 1
/* Define if you have the statfs function. */
#define HAVE_STATFS 1
/* Define if you have the statvfs function. */
#define HAVE_STATVFS 1
/* Define if you have the strcasecmp function. */
#define HAVE_STRCASECMP 1
/* Define if you have the strspn function. */
#define HAVE_STRSPN 1
/* Define if you have the <dirent.h> header file. */
#define HAVE_DIRENT_H 1
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the <ndir.h> header file. */
/* #undef HAVE_NDIR_H */
/* Define if you have the <sys/dir.h> header file. */
/* #undef HAVE_SYS_DIR_H */
/* Define if you have the <sys/file.h> header file. */
#define HAVE_SYS_FILE_H 1
/* Define if you have the <sys/ioctl.h> header file. */
#define HAVE_SYS_IOCTL_H 1
/* Define if you have the <sys/mount.h> header file. */
#define HAVE_SYS_MOUNT_H 1
/* Define if you have the <sys/ndir.h> header file. */
/* #undef HAVE_SYS_NDIR_H */
/* Define if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H 1
/* Define if you have the <sys/select.h> header file. */
#define HAVE_SYS_SELECT_H 1
/* Define if you have the <sys/statfs.h> header file. */
#define HAVE_SYS_STATFS_H 1
/* Define if you have the <sys/statvfs.h> header file. */
#define HAVE_SYS_STATVFS_H 1
/* Define if you have the <sys/termiox.h> header file. */
/* #undef HAVE_SYS_TERMIOX_H */
/* Define if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define if you have the <sys/vfs.h> header file. */
#define HAVE_SYS_VFS_H 1
/* Define if you have the <termios.h> header file. */
#define HAVE_TERMIOS_H 1
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define if you want buggy emsi :) */
#define BUGGY_EMSI 0

@ -53,6 +53,7 @@
#define BINKP_OPT_MD5 0x08 /* CRAM-MD5 authentication */
#define BINKP_OPT_SHA1 0x10 /* CRAM-SHA1 authentication */
#define BINKP_OPT_DES 0x20 /* CRAM-DES authentication */
#define BINKP_OPT_CRYPT 0x40 /* CRYPT support */
typedef enum binkp_mode {
bmode_failoff,
@ -85,6 +86,8 @@ typedef struct {
bool has_TRF;
int TRF_PKT;
int TRF_other;
unsigned long keys_out[3]; /* Encription keys for outbound */
unsigned long keys_in[3]; /* Encription keys for inbound */
} s_binkp_sysinfo;
@ -180,5 +183,13 @@ int binkp_remote_traffic(s_handshake_protocol *THIS, s_traffic *dest);
/* prot_binkp_api.c */
extern s_handshake_protocol handshake_protocol_binkp;
#define CRC32(c, b) (crc_32_tab[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8))
extern unsigned long crc_32_tab[256];
int update_keys (unsigned long keys[3], int c);
void init_keys (unsigned long keys[3], const char *passwd);
int decrypt_byte (unsigned long keys[3]);
void decrypt_buf (char *buf, unsigned int bufsize, unsigned long keys[3]);
void encrypt_buf (char *buf, unsigned int bufsize, unsigned long keys[3]);
#endif /* _P_BINKP_H_ */

Loading…
Cancel
Save