Compare commits
No commits in common. "master" and "bip08" have entirely different histories.
|
@ -1,22 +0,0 @@
|
|||
---
|
||||
BasedOnStyle: LLVM
|
||||
Language: Cpp
|
||||
IndentWidth: 8
|
||||
UseTab: Always
|
||||
BreakBeforeBraces: Linux
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: false
|
||||
IndentCaseLabels: false
|
||||
AlignEscapedNewlinesLeft: false
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AlignAfterOpenBracket: true
|
||||
SpaceAfterCStyleCast: false
|
||||
MaxEmptyLinesToKeep: 2
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakStringLiterals: false
|
||||
SortIncludes: false
|
||||
ContinuationIndentWidth: 8
|
||||
ColumnLimit: 80
|
|
@ -1,63 +0,0 @@
|
|||
# http://www.gnu.org/software/automake
|
||||
|
||||
Makefile.in
|
||||
/ar-lib
|
||||
/mdate-sh
|
||||
/py-compile
|
||||
/test-driver
|
||||
/ylwrap
|
||||
|
||||
# http://www.gnu.org/software/autoconf
|
||||
|
||||
autom4te.cache
|
||||
/autoscan.log
|
||||
/autoscan-*.log
|
||||
/aclocal.m4
|
||||
/compile
|
||||
/config.guess
|
||||
/config.h.in
|
||||
/config.log
|
||||
/config.status
|
||||
/config.sub
|
||||
/configure
|
||||
/configure.scan
|
||||
/depcomp
|
||||
/install-sh
|
||||
/missing
|
||||
/stamp-h1
|
||||
|
||||
# https://www.gnu.org/software/libtool/
|
||||
|
||||
/ltmain.sh
|
||||
|
||||
# http://www.gnu.org/software/texinfo
|
||||
|
||||
/texinfo.tex
|
||||
|
||||
# http://www.gnu.org/software/m4/
|
||||
|
||||
m4/libtool.m4
|
||||
m4/ltoptions.m4
|
||||
m4/ltsugar.m4
|
||||
m4/ltversion.m4
|
||||
m4/lt~obsolete.m4
|
||||
|
||||
# Makefiles
|
||||
Makefile
|
||||
src/.deps/
|
||||
src/Makefile
|
||||
tests/.deps/
|
||||
tests/Makefile
|
||||
|
||||
# Generated code
|
||||
src/conf.c
|
||||
src/conf.h
|
||||
src/config.h
|
||||
src/config.h.in
|
||||
src/lex.c
|
||||
|
||||
# Binaries
|
||||
src/*.o
|
||||
src/*.a
|
||||
src/bip
|
||||
src/bipmkpw
|
1
AUTHORS
1
AUTHORS
|
@ -10,4 +10,3 @@ Thanks to our marketting and management team:
|
|||
ack|, ato, blackmore, lafouine, Gaston & gromit
|
||||
|
||||
Crypto shamelessly stolen from Christophe 'sexy' Devine.
|
||||
Credits to Jouni Malinen for base64 library (http://web.mit.edu/freebsd/head/contrib/wpa/src/utils/)
|
||||
|
|
406
INSTALL
406
INSTALL
|
@ -1,370 +1,182 @@
|
|||
Installation Instructions
|
||||
*************************
|
||||
|
||||
Copyright (C) 1994-1996, 1999-2002, 2004-2012 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved. This file is offered as-is,
|
||||
without warranty of any kind.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
Briefly, the shell commands './configure; make; make install' should
|
||||
configure, build, and install this package. The following
|
||||
more-detailed instructions are generic; see the 'README' file for
|
||||
instructions specific to this package. Some packages provide this
|
||||
'INSTALL' file but do not implement all of the features documented
|
||||
below. The lack of an optional feature in a given package is not
|
||||
necessarily a bug. More recommendations for GNU packages can be found
|
||||
in *note Makefile Conventions: (standards)Makefile Conventions.
|
||||
These are generic installation instructions.
|
||||
|
||||
The 'configure' shell script attempts to guess correct values for
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a 'Makefile' in each directory of the package.
|
||||
It may also create one or more '.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script 'config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file 'config.log' containing compiler output (useful mainly for
|
||||
debugging 'configure').
|
||||
|
||||
It can also use an optional file (typically called 'config.cache'
|
||||
and enabled with '--cache-file=config.cache' or simply '-C') that saves
|
||||
the results of its tests to speed up reconfiguring. Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, a file
|
||||
`config.cache' that saves the results of its tests to speed up
|
||||
reconfiguring, and a file `config.log' containing compiler output
|
||||
(useful mainly for debugging `configure').
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how 'configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the 'README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point 'config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If at some point `config.cache'
|
||||
contains results you don't want to keep, you may remove or edit it.
|
||||
|
||||
The file 'configure.ac' (or 'configure.in') is used to create
|
||||
'configure' by a program called 'autoconf'. You need 'configure.ac' if
|
||||
you want to change it or regenerate 'configure' using a newer version
|
||||
of 'autoconf'.
|
||||
The file `configure.in' is used to create `configure' by a program
|
||||
called `autoconf'. You only need `configure.in' if you want to change
|
||||
it or regenerate `configure' using a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. 'cd' to the directory containing the package's source code and type
|
||||
'./configure' to configure the package for your system.
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running 'configure' might take a while. While running, it prints
|
||||
some messages telling which features it is checking for.
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type 'make' to compile the package.
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type 'make check' to run any self-tests that come with
|
||||
the package, generally using the just-built uninstalled binaries.
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type 'make install' to install the programs and any data files and
|
||||
documentation. When installing into a prefix owned by root, it is
|
||||
recommended that the package be configured and built as a regular
|
||||
user, and only the 'make install' phase executed with root
|
||||
privileges.
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. Optionally, type 'make installcheck' to repeat any self-tests, but
|
||||
this time using the binaries in their final installed location.
|
||||
This target does not install anything. Running this target as a
|
||||
regular user, particularly if the prior 'make install' required
|
||||
root privileges, verifies that the installation completed
|
||||
correctly.
|
||||
|
||||
6. You can remove the program binaries and object files from the
|
||||
source code directory by typing 'make clean'. To also remove the
|
||||
files that 'configure' created (so you can compile the package for
|
||||
a different kind of computer), type 'make distclean'. There is
|
||||
also a 'make maintainer-clean' target, but that is intended mainly
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
7. Often, you can also type 'make uninstall' to remove the installed
|
||||
files again. In practice, not all packages have tested that
|
||||
uninstallation works correctly, even though it is required by the
|
||||
GNU Coding Standards.
|
||||
|
||||
8. Some packages, particularly those that use Automake, provide `make
|
||||
distcheck', which can by used by developers to test that all other
|
||||
targets like 'make install' and 'make uninstall' work correctly.
|
||||
This target is generally not run by end users.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the 'configure' script does not know about. Run './configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
the `configure' script does not know about. You can give `configure'
|
||||
initial values for variables by setting them in the environment. Using
|
||||
a Bourne-compatible shell, you can do that on the command line like
|
||||
this:
|
||||
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
|
||||
|
||||
You can give 'configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c99 CFLAGS=-g LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
Or on systems that have the `env' program, you can do it like this:
|
||||
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you can use GNU 'make'. 'cd' to the
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the 'configure' script. 'configure' automatically checks for the
|
||||
source code in the directory that 'configure' is in and in '..'. This
|
||||
is known as a "VPATH" build.
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
With a non-GNU 'make', it is safer to compile the package for one
|
||||
architecture at a time in the source code directory. After you have
|
||||
installed the package for one architecture, use 'make distclean' before
|
||||
reconfiguring for another architecture.
|
||||
|
||||
On MacOS X 10.5 and later systems, you can create libraries and
|
||||
executables that work on multiple system types--known as "fat" or
|
||||
"universal" binaries--by specifying multiple '-arch' options to the
|
||||
compiler but only a single '-arch' option to the preprocessor. Like
|
||||
this:
|
||||
|
||||
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||
CPP="gcc -E" CXXCPP="g++ -E"
|
||||
|
||||
This is not guaranteed to produce working output in all cases, you
|
||||
may have to build one architecture at a time and combine the results
|
||||
using the 'lipo' tool if you have problems.
|
||||
If you have to use a `make' that does not supports the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a time
|
||||
in the source code directory. After you have installed the package for
|
||||
one architecture, use `make distclean' before reconfiguring for another
|
||||
architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, 'make install' installs the package's commands under
|
||||
'/usr/local/bin', include files under '/usr/local/include', etc. You
|
||||
can specify an installation prefix other than '/usr/local' by giving
|
||||
'configure' the option '--prefix=PREFIX', where PREFIX must be an
|
||||
absolute file name.
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
pass the option '--exec-prefix=PREFIX' to 'configure', the package uses
|
||||
PREFIX as the prefix for installing programs and libraries.
|
||||
Documentation and other data files still use the regular prefix.
|
||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||
PATH as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like '--bindir=DIR' to specify different values for particular
|
||||
kinds of files. Run 'configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them. In general, the
|
||||
default for these options is expressed in terms of '${prefix}', so that
|
||||
specifying just '--prefix' will affect all of the other directory
|
||||
specifications that were not explicitly provided.
|
||||
options like `--bindir=PATH' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
The most portable way to affect installation locations is to pass the
|
||||
correct locations to 'configure'; however, many packages provide one or
|
||||
both of the following shortcuts of passing variable assignments to the
|
||||
'make install' command line to change installation locations without
|
||||
having to reconfigure or recompile.
|
||||
|
||||
The first method involves providing an override variable for each
|
||||
affected directory. For example, `make install
|
||||
prefix=/alternate/directory' will choose an alternate location for all
|
||||
directory configuration variables that were expressed in terms of
|
||||
'${prefix}'. Any directories that were specified during 'configure',
|
||||
but not in terms of '${prefix}', must each be overridden at install
|
||||
time for the entire installation to be relocated. The approach of
|
||||
makefile variable overrides for each directory variable is required by
|
||||
the GNU Coding Standards, and ideally causes no recompilation.
|
||||
However, some platforms have known limitations with the semantics of
|
||||
shared libraries that end up requiring recompilation when using this
|
||||
method, particularly noticeable in packages that use GNU Libtool.
|
||||
|
||||
The second method involves providing the 'DESTDIR' variable. For
|
||||
example, 'make install DESTDIR=/alternate/directory' will prepend
|
||||
'/alternate/directory' before all installation names. The approach of
|
||||
'DESTDIR' overrides is not required by the GNU Coding Standards, and
|
||||
does not work on platforms that have drive letters. On the other hand,
|
||||
it does better at avoiding recompilation issues, and works well even
|
||||
when some directory options were not specified in terms of '${prefix}'
|
||||
at 'configure' time.
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving 'configure' the
|
||||
option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'.
|
||||
|
||||
Some packages pay attention to '--enable-FEATURE' options to
|
||||
'configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to '--with-PACKAGE' options, where PACKAGE
|
||||
is something like 'gnu-as' or 'x' (for the X Window System). The
|
||||
'README' should mention any '--enable-' and '--with-' options that the
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, 'configure' can usually
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the 'configure' options '--x-includes=DIR' and
|
||||
'--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Some packages offer the ability to configure how verbose the
|
||||
execution of 'make' will be. For these packages, running `./configure
|
||||
--enable-silent-rules' sets the default to minimal output, which can be
|
||||
overridden with 'make V=1'; while running `./configure
|
||||
--disable-silent-rules' sets the default to verbose, which can be
|
||||
overridden with 'make V=0'.
|
||||
|
||||
Particular systems
|
||||
==================
|
||||
|
||||
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
|
||||
CC is not installed, it is recommended to use the following options in
|
||||
order to use an ANSI C compiler:
|
||||
|
||||
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
|
||||
|
||||
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
|
||||
|
||||
HP-UX 'make' updates targets which have the same time stamps as
|
||||
their prerequisites, which makes it generally unusable when shipped
|
||||
generated files such as 'configure' are involved. Use GNU 'make'
|
||||
instead.
|
||||
|
||||
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
|
||||
parse its '<wchar.h>' header file. The option '-nodtk' can be used as
|
||||
a workaround. If GNU CC is not installed, it is therefore recommended
|
||||
to try
|
||||
|
||||
./configure CC="cc"
|
||||
|
||||
and if that doesn't work, try
|
||||
|
||||
./configure CC="cc -nodtk"
|
||||
|
||||
On Solaris, don't put '/usr/ucb' early in your 'PATH'. This
|
||||
directory contains several dysfunctional programs; working variants of
|
||||
these programs are available in '/usr/bin'. So, if you need '/usr/ucb'
|
||||
in your 'PATH', put it _after_ '/usr/bin'.
|
||||
|
||||
On Haiku, software installed for all users goes in '/boot/common',
|
||||
not '/usr/local'. It is recommended to use the following options:
|
||||
|
||||
./configure --prefix=/boot/common
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features 'configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, 'configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
'--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as 'sun4', or a canonical name which has the form:
|
||||
|
||||
There may be some features `configure' can not figure out
|
||||
automatically, but needs to determine by the type of host the package
|
||||
will run on. Usually `configure' can figure that out, but if it prints
|
||||
a message saying it can not guess the host type, give it the
|
||||
`--host=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name with three fields:
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the host type.
|
||||
|
||||
OS
|
||||
KERNEL-OS
|
||||
|
||||
See the file 'config.sub' for the possible values of each field. If
|
||||
'config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the option '--target=TYPE' to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with '--host=TYPE'.
|
||||
If you are building compiler tools for cross-compiling, you can also
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for and the `--build=TYPE' option to select the type of
|
||||
system on which you are compiling the package.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for 'configure' scripts to share,
|
||||
you can create a site shell script called 'config.site' that gives
|
||||
default values for variables like 'CC', 'cache_file', and 'prefix'.
|
||||
'configure' looks for 'PREFIX/share/config.site' if it exists, then
|
||||
'PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
'CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all 'configure' scripts look for a site script.
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
Operation Controls
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to 'configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the 'configure' command line, using 'VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
causes the specified 'gcc' to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
Unfortunately, this technique does not work for 'CONFIG_SHELL' due to
|
||||
an Autoconf limitation. Until the limitation is lifted, you can use
|
||||
this workaround:
|
||||
|
||||
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
|
||||
|
||||
'configure' Invocation
|
||||
======================
|
||||
|
||||
'configure' recognizes the following options to control how it
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
'--help'
|
||||
'-h'
|
||||
Print a summary of all of the options to 'configure', and exit.
|
||||
`--cache-file=FILE'
|
||||
Use and save the results of the tests in FILE instead of
|
||||
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
|
||||
debugging `configure'.
|
||||
|
||||
'--help=short'
|
||||
'--help=recursive'
|
||||
Print a summary of the options unique to this package's
|
||||
'configure', and exit. The 'short' variant lists options used
|
||||
only in the top level, while the 'recursive' variant lists options
|
||||
also present in any nested packages.
|
||||
`--help'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
'--version'
|
||||
'-V'
|
||||
Print the version of Autoconf used to generate the 'configure'
|
||||
script, and exit.
|
||||
|
||||
'--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally 'config.cache'. FILE defaults to '/dev/null' to
|
||||
disable caching.
|
||||
|
||||
'--config-cache'
|
||||
'-C'
|
||||
Alias for '--cache-file=config.cache'.
|
||||
|
||||
'--quiet'
|
||||
'--silent'
|
||||
'-q'
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to '/dev/null' (any error
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
'--srcdir=DIR'
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
'configure' can determine that directory automatically.
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
'--prefix=DIR'
|
||||
Use DIR as the installation prefix. *note Installation Names::
|
||||
for more details, including other options available for fine-tuning
|
||||
the installation locations.
|
||||
`--version'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
'--no-create'
|
||||
'-n'
|
||||
Run the configure checks, but stop before creating any output
|
||||
files.
|
||||
|
||||
'configure' also accepts some other, not widely useful, options. Run
|
||||
'configure --help' for more details.
|
||||
`configure' also accepts some other, not widely useful, options.
|
||||
|
|
20
Makefile.am
20
Makefile.am
|
@ -1,18 +1,2 @@
|
|||
if COND_WANT_TESTS
|
||||
MAYBE_TESTS = tests
|
||||
endif
|
||||
SUBDIRS = src . $(MAYBE_TESTS)
|
||||
|
||||
dist_man_MANS = bip.1 bip.conf.5 bipmkpw.1 bipgenconfig.1
|
||||
|
||||
examplesdir = $(prefix)/share/doc/bip/examples/
|
||||
dist_examples_DATA = samples/bip.conf samples/bip.vim
|
||||
|
||||
EXTRA_DIST = \
|
||||
BUGS \
|
||||
scripts/bip-release \
|
||||
scripts/bipgenconfig \
|
||||
systemd
|
||||
|
||||
lint:
|
||||
find src/ tests/ \( -name *.c -o -name *.h \) -type f -print0 | xargs -0 clang-format -i
|
||||
SUBDIRS = src samples
|
||||
man_MANS = bip.1 bip.conf.5
|
||||
|
|
146
NEWS
146
NEWS
|
@ -1,111 +1,3 @@
|
|||
2022-03-10 (0.9.3) "sanitize our bip and add some layers"
|
||||
- Add SASL authentication support (EXTERNAL, PLAIN)
|
||||
- Handle some recommended GCC flags
|
||||
- fix /bip user info command
|
||||
|
||||
2021-10-12 (0.9.2) "for the love of unsubsquirrel"
|
||||
- Update and fix minor issues in sample bip and vim configuration files
|
||||
|
||||
2021-10-12 (0.9.1) "one more"
|
||||
- ENABLED might not be defined: use a default value.
|
||||
|
||||
2021-10-08 (0.9.0) "it's never too late"
|
||||
Visible changes:
|
||||
- "backlog_no_timestamp" is deprecated, "backlog_timestamp" should be used
|
||||
instead. The allowed values for this new parameter are: "none", "time",
|
||||
"datetime". "time" is the default value and allow to keep the default
|
||||
behavior.
|
||||
- allow to set TLS ciphers: for bip client side (client_side_ciphers),
|
||||
globally for all connections (ssl_default_ciphers) and foreach connection
|
||||
(ssl_ciphers).
|
||||
- allow to set DH parameter used for clients SSL connections with the new
|
||||
client_side_dh_param parameter.
|
||||
- Add write_oidentd_file parameter. Existing oidentd users must use
|
||||
'write_oidentd = true' in their config to keep existing behavior.
|
||||
|
||||
2013-10-19 (0.8.9) "If it's really that urgent, why don't you do it yourself?"
|
||||
- code fixes
|
||||
- buildsys fixes (bison 2.6 compatibility and others)
|
||||
- improved TRUST OK command replies when there's no untrusted certificate
|
||||
- fixed GCC warnings
|
||||
|
||||
2011-04-14 (0.8.8) "spring release"
|
||||
- Allow to disable logs by connection.
|
||||
- When global option log is disabled, query are not backlogged.
|
||||
- Avoid segfault when global option log is false.
|
||||
|
||||
2011-01-18 (0.8.7) "bazooka"
|
||||
- Fix "FATAL: list_remove: item not found"
|
||||
- Fix build errors on armel
|
||||
- minor fixes
|
||||
|
||||
2010-09-12 (0.8.6) "CVE-2010-3071"
|
||||
- Fix for CVE-2010-3071.
|
||||
|
||||
2010-08-07 (0.8.5) "Unpacking"
|
||||
- Now builds position independant executables
|
||||
|
||||
2009-11-15 (0.8.4) "I’ll have the same thing please"
|
||||
- Fix build OpenSSL detection issue.
|
||||
|
||||
2009-11-15 (0.8.3) "Hey Dublin! What’s the craic?"
|
||||
- Fixes a fatal() on gamesurge networks.
|
||||
|
||||
2009-08-24 (0.8.2) "Farewell Paris"
|
||||
- Fix hanging bip on hanging client connexions.
|
||||
|
||||
2009-07-17 (0.8.1) "Ran ran ru in Praha"
|
||||
- Fixed an annoying bug that resulted in too much backlog.
|
||||
- Fix TRUST command.
|
||||
- Close some unused log files.
|
||||
|
||||
2009-03-02 (0.8.0) "swelling millionnaire"
|
||||
- Cosmetic bug fixes since last rc.
|
||||
|
||||
2009-02-02 (0.8.0-rc1) "got booze?"
|
||||
- One bug fixed and a client hack added to avoid the "+" or "-" prefix in
|
||||
irssi when connecting irssi and xchat to the same bip connection.
|
||||
|
||||
2009-01-24 (0.8.x)
|
||||
Visible changes:
|
||||
- One logfile per nick for queries, instead of the messy privates.x.log
|
||||
Slight log format change (now the format of the log of queries is very
|
||||
similar to the on used for channels)
|
||||
- "Window"-local blreset and blreset on talk. By default the blreset_on_talk
|
||||
now only clears the backlog of the query you talked to or the channel you
|
||||
talked to. The /quote bip blreset command now can take a query name or a
|
||||
channel name as an argument. "/quote bip blreset" still resets the backlog of
|
||||
the whole network.
|
||||
- /quote bip backlog x command where x is the number of hours will backlog x
|
||||
hours.
|
||||
- autorejoin on kick by default. Can be disabled with the option
|
||||
autojoin_on_kick = false in a connection block.
|
||||
- bip SSL on the client<->bip part now support Ephemeral Diffie Hellman key
|
||||
exchange.
|
||||
|
||||
2008-10-24 (0.7.5) "But I have promises to keep, And miles to go before I
|
||||
sleep, And miles to go before I sleep."
|
||||
- Halfop handling fixed, and a shameful segfault. The segfault may be
|
||||
exploitable by clients, but only after successful login. Please upgrade.
|
||||
|
||||
2008-06-28 (0.7.4) "But where is 0.7.3 ?!"
|
||||
- Some usefull bugfixes, especially for unreal irc network users.
|
||||
|
||||
2008-04-05 (0.7.2) "Enjoy the fish"
|
||||
- Contains a compilation fix for OpenBSD.
|
||||
|
||||
2008-04-02: bip 0.7.1 "hot mama"
|
||||
- Contains a configuration validation fix, and a memory leak fix.
|
||||
|
||||
2008-02-16 (0.7.0) "birthday party"
|
||||
- The good stuff: sighup support, /bip reload should also work now
|
||||
- New commands (allow a user to add a new network without restarting bip for
|
||||
instance)
|
||||
- Better user feedback when issuing /bip commands.
|
||||
- Lots of new backlog options, some of which can now be set per user instead of
|
||||
globally.
|
||||
- And a few fixes on top of that.
|
||||
|
||||
2008-02-07 Arnaud Cornet <nohar@t1r.net>
|
||||
What's to expect in bip now:
|
||||
- Support kill -HUP and /bip reload cleanly.
|
||||
|
@ -128,33 +20,15 @@ What's to expect in bip now:
|
|||
- Have a bold arrow to highligh your own word on private messages and multiple
|
||||
connected clients.
|
||||
|
||||
2007-12-09
|
||||
- Bip has now two types of users "admins" and normal user. Some commands are
|
||||
reserved to admin. Add a admin = true; statement in your config (in user
|
||||
block) accordingly.
|
||||
09-12-2007: Bip has now two types of users "admins" and normal user. Some
|
||||
commands are reserved to admin. Add a admin = true; statement in your config
|
||||
(in user block) accordingly.
|
||||
|
||||
2007-10-29
|
||||
- Certificate validation change. In "basic" mode, expired certificates are now
|
||||
accepted as long as they are in store (therefore trusted). This makes the
|
||||
basic mode be more SSH like. Some extreme security zealots might want to be
|
||||
warned.
|
||||
29-10-2007: Certificate validation change. In "basic" mode, expired
|
||||
certificates are now accepted as long as they are in store (therefore trusted).
|
||||
This makes the basic mode be more SSH like. Some extreme security zealots might
|
||||
want to be warned.
|
||||
|
||||
2007-09-02
|
||||
- as of now log parameters go in the user {} statment. This breaks
|
||||
every config and there is no backwrads compatibility as of now.
|
||||
- Lots of internal changes, expect crashes.
|
||||
|
||||
2007-08-19 (0.6.1)
|
||||
- Fixes half closed socket descriptor leak, as well as a potential crash on
|
||||
startup.
|
||||
- Bip switches to git. You can clone the public repository with:
|
||||
- git clone http://bip.t1r.net/bip.git
|
||||
|
||||
2007-02-27 (0.6.0)
|
||||
- Includes more commands, more options, more fixes.
|
||||
- UPDATE: Thanks to YS for the sexy logo! How rude of me to forget to give
|
||||
proper credits!
|
||||
- Bip is developed by Arnaud Cornet and Loïc Gomez and is distributed under
|
||||
the GNU Public License Version 2 (see the AUTHORS file for a list of
|
||||
contributors).
|
||||
- BIP IRC channel is on OFTC : irc://irc.oftc.net/bip
|
||||
02-09-2007: as of now log parameters go in the user {} statment. This breaks
|
||||
every config and there is no backwrads compatibility as of now.
|
||||
Lots of internal changes, expect crashes.
|
||||
|
|
22
README
22
README
|
@ -29,25 +29,15 @@ I. INSTALLATION
|
|||
distro's package. Then create a configuration file.
|
||||
|
||||
Choose your distribution package if available. If not, build bip the
|
||||
old-fashioned way. You will need make, gcc, lex, yacc, automake,
|
||||
autoconf-archive and optionally libssl-dev to build bip.
|
||||
|
||||
old-fashioned way. You will need make, gcc, lex and yacc to build bip.
|
||||
Just issue:
|
||||
|
||||
From bip-X.Y.Z.tar.gz package:
|
||||
# ./configure && make
|
||||
|
||||
From repository:
|
||||
# autoreconf -i
|
||||
# ./configure --enable-maintainer-mode && make
|
||||
# ./configure --enable-oidentd && make
|
||||
|
||||
If openssl and its developement files are installed, bip should build with
|
||||
SSL support. After a successful build the bip binary can be found in
|
||||
./src/bip.
|
||||
|
||||
By default, "-Werror" is used. If you encounter warnings, you could try:
|
||||
# CFLAGS="-Wno-error" ./configure && make
|
||||
|
||||
|
||||
II. CONFIGURATION
|
||||
|
||||
|
@ -190,10 +180,10 @@ IV. USING BIP
|
|||
a default_username set to "myuser", he would appear as ~myuser@yourhost,
|
||||
which may be sufficient for most networks.
|
||||
|
||||
If the network you're on is a bit more demanding, you can set up an
|
||||
oidentd server on your host, and enable oidentd spoofing support
|
||||
('write_oidentd = true;' option in bip configuration file). Let's
|
||||
say bip is the system user running bip, you should add to
|
||||
If the network you're on is a bit more requiring, you can set up an
|
||||
oidentd server on your host, and (if not already) compile bip with
|
||||
oidentd spoofing support (--enable-oidentd option of the configure
|
||||
script). Let's say bip is the system user running bip, you should add to
|
||||
your /etc/oidentd.conf :
|
||||
|
||||
user "bip" {
|
||||
|
|
21
TODO
21
TODO
|
@ -1,3 +1,24 @@
|
|||
<jj> home = getenv("HOME");
|
||||
<jj> if (!home) {
|
||||
<jj> conf_die(&bip, "no $HOME !, do you live in a trailer ?");
|
||||
<jj> faudrait virer ca
|
||||
<nohar> pourquoi ?
|
||||
<jj> bah mon bip a pas de HOME
|
||||
<nohar> ?
|
||||
<nohar> un user sans home ?
|
||||
<jj> et je le definis juste pour pas qu'il conf_die
|
||||
<nohar> c'est possible ca ? :)
|
||||
<gromit> sarko
|
||||
<jj> env - bip
|
||||
<jj> le -s suffit
|
||||
<nohar> hum ok :)
|
||||
<nohar> c'est complètement élite "env -" :)
|
||||
<jj> faudrait ptet pouvoir specifier directement le oidentd_path
|
||||
<nohar> oui et documenter -s
|
||||
<jj> rajoute le -s au --help aussi a l'occasion
|
||||
<jj> voila
|
||||
|
||||
|
||||
- Allow to dump a config file, so that when the config is dynamically
|
||||
changed, we can find it back after bip restart.
|
||||
|
||||
|
|
8
bip.1
8
bip.1
|
@ -6,7 +6,7 @@ bip \- BIP IRC Proxy
|
|||
|
||||
.SH SYNOPSIS
|
||||
|
||||
\fBbip\fP [ \fB-n\fP ] [ \fB-f\fP \fIconfig_file\fP ] [ \fB-s\fP \fIbipdir\fP ] [ \fB-h\fP ]
|
||||
\fBbip\fP [ \fB-f\fP \fIconfig_file\fP ] [ \fB-n\fP ] [ \fB-h\fP ]
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
|
@ -24,10 +24,8 @@ Use config_file as the configuration file.
|
|||
If no config file is given, bip will try to open ~/.bip/bip.conf.
|
||||
|
||||
.TP
|
||||
\fB-s\fP bipdir
|
||||
Set bip home directory to bipdir instead of $HOME/.bip. \fBbipdir\fP is
|
||||
the default parent directory for client certificate, configuration, logs, pid,
|
||||
oidentd.
|
||||
\fB-s\fP homedir
|
||||
Set bip home directory to homedir instead of $HOME/.bip.
|
||||
|
||||
.TP
|
||||
\fB-h\fP
|
||||
|
|
227
bip.conf.5
227
bip.conf.5
|
@ -1,14 +1,9 @@
|
|||
.TH BIP.CONF 5 "2 January 2022"
|
||||
.TH BIP.CONF 5 "10 October 2005"
|
||||
|
||||
.SH NAME
|
||||
|
||||
bip.conf \- Configuration file for BIP IRC Proxy
|
||||
|
||||
.SH SYNOPSIS
|
||||
|
||||
.PP
|
||||
~/.bip/bip.conf
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
A BIP configuration file consists of a list of variable affectations or
|
||||
|
@ -16,11 +11,9 @@ sections. It contains the global options, networks definitions, users
|
|||
configuration, users connections declarations. Each section is described in
|
||||
this manpage.
|
||||
|
||||
The
|
||||
.BR bip.conf
|
||||
skeleton should be something like this :
|
||||
The bip.conf skeleton should be something like this :
|
||||
|
||||
.EX
|
||||
.nf
|
||||
option1 = value;
|
||||
option2 = value;
|
||||
...
|
||||
|
@ -49,61 +42,39 @@ user {
|
|||
...
|
||||
};
|
||||
};
|
||||
.EE
|
||||
.fi
|
||||
|
||||
.SH SYNTAX RULES
|
||||
|
||||
The syntax is quite simple :
|
||||
.RS
|
||||
.IP \(bu 4
|
||||
everything after the \fB#\fP character is ignored (comments)
|
||||
.IP \(bu 4
|
||||
each variable affectation must be finished with a \fB;\fP
|
||||
.IP \(bu 4
|
||||
each section { } must be finished with a \fB;\fP
|
||||
.RE
|
||||
.br
|
||||
\- everything after the \fB#\fP character is ignored (comments)
|
||||
.br
|
||||
\- each variable affectation must be finished with a \fB;\fP
|
||||
.br
|
||||
\- each section { } must be finished with a \fB;\fP
|
||||
.br
|
||||
|
||||
If you use vim you will probably want to use vim with the provided
|
||||
\fBbip.vim\fP syntax file to avoid common syntax and lexical mistakes. You can
|
||||
also find an example configuration file along with BIP.
|
||||
|
||||
By default, \fBbipdir\fR is the \fI$HOME/.bip\fR directory and the parent
|
||||
directory for client certificate, configuration, logs, pid, oidentd. If
|
||||
environment variable \fB$HOME\fP doesn't exist, \fB-s\fP parameter must be
|
||||
used.
|
||||
|
||||
.SH GLOBAL OPTIONS
|
||||
|
||||
.TP
|
||||
\fBclient_side_ssl\fP (default: \fBfalse\fP)
|
||||
When true, clients will need to connect to BIP using SSL.
|
||||
You'll also need to generate a SSL cert/key pair in \fIbipdir/bip.pem\fR
|
||||
(usually \fI~/.bip/bip.pem\fR or \fI/var/lib/bip/bip.pem\fR) or \fBclient_side_ssl_pem\fP if
|
||||
defined.
|
||||
You'll also need to generate a SSL cert/key pair in <bipdir>/bip.pem (usually
|
||||
~/.bip/bip.pem or /var/lib/bip/bip.pem) or <client_side_ssl_pem> if defined.
|
||||
|
||||
.TP
|
||||
\fBclient_side_ssl_pem\fP (default: \fI<bipdir>/bip.pem\fR)
|
||||
\fBclient_side_ssl_pem\fP (default: \fB<bipdir>/bip.pem\fP)
|
||||
Set this to the full path of the cert/key pair bip should use to accept clients
|
||||
SSL connections.
|
||||
|
||||
.TP
|
||||
\fBclient_side_ciphers\fP
|
||||
OpenSSL cipher lists used for clients SSL connections. If not set, OpenSSL
|
||||
default ciphers will be used.
|
||||
|
||||
.TP
|
||||
\fBclient_side_dh_param\fP DH parameters filename\fP (default: \fI<bipdir>/dh.pem\fR)
|
||||
Used for clients SSL connections, Supply at least 2048-bit parameters.
|
||||
|
||||
.TP
|
||||
\fBssl_default_ciphers\fP
|
||||
OpenSSL cipher lists used for server connections. If not set, OpenSSL default
|
||||
ciphers will be used.
|
||||
|
||||
.TP
|
||||
\fBip\fP (default: \fB0.0.0.0\fP)
|
||||
Listening IP address. This is the IP address bip will listen for incoming
|
||||
client connections.
|
||||
\fBip\fP
|
||||
Ignored for the time beeing.
|
||||
|
||||
.TP
|
||||
\fBlog\fP (default: \fBtrue\fP)
|
||||
|
@ -112,16 +83,15 @@ file. Backlog is then stored into memory.
|
|||
|
||||
.TP
|
||||
\fBlog_system\fP (default: \fBtrue\fP)
|
||||
When true, system messages such as connection errors are logged. Else, BIP will
|
||||
not write system logs.
|
||||
When true, system messages such as connection errors are logged. Else, BIP will not write system logs.
|
||||
|
||||
.TP
|
||||
\fBlog_format\fP (default: \fB%u/%n/%Y-%m/%c.%d.log\fP)
|
||||
Determines the log filename depending on :
|
||||
Determines the log file name depending on :
|
||||
.br
|
||||
\- %u username (name in \fBuser\fP { }; section)
|
||||
\- %u username (name in user { }; section)
|
||||
.br
|
||||
\- %n network name (name in \fBconnection\fP { }; section)
|
||||
\- %n network name (name in connection { }; section)
|
||||
.br
|
||||
\- %c channel name
|
||||
.br
|
||||
|
@ -136,7 +106,7 @@ Determines the log filename depending on :
|
|||
Specify the verbosity of BIP from 0 (fatal errors) to 6 (huge debug output)
|
||||
|
||||
.TP
|
||||
\fBlog_root\fP (default: \fI<bipdir>/logs\fR
|
||||
\fBlog_root\fP (default: \fBHOME/.bip/logs\fP)
|
||||
Main log directory. Sub-directories and files will be created from there
|
||||
depending on \fBlog_format\fP.
|
||||
|
||||
|
@ -146,24 +116,10 @@ Defines the delay between each logfiles sync to the disk. Must be a non null
|
|||
positive integer.
|
||||
|
||||
.TP
|
||||
\fBreconn_timer\fP (default: \fB30\fP)
|
||||
Defines the initial delay (in seconds) before a reconnection attempt.
|
||||
The delay increases with the number of attempts:
|
||||
delay = reconn_timer * number of attempts
|
||||
|
||||
.TP
|
||||
\fBpid_file\fP (default: \fI<bipdir>/bip.pid\fR)
|
||||
\fBpid_file\fP (default: \fBHOME/.bip/bip.pid\fP)
|
||||
Defines the file where BIP's pid will be stored. BIP checks if this file exists
|
||||
and if the pid is still alive upon startup. If true, BIP refuses to start.
|
||||
|
||||
.TP
|
||||
\fBwrite_oidentd\fP (default: \fIfalse\fR)
|
||||
Must be set to true to overwrite oidentd configs.
|
||||
|
||||
.TP
|
||||
\fBoidentd_file\fP (default: \fI<bipdir>/.oidentd.conf\fR)
|
||||
oidentd configuration file (if oidentd enabled).
|
||||
|
||||
.TP
|
||||
\fBport\fP (default: \fB7778\fP)
|
||||
The port on which BIP should listen for clients.
|
||||
|
@ -176,18 +132,14 @@ sections. It may appear more than once in the configuration file.
|
|||
.TP
|
||||
\fBssl\fP (default: \fBfalse\fP)
|
||||
If true, BIP will connect to this network using SSL only. You cannot mix
|
||||
SSL servers and non-SSL servers in the same \fBnetwork\fP section. This is by choice,
|
||||
SSL servers and non-SSL servers in the same network section. This is by choice,
|
||||
we believe it's a bad idea.
|
||||
|
||||
.TP
|
||||
\fBssl_ciphers\fP (override global \fBssl_default_ciphers\fP)
|
||||
OpenSSL cipher lists used for this network.
|
||||
|
||||
.TP
|
||||
\fBname\fP
|
||||
It's the network name used in the \fBconnection\fP section. Please note that
|
||||
It's the network name used in the \fBconnection section\fP. Please note that
|
||||
this value is not used in \fBlog_format\fP, since it uses the variable
|
||||
\fBname\fP from the \fBconnection\fP section.
|
||||
\fBname\fP from the \fBconnection section\fP.
|
||||
|
||||
.SH SERVER SUB-SECTION
|
||||
|
||||
|
@ -210,7 +162,7 @@ options. It may appear more than once in the configuration file.
|
|||
.TP
|
||||
\fBadmin\fP (default: \fBfalse\fP)
|
||||
If a user has admin set to true, he'll become a bip administrator, which allows
|
||||
him for example to reload bip from IRC or to see the user configuration.
|
||||
him for example to RELOAD bip from IRC or to see the user configuration.
|
||||
|
||||
.TP
|
||||
\fBbacklog\fP (default: \fBtrue\fP)
|
||||
|
@ -224,10 +176,10 @@ they were already sent before. That means :
|
|||
If \fBbacklog_always\fP is false, backlog will be reset whenever there
|
||||
is no more client connected to a network. Else backlog will not be reset.
|
||||
This option should of course not be enabled if \fBbacklog_lines\fP is 0 !
|
||||
If you still want to do so, don't forget to \fB/BIP BLRESET\fP sometimes.
|
||||
If you still want to do so, don't forget to /BIP BLRESET sometimes.
|
||||
|
||||
.TP
|
||||
\fBbacklog_lines\fP (default: \fB0\fP)
|
||||
\fBbacklog_lines\fP (default: \fB10\fP)
|
||||
If set to 0, BIP will replay all the logs since last client disconnect. Else,
|
||||
it'll replay exactly \fBbacklog_lines\fP lines on each channel and privates.
|
||||
Be aware that BIP will replay \fBbacklog_lines\fP lines of all privates, even
|
||||
|
@ -235,34 +187,14 @@ if there are more. For example if Coyote told you 12 lines and then RoadRunner
|
|||
6, you'll only have a replay of the 6 RoadRunner's lines and the last 4 of
|
||||
Coyote's.
|
||||
|
||||
.TP
|
||||
\fBbacklog_timestamp\fP (default: \fBtime\fP)
|
||||
\fBnone\fP disables timestamps in backlogged lines, \fBtime\fP or
|
||||
\fBdatetime\fP allow one to select the timestamp format in backlogged lines.
|
||||
|
||||
.TP
|
||||
\fBbacklog_no_timestamp\fP (default: \fBfalse\fP)
|
||||
This parameter is deprecated, use \fBbacklog_timestamp\fP instead.
|
||||
.I false
|
||||
implies
|
||||
.I backlog_timestamp = "none"
|
||||
and
|
||||
.I true
|
||||
implies
|
||||
.I backlog_timestamp = "time"
|
||||
\&.
|
||||
If true, backlogged line won't include the timestamp.
|
||||
|
||||
.TP
|
||||
\fBbacklog_reset_on_talk\fP (default: \fBfalse\fP)
|
||||
When true, backlog will be reset upon client talk (channel/private message or
|
||||
action). It means that next time you log to your bip session, the backlogging
|
||||
will start at the time right after your last words on that specific channel or
|
||||
query.
|
||||
|
||||
.TP
|
||||
\fBbacklog_reset_connection\fP (default: \fBfalse\fP)
|
||||
When true, backlog_reset_on_talk option above is changed in that the whole
|
||||
network backlog is reset when you talk in the network.
|
||||
will start at the time right after your last words on that specific network.
|
||||
|
||||
.TP
|
||||
\fBbacklog_msg_only\fP (default: \fBfalse\fP)
|
||||
|
@ -273,30 +205,30 @@ change, nick change, user quit/part/join will be backlogged upon connection.
|
|||
\fBbip_use_notice\fP (default: \fBfalse\fP)
|
||||
If \fBbip_use_notice\fP is true, bip's notifications to the clients will be
|
||||
send as notices instead of private messages. For example, this setting applies
|
||||
to disconnection notifications or \fB/BIP\fP command replies.
|
||||
to disconnection notifications or /BIP command replies.
|
||||
|
||||
.TP
|
||||
\fBdefault_nick\fP
|
||||
The default nick option for each \fBconnection\fP section where no \fBnick\fP
|
||||
The default nick option for each \fBconnection section\fP where no \fBnick\fP
|
||||
is defined. See \fBCONNECTION SECTION\fP for more details.
|
||||
|
||||
.TP
|
||||
\fBdefault_realname\fP
|
||||
The default realname option for each \fBconnection\fP section where no
|
||||
The default realname option for each \fBconnection section\fP where no
|
||||
\fBrealname\fP is defined. See \fBCONNECTION SECTION\fP for more details.
|
||||
|
||||
.TP
|
||||
\fBdefault_user\fP
|
||||
The default user option for each \fBconnection\fP section where no \fBuser\fP
|
||||
The default user option for each \fBconnection section\fP where no \fBuser\fP
|
||||
is defined. See \fBCONNECTION SECTION\fP for more details.
|
||||
|
||||
.TP
|
||||
\fBname\fP
|
||||
The username. It'll be used to authenticate to bip and in \fBlog_format\fP.
|
||||
The user name. It'll be used to authenticate to bip and in \fBlog_format\fP.
|
||||
|
||||
.TP
|
||||
\fBpassword\fP
|
||||
The password. It \fBMUST\fP be generated with \fBbipmkpw\fP or it'll not work.
|
||||
The password. It \fBMUST\fP be generated with \fBbimkpw\fP or it'll not work.
|
||||
|
||||
.TP
|
||||
\fBssl_check_mode\fP (default: \fBnone\fP)
|
||||
|
@ -313,13 +245,6 @@ allows a "ssh-like" private key generation scheme. Note that in basic mode:
|
|||
.TP
|
||||
\fBssl_check_store\fP (default: \fBnot set\fP)
|
||||
This repository is browsed by BIP when a SSL certificate or CA check is needed.
|
||||
In ssl_check_mode \fBbasic\fP it must be a file, to which certificates you
|
||||
choose to trust will be appended. In ssl_check_mode \fBca\fP it may be a
|
||||
single file containing one or more trusted certificates concatenated together
|
||||
between BEGIN CERTIFICATE and END CERTIFICATE lines, a directory containing
|
||||
individual certificates in PEM format which has been processed by \fBc_rehash\fP,
|
||||
or unset, in which case bip will attempt to use the default certificate store of
|
||||
the OpenSSL it is built against.
|
||||
|
||||
.TP
|
||||
\fBssl_client_certfile\fP (default: \fBnot set\fP)
|
||||
|
@ -329,8 +254,8 @@ use this feature.
|
|||
|
||||
.SH CONNECTION SUB-SECTION
|
||||
|
||||
Each \fBconnection\fP section associates a user to the networks he wants to connect
|
||||
to. Thus, it must be declared in the \fBUser\fP sections, and can be used more than
|
||||
Each connection section associates a user to the networks he wants to connect
|
||||
to. Thus, it must be declared in the user sections, and can be used more than
|
||||
once.
|
||||
|
||||
.TP
|
||||
|
@ -349,72 +274,36 @@ If set to true, when you change nick, BIP stores the new nickname as the new
|
|||
default nickname value. Thus, if you are disconnected from the server, BIP will
|
||||
restore the correct nickname.
|
||||
|
||||
.TP
|
||||
\fBautojoin_on_kick\fP (default: \fBtrue\fP)
|
||||
If set to false bip will not attempt to re-join a channel from which you were
|
||||
kicked.
|
||||
|
||||
.TP
|
||||
\fBignore_first_nick\fP (default: \fBfalse\fP)
|
||||
If set to true, BIP will ignore the nickname sent by the client upon connect.
|
||||
Further nickname changes will be processed as usual.
|
||||
|
||||
.TP
|
||||
\fBignore_server_capab\fP (default: \fBtrue\fP)
|
||||
By default bip ignores when a server advertises the CAPAB feature. Servers that
|
||||
support this can prefix each line with a "+" or a "-" depending if a user is
|
||||
registered or not. xchat checks if a server has the CAPAB feature and enables
|
||||
it.
|
||||
If you have two clients connected to a bip connection, one that supports this
|
||||
mode and one that does not, you see the plus and the minuses on each line in
|
||||
the client that does not support CAPAB. To avoid that, when a server advertises
|
||||
CAPAB bip simply removes it. You can set this option to false to keep using
|
||||
CAPAB (if you only use clients that support it for instance).
|
||||
|
||||
.TP
|
||||
\fBnetwork\fP
|
||||
The network name. See the \fBNETWORK SECTION\fP.
|
||||
|
||||
.TP
|
||||
\fBlog\fP (override global log)
|
||||
When \fBtrue\fP, the file logs are enabled for this connection.
|
||||
When \fBfalse\fP, no log file is written, logs are kept in memory.
|
||||
|
||||
.TP
|
||||
\fBnick\fP
|
||||
BIP will send that string as your nickname upon connect. If not specified
|
||||
and if \fBdefault_nickname\fP is specified in the \fBuser\fP section, BIP will
|
||||
and if \fBdefault_nickname\fP is specified in the \fBuser section\fP, BIP will
|
||||
use that default nickname string.
|
||||
|
||||
.TP
|
||||
\fBon_connect_send\fP
|
||||
You can specify this field more than once. BIP will send the text as is to the
|
||||
server. It'd be useful for a greet on connect or to send your NickServ password.
|
||||
server. It'd be useful for a greet on connect or to send you NickServ password.
|
||||
|
||||
.TP
|
||||
\fBpassword\fP
|
||||
This is the IRC server password, which is sent upon connection to the IRC server
|
||||
This is the irc server password, which is sent upon connection to the irc server
|
||||
only.
|
||||
|
||||
.TP
|
||||
\fBrealname\fP
|
||||
BIP will send that string as the realname part (description in whois result)
|
||||
upon connect. If not specified and if \fBdefault_realname\fP is specified in
|
||||
the \fBuser\fP section, BIP will use that default realname string.
|
||||
|
||||
.TP
|
||||
\fBsasl_mechanism\fP
|
||||
Tells BIP to use specified SASL mechanism. Currently supported: PLAIN, EXTERNAL.
|
||||
PLAIN mechanism requires \fBsasl_username\fP and \fBsasl_password\fP and is the
|
||||
default if these are set.
|
||||
|
||||
.TP
|
||||
\fBsasl_username\fP
|
||||
This connection's username to pass on using SASL authentication.
|
||||
|
||||
.TP
|
||||
\fBsasl_password\fP
|
||||
This connection's password to pass on using SASL authentication.
|
||||
the \fBuser section\fP, BIP will use that default realname string.
|
||||
|
||||
.TP
|
||||
\fBsource_port\fP
|
||||
|
@ -422,13 +311,13 @@ If specified, tells BIP to connect from this port to the IRC server.
|
|||
|
||||
.TP
|
||||
\fBssl_check_mode\fP (default: \fBthe user's option\fP)
|
||||
See \fBssl_check_mode\fP option in \fBUser\fP section.
|
||||
See \fBssl_check_mode\fP option in User options.
|
||||
|
||||
.TP
|
||||
\fBuser\fP
|
||||
BIP will send that string as the user part (usually between ! and @ in a whois
|
||||
result) upon connect. It's also used by the oidentd support (if enabled). If
|
||||
not specified and if \fBdefault_user\fP is specified in the \fBuser\fP section,
|
||||
not specified and if \fBdefault_user\fP is specified in the \fBuser section\fP,
|
||||
BIP will use that default user string.
|
||||
|
||||
.TP
|
||||
|
@ -441,8 +330,8 @@ to people who only have one IP address.
|
|||
.SH CHANNEL SUB-SUB-SECTION
|
||||
|
||||
This section defines the list of channels to join for a user on a particular
|
||||
network. It is to be found in the \fBconnection\fP sections and appear more than once
|
||||
in a \fBconnection\fP section.
|
||||
network. It is to be found in the connection sections and appear more than once
|
||||
in a connection section.
|
||||
|
||||
.TP
|
||||
\fBname\fP
|
||||
|
@ -455,31 +344,11 @@ The channel key if needed.
|
|||
.TP
|
||||
\fBbacklog\fP (default: \fBtrue\fP)
|
||||
Enable or disable backlogging of this particular channel.
|
||||
Setting this to true will NOT enable the backlog system, see the \fBuser\fP
|
||||
section.
|
||||
|
||||
.SH IRC CLIENT CONFIGURATION
|
||||
.P
|
||||
On your IRC client, setup as many IRC servers as connections defined in your
|
||||
\fBconnection\fP section.
|
||||
.P
|
||||
Host and port must match values defined in \fBip\fP and \fBport\fP global
|
||||
option. The password must be \fIusername:password:connectionname\fR where:
|
||||
|
||||
.RS
|
||||
.IP \(bu 4
|
||||
username is the \fIname\fR defined in the \fIuser\fR section;
|
||||
.IP \(bu 4
|
||||
password is the clear text value of the \fIpassword\fR corresponding to the
|
||||
hashed password defined in the \fIuser\fR section;
|
||||
.IP \(bu 4
|
||||
connectionname is the \fIname\fR defined in \fIconnection\fR sub-section.
|
||||
.RE
|
||||
Setting this to true will NOT enable the backlog system, see the User section.
|
||||
|
||||
.SH SEE ALSO
|
||||
|
||||
.BR bip (1),
|
||||
.BR bipmkpw (1)
|
||||
bip, bipmkpw
|
||||
|
||||
.SH AUTHOR
|
||||
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
.TH BIP 1 "10 October 2005"
|
||||
|
||||
.SH NAME
|
||||
|
||||
bipgenconfig \- BIP IRC Proxy configuration program
|
||||
|
||||
.SH SYNOPSIS
|
||||
|
||||
\fBbipgenconfig\fP
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
bipgenconfig will help you build a configuration file for BIP IRC Proxy
|
||||
|
||||
.SH SEE ALSO
|
||||
|
||||
bip, bip.conf, bipmkpw
|
||||
|
||||
.SH AUTHOR
|
||||
|
||||
Arnaud 'nohar' Cornet
|
||||
Loïc 'Kyoshiro' Gomez
|
||||
|
||||
Thanks to jj, YS and lafouine, for hanging around while we were coding.
|
||||
|
||||
Crypto shamelessly taken from Christophe 'sexy' Devine.
|
||||
|
|
@ -13,12 +13,9 @@ bipmkpw \- Password hasher for BIP
|
|||
bipmkpw converts a password into the double-hash used by bip. Copy the
|
||||
generated output from bipmkpw into bip config file.
|
||||
|
||||
Password cannot contain spaces.
|
||||
|
||||
.SH SEE ALSO
|
||||
|
||||
.BR bip.conf (5)
|
||||
.BR bip (1)
|
||||
bip.conf
|
||||
|
||||
.SH COPYRIGHT
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This thinggie bootstraps the auto* build sys.
|
||||
|
||||
set -e
|
||||
|
||||
aclocal
|
||||
autoheader
|
||||
autoconf
|
||||
automake --add-missing --copy -Wall
|
||||
|
180
configure.ac
180
configure.ac
|
@ -1,180 +0,0 @@
|
|||
m4_pattern_allow([^AM_])
|
||||
m4_pattern_allow([^AC_])
|
||||
|
||||
AC_PREREQ([2.69])
|
||||
AC_INIT([Bip IRC Proxy],[0.9.3-git],[http://bip.milkypond.org/projects/bip/activity],[bip],[http://bip.milkypond.org/])
|
||||
AM_INIT_AUTOMAKE([foreign subdir-objects -Wall -Werror])
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_CONFIG_HEADERS([src/config.h])
|
||||
|
||||
# Checks for programs
|
||||
AC_PROG_CC
|
||||
AM_PROG_AR
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_INSTALL
|
||||
AM_PROG_LEX
|
||||
AC_PROG_YACC
|
||||
|
||||
dnl PKG_PREREQ(MIN-VERSION)
|
||||
dnl -----------------------
|
||||
dnl Since: 0.29
|
||||
dnl
|
||||
dnl Verify that the version of the pkg-config macros are at least
|
||||
dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
|
||||
dnl installed version of pkg-config, this checks the developer's version
|
||||
dnl of pkg.m4 when generating configure.
|
||||
dnl
|
||||
dnl To ensure that this macro is defined, also add:
|
||||
dnl m4_ifndef([PKG_PREREQ],
|
||||
dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
|
||||
dnl
|
||||
dnl See the "Since" comment for each macro you use to see what version
|
||||
dnl of the macros you require.
|
||||
m4_defun([PKG_PREREQ],
|
||||
[m4_define([PKG_MACROS_VERSION], [0.29.1])
|
||||
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
|
||||
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
|
||||
])dnl PKG_PREREQ
|
||||
|
||||
dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
|
||||
dnl ----------------------------------
|
||||
dnl Since: 0.16
|
||||
dnl
|
||||
dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
|
||||
dnl first found in the path. Checks that the version of pkg-config found
|
||||
dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
|
||||
dnl used since that's the first version where most current features of
|
||||
dnl pkg-config existed.
|
||||
AC_DEFUN([PKG_PROG_PKG_CONFIG],
|
||||
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
|
||||
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
|
||||
m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
|
||||
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
|
||||
AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
|
||||
AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
|
||||
|
||||
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
|
||||
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
|
||||
fi
|
||||
if test -n "$PKG_CONFIG"; then
|
||||
_pkg_min_version=m4_default([$1], [0.9.0])
|
||||
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
PKG_CONFIG=""
|
||||
fi
|
||||
fi[]dnl
|
||||
])dnl PKG_PROG_PKG_CONFIG
|
||||
|
||||
PKG_CHECK_MODULES(OPENSSL, [libssl >= 0.9.8 libcrypto >= 0.9.8], [
|
||||
with_openssl=yes
|
||||
AC_DEFINE([HAVE_LIBSSL], [1],
|
||||
[Build SSL support])
|
||||
], [ with_openssl=no ])
|
||||
|
||||
AC_CACHE_CHECK([whether $CC accepts PIE flags], [ap_cv_cc_pie], [
|
||||
save_CFLAGS=$CFLAGS
|
||||
save_LDFLAGS=$LDFLAGS
|
||||
CFLAGS="$CFLAGS -fPIE"
|
||||
LDFLAGS="$LDFLAGS -pie"
|
||||
AC_RUN_IFELSE([AC_LANG_SOURCE([[static int foo[30000]; int main () { return 0; }]])],
|
||||
[ap_cv_cc_pie=yes],
|
||||
[ap_cv_cc_pie=no],
|
||||
[ap_cv_cc_pie=yes]
|
||||
)
|
||||
CFLAGS=$save_CFLAGS
|
||||
LDFLAGS=$save_LDFLAGS
|
||||
])
|
||||
if test "$ap_cv_cc_pie" = "yes"; then
|
||||
CFLAGS="$CFLAGS -fPIE"
|
||||
LDFLAGS="$LDFLAGS -pie"
|
||||
enable_pie=yes
|
||||
fi
|
||||
|
||||
|
||||
AC_CACHE_CHECK([whether $CC accepts hardening flags], [ap_cv_cc_hardening], [
|
||||
save_CFLAGS=$CFLAGS
|
||||
save_LDFLAGS=$LDFLAGS
|
||||
CFLAGS="$CFLAGS -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,-z,separate-code"
|
||||
AC_RUN_IFELSE([AC_LANG_SOURCE([[static int foo[30000]; int main () { return 0; }]])],
|
||||
[ap_cv_cc_hardening=yes],
|
||||
[ap_cv_cc_hardening=no],
|
||||
[ap_cv_cc_hardening=yes]
|
||||
)
|
||||
CFLAGS=$save_CFLAGS
|
||||
])
|
||||
if test "$ap_cv_cc_hardening" = "yes"; then
|
||||
CFLAGS="$CFLAGS -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,-z,separate-code"
|
||||
enable_cc_hardening=yes
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([whether $CC accepts some warning flags], [ap_cv_cc_warnings], [
|
||||
save_CFLAGS=$CFLAGS
|
||||
save_LDFLAGS=$LDFLAGS
|
||||
CFLAGS="$CFLAGS -Wformat-overflow=2 -Wformat-truncation=2 -Wtrampolines -Warray-bounds=2 -Wimplicit-fallthrough=3 -Wtraditional-conversion -Wshift-overflow=2 -Wstringop-overflow=4 -Wlogical-op -Wduplicated-cond -Wduplicated-branches -Wformat-signedness -Wstack-usage=1000000 -Wcast-align=strict"
|
||||
AC_RUN_IFELSE([AC_LANG_SOURCE([[static int foo[30000]; int main () { return 0; }]])],
|
||||
[ap_cv_cc_warnings=yes],
|
||||
[ap_cv_cc_warnings=no],
|
||||
[ap_cv_cc_warnings=yes]
|
||||
)
|
||||
CFLAGS=$save_CFLAGS
|
||||
])
|
||||
if test "$ap_cv_cc_warnings" = "yes"; then
|
||||
CFLAGS="$CFLAGS -Wformat-overflow=2 -Wformat-truncation=2 -Wtrampolines -Warray-bounds=2 -Wimplicit-fallthrough=3 -Wtraditional-conversion -Wshift-overflow=2 -Wstringop-overflow=4 -Wlogical-op -Wduplicated-cond -Wduplicated-branches -Wformat-signedness -Wstack-usage=1000000 -Wcast-align=strict"
|
||||
enable_cc_warnings=yes
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([whether $CC accepts some supplementary warning flags], [ap_cv_cc_warnings2], [
|
||||
save_CFLAGS=$CFLAGS
|
||||
save_LDFLAGS=$LDFLAGS
|
||||
CFLAGS="$CFLAGS -Wformat=2 -Wformat-security -Wnull-dereference -Wstack-protector -Walloca -Wvla -Wcast-qual -Wconversion -Wshadow -Wstrict-overflow=4 -Wstrict-prototypes -Wswitch-default -Wswitch-enum"
|
||||
AC_RUN_IFELSE([AC_LANG_SOURCE([[static int foo[30000]; int main () { return 0; }]])],
|
||||
[ap_cv_cc_warnings2=yes],
|
||||
[ap_cv_cc_warnings2=no],
|
||||
[ap_cv_cc_warnings2=yes]
|
||||
)
|
||||
CFLAGS=$save_CFLAGS
|
||||
])
|
||||
if test "$ap_cv_cc_warnings2" = "yes"; then
|
||||
CFLAGS="$CFLAGS -Wformat=2 -Wformat-security -Wnull-dereference -Wstack-protector -Walloca -Wvla -Wcast-qual -Wconversion -Wshadow -Wstrict-overflow=4 -Wstrict-prototypes -Wswitch-default -Wswitch-enum"
|
||||
enable_cc_warnings2=yes
|
||||
fi
|
||||
|
||||
|
||||
|
||||
AC_CACHE_CHECK([whether $CC accepts -Warith-conversion flag], [ap_cv_cc_warith], [
|
||||
save_CFLAGS=$CFLAGS
|
||||
save_LDFLAGS=$LDFLAGS
|
||||
CFLAGS="$CFLAGS -Warith-conversion"
|
||||
AC_RUN_IFELSE([AC_LANG_SOURCE([[static int foo[30000]; int main () { return 0; }]])],
|
||||
[ap_cv_cc_warith=yes],
|
||||
[ap_cv_cc_warith=no],
|
||||
[ap_cv_cc_warith=yes]
|
||||
)
|
||||
CFLAGS=$save_CFLAGS
|
||||
])
|
||||
if test "$ap_cv_cc_warith" = "yes"; then
|
||||
CFLAGS="$CFLAGS -Warith-conversion"
|
||||
enable_warith_conversion=yes
|
||||
fi
|
||||
|
||||
|
||||
PKG_CHECK_MODULES([CHECK], [check >= 0.9.6], [enable_tests=yes], [enable_tests=no])
|
||||
AM_CONDITIONAL([COND_WANT_TESTS], [test "$enable_tests" = yes])
|
||||
|
||||
AC_CHECK_FUNC(backtrace_symbols_fd, [
|
||||
AC_DEFINE(HAVE_BACKTRACE, [], [Use glibc backtrace on fatal()])
|
||||
LDFLAGS="-rdynamic $LDFLAGS"
|
||||
backtrace="(with backtrace)"
|
||||
])
|
||||
|
||||
|
||||
AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
echo OPENSSL: $with_openssl
|
||||
echo PIE: $enable_pie
|
||||
echo TESTS: $enable_tests
|
|
@ -0,0 +1,63 @@
|
|||
AC_INIT(src/bip.c)
|
||||
AM_CONFIG_HEADER(src/config.h)
|
||||
AM_INIT_AUTOMAKE(bip,0.8.0)
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
|
||||
AM_PROG_LEX
|
||||
AC_PROG_YACC
|
||||
|
||||
AC_ARG_ENABLE(debug,
|
||||
[ --enable-debug Turn on debugging],
|
||||
[ enable_debug=$enableval ],
|
||||
[ enable_debug=no ])
|
||||
|
||||
AM_CONDITIONAL(DEBUG, test x$enable_debug = xyes)
|
||||
|
||||
case $enable_debug in
|
||||
yes)
|
||||
CFLAGS="-O0 -g -W -Wall"
|
||||
;;
|
||||
no)
|
||||
CFLAGS="-O2 -W -Wall"
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR(bad value ${enable_debug} for --enable-debug)
|
||||
esac
|
||||
|
||||
backtrace=
|
||||
if test x$enable_debug = xyes ; then
|
||||
AC_CHECK_FUNC(backtrace_symbols_fd, [
|
||||
AC_DEFINE(HAVE_BACKTRACE, [], [Use Glibcs backtrace function on fatal()])
|
||||
LDFLAGS="-rdynamic $LDFLAGS"
|
||||
backtrace="(with backtrace)"
|
||||
])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(oidentd,
|
||||
[ --enable-oidentd Enable oidentd support (bip overwrites ~/.oidentd.conf with this on!)],
|
||||
enable_oidentd=yes
|
||||
AC_DEFINE([HAVE_OIDENTD], [], [Enable oidentd.conf management support]),
|
||||
[enable_oidentd=no]
|
||||
)
|
||||
|
||||
AM_CONDITIONAL(OIDENTD, test x$enable_identd = xyes)
|
||||
|
||||
AC_ARG_ENABLE(openssl,
|
||||
[ --disable-openssl Drop OpenSSL support],
|
||||
[ enable_openssl=$enableval ],
|
||||
[ enable_openssl=yes ])
|
||||
|
||||
if test "x$enable_openssl" = "xyes" ; then
|
||||
AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [
|
||||
AC_MSG_ERROR([library 'crypto' is required for OpenSSL support])
|
||||
], -lcrypto)
|
||||
AC_CHECK_LIB(ssl, SSL_read, [], [
|
||||
AC_MSG_ERROR([library 'ssl' is required for OpenSSL support])
|
||||
])
|
||||
fi
|
||||
AC_OUTPUT(Makefile src/Makefile samples/Makefile)
|
||||
|
||||
echo OPENSSL: $enable_openssl
|
||||
echo DEBUG: $enable_debug $backtrace
|
||||
echo OIDENTD: $enable_oidentd
|
|
@ -0,0 +1,2 @@
|
|||
examplesdir = $(prefix)/share/doc/bip/examples/
|
||||
examples_DATA = bip.conf bip.vim
|
263
samples/bip.conf
263
samples/bip.conf
|
@ -1,56 +1,30 @@
|
|||
# bip default config file.
|
||||
# Thou shoult change thy password
|
||||
|
||||
# Default values are commented out.
|
||||
|
||||
# Listening IP address. This is the IP address bip will listen for incoming
|
||||
# client connections.
|
||||
#ip = "0.0.0.0";
|
||||
ip = "0.0.0.0";
|
||||
|
||||
# To connect a client to bip, try the port below, and
|
||||
# be sure to set the password to the value
|
||||
# specified in the network you want to connect to.
|
||||
# Port is 7778 by default.
|
||||
#port = 7778;
|
||||
# specified in the network you want to connect to.
|
||||
# Port is 6667 by default.
|
||||
port = 7778;
|
||||
|
||||
# If you set this to true, you'll only be able to connect to bip
|
||||
# with a SSL capable IRC client. Be sure to generate a certificate
|
||||
# for bip using scripts/bipgenconfig.
|
||||
#client_side_ssl = false;
|
||||
client_side_ssl = false;
|
||||
|
||||
# This is the file containing the SSL cert/key pair bip'll use to
|
||||
# serve SSL clients. If unset, it defaults to <bipdir>/bip.pem
|
||||
# Supply at least 2048-bit parameters, for example using openssl:
|
||||
# openssl dhparam -out dh.pem 2048;
|
||||
#client_side_ssl_pem = "<bipdir>/bip.pem";
|
||||
# serve SSL clients. If unset, it defaults to <biphome>/bip.pem
|
||||
#client_side_ssl_pem = "/path/to/pemfile";
|
||||
|
||||
# OpenSSL cipher lists used with SSL client connections.
|
||||
# If not set, OpenSSL default ciphers will be used. See OpenSSL ciphers
|
||||
# command. An example value: "ECDHE-RSA-AES128-GCM-SHA256".
|
||||
#client_side_ciphers = ;
|
||||
# Define where the pidfile should be stored. Defaults to <biphome>/bip.pid
|
||||
#pid_file="/var/run/bip/bip.pid";
|
||||
|
||||
# DH parameters bip'll use when serving SSL clients.
|
||||
# Supply at least 2048-bit parameters, for example using openssl:
|
||||
# openssl dhparam -out dh.pem 2048;
|
||||
#client_side_dh_param = "<bipdir>/dh.pem";
|
||||
|
||||
# Default OpenSSL cipher lists used with outgoing connections to IRC servers.
|
||||
# If not set, OpenSSL default ciphers will be used. See OpenSSL ciphers
|
||||
# command. An example value: "ECDHE-RSA-AES128-GCM-SHA256".
|
||||
# If not set, OpenSSL default ciphers will be used.
|
||||
#ssl_default_ciphers = ;
|
||||
|
||||
# Define where the pidfile should be stored. Defaults to <bipdir>/bip.pid.
|
||||
#pid_file="";
|
||||
|
||||
# Defaults to false, whether to write oidentd.conf files (see below).
|
||||
#write_oidentd = true;
|
||||
|
||||
# Defaults to <bipdir>/.oidentd.conf
|
||||
#oidentd_file="";
|
||||
|
||||
# Set to false and uncomment this line to disable logging and backlogging.
|
||||
#log = true;
|
||||
# Uncomment this line to disable logging and backlogging.
|
||||
#log = false
|
||||
|
||||
# Define bip's log level :
|
||||
# 0 : only fatal errors
|
||||
|
@ -58,83 +32,78 @@
|
|||
# 2 : add warnings
|
||||
# 3 : add info messages
|
||||
# 4 : add debug messages
|
||||
#log_level = 3;
|
||||
log_level = 3;
|
||||
|
||||
# This is where logs go. Channel and private messages will use that
|
||||
# configuration value as a prefix, and then log_format to determine
|
||||
# full log filename. Defaults to <bipdir>/logs.
|
||||
#log_root = "";
|
||||
# full log filename.
|
||||
#log_root = "/var/proxy/logs";
|
||||
|
||||
# Set to false and uncomment this line to disable bip's internal messages
|
||||
# logging. This is not recommended, a better option is to reduce log_level.
|
||||
#log_system = true;
|
||||
# Uncomment this line to disable bip's internal messages logging.
|
||||
# This is not recommended, a better option is to reduce log_level.
|
||||
#log_system = false;
|
||||
|
||||
# Log format allows you to make log filenames depend on the log line's
|
||||
# attributes. Here's a list :
|
||||
# %u -> username
|
||||
# %u -> user name
|
||||
# %n -> network name
|
||||
# %Y -> 4 digit year
|
||||
# %m -> 2 digit month
|
||||
# %d -> 2 digit day
|
||||
# %h -> 2 digit hour of the day
|
||||
# %c -> destination (#chan, nick, ...)
|
||||
# %c -> destination (#chan, privates, ...)
|
||||
#log_format = "%u/%n/%Y-%m/%c.%d.log";
|
||||
|
||||
# Sets the frequency (in seconds) of log syncing (real write to kernel)
|
||||
#log_sync_interval = 5;
|
||||
|
||||
# Sets the initial delay (in seconds) before a reconnection attempt.
|
||||
# The delay increases with the number of attempts:
|
||||
# delay = reconn_timer * number of attempts
|
||||
#reconn_timer = 30;
|
||||
|
||||
# Network definition, a name and server info
|
||||
#network {
|
||||
# name = "iiens";
|
||||
# server { host = "irc.iiens.net"; port = 6667; };
|
||||
#};
|
||||
network {
|
||||
name = "iiens";
|
||||
server { host = "irc.iiens.net"; port = 6667; };
|
||||
};
|
||||
|
||||
#network {
|
||||
# name = "oftc";
|
||||
# server { host = "irc.oftc.net"; port = 6667; };
|
||||
# server { host = "other.oftc.server"; port = 6667; };
|
||||
#};
|
||||
network {
|
||||
name = "oftc";
|
||||
server { host = "irc.oftc.net"; port = 6667; };
|
||||
#server { host = "other.oftc.server"; port = 6667; };
|
||||
};
|
||||
|
||||
# SSL network sample. SSL is per-network option, not per-server !
|
||||
#network {
|
||||
# name = "oftcs";
|
||||
# ssl = true;
|
||||
# server { host = "ircs.oftc.net"; port = 9999; };
|
||||
#};
|
||||
network {
|
||||
name = "oftcs";
|
||||
ssl = true;
|
||||
server { host = "ircs.oftc.net"; port = 9999; };
|
||||
};
|
||||
|
||||
# Configuration example with one user who connects to two irc networks
|
||||
# To use the multi-server feature:
|
||||
# - define the connections
|
||||
# - chose and setup a different login for each connection
|
||||
# on your irc client:
|
||||
# - Use the multi server feature of your client, the server being each time
|
||||
# - Use the multi server feature of your client, the server beeing each time
|
||||
# the server where bip is running. In your client setup server password to:
|
||||
# username:password:connectionname
|
||||
# - do not store the password in clear here, use the bipmkpw util to generate
|
||||
# a hash
|
||||
# a hash
|
||||
|
||||
# User structure is grouping information for a given user
|
||||
#user {
|
||||
# The name in bip of the user, required. This is used by bip only.
|
||||
#name = ;
|
||||
# This user's password (md5(md5("tata"))) with seed - generated by
|
||||
# bipmkpw, for example: "3880f2b39b3b9cb507b052b695d2680859bfc327".
|
||||
#password = ;
|
||||
user {
|
||||
# The name in bip of the user
|
||||
# This is used by bip only
|
||||
name = "bip4ever";
|
||||
# this user's password (md5(md5("tata"))) with seed - generated by
|
||||
# bipmkpw
|
||||
password = "3880f2b39b3b9cb507b052b695d2680859bfc327";
|
||||
|
||||
# Set this to true if you want this user to have admin privileges on
|
||||
# bip. User will be able to RELOAD bip and see all users' configuration
|
||||
# (except pass).
|
||||
#admin = false;
|
||||
# Set this to true if you want "bip4ever" to have admin privileges on
|
||||
# bip He'll be able to RELOAD bip and see all users' configuration
|
||||
# (except pass)
|
||||
admin = true;
|
||||
|
||||
# When bip_use_notice is true, bip will send internal messages like
|
||||
# disconnection notifications or /BIP commands replies as notices
|
||||
# instead of private messages. The default is false.
|
||||
#bip_use_notice = false;
|
||||
#bip_use_notice = true;
|
||||
|
||||
# SSL certificates checking mode for user:
|
||||
# - "none" to accept anything;
|
||||
|
@ -145,144 +114,108 @@
|
|||
# in the store below (you have to put in it every cert, CRL, up to the
|
||||
# root CA). You have to build your store manually, so you may prefer
|
||||
# using "basic" unless you're a crypto zealot...
|
||||
#ssl_check_mode = "none";
|
||||
ssl_check_mode = "none";
|
||||
|
||||
# Location of the user's store for server SSL certificate check
|
||||
# Location of the user's store for SSL certificate check
|
||||
# In "basic" mode, that must point to a single file with all trusted
|
||||
# certs concatenated together (the interactive "trust" appends to this
|
||||
# file).
|
||||
# In "ca" mode, it can be either:
|
||||
# - a directory of a standard openssl store; you must put PEM objects
|
||||
# (certificates, CRLs...) with .pem extension and run `c_rehash .' in it
|
||||
# - a certificate bundle file containing one or more certificates in PEM
|
||||
# format, enclosed in BEGIN CERTIFICATE / END CERTIFICATE lines
|
||||
# - unspecified: in this case, bip will attempt to use the default
|
||||
# certificate store of the OpenSSL it is built against. This is the default.
|
||||
#ssl_check_store = "";
|
||||
# In "ca" mode, it's a directory of a standard openssl store; you must
|
||||
# put PEM objects (certificates, CRLs...) with .pem extension and run
|
||||
# `c_rehash .' in it
|
||||
ssl_check_store = "/home/bip4ever/.bip/trustedcerts.txt";
|
||||
|
||||
# Some networks (OFTC at least) allow you to authenticate to nickserv
|
||||
# using client side certificates, see
|
||||
# http://www.oftc.net/oftc/NickServ/CertFP
|
||||
# This is where you put your user's certificate.
|
||||
# The default is not to use a certificate.
|
||||
#ssl_client_certfile = "";
|
||||
# ssl_client_certfile = "/home/bip4ever/.bip/bip4ever_client_auth.pem";
|
||||
|
||||
# These will be the default for each connections.
|
||||
#default_nick = ;
|
||||
#default_user = ;
|
||||
#default_realname = ;
|
||||
# These will be the default for each connections
|
||||
default_nick = "bip4ever";
|
||||
default_user = "bip4ever";
|
||||
default_realname = "bip4ever";
|
||||
|
||||
# Makes bip send the log of each channel and privates while
|
||||
# you were not connected to the proxy upon connection.
|
||||
# you were not connected to the proxy upon connection.
|
||||
#backlog = true; # enable backlog
|
||||
#backlog_lines = 10; # number of lines in backlog, 0 means no limit
|
||||
|
||||
# When true, backlog even lines already backlogged, do not reset backlog
|
||||
# when no client attached anymore.
|
||||
#backlog_always = false;
|
||||
|
||||
# "none", "time" or "datetime": disables time stamps, use time or datetime.
|
||||
#backlog_timestamp = "time";
|
||||
|
||||
# This parameter is deprecated, use backlog_timestamp instead.
|
||||
#backlog_no_timestamp = false; # implies backlog_timestamp = "none";
|
||||
backlog_lines = 10; # number of lines in backlog, 0 means
|
||||
# no limit
|
||||
backlog_always = true; # backlog even lines already backlogged
|
||||
# = do not reset backlog when no client
|
||||
# attached anymore
|
||||
#backlog_no_timestamp = false; # Disables time stamps if you find them
|
||||
# ugly.
|
||||
|
||||
# If blreset_on_talk talking on an irc network has the same effect of
|
||||
# issuing /bip blreset <current window>, meaning that stuffed logged
|
||||
# before the command won't be read back on backlog.
|
||||
# issuing /bip blreset, meaning that stuffed logged before the command
|
||||
# won't be read back on backlog
|
||||
#backlog_reset_on_talk = false;
|
||||
|
||||
# If you have backlog_reset_on_talk set to true, talking in a query
|
||||
# will reset the backlog for the query. Same goes for channel. With the
|
||||
# following option set to true, talking in a connection will reset the
|
||||
# whole connection. The backlog for the current network is reset.
|
||||
#backlog_reset_connection = false;
|
||||
|
||||
# If bl_msg_only is true, only channel and private messages will be
|
||||
# backlogged upon the reconnection of a client. Default is false, thus
|
||||
# joins, parts, quits, nick changes, topic changes, ... are backlogged.
|
||||
# joins, parts, quits, nick changes, topic changes, ... are backlogged
|
||||
#backlog_msg_only = false;
|
||||
|
||||
|
||||
# A user can have mutiple connections to irc networks.
|
||||
# define a connection:
|
||||
#connection {
|
||||
# used by bip only, required (for example: "oftc").
|
||||
#name = ;
|
||||
# which ircnet to connect to, required (for example: "oftc").
|
||||
#network = ;
|
||||
#log = false; # disable or enable logging and backlogging for
|
||||
# the current connection. Overrides global
|
||||
# (top-level) log parameter.
|
||||
connection {
|
||||
name = "iiens"; # used by bip only
|
||||
network = "iiens"; # which ircnet to connect to
|
||||
|
||||
# You can define ssl_check_mode here, if you want a different
|
||||
# behavior than the one defined in the parent level ('user' section).
|
||||
# behavior than the one defined in the parent user {}.
|
||||
#ssl_check_mode = "none";
|
||||
|
||||
# If you have multiple IP addresses, you can set the one you
|
||||
# want bip to use here. This options is totally useless to people who
|
||||
# only have one IP address.
|
||||
#vhost = "";
|
||||
# want bip to use here. See manpage for more information.
|
||||
#vhost = "192.168.10.6";
|
||||
|
||||
# When source_port is defined, bip will connect to the IRC
|
||||
# server from this port number. That means the IRC server will
|
||||
# see the socket coming from <your_ip>:source_port.
|
||||
#source_port = 10000;
|
||||
#source_port = "4567";
|
||||
|
||||
# These will be sent to the real server. Nick, user and realname are
|
||||
# required. Default values are defined at the parent level
|
||||
# (default_nick, default_user, default_realname).
|
||||
# these will be sent to the real server
|
||||
#nick = "othernick";
|
||||
#user = "otheruser";
|
||||
#realname = "otheruser";
|
||||
#password = "server password";
|
||||
|
||||
#You can specify this field more than once. BIP will send the text as is to the server.
|
||||
#on_connect_send = "PRIVMSG NickServ :IDENTIFY nspassword";
|
||||
|
||||
# You can connect with SASL on networks supporting it
|
||||
#sasl_username = "username";
|
||||
#sasl_password = "sikioure password";
|
||||
#sasl_mechanism = "PLAIN";
|
||||
#password = "serverpassword";
|
||||
|
||||
# Some options:
|
||||
#away_nick = "bip`away";
|
||||
# Away message to be set when no client is connected
|
||||
#no_client_away_msg = "Having life, knock again later";
|
||||
#follow_nick = false;
|
||||
#ignore_first_nick = false;
|
||||
|
||||
#autojoin_on_kick = true;
|
||||
#ignore_server_capab = true;
|
||||
#follow_nick = true;
|
||||
#ignore_first_nick = true;
|
||||
|
||||
# Autojoined channels:
|
||||
#channel { name = "#bip"; }; # name is required.
|
||||
|
||||
channel { name = "#bip"; };
|
||||
# Password protected channel
|
||||
#channel {
|
||||
# name = "#elite_UnDeRgR0uNd";
|
||||
# key = "sikiour";
|
||||
#};
|
||||
|
||||
#another channel
|
||||
#channel {
|
||||
# name = "#huge(28)_activity";
|
||||
channel {
|
||||
name = "#elite_UnDeRgR0uNd";
|
||||
key = "sikiour";
|
||||
};
|
||||
channel {
|
||||
name = "#huge(28)_activity";
|
||||
# disable backlogging of this channel.
|
||||
# backlog = false;
|
||||
#};
|
||||
#};
|
||||
backlog = false;
|
||||
};
|
||||
};
|
||||
|
||||
# another connection (optional)
|
||||
#connection {
|
||||
#name = "iiens"; # used by bip only
|
||||
#network = "iiens"; # which ircnet to connect to
|
||||
# another connection (optionnal)
|
||||
connection {
|
||||
name = "oftc"; # used by bip only
|
||||
network = "oftc"; # which ircnet to connect to
|
||||
|
||||
# Some options:
|
||||
#away_nick = "bip`away";
|
||||
#follow_nick = true;
|
||||
#ignore_first_nick = true;
|
||||
#on_connect_send = "PRIVMSG NickServ :IDENTIFY nspassword";
|
||||
|
||||
# Autojoined channels:
|
||||
#channel { name = "#bip"; };
|
||||
#};
|
||||
#};
|
||||
channel { name = "#bip"; };
|
||||
};
|
||||
};
|
||||
|
|
|
@ -53,19 +53,18 @@ syn region bipMain start=/\%^/ end=/\%$/
|
|||
|
||||
" Top level elements
|
||||
syn keyword bipKeyword contained nextgroup=bipBoolV client_side_ssl
|
||||
\ log log_system write_oidentd
|
||||
\ log log_system
|
||||
syn keyword bipKeyword contained nextgroup=bipStringV log_root
|
||||
\ log_format oidentd_file pid_file client_side_ssl_pem client_side_ciphers
|
||||
\ client_side_dh_param ssl_default_ciphers
|
||||
\ log_format pid_file client_side_ssl_pem
|
||||
syn keyword bipKeyword contained nextgroup=bipNumericV port log_level
|
||||
\ log_sync_interval reconn_timer
|
||||
\ log_sync_interval
|
||||
syn keyword bipKeyword contained nextgroup=bipIPV ip
|
||||
|
||||
" Network block (level 1)
|
||||
syn region bipNetwork contained matchgroup=Macro
|
||||
\ start=/network\s*{\s*/ end=/};/
|
||||
\ contains=bipNKeyword,bipServer,bipComment,bipEndError,bipWhite
|
||||
syn keyword bipNKeyword contained nextgroup=bipStringV name ciphers
|
||||
syn keyword bipNKeyword contained nextgroup=bipStringV name
|
||||
syn keyword bipNKeyword contained nextgroup=bipBoolV ssl
|
||||
|
||||
" User block (level 1)
|
||||
|
@ -74,25 +73,22 @@ syn region bipUser contained matchgroup=Macro start=/user\s*{\s*/
|
|||
\ contains=bipUKeyword,bipConnection,bipComment,bipEndError,bipWhite
|
||||
syn keyword bipUKeyword contained nextgroup=bipStringV password name
|
||||
\ default_nick default_user default_realname ssl_check_store
|
||||
\ ssl_check_mode ssl_client_certfile backlog_timestamp
|
||||
\ ssl_check_mode ssl_client_certfile
|
||||
syn keyword bipUKeyword contained nextgroup=bipNumericV backlog_lines
|
||||
syn keyword bipUKeyword contained nextgroup=bipBoolV admin
|
||||
\ backlog backlog_reset_on_talk
|
||||
" DEPRECATED \ always_backlog bl_msg_only blreset_on_talk
|
||||
\ backlog_no_timestamp backlog backlog_reset_on_talk
|
||||
\ backlog_msg_only backlog_always bip_use_notice
|
||||
\ backlog_reset_connection
|
||||
" DEPRECATED \ always_backlog bl_msg_only blreset_on_talk
|
||||
" DEPRECATED \ backlog_no_timestamp
|
||||
|
||||
" Connection block (level 2)
|
||||
syn region bipConnection contained matchgroup=Macro
|
||||
\ start=/connection\s*{\s*/ end=/};/
|
||||
\ contains=bipCoKeyword,bipChannel,bipComment,bipEndError,bipWhite
|
||||
syn keyword bipCoKeyword contained nextgroup=bipBoolV autojoin_on_kick
|
||||
\ follow_nick ignore_first_nick log ignore_server_capab
|
||||
syn keyword bipCoKeyword contained nextgroup=bipBoolV follow_nick
|
||||
\ ignore_first_nick
|
||||
syn keyword bipCoKeyword contained nextgroup=bipStringV name user nick
|
||||
\ network password vhost away_nick on_connect_send realname
|
||||
\ no_client_away_msg ssl_check_mode sasl_username sasl_password
|
||||
\ sasl_mechanism
|
||||
\ no_client_away_msg ssl_check_mode
|
||||
syn keyword bipCoKeyword contained nextgroup=bipNumericV source_port
|
||||
|
||||
" Channel elements (lvl 2)
|
||||
|
|
|
@ -2,82 +2,41 @@
|
|||
|
||||
set -e
|
||||
|
||||
if [ ! -d src ] || [ ! -f NEWS ] ; then
|
||||
if [ ! -d src ] ; then
|
||||
echo "Please run me in bip sources root." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
release_version="$1"
|
||||
release_name="$2"
|
||||
: ${MAKEOPTS:=-j -l4}
|
||||
release="$1"
|
||||
|
||||
set_version() {
|
||||
local release_version
|
||||
release_version="${1}"
|
||||
sed -i -e '/^AC_INIT/s/\(,\[\)[^]]*/\1'${release_version}'/' configure.ac
|
||||
}
|
||||
|
||||
get_version() {
|
||||
grep -e '^AC_INIT' configure.ac | cut -d [ -f 3 | cut -d ] -f 1
|
||||
}
|
||||
|
||||
make_distcheck() {
|
||||
# prepare sources
|
||||
autoreconf -i -Wall
|
||||
# Create makefile, use all possible options
|
||||
./configure
|
||||
# run distcheck
|
||||
if ! make ${MAKEOPTS} distcheck; then
|
||||
echo "'make distcheck' fails, please try again." >&2
|
||||
return 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
}
|
||||
|
||||
git log > ChangeLog
|
||||
if [ -n "$release_version" ]; then
|
||||
# Don't forget to update NEWS file before a release
|
||||
expected="$(date --rfc-3339=date) (${release_version})"
|
||||
if [ -n "${release_name}" ]; then
|
||||
expected="${expected} \"${release_name}\""
|
||||
fi
|
||||
head -n 1 NEWS | grep -q "^${expected}$" || (echo "NEWS file doesn't match the expected format (${expected})" && exit 1)
|
||||
|
||||
set_version "${release_version}"
|
||||
make_distcheck || exit 1
|
||||
|
||||
git commit -a --gpg-sign -m "Update version and ChangeLog for bip-${release_version} release."
|
||||
TAG_COMMENT="Release ${release_version}"
|
||||
if [ -n "${release_name}" ]; then
|
||||
TAG_COMMENT="${TAG_COMMENT} '${release_name}'"
|
||||
fi
|
||||
git tag --sign -m "${TAG_COMMENT}" release-${release_version}
|
||||
|
||||
set_version "${release_version}-git"
|
||||
git commit -a --gpg-sign -m "Add -git to version string."
|
||||
|
||||
echo "See bip-${release_version}.tar.gz"
|
||||
if [ -n "$release" ]
|
||||
then
|
||||
git log > ChangeLog
|
||||
echo '#define BIP_VERSION "'$release'"' > src/version.h
|
||||
git commit -a -m "Update src/version.h and Changelog for release."
|
||||
git tag release-$release
|
||||
prefix=bip-$release
|
||||
else
|
||||
make_distcheck || exit 1
|
||||
|
||||
tarname=bip-$(get_version)
|
||||
prefix=bip-$(date +%Y%m%d)
|
||||
|
||||
rm -rf "${tarname}" "${prefix}"
|
||||
tar -xzf "${tarname}".tar.gz
|
||||
rm -rf "${tarname}".tar.gz
|
||||
|
||||
mv "${tarname}" "${prefix}"
|
||||
tar -czf "${prefix}".tar.gz "${prefix}"
|
||||
rm -rf "${prefix}"
|
||||
|
||||
# Revert the ChangeLog.
|
||||
git checkout HEAD -- ChangeLog
|
||||
|
||||
echo "See ${prefix}.tar.gz"
|
||||
prefix=bip-$(date +%y%m%d)
|
||||
fi
|
||||
|
||||
# cleanup
|
||||
git clean -d -i -e "bip-*.tar.gz"
|
||||
olddir=$(pwd)
|
||||
tmpdir=$(mktemp -d /var/tmp/bip-XXXXX)
|
||||
git-archive --format=tar --prefix=$prefix/ HEAD > $tmpdir/$prefix.tar
|
||||
cd $tmpdir
|
||||
tar xf $prefix.tar
|
||||
cd $prefix
|
||||
./bootstrap
|
||||
rm -rf autom4te.cache
|
||||
cd ..
|
||||
tar czf $olddir/../$prefix.tar.gz $prefix
|
||||
cd $olddir
|
||||
rm -rf $tmpdir
|
||||
echo "See ../$prefix.tar.gz"
|
||||
|
||||
if [ -n "$release" ]
|
||||
then
|
||||
echo '#define BIP_VERSION "'$release'-git"' > src/version.h
|
||||
git commit -a -m "Add -git to version string."
|
||||
fi
|
||||
|
||||
|
|
|
@ -119,16 +119,15 @@ my %optdesc = (
|
|||
'optional' => 1,
|
||||
'depends' => 'log', 'depval' => 'true',
|
||||
'desc' => 'Do you want to activate backlog {play back logs} system ?' },
|
||||
'backlog_lines' => { 'type' => 'i', 'adv' => 0, 'default' => '0',
|
||||
'backlog_lines' => { 'type' => 'i', 'adv' => 0, 'default' => '10',
|
||||
'optional' => 1,
|
||||
'depends' => 'backlog', 'depval' => 'true',
|
||||
'desc' => 'How much line do you want bip to play back upon client connect' .
|
||||
" {0 => replay everything since backlog's last reset} ?" },
|
||||
'backlog_timestamp' => { 'type' => 's', 'adv' => 0,
|
||||
'backlog_no_timestamp' => { 'type' => 'b', 'adv' => 0,
|
||||
'optional' => 1,
|
||||
'default' => 'time', 'depends' => 'backlog', 'depval' => 'true',
|
||||
'desc' => 'Use time, datetime or disable prefix in backlog',
|
||||
'values' => ['none', 'time', 'datetime'] },
|
||||
'default' => 'false', 'depends' => 'backlog', 'depval' => 'true',
|
||||
'desc' => 'Disable timestamp in backlog ?' },
|
||||
'backlog_msg_only' => { 'type' => 'b', 'adv' => 0,
|
||||
'optional' => 1,
|
||||
'default' => 'false', 'depends' => 'backlog', 'depval' => 'true',
|
||||
|
@ -249,7 +248,7 @@ my %optorder = (
|
|||
undef,
|
||||
'backlog' ,
|
||||
'backlog_lines' ,
|
||||
'backlog_timestamp' ,
|
||||
'backlog_no_timestamp' ,
|
||||
'backlog_msg_only' ,
|
||||
'backlog_always' ,
|
||||
'backlog_reset_on_talk' ,
|
||||
|
@ -314,10 +313,6 @@ sub askOpt {
|
|||
} else {
|
||||
$o = askval($e->{'desc'}, $sel, ($mayempty && ($opt ne 1 ||
|
||||
$e->{'type'} eq 'i' ? 1 : undef)), 1);
|
||||
if (defined $e->{'values'} && !grep(/^$o$/, @{$e->{'values'}})) {
|
||||
print("The allowed values are '@{[ join '\', \'', @{$e->{'values'}} ]}'\n");
|
||||
next;
|
||||
}
|
||||
}
|
||||
if ($o eq undef && $opt eq 0) {
|
||||
print("This value is mandatory, please enter a value\n");
|
||||
|
@ -467,11 +462,6 @@ sub loadConfig {
|
|||
$_->{'server'} = [ values %{$_->{'server'}} ];
|
||||
}
|
||||
foreach my $tcu (@{$cf{'users'}}) {
|
||||
my $backlog_no_timestamp = delete($tcu->{'backlog_no_timestamp'});
|
||||
if (defined $backlog_no_timestamp) {
|
||||
grep(/^$backlog_no_timestamp$/, ('false', 'true')) || return "Invalid value for backlog_no_timestamp: '$backlog_no_timestamp'";
|
||||
$tcu->{'backlog_timestamp'} = $backlog_no_timestamp == 'false' ? 'time' : 'none';
|
||||
}
|
||||
$tcu->{'connection'} = [ values %{$tcu->{'connection'}} ];
|
||||
foreach my $tcc (@{$tcu->{'connection'}}) {
|
||||
$tcc->{'channel'} = [ values %{$tcc->{'channel'}} ];
|
||||
|
|
|
@ -1,39 +1,10 @@
|
|||
noinst_LIBRARIES = libbip.a libbiplex.a
|
||||
|
||||
libbiplex_a_SOURCES = \
|
||||
conf.y lex.l
|
||||
|
||||
# Not adding AM_CFLAGS here, because many debian flex releases generate code
|
||||
# that compares signed and unsigned integers. It looks like this issue is
|
||||
# fixed by flex 2.6.5 which is unreleased.
|
||||
libbiplex_a_CFLAGS = $(OPENSSL_CFLAGS)
|
||||
|
||||
libbip_a_SOURCES = \
|
||||
bip.c bip.h \
|
||||
connection.c connection.h \
|
||||
defaults.h \
|
||||
irc.c irc.h \
|
||||
line.c line.h \
|
||||
log.c log.h \
|
||||
md5.c md5.h \
|
||||
path_util.c path_util.h \
|
||||
tuple.h \
|
||||
util.c util.h \
|
||||
utils/base64.c utils/base64.h
|
||||
|
||||
libbip_a_CFLAGS = ${OPENSSL_CFLAGS} $(AM_CFLAGS)
|
||||
|
||||
bin_PROGRAMS = bip bipmkpw
|
||||
|
||||
bip_SOURCES = bip_main.c
|
||||
bip_CFLAGS = ${OPENSSL_CFLAGS} $(AM_CFLAGS)
|
||||
bip_LDADD = libbip.a libbiplex.a ${OPENSSL_LIBS}
|
||||
|
||||
bip_SOURCES = conf.y lex.l bip.c connection.c irc.c line.c log.c md5.c util.c
|
||||
bipmkpw_SOURCES = bipmkpw.c md5.c util.c
|
||||
bipmkpw_CFLAGS = ${OPENSSL_CFLAGS} $(AM_CFLAGS)
|
||||
bipmkpw_LDADD = libbip.a libbiplex.a $(OPENSSL_LIBS)
|
||||
|
||||
AM_YFLAGS= -d
|
||||
BUILT_SOURCES = conf.c conf.h lex.c
|
||||
|
||||
AM_CFLAGS=-Wall -Wextra -Werror -Wundef -Wpedantic
|
||||
if DEBUG
|
||||
AM_CFLAGS+=-Wall -g
|
||||
AM_LDFLAGS+=-g
|
||||
else
|
||||
AM_CFLAGS+=-Wall
|
||||
endif
|
||||
|
|
363
src/bip_main.c
363
src/bip_main.c
|
@ -1,363 +0,0 @@
|
|||
/*
|
||||
* $Id: bip.c,v 1.39 2005/04/21 06:58:50 nohar Exp $
|
||||
*
|
||||
* This file is part of the bip project
|
||||
* Copyright (C) 2004,2005 Arnaud Cornet
|
||||
* Copyright (C) 2004,2005,2022 Loïc Gomez
|
||||
*
|
||||
* 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 the file "COPYING" for the exact licensing terms.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include "irc.h"
|
||||
#include "conf.h"
|
||||
#include "path_util.h"
|
||||
#include "tuple.h"
|
||||
#include "log.h"
|
||||
#include "bip.h"
|
||||
#include "line.h"
|
||||
#include "defaults.h"
|
||||
|
||||
#define S_CONF "bip.conf"
|
||||
#define OIDENTD_FILENAME ".oidentd.conf"
|
||||
|
||||
extern int sighup;
|
||||
extern char *conf_log_root;
|
||||
extern char *conf_log_format;
|
||||
extern int conf_log_level;
|
||||
extern char *conf_ip;
|
||||
extern unsigned short conf_port;
|
||||
extern int conf_css;
|
||||
#ifdef HAVE_LIBSSL
|
||||
extern char *conf_ssl_certfile;
|
||||
extern char *conf_client_ciphers;
|
||||
extern char *conf_client_dh_file;
|
||||
extern char *conf_server_default_ciphers;
|
||||
#endif
|
||||
extern int conf_daemonize;
|
||||
extern char *conf_pid_file;
|
||||
extern char *conf_biphome;
|
||||
extern int conf_reconn_timer;
|
||||
|
||||
/* log options, for sure the trickiest :) */
|
||||
extern int conf_log;
|
||||
extern int conf_log_system;
|
||||
extern int conf_log_sync_interval;
|
||||
extern bip_t *_bip;
|
||||
extern FILE *conf_global_log_file;
|
||||
|
||||
void reload_config(int i);
|
||||
void bad_quit(int i);
|
||||
void check_rlimits(void);
|
||||
void rlimit_cpu_reached(int i);
|
||||
void rlimit_bigfile_reached(int i);
|
||||
void conf_die(bip_t *bip, char *fmt, ...);
|
||||
int fireup(bip_t *bip, FILE *conf);
|
||||
int check_ssl_files(int failmode);
|
||||
int do_pid_stuff(void);
|
||||
|
||||
static void usage(char *name)
|
||||
{
|
||||
printf("Usage: %s [-f config_file] [-h] [-n]\n"
|
||||
" -f config_file: Use config_file as the configuration file\n"
|
||||
" If no config file is given %s will try to open ~/.bip/" S_CONF
|
||||
"\n"
|
||||
" -n: Don't daemonize, log in stderr\n"
|
||||
" -s: Bip HOME, default parent directory for client certificate,\n"
|
||||
" configuration, logs, pid, oidentd\n"
|
||||
" -v: Print version and exit\n"
|
||||
" -h: This help\n",
|
||||
name, name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void version(void)
|
||||
{
|
||||
printf("Bip IRC Proxy - " PACKAGE_VERSION
|
||||
"\n"
|
||||
"Copyright © Arnaud Cornet and Loïc Gomez (2004 - 2008)\n"
|
||||
"Distributed under the GNU General Public License Version 2\n");
|
||||
}
|
||||
|
||||
static void log_file_setup(void)
|
||||
{
|
||||
char buf[4096];
|
||||
|
||||
if (conf_log_system && conf_daemonize) {
|
||||
if (conf_global_log_file && conf_global_log_file != stderr)
|
||||
fclose(conf_global_log_file);
|
||||
snprintf(buf, (size_t)4095, "%s/bip.log", conf_log_root);
|
||||
FILE *f = fopen(buf, "a");
|
||||
if (!f)
|
||||
fatal("Can't open %s: %s", buf, strerror(errno));
|
||||
conf_global_log_file = f;
|
||||
} else {
|
||||
conf_global_log_file = stderr;
|
||||
}
|
||||
}
|
||||
|
||||
static pid_t daemonize(void)
|
||||
{
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
fatal("Fork failed");
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
if (setsid() < 0)
|
||||
fatal("setsid() failed");
|
||||
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
fatal("Fork failed");
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
close(0);
|
||||
close(1);
|
||||
close(2);
|
||||
/* This better be the very last action since fatal makes use of
|
||||
* conf_global_log_file */
|
||||
return getpid();
|
||||
}
|
||||
|
||||
int check_ssl_files(int failmode)
|
||||
{
|
||||
int e;
|
||||
struct stat fs;
|
||||
|
||||
if (!conf_ssl_certfile) {
|
||||
conf_ssl_certfile = default_path(
|
||||
conf_biphome, "bip.pem", "SSL certificate");
|
||||
}
|
||||
|
||||
if (failmode == HARD_FAIL)
|
||||
assert_path_exists(conf_ssl_certfile);
|
||||
else if (!check_path_exists(conf_ssl_certfile))
|
||||
return 0;
|
||||
|
||||
e = stat(conf_ssl_certfile, &fs);
|
||||
if (e)
|
||||
mylog(LOG_WARN,
|
||||
"Unable to check PEM file, stat(%s): %s",
|
||||
conf_ssl_certfile, strerror(errno));
|
||||
else if ((fs.st_mode & S_IROTH) | (fs.st_mode & S_IWOTH))
|
||||
mylog(LOG_ERROR,
|
||||
"PEM file %s should not be world "
|
||||
"readable / writable. Please fix the modes.",
|
||||
conf_ssl_certfile);
|
||||
|
||||
if (conf_client_dh_file) {
|
||||
if (failmode == HARD_FAIL) {
|
||||
assert_path_exists(conf_client_dh_file);
|
||||
} else if (!check_path_exists(conf_client_dh_file)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* all is well */
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
FILE *conf = NULL;
|
||||
char *confpath = NULL;
|
||||
int ch;
|
||||
int r, fd;
|
||||
char buf[30];
|
||||
bip_t bip;
|
||||
|
||||
bip_init(&bip);
|
||||
_bip = &bip;
|
||||
|
||||
conf_ip = bip_strdup("0.0.0.0");
|
||||
conf_port = 7778;
|
||||
conf_css = 0;
|
||||
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
signal(SIGHUP, reload_config);
|
||||
signal(SIGINT, bad_quit);
|
||||
signal(SIGQUIT, bad_quit);
|
||||
signal(SIGTERM, bad_quit);
|
||||
signal(SIGXFSZ, rlimit_bigfile_reached);
|
||||
signal(SIGXCPU, rlimit_cpu_reached);
|
||||
|
||||
conf_log_root = NULL;
|
||||
conf_log_format = bip_strdup(DEFAULT_LOG_FORMAT);
|
||||
conf_log_level = DEFAULT_LOG_LEVEL;
|
||||
conf_reconn_timer = DEFAULT_RECONN_TIMER;
|
||||
conf_daemonize = 1;
|
||||
conf_global_log_file = stderr;
|
||||
conf_pid_file = NULL;
|
||||
#ifdef HAVE_LIBSSL
|
||||
conf_ssl_certfile = NULL;
|
||||
conf_client_ciphers = NULL;
|
||||
conf_server_default_ciphers = NULL;
|
||||
conf_client_dh_file = NULL;
|
||||
#endif
|
||||
|
||||
while ((ch = getopt(argc, argv, "hvnf:s:")) != -1) {
|
||||
switch (ch) {
|
||||
case 'f':
|
||||
confpath = bip_strdup(optarg);
|
||||
break;
|
||||
case 'n':
|
||||
conf_daemonize = 0;
|
||||
break;
|
||||
case 's':
|
||||
conf_biphome = bip_strdup(optarg);
|
||||
break;
|
||||
case 'v':
|
||||
version();
|
||||
exit(0);
|
||||
break;
|
||||
default:
|
||||
version();
|
||||
usage(argv[0]);
|
||||
}
|
||||
}
|
||||
|
||||
umask(0027);
|
||||
|
||||
check_rlimits();
|
||||
|
||||
char *home = NULL; /* oidentd path searching ignores conf_biphome */
|
||||
home = getenv("HOME");
|
||||
if (!home && !conf_biphome) {
|
||||
conf_die(&bip,
|
||||
"no value for environment variable $HOME,"
|
||||
"use '-s' parameter");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!conf_biphome) {
|
||||
conf_biphome = bip_malloc(strlen(home) + strlen("/.bip") + 1);
|
||||
strcpy(conf_biphome, home);
|
||||
strcat(conf_biphome, "/.bip");
|
||||
}
|
||||
|
||||
if (!bip.oidentdpath) {
|
||||
bip.oidentdpath = bip_malloc(strlen(conf_biphome) + 1
|
||||
+ strlen(OIDENTD_FILENAME) + 1);
|
||||
strcpy(bip.oidentdpath, conf_biphome);
|
||||
strcat(bip.oidentdpath, "/");
|
||||
strcat(bip.oidentdpath, OIDENTD_FILENAME);
|
||||
}
|
||||
|
||||
if (!confpath) {
|
||||
confpath = bip_malloc(strlen(conf_biphome) + 1 + strlen(S_CONF)
|
||||
+ 1);
|
||||
strcpy(confpath, conf_biphome);
|
||||
strcat(confpath, "/");
|
||||
strcat(confpath, S_CONF);
|
||||
}
|
||||
conf = fopen(confpath, "r");
|
||||
if (!conf)
|
||||
fatal("config file not found (%s)", confpath);
|
||||
|
||||
r = fireup(&bip, conf);
|
||||
fclose(conf);
|
||||
if (!r)
|
||||
fatal("Not starting: error in config file.");
|
||||
|
||||
if (!conf_log_root) {
|
||||
char *ap = "/logs";
|
||||
conf_log_root =
|
||||
bip_malloc(strlen(conf_biphome) + strlen(ap) + 1);
|
||||
strcpy(conf_log_root, conf_biphome);
|
||||
strcat(conf_log_root, ap);
|
||||
mylog(LOG_INFO, "Default log root: %s", conf_log_root);
|
||||
}
|
||||
if (!conf_pid_file) {
|
||||
char *pid = "/bip.pid";
|
||||
conf_pid_file =
|
||||
bip_malloc(strlen(conf_biphome) + strlen(pid) + 1);
|
||||
strcpy(conf_pid_file, conf_biphome);
|
||||
strcat(conf_pid_file, pid);
|
||||
mylog(LOG_INFO, "Default pid file: %s", conf_pid_file);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBSSL
|
||||
if (conf_css) {
|
||||
check_ssl_files(HARD_FAIL);
|
||||
}
|
||||
#endif
|
||||
|
||||
check_dir(conf_log_root, 1);
|
||||
fd = do_pid_stuff();
|
||||
pid_t pid = 0;
|
||||
|
||||
log_file_setup();
|
||||
if (conf_daemonize)
|
||||
pid = daemonize();
|
||||
else
|
||||
pid = getpid();
|
||||
snprintf(buf, (size_t)29, "%lu\n", (unsigned long int)pid);
|
||||
ssize_t written;
|
||||
written = write(fd, buf, strlen(buf));
|
||||
if (written <= 0)
|
||||
mylog(LOG_ERROR, "Could not write to PID file");
|
||||
close(fd);
|
||||
|
||||
bip.listener = listen_new(conf_ip, conf_port, conf_css);
|
||||
if (!bip.listener || bip.listener->connected == CONN_ERROR)
|
||||
fatal("Could not create listening socket");
|
||||
|
||||
for (;;) {
|
||||
irc_main(&bip);
|
||||
|
||||
sighup = 0;
|
||||
|
||||
conf = fopen(confpath, "r");
|
||||
if (!conf)
|
||||
fatal("%s config file not found", confpath);
|
||||
fireup(&bip, conf);
|
||||
fclose(conf);
|
||||
|
||||
/* re-open to allow logfile rotate */
|
||||
log_file_setup();
|
||||
|
||||
#ifdef HAVE_LIBSSL
|
||||
/*
|
||||
* reload SSL context if server-side SSL is enabled and SSL files
|
||||
* seem accessible.
|
||||
*/
|
||||
if (conf_css) {
|
||||
if (check_ssl_files(SOFT_FAIL)) {
|
||||
if (set_ssl_context(SSLCTX_FORCE_UPDATE) == 1)
|
||||
mylog(LOG_DEBUG, "SSL context has been updated");
|
||||
else
|
||||
mylog(LOG_DEBUG, "SSL context has not been updated");
|
||||
} else {
|
||||
mylog(LOG_ERROR, "Unable to update SSL context, "
|
||||
"file checks failed");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return 1;
|
||||
}
|
|
@ -2,8 +2,7 @@
|
|||
* $Id$
|
||||
*
|
||||
* This file is part of the bip project
|
||||
* Copyright (C) 2004,2005 Arnaud Cornet
|
||||
* Copyright (C) 2004,2005,2022 Loïc Gomez
|
||||
* Copyright (C) 2004 2005 Arnaud Cornet and Loïc Gomez
|
||||
*
|
||||
* 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
|
||||
|
@ -23,66 +22,48 @@
|
|||
#include "util.h"
|
||||
#include "md5.h"
|
||||
|
||||
extern int conf_log_level;
|
||||
extern FILE *conf_global_log_file;
|
||||
extern int conf_log_system;
|
||||
|
||||
void bipmkpw_fatal(char *msg, char *err)
|
||||
{
|
||||
fprintf(stderr, "%s: %s\n", msg, err);
|
||||
exit(1);
|
||||
}
|
||||
int conf_log_level;
|
||||
FILE *conf_global_log_file;
|
||||
int conf_log_system;
|
||||
|
||||
void readpass(char *buffer, int buflen)
|
||||
{
|
||||
int ttyfd = open("/dev/tty", O_RDWR);
|
||||
if (ttyfd == -1)
|
||||
bipmkpw_fatal("Unable to open tty", strerror(errno));
|
||||
if (ttyfd == -1) {
|
||||
fprintf(stderr, "Unable to open tty: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
struct termios tt, ttback;
|
||||
memset(&ttback, 0, sizeof(ttback));
|
||||
if (tcgetattr(ttyfd, &ttback) < 0)
|
||||
bipmkpw_fatal("tcgetattr failed", strerror(errno));
|
||||
if (tcgetattr(ttyfd, &ttback) < 0) {
|
||||
fprintf(stderr, "tcgetattr failed: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
memcpy(&tt, &ttback, sizeof(ttback));
|
||||
// unsigned conversion from ‘int’ to ‘tcflag_t’ {aka ‘unsigned int’} changes
|
||||
// value from ‘-11’ to ‘4294967285’
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
tt.c_lflag &= ~(ICANON | ECHO);
|
||||
#pragma GCC diagnostic pop
|
||||
if (tcsetattr(ttyfd, TCSANOW, &tt) < 0)
|
||||
bipmkpw_fatal("tcsetattr failed", strerror(errno));
|
||||
tt.c_lflag &= ~(ICANON|ECHO);
|
||||
if (tcsetattr(ttyfd, TCSANOW, &tt) < 0) {
|
||||
fprintf(stderr, "tcsetattr failed: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!write(ttyfd, "Password: ", (size_t)10))
|
||||
bipmkpw_fatal("tty write failed", strerror(errno));
|
||||
write(ttyfd, "Password: ", 10);
|
||||
|
||||
int idx = 0;
|
||||
int valid = 1;
|
||||
while (idx < buflen) {
|
||||
ssize_t rbytes = read(ttyfd, buffer + idx, (size_t)1);
|
||||
if (rbytes <= 0) {
|
||||
break;
|
||||
}
|
||||
read(ttyfd, buffer+idx, 1);
|
||||
if (buffer[idx] == '\n') {
|
||||
buffer[idx] = 0;
|
||||
break;
|
||||
} else if (buffer[idx] == ' ') {
|
||||
valid = 0;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
|
||||
if (!write(ttyfd, "\n", (size_t)1))
|
||||
bipmkpw_fatal("tty write failed", strerror(errno));
|
||||
write(ttyfd, "\n", 1);
|
||||
|
||||
tcsetattr(ttyfd, TCSANOW, &ttback);
|
||||
close(ttyfd);
|
||||
|
||||
if (!valid) {
|
||||
fprintf(stderr, "Password cannot contain spaces.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
@ -95,19 +76,12 @@ int main(void)
|
|||
readpass(str, 256);
|
||||
str[255] = 0;
|
||||
|
||||
// passing argument 1 of ‘srand’ with different width due to prototype
|
||||
// [-Werror=traditional-conversion] conversion from ‘time_t’ {aka ‘long int’} to
|
||||
// ‘unsigned int’ may change value [-Werror=conversion] We don't care.
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wtraditional-conversion"
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
// the time used to type the pass is entropy
|
||||
srand(time(NULL));
|
||||
#pragma GCC diagnostic pop
|
||||
seed = (unsigned)rand(); // rand should be > 0
|
||||
seed = rand();
|
||||
|
||||
md5 = chash_double(str, seed);
|
||||
for (i = 0; i < 20; i++)
|
||||
for (i = 0; i < 20; i++)
|
||||
printf("%02x", md5[i]);
|
||||
printf("\n");
|
||||
free(md5);
|
||||
|
|
38
src/conf.y
38
src/conf.y
|
@ -4,7 +4,6 @@
|
|||
*
|
||||
* This file is part of the bip proproject
|
||||
* Copyright (C) 2004 Arnaud Cornet
|
||||
* Copyright (C) 2022 Loïc Gomez
|
||||
*
|
||||
* 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
|
||||
|
@ -25,7 +24,7 @@ extern int linec;
|
|||
|
||||
extern int yyerror(char *);
|
||||
|
||||
int yywrap(void)
|
||||
int yywrap()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -69,7 +68,7 @@ struct tuple *tuple_l_new(int type, void *p)
|
|||
|
||||
%}
|
||||
|
||||
%token LEX_IP LEX_EQ LEX_PORT LEX_CSS LEX_SEMICOLON LEX_CONNECTION LEX_NETWORK LEX_LBRA LEX_RBRA LEX_USER LEX_NAME LEX_NICK LEX_SERVER LEX_PASSWORD LEX_SRCIP LEX_HOST LEX_VHOST LEX_SOURCE_PORT LEX_NONE LEX_COMMENT LEX_BUNCH LEX_REALNAME LEX_SSL LEX_SSL_CHECK_MODE LEX_SSL_CHECK_STORE LEX_SSL_CLIENT_CERTFILE LEX_CIPHERS LEX_CSS_CIPHERS LEX_DEFAULT_CIPHERS LEX_DH_PARAM LEX_CHANNEL LEX_KEY LEX_LOG_ROOT LEX_LOG_FORMAT LEX_LOG_LEVEL LEX_BACKLOG_LINES LEX_BACKLOG_TIMESTAMP LEX_BACKLOG_NO_TIMESTAMP LEX_BACKLOG LEX_LOG LEX_LOG_SYSTEM LEX_LOG_SYNC_INTERVAL LEX_FOLLOW_NICK LEX_ON_CONNECT_SEND LEX_AWAY_NICK LEX_PID_FILE LEX_WRITE_OIDENTD LEX_OIDENTD_FILE LEX_IGN_FIRST_NICK LEX_ALWAYS_BACKLOG LEX_BLRESET_ON_TALK LEX_BLRESET_CONNECTION LEX_DEFAULT_USER LEX_DEFAULT_NICK LEX_DEFAULT_REALNAME LEX_NO_CLIENT_AWAY_MSG LEX_BL_MSG_ONLY LEX_ADMIN LEX_BIP_USE_NOTICE LEX_CSS_PEM LEX_AUTOJOIN_ON_KICK LEX_IGNORE_CAPAB LEX_RECONN_TIMER LEX_SASL_USERNAME LEX_SASL_PASSWORD LEX_SASL_MECHANISM
|
||||
%token LEX_IP LEX_EQ LEX_PORT LEX_CSS LEX_SEMICOLON LEX_CONNECTION LEX_NETWORK LEX_LBRA LEX_RBRA LEX_USER LEX_NAME LEX_NICK LEX_SERVER LEX_PASSWORD LEX_SRCIP LEX_HOST LEX_VHOST LEX_SOURCE_PORT LEX_NONE LEX_COMMENT LEX_BUNCH LEX_REALNAME LEX_SSL LEX_SSL_CHECK_MODE LEX_SSL_CHECK_STORE LEX_SSL_CLIENT_CERTFILE LEX_CHANNEL LEX_KEY LEX_LOG_ROOT LEX_LOG_FORMAT LEX_LOG_LEVEL LEX_BACKLOG_LINES LEX_BACKLOG_NO_TIMESTAMP LEX_BACKLOG LEX_LOG LEX_LOG_SYSTEM LEX_LOG_SYNC_INTERVAL LEX_FOLLOW_NICK LEX_ON_CONNECT_SEND LEX_AWAY_NICK LEX_PID_FILE LEX_IGN_FIRST_NICK LEX_ALWAYS_BACKLOG LEX_BLRESET_ON_TALK LEX_DEFAULT_USER LEX_DEFAULT_NICK LEX_DEFAULT_REALNAME LEX_NO_CLIENT_AWAY_MSG LEX_BL_MSG_ONLY LEX_ADMIN LEX_BIP_USE_NOTICE LEX_CSS_PEM
|
||||
|
||||
%union {
|
||||
int number;
|
||||
|
@ -95,28 +94,19 @@ command:
|
|||
| LEX_LOG_FORMAT LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_LOG_FORMAT,
|
||||
$3); }
|
||||
| LEX_LOG_LEVEL LEX_EQ LEX_INT { $$ = tuple_i_new(LEX_LOG_LEVEL, $3); }
|
||||
| LEX_RECONN_TIMER LEX_EQ LEX_INT { $$ = tuple_i_new(LEX_RECONN_TIMER, $3); }
|
||||
| LEX_IP LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_IP, $3); }
|
||||
| LEX_PORT LEX_EQ LEX_INT { $$ = tuple_i_new(LEX_PORT, $3); }
|
||||
| LEX_CSS LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_CSS, $3); }
|
||||
| LEX_CSS_PEM LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_CSS_PEM, $3); }
|
||||
| LEX_CSS_CIPHERS LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_CSS_CIPHERS, $3); }
|
||||
| LEX_DEFAULT_CIPHERS LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_DEFAULT_CIPHERS, $3); }
|
||||
| LEX_DH_PARAM LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_DH_PARAM, $3); }
|
||||
| LEX_LOG LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_LOG, $3); }
|
||||
| LEX_LOG_SYSTEM LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_LOG_SYSTEM, $3); }
|
||||
| LEX_LOG_SYNC_INTERVAL LEX_EQ LEX_INT { $$ = tuple_i_new(
|
||||
LEX_LOG_SYNC_INTERVAL, $3); }
|
||||
| LEX_PID_FILE LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_PID_FILE, $3); }
|
||||
| LEX_WRITE_OIDENTD LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_WRITE_OIDENTD, $3); }
|
||||
| LEX_OIDENTD_FILE LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_OIDENTD_FILE, $3); }
|
||||
/* deprecated */
|
||||
| LEX_BACKLOG_LINES LEX_EQ LEX_INT {
|
||||
$$ = tuple_i_new(LEX_BACKLOG_LINES, $3);
|
||||
}
|
||||
| LEX_BACKLOG_TIMESTAMP LEX_EQ LEX_STRING {
|
||||
$$ = tuple_s_new(LEX_BACKLOG_TIMESTAMP, $3);
|
||||
}
|
||||
| LEX_BACKLOG_NO_TIMESTAMP LEX_EQ LEX_BOOL {
|
||||
$$ = tuple_i_new(LEX_BACKLOG_NO_TIMESTAMP, $3);
|
||||
}
|
||||
|
@ -141,7 +131,6 @@ network:
|
|||
net_command:
|
||||
LEX_NAME LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_NAME, $3); }
|
||||
| LEX_SSL LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_SSL, $3); }
|
||||
| LEX_CIPHERS LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_CIPHERS, $3); }
|
||||
| LEX_SERVER LEX_LBRA server LEX_RBRA {
|
||||
$$ = tuple_l_new(LEX_SERVER, $3); }
|
||||
|
||||
|
@ -172,9 +161,6 @@ usr_command:
|
|||
| LEX_BACKLOG_LINES LEX_EQ LEX_INT {
|
||||
$$ = tuple_i_new(LEX_BACKLOG_LINES, $3);
|
||||
}
|
||||
| LEX_BACKLOG_TIMESTAMP LEX_EQ LEX_STRING {
|
||||
$$ = tuple_s_new(LEX_BACKLOG_TIMESTAMP, $3);
|
||||
}
|
||||
| LEX_BACKLOG_NO_TIMESTAMP LEX_EQ LEX_BOOL {
|
||||
$$ = tuple_i_new(LEX_BACKLOG_NO_TIMESTAMP, $3);
|
||||
}
|
||||
|
@ -182,9 +168,6 @@ usr_command:
|
|||
| LEX_BLRESET_ON_TALK LEX_EQ LEX_BOOL {
|
||||
$$ = tuple_i_new(LEX_BLRESET_ON_TALK, $3);
|
||||
}
|
||||
| LEX_BLRESET_CONNECTION LEX_EQ LEX_BOOL {
|
||||
$$ = tuple_i_new(LEX_BLRESET_CONNECTION, $3);
|
||||
}
|
||||
| LEX_BL_MSG_ONLY LEX_EQ LEX_BOOL {
|
||||
$$ = tuple_i_new(LEX_BL_MSG_ONLY, $3);
|
||||
}
|
||||
|
@ -202,19 +185,12 @@ con_command:
|
|||
LEX_NAME LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_NAME, $3); }
|
||||
| LEX_NETWORK LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_NETWORK,
|
||||
$3); }
|
||||
| LEX_LOG LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_LOG, $3); }
|
||||
| LEX_NICK LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_NICK, $3); }
|
||||
| LEX_USER LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_USER, $3); }
|
||||
| LEX_REALNAME LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_REALNAME,
|
||||
$3); }
|
||||
| LEX_PASSWORD LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_PASSWORD,
|
||||
$3); }
|
||||
| LEX_SASL_USERNAME LEX_EQ LEX_STRING { $$ = tuple_s_new(
|
||||
LEX_SASL_USERNAME, $3); }
|
||||
| LEX_SASL_PASSWORD LEX_EQ LEX_STRING { $$ = tuple_s_new(
|
||||
LEX_SASL_PASSWORD, $3); }
|
||||
| LEX_SASL_MECHANISM LEX_EQ LEX_STRING { $$ = tuple_s_new(
|
||||
LEX_SASL_MECHANISM, $3); }
|
||||
| LEX_VHOST LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_VHOST, $3); }
|
||||
| LEX_SOURCE_PORT LEX_EQ LEX_INT {
|
||||
$$ = tuple_i_new(LEX_SOURCE_PORT, $3); }
|
||||
|
@ -224,16 +200,12 @@ con_command:
|
|||
$$ = tuple_i_new(LEX_FOLLOW_NICK, $3); }
|
||||
| LEX_IGN_FIRST_NICK LEX_EQ LEX_BOOL { $$ = tuple_i_new(
|
||||
LEX_IGN_FIRST_NICK, $3); }
|
||||
| LEX_AUTOJOIN_ON_KICK LEX_EQ LEX_BOOL {
|
||||
$$ = tuple_i_new(LEX_AUTOJOIN_ON_KICK, $3); }
|
||||
| LEX_IGNORE_CAPAB LEX_EQ LEX_BOOL {
|
||||
$$ = tuple_i_new(LEX_IGNORE_CAPAB, $3); }
|
||||
| LEX_CHANNEL LEX_LBRA channel LEX_RBRA { $$ = tuple_l_new(
|
||||
LEX_CHANNEL, $3); }
|
||||
LEX_CHANNEL, $3); }
|
||||
| LEX_ON_CONNECT_SEND LEX_EQ LEX_STRING { $$ = tuple_s_new(
|
||||
LEX_ON_CONNECT_SEND, $3); }
|
||||
LEX_ON_CONNECT_SEND, $3); }
|
||||
| LEX_NO_CLIENT_AWAY_MSG LEX_EQ LEX_STRING { $$ = tuple_s_new(
|
||||
LEX_NO_CLIENT_AWAY_MSG, $3); }
|
||||
LEX_NO_CLIENT_AWAY_MSG, $3); }
|
||||
| LEX_SSL_CHECK_MODE LEX_EQ LEX_STRING { $$ = tuple_s_new(
|
||||
LEX_SSL_CHECK_MODE, $3); }
|
||||
channel:
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/* src/config.h.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Use Glibcs backtrace function on fatal() */
|
||||
#undef HAVE_BACKTRACE
|
||||
|
||||
/* Define to 1 if you have the `crypto' library (-lcrypto). */
|
||||
#undef HAVE_LIBCRYPTO
|
||||
|
||||
/* Define to 1 if you have the `ssl' library (-lssl). */
|
||||
#undef HAVE_LIBSSL
|
||||
|
||||
/* Enable oidentd.conf management support */
|
||||
#undef HAVE_OIDENTD
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
|
||||
`char[]'. */
|
||||
#undef YYTEXT_POINTER
|
1048
src/connection.c
1048
src/connection.c
File diff suppressed because it is too large
Load Diff
|
@ -2,8 +2,7 @@
|
|||
* $Id: connection.h,v 1.40 2005/04/12 19:34:35 nohar Exp $
|
||||
*
|
||||
* This file is part of the bip project
|
||||
* Copyright (C) 2004,2005 Arnaud Cornet
|
||||
* Copyright (C) 2004,2005,2022 Loïc Gomez
|
||||
* Copyright (C) 2004 2005 Arnaud Cornet and Loïc Gomez
|
||||
*
|
||||
* 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
|
||||
|
@ -60,9 +59,6 @@
|
|||
#define SSL_CHECK_NONE (0)
|
||||
#define SSL_CHECK_BASIC (1)
|
||||
#define SSL_CHECK_CA (2)
|
||||
|
||||
#define SSLCTX_NO_REPLACE 0
|
||||
#define SSLCTX_FORCE_UPDATE 1
|
||||
#endif
|
||||
|
||||
struct connecting_data;
|
||||
|
@ -78,11 +74,11 @@ typedef struct connection {
|
|||
time_t connect_time;
|
||||
time_t timeout;
|
||||
char *incoming;
|
||||
size_t incoming_end;
|
||||
unsigned incoming_end;
|
||||
list_t *outgoing;
|
||||
char *partial;
|
||||
list_t *incoming_lines;
|
||||
void *user_data;
|
||||
list_t *ip_list;
|
||||
struct connecting_data *connecting_data;
|
||||
#ifdef HAVE_LIBSSL
|
||||
SSL_CTX *ssl_ctx_h;
|
||||
|
@ -95,9 +91,8 @@ typedef struct connection {
|
|||
} connection_t;
|
||||
|
||||
connection_t *connection_new(char *dsthostname, int dstport, char *srchostname,
|
||||
int srcport, int ssl, char *ssl_ciphers,
|
||||
int ssl_check_mode, char *ssl_check_store,
|
||||
char *ssl_client_certfile, time_t timeout);
|
||||
int srcport, int ssl, int ssl_check_mode,
|
||||
char *ssl_check_store, char *ssl_client_certfile, int timeout);
|
||||
connection_t *listen_new(char *hostname, int port, int ssl);
|
||||
connection_t *accept_new(connection_t *cn);
|
||||
void connection_free(connection_t *cn);
|
||||
|
@ -107,18 +102,13 @@ void write_line(connection_t *cn, char *line);
|
|||
void write_lines(connection_t *cn, list_t *lines);
|
||||
void write_line_fast(connection_t *cn, char *line);
|
||||
list_t *read_lines(connection_t *cn, int *error);
|
||||
list_t *wait_event(list_t *cn_list, time_t *msec, int *nc);
|
||||
list_t *wait_event(list_t *cn_list, int *msec, int *nc);
|
||||
|
||||
int cn_is_connected(connection_t *cn);
|
||||
int cn_is_listening(connection_t *cn);
|
||||
|
||||
uint16_t connection_localport(connection_t *cn);
|
||||
uint16_t connection_remoteport(connection_t *cn);
|
||||
int connection_localport(connection_t *cn);
|
||||
int connection_remoteport(connection_t *cn);
|
||||
char *connection_localip(connection_t *cn);
|
||||
char *connection_remoteip(connection_t *cn);
|
||||
#ifdef HAVE_LIBSSL
|
||||
/* Set SSL context, force update if already set and force is 1
|
||||
* Return 1 if SSL context has been set */
|
||||
int set_ssl_context(int force);
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -14,21 +14,17 @@
|
|||
#ifndef DEFAULTS_H
|
||||
#define DEFAULTS_H
|
||||
|
||||
#include "irc.h"
|
||||
|
||||
#define DEFAULT_BACKLOG 1
|
||||
#define DEFAULT_ALWAYS_BACKLOG 0
|
||||
#define DEFAULT_BL_MSG_ONLY 0
|
||||
#define DEFAULT_BACKLOG_LINES 0
|
||||
#define DEFAULT_BACKLOG_TIMESTAMP BLTSTime
|
||||
#define DEFAULT_BACKLOG_LINES 10
|
||||
#define DEFAULT_BACKLOG_NO_TIMESTAMP 0
|
||||
#define DEFAULT_BLRESET_ON_TALK 0
|
||||
#define DEFAULT_BLRESET_CONNECTION 0
|
||||
#define DEFAULT_LOG 1
|
||||
#define DEFAULT_LOG_SYSTEM 1
|
||||
#define DEFAULT_LOG_SYNC_INTERVAL 5
|
||||
#define DEFAULT_LOG_LEVEL LOG_INFO
|
||||
#define DEFAULT_LOG_FORMAT "%u/%n/%Y-%m/%c.%d.log"
|
||||
#define DEFAULT_BIP_USE_NOTICE 0
|
||||
#define DEFAULT_RECONN_TIMER 30
|
||||
|
||||
#endif /* DEFAULTS_H */
|
||||
|
|
91
src/irc.h
91
src/irc.h
|
@ -2,8 +2,7 @@
|
|||
* $Id: irc.h,v 1.43 2005/04/21 06:58:50 nohar Exp $
|
||||
*
|
||||
* This file is part of the bip project
|
||||
* Copyright (C) 2004,2005 Arnaud Cornet
|
||||
* Copyright (C) 2004,2005,2022 Loïc Gomez
|
||||
* Copyright (C) 2004 2005 Arnaud Cornet and Loïc Gomez
|
||||
*
|
||||
* 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
|
||||
|
@ -37,6 +36,10 @@ struct server {
|
|||
|
||||
#define server_new() bip_calloc(sizeof(struct server), 1)
|
||||
|
||||
#define NICKOP 1
|
||||
#define NICKHALFOP (1<<1)
|
||||
#define NICKVOICED (1<<2)
|
||||
|
||||
struct channel {
|
||||
char *name;
|
||||
char *mode;
|
||||
|
@ -52,16 +55,10 @@ struct channel {
|
|||
|
||||
#define IRC_TYPE_CLIENT (0)
|
||||
#define IRC_TYPE_SERVER (1)
|
||||
#define IRC_TYPE_LOGGING_CLIENT (2)
|
||||
#define IRC_TYPE_LOGING_CLIENT (2)
|
||||
#define IRC_TYPE_TRUST_CLIENT (3)
|
||||
|
||||
enum BLTimestamp {
|
||||
BLTSNone = 0,
|
||||
BLTSTime,
|
||||
BLTSDateTime,
|
||||
};
|
||||
|
||||
struct bipuser {
|
||||
struct user {
|
||||
/** client connection static data **/
|
||||
|
||||
char *name;
|
||||
|
@ -77,14 +74,12 @@ struct bipuser {
|
|||
char *default_realname;
|
||||
|
||||
/* backlog options */
|
||||
char backlog;
|
||||
int backlog;
|
||||
int backlog_lines;
|
||||
char always_backlog;
|
||||
char bl_msg_only;
|
||||
char blreset_on_talk;
|
||||
char blreset_connection;
|
||||
|
||||
enum BLTimestamp backlog_timestamp;
|
||||
int always_backlog;
|
||||
int bl_msg_only;
|
||||
int backlog_no_timestamp;
|
||||
int blreset_on_talk;
|
||||
|
||||
#ifdef HAVE_LIBSSL
|
||||
int ssl_check_mode;
|
||||
|
@ -93,28 +88,25 @@ struct bipuser {
|
|||
#endif
|
||||
|
||||
hash_t connections;
|
||||
char in_use; /* for mark and sweep on reload */
|
||||
int in_use; /* for mark and sweep on reload */
|
||||
};
|
||||
|
||||
struct network {
|
||||
struct network
|
||||
{
|
||||
char *name;
|
||||
#ifdef HAVE_LIBSSL
|
||||
int ssl;
|
||||
char *ciphers;
|
||||
#endif
|
||||
int serverc;
|
||||
struct server *serverv;
|
||||
};
|
||||
|
||||
#define SASL_AUTH_EXTERNAL 1
|
||||
#define SASL_AUTH_PLAIN 2
|
||||
|
||||
struct link {
|
||||
char *name; /* id */
|
||||
char *name; /* id */
|
||||
|
||||
/** link live data **/
|
||||
struct link_server *l_server;
|
||||
unsigned int l_clientc;
|
||||
int l_clientc;
|
||||
struct link_client **l_clientv;
|
||||
|
||||
struct log *log;
|
||||
|
@ -136,17 +128,15 @@ struct link {
|
|||
|
||||
/** link options */
|
||||
|
||||
char follow_nick;
|
||||
char ignore_first_nick;
|
||||
char autojoin_on_kick;
|
||||
char ignore_server_capab;
|
||||
int follow_nick;
|
||||
int ignore_first_nick;
|
||||
list_t on_connect_send;
|
||||
char *no_client_away_msg;
|
||||
char *away_nick;
|
||||
hash_t chan_infos; /* channels we want */
|
||||
list_t chan_infos_order; /* for order only */
|
||||
hash_t chan_infos; /* channels we want */
|
||||
list_t chan_infos_order; /* for order only */
|
||||
|
||||
struct bipuser *user;
|
||||
struct user *user;
|
||||
|
||||
/** server connection static data **/
|
||||
/* server list */
|
||||
|
@ -156,9 +146,6 @@ struct link {
|
|||
char *username;
|
||||
char *realname;
|
||||
char *s_password;
|
||||
char *sasl_username;
|
||||
char *sasl_password;
|
||||
int sasl_mechanism;
|
||||
char *connect_nick;
|
||||
|
||||
/* socket creation info */
|
||||
|
@ -167,7 +154,7 @@ struct link {
|
|||
|
||||
#ifdef HAVE_LIBSSL
|
||||
int ssl_check_mode;
|
||||
STACK_OF(X509) * untrusted_certs;
|
||||
STACK_OF(X509) *untrusted_certs;
|
||||
#endif
|
||||
int in_use; /* for mark and sweep on reload */
|
||||
};
|
||||
|
@ -188,9 +175,9 @@ struct link_any {
|
|||
|
||||
#define IRCC_NONE (0)
|
||||
#define IRCC_NICK (1)
|
||||
#define IRCC_USER (1 << 1)
|
||||
#define IRCC_PASS (1 << 2)
|
||||
#define IRCC_READY (IRCC_NICK | IRCC_PASS | IRCC_USER)
|
||||
#define IRCC_USER (1<<1)
|
||||
#define IRCC_PASS (1<<2)
|
||||
#define IRCC_READY (IRCC_NICK|IRCC_PASS|IRCC_USER)
|
||||
|
||||
struct link_client {
|
||||
struct link_connection _link_c;
|
||||
|
@ -224,7 +211,7 @@ struct chan_info {
|
|||
int backlog;
|
||||
};
|
||||
|
||||
#define chan_info_new() bip_calloc(sizeof(struct chan_info), (size_t)1)
|
||||
#define chan_info_new() bip_calloc(sizeof(struct chan_info), 1)
|
||||
|
||||
struct link_server {
|
||||
struct link_connection _link_c;
|
||||
|
@ -235,19 +222,12 @@ struct link_server {
|
|||
hash_t channels;
|
||||
|
||||
char *user_mode;
|
||||
size_t user_mode_len;
|
||||
int user_mode_len;
|
||||
|
||||
/* init stuff */
|
||||
unsigned lag;
|
||||
time_t laginit_ts;
|
||||
int lag;
|
||||
int laginit_ts;
|
||||
int lagtest_timeout;
|
||||
|
||||
/* chanmodes */
|
||||
array_t chanmodes;
|
||||
|
||||
/* user modes */
|
||||
char *prefixes;
|
||||
char *usermodes;
|
||||
};
|
||||
|
||||
typedef struct bip {
|
||||
|
@ -263,23 +243,26 @@ typedef struct bip {
|
|||
hash_t users;
|
||||
list_t errors;
|
||||
struct link_client *reloading_client;
|
||||
|
||||
#ifdef HAVE_OIDENTD
|
||||
char *oidentdpath;
|
||||
int write_oidentd;
|
||||
#endif
|
||||
} bip_t;
|
||||
|
||||
void bip_init(bip_t *bip);
|
||||
struct link_client *irc_client_new(void);
|
||||
struct link_server *irc_server_new(struct link *link, connection_t *conn);
|
||||
void irc_server_free(struct link_server *is);
|
||||
struct client *client_new(void);
|
||||
struct client *client_new();
|
||||
void irc_main(bip_t *);
|
||||
int ischannel(char p);
|
||||
void irc_client_close(struct link_client *);
|
||||
void irc_client_free(struct link_client *);
|
||||
struct link *irc_link_new(void);
|
||||
struct link *irc_link_new();
|
||||
void link_kill(bip_t *bip, struct link *);
|
||||
void unbind_from_link(struct link_client *ic);
|
||||
char *nick_from_ircmask(const char *mask);
|
||||
void irc_cli_backlog(struct link_client *ic, int hours);
|
||||
#define BIP_FAKEMASK "!bip@bip.bip.bip"
|
||||
|
||||
#endif
|
||||
|
||||
|
|
20
src/lex.l
20
src/lex.l
|
@ -1,11 +1,9 @@
|
|||
%option nounput noinput
|
||||
%{
|
||||
/*
|
||||
* $Id: lex.l,v 1.23 2005/04/12 19:34:35 nohar Exp $
|
||||
*
|
||||
* This file is part of the bip proproject
|
||||
* Copyright (C) 2004 Arnaud Cornet
|
||||
* Copyright (C) 2022 Loïc Gomez
|
||||
*
|
||||
* 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
|
||||
|
@ -18,7 +16,7 @@
|
|||
int linec;
|
||||
#include "util.h"
|
||||
extern list_t *root_list;
|
||||
extern int yyparse(void);
|
||||
void yyparse(void);
|
||||
void free_conf(list_t*);
|
||||
int conf_error;
|
||||
typedef struct bip bip_t;
|
||||
|
@ -82,22 +80,17 @@ list_t *parse_conf(FILE *file, int *err)
|
|||
"ssl_check_mode" { return LEX_SSL_CHECK_MODE; }
|
||||
"ssl_check_store" { return LEX_SSL_CHECK_STORE; }
|
||||
"ssl_client_certfile" { return LEX_SSL_CLIENT_CERTFILE; }
|
||||
"ssl_default_ciphers" { return LEX_DEFAULT_CIPHERS; }
|
||||
"ciphers" { return LEX_CIPHERS; }
|
||||
"key" { return LEX_KEY; }
|
||||
"autojoin_on_kick" { return LEX_AUTOJOIN_ON_KICK; }
|
||||
"channel" { return LEX_CHANNEL; }
|
||||
"log_level" { return LEX_LOG_LEVEL; }
|
||||
"log_root" { return LEX_LOG_ROOT; }
|
||||
"log_format" { return LEX_LOG_FORMAT; }
|
||||
"backlog_lines" { return LEX_BACKLOG_LINES; }
|
||||
"backlog_timestamp" { return LEX_BACKLOG_TIMESTAMP; }
|
||||
"backlog_no_timestamp" { return LEX_BACKLOG_NO_TIMESTAMP; }
|
||||
"backlog_no_timestamp" { return LEX_BACKLOG_NO_TIMESTAMP; }
|
||||
"backlog" { return LEX_BACKLOG; }
|
||||
"backlog_always" { return LEX_ALWAYS_BACKLOG; }
|
||||
"backlog_msg_only" { return LEX_BL_MSG_ONLY; }
|
||||
"backlog_reset_on_talk" { return LEX_BLRESET_ON_TALK; }
|
||||
"backlog_reset_connection" { return LEX_BLRESET_CONNECTION; }
|
||||
"blreset_on_talk" { return LEX_BLRESET_ON_TALK; }
|
||||
"bl_msg_only" { return LEX_BL_MSG_ONLY; }
|
||||
"always_backlog" { return LEX_ALWAYS_BACKLOG; }
|
||||
|
@ -110,17 +103,8 @@ list_t *parse_conf(FILE *file, int *err)
|
|||
"on_connect_send" { return LEX_ON_CONNECT_SEND; }
|
||||
"no_client_away_msg" { return LEX_NO_CLIENT_AWAY_MSG; }
|
||||
"pid_file" { return LEX_PID_FILE; }
|
||||
"write_oidentd" { return LEX_WRITE_OIDENTD; }
|
||||
"oidentd_file" { return LEX_OIDENTD_FILE; }
|
||||
"bip_use_notice" { return LEX_BIP_USE_NOTICE; }
|
||||
"client_side_ssl_pem" { return LEX_CSS_PEM; }
|
||||
"client_side_ciphers" { return LEX_CSS_CIPHERS; }
|
||||
"client_side_dh_param" { return LEX_DH_PARAM; }
|
||||
"sasl_username" { return LEX_SASL_USERNAME; }
|
||||
"sasl_password" { return LEX_SASL_PASSWORD; }
|
||||
"sasl_mechanism" { return LEX_SASL_MECHANISM; }
|
||||
"ignore_server_capab" { return LEX_IGNORE_CAPAB; }
|
||||
"reconn_timer" { return LEX_RECONN_TIMER; }
|
||||
\"[^"]*\" {
|
||||
size_t len = strlen(yytext) - 2;
|
||||
yylval.string = bip_malloc(len + 1);
|
||||
|
|
67
src/line.c
67
src/line.c
|
@ -2,8 +2,7 @@
|
|||
* $Id$
|
||||
*
|
||||
* This file is part of the bip project
|
||||
* Copyright (C) 2004,2005 Arnaud Cornet
|
||||
* Copyright (C) 2004,2005,2022 Loïc Gomez
|
||||
* Copyright (C) 2004 2005 Arnaud Cornet and Loïc Gomez
|
||||
*
|
||||
* 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
|
||||
|
@ -16,12 +15,6 @@
|
|||
#include "line.h"
|
||||
#include "util.h"
|
||||
|
||||
char *_irc_line_to_string(struct line *l, int skip_first);
|
||||
|
||||
// TODO resolve assuming signed overflow does not occur when changing X +- C1
|
||||
// cmp C2 to X cmp C2 -+ C1
|
||||
#pragma GCC diagnostic ignored "-Wstrict-overflow"
|
||||
|
||||
void irc_line_init(struct line *l)
|
||||
{
|
||||
memset(l, 0, sizeof(struct line));
|
||||
|
@ -69,7 +62,7 @@ char *irc_line_pop(struct line *l)
|
|||
|
||||
void _irc_line_append(struct line *l, const char *s)
|
||||
{
|
||||
array_push(&l->words, bip_strdup(s));
|
||||
array_push(&l->words, (char *)s);
|
||||
}
|
||||
|
||||
void irc_line_append(struct line *l, const char *s)
|
||||
|
@ -78,19 +71,6 @@ void irc_line_append(struct line *l, const char *s)
|
|||
}
|
||||
|
||||
char *irc_line_to_string(struct line *l)
|
||||
{
|
||||
return _irc_line_to_string(l, 0);
|
||||
}
|
||||
|
||||
char *irc_line_to_string_skip(struct line *l, int skip_first)
|
||||
{
|
||||
if (skip_first >= irc_line_count(l)) {
|
||||
return NULL;
|
||||
}
|
||||
return _irc_line_to_string(l, skip_first);
|
||||
}
|
||||
|
||||
char *_irc_line_to_string(struct line *l, int skip_first)
|
||||
{
|
||||
size_t len = 0;
|
||||
int i;
|
||||
|
@ -98,10 +78,10 @@ char *_irc_line_to_string(struct line *l, int skip_first)
|
|||
|
||||
if (l->origin)
|
||||
len = strlen(l->origin) + 2;
|
||||
for (i = skip_first; i < array_count(&l->words); i++)
|
||||
for (i = 0; i < array_count(&l->words); i++)
|
||||
len += strlen(array_get(&l->words, i)) + 1;
|
||||
len += 1; /* remove one trailing space and add \r\n */
|
||||
len++; /* last args ":" */
|
||||
len++; /* last args ":" */
|
||||
ret = bip_malloc(len + 1);
|
||||
ret[0] = 0;
|
||||
|
||||
|
@ -110,7 +90,7 @@ char *_irc_line_to_string(struct line *l, int skip_first)
|
|||
strcat(ret, l->origin);
|
||||
strcat(ret, " ");
|
||||
}
|
||||
for (i = skip_first; i < array_count(&l->words) - 1; i++) {
|
||||
for (i = 0; i < array_count(&l->words) - 1; i++) {
|
||||
strcat(ret, array_get(&l->words, i));
|
||||
strcat(ret, " ");
|
||||
}
|
||||
|
@ -126,14 +106,11 @@ char *irc_line_to_string_to(struct line *line, char *nick)
|
|||
{
|
||||
char *tmp;
|
||||
char *l;
|
||||
const char *prev;
|
||||
|
||||
prev = irc_line_elem(line, 1);
|
||||
tmp = bip_strdup(prev);
|
||||
tmp = (char *)irc_line_elem(line, 1);
|
||||
array_set(&line->words, 1, nick);
|
||||
l = irc_line_to_string(line);
|
||||
array_set(&line->words, 1, tmp);
|
||||
bip_cfree(prev);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
@ -153,17 +130,6 @@ const char *irc_line_elem(struct line *line, int elem)
|
|||
return array_get(&line->words, elem);
|
||||
}
|
||||
|
||||
void irc_line_drop(struct line *line, int elem)
|
||||
{
|
||||
bip_cfree(array_drop(&line->words, elem));
|
||||
}
|
||||
|
||||
int irc_line_is_error(struct line *line)
|
||||
{
|
||||
const char *irc_code = irc_line_elem(line, 0);
|
||||
return (irc_code[0] == '4');
|
||||
}
|
||||
|
||||
int irc_line_elem_equals(struct line *line, int elem, const char *cmp)
|
||||
{
|
||||
return !strcmp(irc_line_elem(line, elem), cmp);
|
||||
|
@ -193,8 +159,7 @@ struct line *irc_line_new_from_string(char *str)
|
|||
irc_line_free(line);
|
||||
return NULL;
|
||||
}
|
||||
// space is at least str + 1, len >= 0
|
||||
len = (size_t)(space - str - 1); /* leading ':' */
|
||||
len = space - str - 1; /* leading ':' */
|
||||
line->origin = bip_malloc(len + 1);
|
||||
memcpy(line->origin, str + 1, len);
|
||||
line->origin[len] = 0;
|
||||
|
@ -217,9 +182,7 @@ struct line *irc_line_new_from_string(char *str)
|
|||
while (*space && *space != ' ')
|
||||
space++;
|
||||
}
|
||||
// str is the start of string
|
||||
// space is the end of string or end of word
|
||||
len = (size_t)(space - str);
|
||||
len = space - str;
|
||||
tmp = bip_malloc(len + 1);
|
||||
memcpy(tmp, str, len);
|
||||
tmp[len] = 0;
|
||||
|
@ -239,9 +202,21 @@ void irc_line_free(struct line *l)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < array_count(&l->words); i++)
|
||||
bip_cfree(array_get(&l->words, i));
|
||||
free(array_get(&l->words, i));
|
||||
array_deinit(&l->words);
|
||||
if (l->origin)
|
||||
free(l->origin);
|
||||
free(l);
|
||||
}
|
||||
|
||||
void irc_line_free_args(char **elemv, int elemc)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (elemc == 0)
|
||||
return;
|
||||
for (i = 0; i < elemc; i++)
|
||||
free(elemv[i]);
|
||||
free(elemv);
|
||||
}
|
||||
|
||||
|
|
119
src/line.h
119
src/line.h
|
@ -2,8 +2,7 @@
|
|||
* $Id$
|
||||
*
|
||||
* This file is part of the bip project
|
||||
* Copyright (C) 2004,2005 Arnaud Cornet
|
||||
* Copyright (C) 2004,2005,2022 Loïc Gomez
|
||||
* Copyright (C) 2004 2005 Arnaud Cornet and Loïc Gomez
|
||||
*
|
||||
* 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
|
||||
|
@ -17,65 +16,65 @@
|
|||
|
||||
#include "connection.h"
|
||||
|
||||
#define WRITE_LINE0(con, org, com) \
|
||||
do { \
|
||||
struct line l; \
|
||||
irc_line_init(&l); \
|
||||
l.origin = org; \
|
||||
_irc_line_append(&l, com); \
|
||||
irc_line_write(&l, con); \
|
||||
_irc_line_deinit(&l); \
|
||||
} while (0)
|
||||
#define WRITE_LINE0(con, org, com) \
|
||||
do { \
|
||||
struct line l; \
|
||||
irc_line_init(&l); \
|
||||
l.origin = org; \
|
||||
_irc_line_append(&l, com); \
|
||||
irc_line_write(&l, con); \
|
||||
_irc_line_deinit(&l); \
|
||||
} while(0)
|
||||
|
||||
#define WRITE_LINE1(con, org, com, a) \
|
||||
do { \
|
||||
struct line l; \
|
||||
irc_line_init(&l); \
|
||||
l.origin = org; \
|
||||
_irc_line_append(&l, com); \
|
||||
_irc_line_append(&l, a); \
|
||||
irc_line_write(&l, con); \
|
||||
_irc_line_deinit(&l); \
|
||||
} while (0)
|
||||
#define WRITE_LINE1(con, org, com, a) \
|
||||
do { \
|
||||
struct line l; \
|
||||
irc_line_init(&l); \
|
||||
l.origin = org; \
|
||||
_irc_line_append(&l, com); \
|
||||
_irc_line_append(&l, a); \
|
||||
irc_line_write(&l, con); \
|
||||
_irc_line_deinit(&l); \
|
||||
} while(0)
|
||||
|
||||
#define WRITE_LINE2(con, org, com, a1, a2) \
|
||||
do { \
|
||||
struct line l; \
|
||||
irc_line_init(&l); \
|
||||
l.origin = org; \
|
||||
_irc_line_append(&l, com); \
|
||||
_irc_line_append(&l, a1); \
|
||||
_irc_line_append(&l, a2); \
|
||||
irc_line_write(&l, con); \
|
||||
_irc_line_deinit(&l); \
|
||||
} while (0)
|
||||
#define WRITE_LINE2(con, org, com, a1, a2) \
|
||||
do { \
|
||||
struct line l; \
|
||||
irc_line_init(&l); \
|
||||
l.origin = org; \
|
||||
_irc_line_append(&l, com); \
|
||||
_irc_line_append(&l, a1); \
|
||||
_irc_line_append(&l, a2); \
|
||||
irc_line_write(&l, con); \
|
||||
_irc_line_deinit(&l); \
|
||||
} while(0)
|
||||
|
||||
#define WRITE_LINE3(con, org, com, a1, a2, a3) \
|
||||
do { \
|
||||
struct line l; \
|
||||
irc_line_init(&l); \
|
||||
l.origin = org; \
|
||||
_irc_line_append(&l, com); \
|
||||
_irc_line_append(&l, a1); \
|
||||
_irc_line_append(&l, a2); \
|
||||
_irc_line_append(&l, a3); \
|
||||
irc_line_write(&l, con); \
|
||||
_irc_line_deinit(&l); \
|
||||
} while (0)
|
||||
#define WRITE_LINE3(con, org, com, a1, a2, a3) \
|
||||
do { \
|
||||
struct line l; \
|
||||
irc_line_init(&l); \
|
||||
l.origin = org; \
|
||||
_irc_line_append(&l, com); \
|
||||
_irc_line_append(&l, a1); \
|
||||
_irc_line_append(&l, a2); \
|
||||
_irc_line_append(&l, a3); \
|
||||
irc_line_write(&l, con); \
|
||||
_irc_line_deinit(&l); \
|
||||
} while(0)
|
||||
|
||||
#define WRITE_LINE4(con, org, com, a1, a2, a3, a4) \
|
||||
do { \
|
||||
struct line l; \
|
||||
irc_line_init(&l); \
|
||||
l.origin = org; \
|
||||
_irc_line_append(&l, com); \
|
||||
_irc_line_append(&l, a1); \
|
||||
_irc_line_append(&l, a2); \
|
||||
_irc_line_append(&l, a3); \
|
||||
_irc_line_append(&l, a4); \
|
||||
irc_line_write(&l, con); \
|
||||
_irc_line_deinit(&l); \
|
||||
} while (0)
|
||||
#define WRITE_LINE4(con, org, com, a1, a2, a3, a4) \
|
||||
do { \
|
||||
struct line l; \
|
||||
irc_line_init(&l); \
|
||||
l.origin = org; \
|
||||
_irc_line_append(&l, com); \
|
||||
_irc_line_append(&l, a1); \
|
||||
_irc_line_append(&l, a2); \
|
||||
_irc_line_append(&l, a3); \
|
||||
_irc_line_append(&l, a4); \
|
||||
irc_line_write(&l, con); \
|
||||
_irc_line_deinit(&l); \
|
||||
} while(0)
|
||||
|
||||
struct line {
|
||||
char *origin;
|
||||
|
@ -85,12 +84,11 @@ struct line {
|
|||
|
||||
void irc_line_init(struct line *l);
|
||||
void _irc_line_deinit(struct line *l);
|
||||
struct line *irc_line_new(void);
|
||||
struct line *irc_line_new();
|
||||
void irc_line_write(struct line *l, connection_t *c);
|
||||
void irc_line_append(struct line *l, const char *s);
|
||||
struct line *irc_line_new_from_string(char *str);
|
||||
char *irc_line_to_string(struct line *l);
|
||||
char *irc_line_to_string_skip(struct line *l, int skip_first);
|
||||
char *irc_line_to_string_to(struct line *line, char *nick);
|
||||
void irc_line_free(struct line *l);
|
||||
struct line *irc_line_dup(struct line *line);
|
||||
|
@ -99,9 +97,8 @@ int irc_line_includes(struct line *line, int elem);
|
|||
const char *irc_line_elem(struct line *line, int elem);
|
||||
int irc_line_count(struct line *line);
|
||||
char *irc_line_pop(struct line *l);
|
||||
int irc_line_is_error(struct line *line);
|
||||
int irc_line_elem_equals(struct line *line, int elem, const char *cmp);
|
||||
int irc_line_elem_case_equals(struct line *line, int elem, const char *cmp);
|
||||
void irc_line_drop(struct line *line, int elem);
|
||||
void irc_line_free_args(char **elemv, int elemc);
|
||||
|
||||
#endif
|
||||
|
|
48
src/log.h
48
src/log.h
|
@ -2,8 +2,7 @@
|
|||
* $Id: log.h,v 1.26 2005/04/12 19:34:35 nohar Exp $
|
||||
*
|
||||
* This file is part of the bip project
|
||||
* Copyright (C) 2004 Arnaud Cornet
|
||||
* Copyright (C) 2004,2022 Loïc Gomez
|
||||
* Copyright (C) 2004 Arnaud Cornet and Loïc Gomez
|
||||
*
|
||||
* 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
|
||||
|
@ -14,7 +13,6 @@
|
|||
|
||||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
#define _XOPEN_SOURCE 500
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -29,15 +27,16 @@
|
|||
|
||||
struct list;
|
||||
|
||||
typedef struct logfile {
|
||||
typedef struct logfile
|
||||
{
|
||||
FILE *file;
|
||||
char *filename;
|
||||
char *canonical_filename;
|
||||
struct tm last_log;
|
||||
size_t len;
|
||||
} logfile_t;
|
||||
|
||||
typedef struct logstore {
|
||||
typedef struct logstore
|
||||
{
|
||||
char *name;
|
||||
list_t file_group;
|
||||
int skip_advance;
|
||||
|
@ -46,49 +45,49 @@ typedef struct logstore {
|
|||
int memc;
|
||||
int track_backlog;
|
||||
list_iterator_t file_it;
|
||||
long file_offset;
|
||||
size_t file_offset;
|
||||
} logstore_t;
|
||||
|
||||
typedef struct log {
|
||||
typedef struct log
|
||||
{
|
||||
hash_t logfgs;
|
||||
char *network;
|
||||
char *buffer;
|
||||
int connected;
|
||||
int backlogging;
|
||||
int lastfile_seeked;
|
||||
int log_to_file;
|
||||
|
||||
struct bipuser *user;
|
||||
struct user *user;
|
||||
} log_t;
|
||||
|
||||
log_t *log_new(struct bipuser *user, const char *network);
|
||||
log_t *log_new(struct user *user, const char *network);
|
||||
void logdata_free(log_t *logdata);
|
||||
|
||||
void log_join(log_t *logdata, const char *ircmask, const char *channel);
|
||||
void log_part(log_t *logdata, const char *ircmask, const char *channel,
|
||||
const char *message);
|
||||
const char *message);
|
||||
void log_kick(log_t *logdata, const char *ircmask, const char *channel,
|
||||
const char *who, const char *message);
|
||||
const char *who, const char *message);
|
||||
void log_quit(log_t *logdata, const char *ircmask, const char *channel,
|
||||
const char *message);
|
||||
const char *message);
|
||||
void log_nick(log_t *logdata, const char *ircmask, const char *channel,
|
||||
const char *newnick);
|
||||
const char *newnick);
|
||||
void log_privmsg(log_t *logdata, const char *ircmask, const char *destination,
|
||||
const char *message);
|
||||
const char *message);
|
||||
void log_notice(log_t *logdata, const char *ircmask, const char *channel,
|
||||
const char *message);
|
||||
void log_cli_privmsg(log_t *logdata, const char *ircmask,
|
||||
const char *destination, const char *message);
|
||||
const char *destination, const char *message);
|
||||
void log_cli_notice(log_t *logdata, const char *ircmask, const char *channel,
|
||||
const char *message);
|
||||
const char *message);
|
||||
void log_write(log_t *logdata, const char *str, const char *destination);
|
||||
void log_mode(log_t *logdata, const char *ircmask, const char *channel,
|
||||
const char *modes, array_t *mode_args);
|
||||
const char *modes, array_t *mode_args);
|
||||
void log_topic(log_t *logdata, const char *ircmask, const char *channel,
|
||||
const char *message);
|
||||
const char *message);
|
||||
void log_init_topic(log_t *logdata, const char *channel, const char *message);
|
||||
void log_init_topic_time(log_t *logdata, const char *channel, const char *who,
|
||||
const char *when);
|
||||
const char *when);
|
||||
void log_connected(log_t *logdata);
|
||||
void log_disconnected(log_t *logdata);
|
||||
void log_ping_timeout(log_t *logdata);
|
||||
|
@ -97,13 +96,12 @@ void log_client_connected(log_t *logdata);
|
|||
int log_has_backlog(log_t *logdata, const char *destination);
|
||||
void log_flush_all(void);
|
||||
void log_client_none_connected(log_t *logdata);
|
||||
void log_reset_all(log_t *logdata);
|
||||
void log_reset(logstore_t *);
|
||||
void log_reinit_all(log_t *logdata);
|
||||
void log_free(log_t *log);
|
||||
int check_dir(char *filename, int is_fatal);
|
||||
void log_reset_store(log_t *log, const char *storename);
|
||||
void log_drop(log_t *log, const char *storename);
|
||||
|
||||
list_t *log_backlogs(log_t *log);
|
||||
list_t *backlog_lines(log_t *log, const char *bl, const char *cli_nick,
|
||||
int hours);
|
||||
list_t *backlog_lines_from_last_mark(log_t *log, const char *bl, const char *);
|
||||
#endif
|
||||
|
|
547
src/md5.c
547
src/md5.c
|
@ -1,8 +1,7 @@
|
|||
/*
|
||||
* RFC 1321 compliant MD5 implementation
|
||||
*
|
||||
* Copyright (C) 2001-2003 Christophe Devine
|
||||
* Copyright (C) 2022 Loïc Gomez
|
||||
* Copyright (C) 2001-2003 Christophe Devine
|
||||
*
|
||||
* 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
|
||||
|
@ -25,218 +24,226 @@
|
|||
#include "md5.h"
|
||||
#include "util.h"
|
||||
|
||||
#define GET_UINT32(n, b, i) \
|
||||
{ \
|
||||
(n) = ((uint32)(b)[(i)]) | ((uint32)(b)[(i) + 1] << 8) \
|
||||
| ((uint32)(b)[(i) + 2] << 16) \
|
||||
| ((uint32)(b)[(i) + 3] << 24); \
|
||||
}
|
||||
|
||||
#define PUT_UINT32(n, b, i) \
|
||||
{ \
|
||||
(b)[(i)] = (uint8)((n)); \
|
||||
(b)[(i) + 1] = (uint8)((n) >> 8); \
|
||||
(b)[(i) + 2] = (uint8)((n) >> 16); \
|
||||
(b)[(i) + 3] = (uint8)((n) >> 24); \
|
||||
}
|
||||
|
||||
void md5_starts(md5_context *ctx)
|
||||
{
|
||||
ctx->total[0] = 0;
|
||||
ctx->total[1] = 0;
|
||||
|
||||
ctx->state[0] = 0x67452301;
|
||||
ctx->state[1] = 0xEFCDAB89;
|
||||
ctx->state[2] = 0x98BADCFE;
|
||||
ctx->state[3] = 0x10325476;
|
||||
#define GET_UINT32(n,b,i) \
|
||||
{ \
|
||||
(n) = ( (uint32) (b)[(i) ] ) \
|
||||
| ( (uint32) (b)[(i) + 1] << 8 ) \
|
||||
| ( (uint32) (b)[(i) + 2] << 16 ) \
|
||||
| ( (uint32) (b)[(i) + 3] << 24 ); \
|
||||
}
|
||||
|
||||
void md5_process(md5_context *ctx, uint8 data[64])
|
||||
{
|
||||
uint32 X[16], A, B, C, D;
|
||||
|
||||
GET_UINT32(X[0], data, 0);
|
||||
GET_UINT32(X[1], data, 4);
|
||||
GET_UINT32(X[2], data, 8);
|
||||
GET_UINT32(X[3], data, 12);
|
||||
GET_UINT32(X[4], data, 16);
|
||||
GET_UINT32(X[5], data, 20);
|
||||
GET_UINT32(X[6], data, 24);
|
||||
GET_UINT32(X[7], data, 28);
|
||||
GET_UINT32(X[8], data, 32);
|
||||
GET_UINT32(X[9], data, 36);
|
||||
GET_UINT32(X[10], data, 40);
|
||||
GET_UINT32(X[11], data, 44);
|
||||
GET_UINT32(X[12], data, 48);
|
||||
GET_UINT32(X[13], data, 52);
|
||||
GET_UINT32(X[14], data, 56);
|
||||
GET_UINT32(X[15], data, 60);
|
||||
|
||||
#define S(x, n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
|
||||
|
||||
#define P(a, b, c, d, k, s, t) \
|
||||
{ \
|
||||
a += F(b, c, d) + X[k] + t; \
|
||||
a = S(a, s) + b; \
|
||||
}
|
||||
|
||||
A = ctx->state[0];
|
||||
B = ctx->state[1];
|
||||
C = ctx->state[2];
|
||||
D = ctx->state[3];
|
||||
|
||||
#define F(x, y, z) (z ^ (x & (y ^ z)))
|
||||
|
||||
P(A, B, C, D, 0, 7, 0xD76AA478);
|
||||
P(D, A, B, C, 1, 12, 0xE8C7B756);
|
||||
P(C, D, A, B, 2, 17, 0x242070DB);
|
||||
P(B, C, D, A, 3, 22, 0xC1BDCEEE);
|
||||
P(A, B, C, D, 4, 7, 0xF57C0FAF);
|
||||
P(D, A, B, C, 5, 12, 0x4787C62A);
|
||||
P(C, D, A, B, 6, 17, 0xA8304613);
|
||||
P(B, C, D, A, 7, 22, 0xFD469501);
|
||||
P(A, B, C, D, 8, 7, 0x698098D8);
|
||||
P(D, A, B, C, 9, 12, 0x8B44F7AF);
|
||||
P(C, D, A, B, 10, 17, 0xFFFF5BB1);
|
||||
P(B, C, D, A, 11, 22, 0x895CD7BE);
|
||||
P(A, B, C, D, 12, 7, 0x6B901122);
|
||||
P(D, A, B, C, 13, 12, 0xFD987193);
|
||||
P(C, D, A, B, 14, 17, 0xA679438E);
|
||||
P(B, C, D, A, 15, 22, 0x49B40821);
|
||||
|
||||
#undef F
|
||||
|
||||
#define F(x, y, z) (y ^ (z & (x ^ y)))
|
||||
|
||||
P(A, B, C, D, 1, 5, 0xF61E2562);
|
||||
P(D, A, B, C, 6, 9, 0xC040B340);
|
||||
P(C, D, A, B, 11, 14, 0x265E5A51);
|
||||
P(B, C, D, A, 0, 20, 0xE9B6C7AA);
|
||||
P(A, B, C, D, 5, 5, 0xD62F105D);
|
||||
P(D, A, B, C, 10, 9, 0x02441453);
|
||||
P(C, D, A, B, 15, 14, 0xD8A1E681);
|
||||
P(B, C, D, A, 4, 20, 0xE7D3FBC8);
|
||||
P(A, B, C, D, 9, 5, 0x21E1CDE6);
|
||||
P(D, A, B, C, 14, 9, 0xC33707D6);
|
||||
P(C, D, A, B, 3, 14, 0xF4D50D87);
|
||||
P(B, C, D, A, 8, 20, 0x455A14ED);
|
||||
P(A, B, C, D, 13, 5, 0xA9E3E905);
|
||||
P(D, A, B, C, 2, 9, 0xFCEFA3F8);
|
||||
P(C, D, A, B, 7, 14, 0x676F02D9);
|
||||
P(B, C, D, A, 12, 20, 0x8D2A4C8A);
|
||||
|
||||
#undef F
|
||||
|
||||
#define F(x, y, z) (x ^ y ^ z)
|
||||
|
||||
P(A, B, C, D, 5, 4, 0xFFFA3942);
|
||||
P(D, A, B, C, 8, 11, 0x8771F681);
|
||||
P(C, D, A, B, 11, 16, 0x6D9D6122);
|
||||
P(B, C, D, A, 14, 23, 0xFDE5380C);
|
||||
P(A, B, C, D, 1, 4, 0xA4BEEA44);
|
||||
P(D, A, B, C, 4, 11, 0x4BDECFA9);
|
||||
P(C, D, A, B, 7, 16, 0xF6BB4B60);
|
||||
P(B, C, D, A, 10, 23, 0xBEBFBC70);
|
||||
P(A, B, C, D, 13, 4, 0x289B7EC6);
|
||||
P(D, A, B, C, 0, 11, 0xEAA127FA);
|
||||
P(C, D, A, B, 3, 16, 0xD4EF3085);
|
||||
P(B, C, D, A, 6, 23, 0x04881D05);
|
||||
P(A, B, C, D, 9, 4, 0xD9D4D039);
|
||||
P(D, A, B, C, 12, 11, 0xE6DB99E5);
|
||||
P(C, D, A, B, 15, 16, 0x1FA27CF8);
|
||||
P(B, C, D, A, 2, 23, 0xC4AC5665);
|
||||
|
||||
#undef F
|
||||
|
||||
#define F(x, y, z) (y ^ (x | ~z))
|
||||
|
||||
P(A, B, C, D, 0, 6, 0xF4292244);
|
||||
P(D, A, B, C, 7, 10, 0x432AFF97);
|
||||
P(C, D, A, B, 14, 15, 0xAB9423A7);
|
||||
P(B, C, D, A, 5, 21, 0xFC93A039);
|
||||
P(A, B, C, D, 12, 6, 0x655B59C3);
|
||||
P(D, A, B, C, 3, 10, 0x8F0CCC92);
|
||||
P(C, D, A, B, 10, 15, 0xFFEFF47D);
|
||||
P(B, C, D, A, 1, 21, 0x85845DD1);
|
||||
P(A, B, C, D, 8, 6, 0x6FA87E4F);
|
||||
P(D, A, B, C, 15, 10, 0xFE2CE6E0);
|
||||
P(C, D, A, B, 6, 15, 0xA3014314);
|
||||
P(B, C, D, A, 13, 21, 0x4E0811A1);
|
||||
P(A, B, C, D, 4, 6, 0xF7537E82);
|
||||
P(D, A, B, C, 11, 10, 0xBD3AF235);
|
||||
P(C, D, A, B, 2, 15, 0x2AD7D2BB);
|
||||
P(B, C, D, A, 9, 21, 0xEB86D391);
|
||||
|
||||
#undef F
|
||||
|
||||
ctx->state[0] += A;
|
||||
ctx->state[1] += B;
|
||||
ctx->state[2] += C;
|
||||
ctx->state[3] += D;
|
||||
#define PUT_UINT32(n,b,i) \
|
||||
{ \
|
||||
(b)[(i) ] = (uint8) ( (n) ); \
|
||||
(b)[(i) + 1] = (uint8) ( (n) >> 8 ); \
|
||||
(b)[(i) + 2] = (uint8) ( (n) >> 16 ); \
|
||||
(b)[(i) + 3] = (uint8) ( (n) >> 24 ); \
|
||||
}
|
||||
|
||||
void md5_update(md5_context *ctx, uint8 *input, uint32 length)
|
||||
void md5_starts( md5_context *ctx )
|
||||
{
|
||||
uint32 left, fill;
|
||||
ctx->total[0] = 0;
|
||||
ctx->total[1] = 0;
|
||||
|
||||
if (!length)
|
||||
return;
|
||||
|
||||
left = ctx->total[0] & 0x3F;
|
||||
fill = 64 - left;
|
||||
|
||||
ctx->total[0] += length;
|
||||
ctx->total[0] &= 0xFFFFFFFF;
|
||||
|
||||
if (ctx->total[0] < length)
|
||||
ctx->total[1]++;
|
||||
|
||||
if (left && length >= fill) {
|
||||
memcpy((void *)(ctx->buffer + left), (void *)input, fill);
|
||||
md5_process(ctx, ctx->buffer);
|
||||
length -= fill;
|
||||
input += fill;
|
||||
left = 0;
|
||||
}
|
||||
|
||||
while (length >= 64) {
|
||||
md5_process(ctx, input);
|
||||
length -= 64;
|
||||
input += 64;
|
||||
}
|
||||
|
||||
if (length) {
|
||||
memcpy((void *)(ctx->buffer + left), (void *)input, length);
|
||||
}
|
||||
ctx->state[0] = 0x67452301;
|
||||
ctx->state[1] = 0xEFCDAB89;
|
||||
ctx->state[2] = 0x98BADCFE;
|
||||
ctx->state[3] = 0x10325476;
|
||||
}
|
||||
|
||||
static uint8 md5_padding[64] = {
|
||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
void md5_finish(md5_context *ctx, uint8 digest[16])
|
||||
void md5_process( md5_context *ctx, uint8 data[64] )
|
||||
{
|
||||
uint32 last, padn;
|
||||
uint32 high, low;
|
||||
uint8 msglen[8];
|
||||
uint32 X[16], A, B, C, D;
|
||||
|
||||
high = (ctx->total[0] >> 29) | (ctx->total[1] << 3);
|
||||
low = (ctx->total[0] << 3);
|
||||
GET_UINT32( X[0], data, 0 );
|
||||
GET_UINT32( X[1], data, 4 );
|
||||
GET_UINT32( X[2], data, 8 );
|
||||
GET_UINT32( X[3], data, 12 );
|
||||
GET_UINT32( X[4], data, 16 );
|
||||
GET_UINT32( X[5], data, 20 );
|
||||
GET_UINT32( X[6], data, 24 );
|
||||
GET_UINT32( X[7], data, 28 );
|
||||
GET_UINT32( X[8], data, 32 );
|
||||
GET_UINT32( X[9], data, 36 );
|
||||
GET_UINT32( X[10], data, 40 );
|
||||
GET_UINT32( X[11], data, 44 );
|
||||
GET_UINT32( X[12], data, 48 );
|
||||
GET_UINT32( X[13], data, 52 );
|
||||
GET_UINT32( X[14], data, 56 );
|
||||
GET_UINT32( X[15], data, 60 );
|
||||
|
||||
PUT_UINT32(low, msglen, 0);
|
||||
PUT_UINT32(high, msglen, 4);
|
||||
#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
|
||||
|
||||
last = ctx->total[0] & 0x3F;
|
||||
padn = (last < 56) ? (56 - last) : (120 - last);
|
||||
#define P(a,b,c,d,k,s,t) \
|
||||
{ \
|
||||
a += F(b,c,d) + X[k] + t; a = S(a,s) + b; \
|
||||
}
|
||||
|
||||
md5_update(ctx, md5_padding, padn);
|
||||
md5_update(ctx, msglen, (unsigned long)8);
|
||||
A = ctx->state[0];
|
||||
B = ctx->state[1];
|
||||
C = ctx->state[2];
|
||||
D = ctx->state[3];
|
||||
|
||||
PUT_UINT32(ctx->state[0], digest, 0);
|
||||
PUT_UINT32(ctx->state[1], digest, 4);
|
||||
PUT_UINT32(ctx->state[2], digest, 8);
|
||||
PUT_UINT32(ctx->state[3], digest, 12);
|
||||
#define F(x,y,z) (z ^ (x & (y ^ z)))
|
||||
|
||||
P( A, B, C, D, 0, 7, 0xD76AA478 );
|
||||
P( D, A, B, C, 1, 12, 0xE8C7B756 );
|
||||
P( C, D, A, B, 2, 17, 0x242070DB );
|
||||
P( B, C, D, A, 3, 22, 0xC1BDCEEE );
|
||||
P( A, B, C, D, 4, 7, 0xF57C0FAF );
|
||||
P( D, A, B, C, 5, 12, 0x4787C62A );
|
||||
P( C, D, A, B, 6, 17, 0xA8304613 );
|
||||
P( B, C, D, A, 7, 22, 0xFD469501 );
|
||||
P( A, B, C, D, 8, 7, 0x698098D8 );
|
||||
P( D, A, B, C, 9, 12, 0x8B44F7AF );
|
||||
P( C, D, A, B, 10, 17, 0xFFFF5BB1 );
|
||||
P( B, C, D, A, 11, 22, 0x895CD7BE );
|
||||
P( A, B, C, D, 12, 7, 0x6B901122 );
|
||||
P( D, A, B, C, 13, 12, 0xFD987193 );
|
||||
P( C, D, A, B, 14, 17, 0xA679438E );
|
||||
P( B, C, D, A, 15, 22, 0x49B40821 );
|
||||
|
||||
#undef F
|
||||
|
||||
#define F(x,y,z) (y ^ (z & (x ^ y)))
|
||||
|
||||
P( A, B, C, D, 1, 5, 0xF61E2562 );
|
||||
P( D, A, B, C, 6, 9, 0xC040B340 );
|
||||
P( C, D, A, B, 11, 14, 0x265E5A51 );
|
||||
P( B, C, D, A, 0, 20, 0xE9B6C7AA );
|
||||
P( A, B, C, D, 5, 5, 0xD62F105D );
|
||||
P( D, A, B, C, 10, 9, 0x02441453 );
|
||||
P( C, D, A, B, 15, 14, 0xD8A1E681 );
|
||||
P( B, C, D, A, 4, 20, 0xE7D3FBC8 );
|
||||
P( A, B, C, D, 9, 5, 0x21E1CDE6 );
|
||||
P( D, A, B, C, 14, 9, 0xC33707D6 );
|
||||
P( C, D, A, B, 3, 14, 0xF4D50D87 );
|
||||
P( B, C, D, A, 8, 20, 0x455A14ED );
|
||||
P( A, B, C, D, 13, 5, 0xA9E3E905 );
|
||||
P( D, A, B, C, 2, 9, 0xFCEFA3F8 );
|
||||
P( C, D, A, B, 7, 14, 0x676F02D9 );
|
||||
P( B, C, D, A, 12, 20, 0x8D2A4C8A );
|
||||
|
||||
#undef F
|
||||
|
||||
#define F(x,y,z) (x ^ y ^ z)
|
||||
|
||||
P( A, B, C, D, 5, 4, 0xFFFA3942 );
|
||||
P( D, A, B, C, 8, 11, 0x8771F681 );
|
||||
P( C, D, A, B, 11, 16, 0x6D9D6122 );
|
||||
P( B, C, D, A, 14, 23, 0xFDE5380C );
|
||||
P( A, B, C, D, 1, 4, 0xA4BEEA44 );
|
||||
P( D, A, B, C, 4, 11, 0x4BDECFA9 );
|
||||
P( C, D, A, B, 7, 16, 0xF6BB4B60 );
|
||||
P( B, C, D, A, 10, 23, 0xBEBFBC70 );
|
||||
P( A, B, C, D, 13, 4, 0x289B7EC6 );
|
||||
P( D, A, B, C, 0, 11, 0xEAA127FA );
|
||||
P( C, D, A, B, 3, 16, 0xD4EF3085 );
|
||||
P( B, C, D, A, 6, 23, 0x04881D05 );
|
||||
P( A, B, C, D, 9, 4, 0xD9D4D039 );
|
||||
P( D, A, B, C, 12, 11, 0xE6DB99E5 );
|
||||
P( C, D, A, B, 15, 16, 0x1FA27CF8 );
|
||||
P( B, C, D, A, 2, 23, 0xC4AC5665 );
|
||||
|
||||
#undef F
|
||||
|
||||
#define F(x,y,z) (y ^ (x | ~z))
|
||||
|
||||
P( A, B, C, D, 0, 6, 0xF4292244 );
|
||||
P( D, A, B, C, 7, 10, 0x432AFF97 );
|
||||
P( C, D, A, B, 14, 15, 0xAB9423A7 );
|
||||
P( B, C, D, A, 5, 21, 0xFC93A039 );
|
||||
P( A, B, C, D, 12, 6, 0x655B59C3 );
|
||||
P( D, A, B, C, 3, 10, 0x8F0CCC92 );
|
||||
P( C, D, A, B, 10, 15, 0xFFEFF47D );
|
||||
P( B, C, D, A, 1, 21, 0x85845DD1 );
|
||||
P( A, B, C, D, 8, 6, 0x6FA87E4F );
|
||||
P( D, A, B, C, 15, 10, 0xFE2CE6E0 );
|
||||
P( C, D, A, B, 6, 15, 0xA3014314 );
|
||||
P( B, C, D, A, 13, 21, 0x4E0811A1 );
|
||||
P( A, B, C, D, 4, 6, 0xF7537E82 );
|
||||
P( D, A, B, C, 11, 10, 0xBD3AF235 );
|
||||
P( C, D, A, B, 2, 15, 0x2AD7D2BB );
|
||||
P( B, C, D, A, 9, 21, 0xEB86D391 );
|
||||
|
||||
#undef F
|
||||
|
||||
ctx->state[0] += A;
|
||||
ctx->state[1] += B;
|
||||
ctx->state[2] += C;
|
||||
ctx->state[3] += D;
|
||||
}
|
||||
|
||||
void md5_update( md5_context *ctx, uint8 *input, uint32 length )
|
||||
{
|
||||
uint32 left, fill;
|
||||
|
||||
if( ! length ) return;
|
||||
|
||||
left = ctx->total[0] & 0x3F;
|
||||
fill = 64 - left;
|
||||
|
||||
ctx->total[0] += length;
|
||||
ctx->total[0] &= 0xFFFFFFFF;
|
||||
|
||||
if( ctx->total[0] < length )
|
||||
ctx->total[1]++;
|
||||
|
||||
if( left && length >= fill )
|
||||
{
|
||||
memcpy( (void *) (ctx->buffer + left),
|
||||
(void *) input, fill );
|
||||
md5_process( ctx, ctx->buffer );
|
||||
length -= fill;
|
||||
input += fill;
|
||||
left = 0;
|
||||
}
|
||||
|
||||
while( length >= 64 )
|
||||
{
|
||||
md5_process( ctx, input );
|
||||
length -= 64;
|
||||
input += 64;
|
||||
}
|
||||
|
||||
if( length )
|
||||
{
|
||||
memcpy( (void *) (ctx->buffer + left),
|
||||
(void *) input, length );
|
||||
}
|
||||
}
|
||||
|
||||
static uint8 md5_padding[64] =
|
||||
{
|
||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
void md5_finish( md5_context *ctx, uint8 digest[16] )
|
||||
{
|
||||
uint32 last, padn;
|
||||
uint32 high, low;
|
||||
uint8 msglen[8];
|
||||
|
||||
high = ( ctx->total[0] >> 29 )
|
||||
| ( ctx->total[1] << 3 );
|
||||
low = ( ctx->total[0] << 3 );
|
||||
|
||||
PUT_UINT32( low, msglen, 0 );
|
||||
PUT_UINT32( high, msglen, 4 );
|
||||
|
||||
last = ctx->total[0] & 0x3F;
|
||||
padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
|
||||
|
||||
md5_update( ctx, md5_padding, padn );
|
||||
md5_update( ctx, msglen, 8 );
|
||||
|
||||
PUT_UINT32( ctx->state[0], digest, 0 );
|
||||
PUT_UINT32( ctx->state[1], digest, 4 );
|
||||
PUT_UINT32( ctx->state[2], digest, 8 );
|
||||
PUT_UINT32( ctx->state[3], digest, 12 );
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
|
@ -248,76 +255,92 @@ void md5_finish(md5_context *ctx, uint8 digest[16])
|
|||
* those are the standard RFC 1321 test vectors
|
||||
*/
|
||||
|
||||
static char *msg[] = {
|
||||
"",
|
||||
"a",
|
||||
"abc",
|
||||
"message digest",
|
||||
"abcdefghijklmnopqrstuvwxyz",
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
||||
"12345678901234567890123456789012345678901234567890123456789012"
|
||||
"345678901234567890"};
|
||||
|
||||
static char *val[] = {
|
||||
"d41d8cd98f00b204e9800998ecf8427e", "0cc175b9c0f1b6a831c399e269772661",
|
||||
"900150983cd24fb0d6963f7d28e17f72", "f96b697d7cb7938d525a2f31aaf161d0",
|
||||
"c3fcd3d76192e4007dfb496cca67e13b", "d174ab98d277d9f5a5611c2c9f419d9f",
|
||||
"57edf4a22be3c955ac49da2e2107b67a"};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static char *msg[] =
|
||||
{
|
||||
FILE *f;
|
||||
int i, j;
|
||||
char output[33];
|
||||
md5_context ctx;
|
||||
unsigned char buf[1000];
|
||||
unsigned char md5sum[16];
|
||||
"",
|
||||
"a",
|
||||
"abc",
|
||||
"message digest",
|
||||
"abcdefghijklmnopqrstuvwxyz",
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
||||
"12345678901234567890123456789012345678901234567890123456789012" \
|
||||
"345678901234567890"
|
||||
};
|
||||
|
||||
if (argc < 2) {
|
||||
printf("\n MD5 Validation Tests:\n\n");
|
||||
static char *val[] =
|
||||
{
|
||||
"d41d8cd98f00b204e9800998ecf8427e",
|
||||
"0cc175b9c0f1b6a831c399e269772661",
|
||||
"900150983cd24fb0d6963f7d28e17f72",
|
||||
"f96b697d7cb7938d525a2f31aaf161d0",
|
||||
"c3fcd3d76192e4007dfb496cca67e13b",
|
||||
"d174ab98d277d9f5a5611c2c9f419d9f",
|
||||
"57edf4a22be3c955ac49da2e2107b67a"
|
||||
};
|
||||
|
||||
for (i = 0; i < 7; i++) {
|
||||
printf(" Test %d ", i + 1);
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
FILE *f;
|
||||
int i, j;
|
||||
char output[33];
|
||||
md5_context ctx;
|
||||
unsigned char buf[1000];
|
||||
unsigned char md5sum[16];
|
||||
|
||||
md5_starts(&ctx);
|
||||
md5_update(&ctx, (uint8 *)msg[i], strlen(msg[i]));
|
||||
md5_finish(&ctx, md5sum);
|
||||
if( argc < 2 )
|
||||
{
|
||||
printf( "\n MD5 Validation Tests:\n\n" );
|
||||
|
||||
for (j = 0; j < 16; j++) {
|
||||
sprintf(output + j * 2, "%02x", md5sum[j]);
|
||||
}
|
||||
for( i = 0; i < 7; i++ )
|
||||
{
|
||||
printf( " Test %d ", i + 1 );
|
||||
|
||||
if (memcmp(output, val[i], 32)) {
|
||||
printf("failed!\n");
|
||||
return (1);
|
||||
}
|
||||
md5_starts( &ctx );
|
||||
md5_update( &ctx, (uint8 *) msg[i], strlen( msg[i] ) );
|
||||
md5_finish( &ctx, md5sum );
|
||||
|
||||
printf("passed.\n");
|
||||
}
|
||||
for( j = 0; j < 16; j++ )
|
||||
{
|
||||
sprintf( output + j * 2, "%02x", md5sum[j] );
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
} else {
|
||||
if (!(f = fopen(argv[1], "rb"))) {
|
||||
perror("fopen");
|
||||
return (1);
|
||||
}
|
||||
if( memcmp( output, val[i], 32 ) )
|
||||
{
|
||||
printf( "failed!\n" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
md5_starts(&ctx);
|
||||
printf( "passed.\n" );
|
||||
}
|
||||
|
||||
while ((i = fread(buf, 1, sizeof(buf), f)) > 0) {
|
||||
md5_update(&ctx, buf, i);
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ! ( f = fopen( argv[1], "rb" ) ) )
|
||||
{
|
||||
perror( "fopen" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
md5_finish(&ctx, md5sum);
|
||||
md5_starts( &ctx );
|
||||
|
||||
for (j = 0; j < 16; j++) {
|
||||
printf("%02x", md5sum[j]);
|
||||
}
|
||||
while( ( i = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
|
||||
{
|
||||
md5_update( &ctx, buf, i );
|
||||
}
|
||||
|
||||
printf(" %s\n", argv[1]);
|
||||
}
|
||||
md5_finish( &ctx, md5sum );
|
||||
|
||||
return (0);
|
||||
for( j = 0; j < 16; j++ )
|
||||
{
|
||||
printf( "%02x", md5sum[j] );
|
||||
}
|
||||
|
||||
printf( " %s\n", argv[1] );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -336,26 +359,21 @@ unsigned char *chash_double(char *str, unsigned int seed)
|
|||
length = strlen(str);
|
||||
length += 4;
|
||||
ptr = bip_malloc(length);
|
||||
// conversion from ‘unsigned int’ to ‘unsigned char’ may change value
|
||||
// [-Werror=conversion]
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
ptr[0] = seed >> 24 & 0xff;
|
||||
#pragma GCC diagnostic pop
|
||||
ptr[1] = seed >> 16 & 0xff;
|
||||
ptr[2] = seed >> 8 & 0xff;
|
||||
ptr[3] = seed & 0xff;
|
||||
memcpy(ptr + 4, str, length - 4);
|
||||
|
||||
md5 = bip_malloc((size_t)16 + 4);
|
||||
memcpy(md5, ptr, (size_t)4);
|
||||
md5 = bip_malloc(16 + 4);
|
||||
memcpy(md5, ptr, 4);
|
||||
|
||||
md5_starts(&ctx);
|
||||
md5_update(&ctx, ptr, length);
|
||||
md5_finish(&ctx, md5 + 4);
|
||||
|
||||
md5_starts(&ctx);
|
||||
md5_update(&ctx, md5, (unsigned long)20);
|
||||
md5_update(&ctx, md5, 20);
|
||||
md5_finish(&ctx, md5 + 4);
|
||||
free(ptr);
|
||||
return md5;
|
||||
|
@ -376,3 +394,4 @@ int chash_cmp(char *try, unsigned char *pass, unsigned int seed)
|
|||
free(try_hash);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
17
src/md5.h
17
src/md5.h
|
@ -2,19 +2,22 @@
|
|||
#define _MD5_H
|
||||
|
||||
#ifndef uint8
|
||||
#define uint8 unsigned char
|
||||
#define uint8 unsigned char
|
||||
#endif
|
||||
|
||||
#ifndef uint32
|
||||
#define uint32 unsigned long int
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint32 total[2];
|
||||
uint32 state[4];
|
||||
uint8 buffer[64];
|
||||
} md5_context;
|
||||
typedef struct
|
||||
{
|
||||
uint32 total[2];
|
||||
uint32 state[4];
|
||||
uint8 buffer[64];
|
||||
}
|
||||
md5_context;
|
||||
|
||||
int chash_cmp(char *try, unsigned char *pass, unsigned int seed);
|
||||
int chash_cmp(char *try, unsigned char *pass,
|
||||
unsigned int seed);
|
||||
unsigned char *chash_double(char *str, unsigned int seed);
|
||||
#endif /* md5.h */
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* This file is part of the bip project
|
||||
* Copyright (C) 2016 Pierre-Louis Bonicoli
|
||||
*
|
||||
* 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 the file "COPYING" for the exact licensing terms.
|
||||
*/
|
||||
|
||||
#include "path_util.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
char *default_path(const char *biphome, const char *filename, const char *desc)
|
||||
{
|
||||
char *conf_file;
|
||||
// '/' and \0
|
||||
conf_file = bip_malloc(strlen(biphome) + strlen(filename) + 2);
|
||||
strcpy(conf_file, biphome);
|
||||
conf_file[strlen(biphome)] = '/';
|
||||
conf_file[strlen(biphome) + 1] = '\0';
|
||||
strcat(conf_file, filename);
|
||||
mylog(LOG_INFO, "Default %s: %s", desc, conf_file);
|
||||
return conf_file;
|
||||
}
|
||||
|
||||
void assert_path_exists(char *path)
|
||||
{
|
||||
struct stat st_buf;
|
||||
|
||||
if (stat(path, &st_buf) != 0)
|
||||
fatal("Path %s doesn't exist (%s)", path, strerror(errno));
|
||||
}
|
||||
|
||||
int check_path_exists(char *path)
|
||||
{
|
||||
struct stat st_buf;
|
||||
|
||||
if (stat(path, &st_buf) != 0) {
|
||||
mylog(LOG_WARN, "Path %s doesn't exist (%s)", path, strerror(errno));
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* This file is part of the bip project
|
||||
* Copyright (C) 2016 Pierre-Louis Bonicoli
|
||||
*
|
||||
* 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 the file "COPYING" for the exact licensing terms.
|
||||
*/
|
||||
#ifndef PATH_UTIL_H
|
||||
#define PATH_UTIL_H
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* return path of filename located in bip home directory */
|
||||
char *default_path(const char *biphome, const char *filename, const char *desc);
|
||||
/* exit program if path doesn't exist */
|
||||
void assert_path_exists(char *path);
|
||||
/* return 1 if path exists, 0 otherwise */
|
||||
int check_path_exists(char *path);
|
||||
|
||||
#endif
|
288
src/util.c
288
src/util.c
|
@ -2,8 +2,7 @@
|
|||
* $Id: util.c,v 1.60 2005/04/12 19:34:35 nohar Exp $
|
||||
*
|
||||
* This file is part of the bip project
|
||||
* Copyright (C) 2004,2005 Arnaud Cornet
|
||||
* Copyright (C) 2004,2005,2022 Loïc Gomez
|
||||
* Copyright (C) 2004 2005 Arnaud Cornet and Loïc Gomez
|
||||
*
|
||||
* 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
|
||||
|
@ -20,7 +19,6 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -29,17 +27,14 @@
|
|||
|
||||
extern int conf_log_level;
|
||||
extern int conf_log_system;
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
|
||||
extern int errno;
|
||||
#pragma GCC diagnostic pop
|
||||
extern FILE *conf_global_log_file;
|
||||
|
||||
void memory_fatal(void)
|
||||
{
|
||||
fflush(conf_global_log_file);
|
||||
#define OOMMSG "Out of memory.\n"
|
||||
fwrite(OOMMSG, (size_t)1, strlen(OOMMSG), conf_global_log_file);
|
||||
fwrite(OOMMSG, 1, strlen(OOMMSG), conf_global_log_file);
|
||||
#undef OOMMSG
|
||||
fflush(conf_global_log_file);
|
||||
exit(28);
|
||||
|
@ -77,17 +72,6 @@ void *bip_realloc(void *ptr, size_t size)
|
|||
return r;
|
||||
}
|
||||
|
||||
void bip_cfree(const void *ptr)
|
||||
{
|
||||
if (!ptr)
|
||||
return;
|
||||
// there's no other way to free a const pointer
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wcast-qual"
|
||||
free((void *)ptr);
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
char *bip_strdup(const char *str)
|
||||
{
|
||||
char *r = strdup(str);
|
||||
|
@ -96,98 +80,6 @@ char *bip_strdup(const char *str)
|
|||
return r;
|
||||
}
|
||||
|
||||
char *bip_strcat_fit(size_t *remaining, char *str, const char *str2)
|
||||
{
|
||||
char *res;
|
||||
|
||||
if (!remaining || !str || !str2) {
|
||||
mylog(LOG_DEBUGVERB, "bip_strcat_fit: got NULL pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res = memccpy(str, str2, '\0', *remaining);
|
||||
if (!res) {
|
||||
mylog(LOG_DEBUGTOOMUCH,
|
||||
"bip_strcat_fit: memccpy() failed, remaining %lu",
|
||||
*remaining);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res--;
|
||||
if (res < str) {
|
||||
mylog(LOG_DEBUG, "bip_strcat_fit: memccpy res < str");
|
||||
return NULL;
|
||||
}
|
||||
(*remaining) -= (size_t)(res - str);
|
||||
return res;
|
||||
}
|
||||
|
||||
#define STRCATF_BUF_MAXLEN 1024
|
||||
char *bip_strcatf_fit(size_t *remaining, char *str, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char str2[STRCATF_BUF_MAXLEN + 1];
|
||||
int written;
|
||||
char *res = NULL;
|
||||
|
||||
if (!remaining || !str || !fmt) {
|
||||
mylog(LOG_DEBUGVERB, "bip_strcatf_fit: NULL pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (*remaining > STRCATF_BUF_MAXLEN) {
|
||||
mylog(LOG_ERROR,
|
||||
"bip_strcatf_fit: remaining "
|
||||
"is over STRCATF_BUF_MAXLEN");
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
str2[*remaining] = '\0';
|
||||
written = vsnprintf(str2, *remaining, fmt, ap);
|
||||
if (written < 0) {
|
||||
mylog(LOG_ERROR, "bip_strcatf_fit: vsnprintf failed with: %s",
|
||||
strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((unsigned)written >= *remaining) {
|
||||
mylog(LOG_DEBUGVERB,
|
||||
"bip_strcatf_fit,vsnprintf: no space left");
|
||||
goto end;
|
||||
}
|
||||
|
||||
res = memccpy(str, str2, '\0', *remaining);
|
||||
if (!res) {
|
||||
mylog(LOG_DEBUGTOOMUCH,
|
||||
"bip_strcatf_fit: memccpy() failed, "
|
||||
"remaining %lu",
|
||||
*remaining);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (res < str) {
|
||||
mylog(LOG_DEBUG, "bip_strcatf_fit: memccpy res < str");
|
||||
goto end;
|
||||
}
|
||||
res--;
|
||||
(*remaining) -= (size_t)(res - str);
|
||||
|
||||
end:
|
||||
va_end(ap);
|
||||
return res;
|
||||
}
|
||||
|
||||
void bip_clock_gettime(clockid_t clockid, struct timespec *tp)
|
||||
{
|
||||
int err = clock_gettime(clockid, tp);
|
||||
|
||||
if (err != 0)
|
||||
fatal("clock_gettime: %s", strerror(errno));
|
||||
|
||||
if (tp->tv_sec < 0 || tp->tv_nsec < 0)
|
||||
fatal("clock_gettime returned negative time");
|
||||
}
|
||||
|
||||
/*
|
||||
* <nick> ::= <letter> { <letter> | <number> | <special> }
|
||||
* <special> ::= '-' | '[' | ']' | '\' | '`' | '^' | '{' | '}'
|
||||
|
@ -199,10 +91,10 @@ int is_valid_nick(char *str)
|
|||
return 0;
|
||||
|
||||
tmp = str;
|
||||
while (*tmp != '\0'
|
||||
&& (isalnum(*tmp) || *tmp == '-' || *tmp == '[' || *tmp == ']'
|
||||
|| *tmp == '\\' || *tmp == '`' || *tmp == '^' || *tmp == '{'
|
||||
|| *tmp == '}' || *tmp == '|' || *tmp == '_'))
|
||||
while (*tmp != '\0' && (isalnum(*tmp) || *tmp == '-' || *tmp == '[' ||
|
||||
*tmp == ']' || *tmp == '\\' || *tmp == '`' ||
|
||||
*tmp == '^' || *tmp == '{' || *tmp == '}' ||
|
||||
*tmp == '|' || *tmp == '_' ))
|
||||
tmp++;
|
||||
return (*tmp == '\0');
|
||||
}
|
||||
|
@ -214,8 +106,8 @@ int is_valid_username(char *str)
|
|||
return 0;
|
||||
|
||||
tmp = str;
|
||||
while (*tmp != '\0' && *tmp != ' ' && *tmp != '\0' && *tmp != '\r'
|
||||
&& *tmp != '\n')
|
||||
while (*tmp != '\0' && *tmp != ' ' && *tmp != '\0' && *tmp != '\r' &&
|
||||
*tmp != '\n')
|
||||
tmp++;
|
||||
return (*tmp == '\0');
|
||||
}
|
||||
|
@ -229,7 +121,9 @@ char *timestamp(void)
|
|||
time(&tv);
|
||||
tm = localtime(&tv);
|
||||
|
||||
strftime(ts, (size_t)20, "%d-%m-%Y %H:%M:%S", tm);
|
||||
snprintf(ts, 20, "%02d-%02d-%04d %02d:%02d:%02d", tm->tm_mday,
|
||||
tm->tm_mon + 1, tm->tm_year + 1900, tm->tm_hour,
|
||||
tm->tm_min, tm->tm_sec);
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
@ -242,7 +136,9 @@ char *hrtime(time_t s)
|
|||
return "never";
|
||||
tm = localtime(&s);
|
||||
|
||||
strftime(ts, (size_t)20, "%d-%m-%Y %H:%M:%S", tm);
|
||||
snprintf(ts, 20, "%02d-%02d-%04d %02d:%02d:%02d", tm->tm_mday,
|
||||
tm->tm_mon + 1, tm->tm_year + 1900, tm->tm_hour,
|
||||
tm->tm_min, tm->tm_sec);
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
@ -271,27 +167,27 @@ void _mylog(int level, char *fmt, va_list ap)
|
|||
return;
|
||||
|
||||
switch (level) {
|
||||
case LOG_FATAL:
|
||||
prefix = "FATAL: ";
|
||||
break;
|
||||
case LOG_DEBUGVERB:
|
||||
prefix = "DEBUGVERB: ";
|
||||
break;
|
||||
case LOG_DEBUG:
|
||||
prefix = "DEBUG: ";
|
||||
break;
|
||||
case LOG_ERROR:
|
||||
prefix = "ERROR: ";
|
||||
break;
|
||||
case LOG_WARN:
|
||||
prefix = "WARNING: ";
|
||||
break;
|
||||
case LOG_INFO:
|
||||
prefix = "";
|
||||
break;
|
||||
default:
|
||||
prefix = "";
|
||||
break;
|
||||
case LOG_FATAL:
|
||||
prefix = "FATAL: ";
|
||||
break;
|
||||
case LOG_DEBUGVERB:
|
||||
prefix = "DEBUGVERB: ";
|
||||
break;
|
||||
case LOG_DEBUG:
|
||||
prefix = "DEBUG: ";
|
||||
break;
|
||||
case LOG_ERROR:
|
||||
prefix = "ERROR: ";
|
||||
break;
|
||||
case LOG_WARN:
|
||||
prefix = "WARNING: ";
|
||||
break;
|
||||
case LOG_INFO:
|
||||
prefix = "";
|
||||
break;
|
||||
default:
|
||||
prefix = "";
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf(conf_global_log_file, "%s %s", timestamp(), prefix);
|
||||
|
@ -313,10 +209,12 @@ void mylog(int level, char *fmt, ...)
|
|||
|
||||
#ifdef HAVE_BACKTRACE
|
||||
#include <execinfo.h>
|
||||
void dump_trace(void)
|
||||
|
||||
void print_trace(void)
|
||||
{
|
||||
void *array[32];
|
||||
int size;
|
||||
size_t size;
|
||||
size_t i;
|
||||
|
||||
size = backtrace(array, 32);
|
||||
fflush(conf_global_log_file);
|
||||
|
@ -334,7 +232,7 @@ void fatal(char *fmt, ...)
|
|||
va_end(ap);
|
||||
|
||||
#ifdef HAVE_BACKTRACE
|
||||
dump_trace();
|
||||
print_trace();
|
||||
#endif
|
||||
|
||||
exit(200);
|
||||
|
@ -380,7 +278,6 @@ void list_add_first(list_t *list, void *ptr)
|
|||
{
|
||||
struct list_item *li;
|
||||
|
||||
assert(list);
|
||||
if (!ptr)
|
||||
fatal("Cannot add NULL ptr to list.");
|
||||
li = list_item(ptr);
|
||||
|
@ -395,8 +292,8 @@ void list_add_first(list_t *list, void *ptr)
|
|||
|
||||
void list_add_first_uniq(list_t *list, void *ptr)
|
||||
{
|
||||
assert(list);
|
||||
assert_msg(ptr, "Cannot add NULL ptr to list.");
|
||||
if (!ptr)
|
||||
fatal("Cannot add NULL ptr to list.");
|
||||
if (list_get(list, ptr))
|
||||
return;
|
||||
list_add_first(list, ptr);
|
||||
|
@ -406,8 +303,8 @@ void list_add_last(list_t *list, void *ptr)
|
|||
{
|
||||
struct list_item *li;
|
||||
|
||||
assert(list);
|
||||
assert_msg(ptr, "Cannot add NULL ptr to list.");
|
||||
if (!ptr)
|
||||
fatal("Cannot add NULL ptr to list.");
|
||||
li = list_item(ptr);
|
||||
if (!list->first) {
|
||||
list->first = list->last = li;
|
||||
|
@ -420,7 +317,6 @@ void list_add_last(list_t *list, void *ptr)
|
|||
|
||||
void *list_get_first(list_t *list)
|
||||
{
|
||||
assert(list);
|
||||
if (!list->first)
|
||||
return NULL;
|
||||
return list->first->ptr;
|
||||
|
@ -428,7 +324,6 @@ void *list_get_first(list_t *list)
|
|||
|
||||
void *list_get_last(list_t *list)
|
||||
{
|
||||
assert(list);
|
||||
if (!list->last)
|
||||
return NULL;
|
||||
return list->last->ptr;
|
||||
|
@ -437,10 +332,8 @@ void *list_get_last(list_t *list)
|
|||
void *list_remove_first(list_t *list)
|
||||
{
|
||||
struct list_item *l;
|
||||
void *ptr;
|
||||
void *ptr = list_get_first(list);
|
||||
|
||||
assert(list);
|
||||
ptr = list_get_first(list);
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
l = list->first;
|
||||
|
@ -454,10 +347,7 @@ void *list_remove_first(list_t *list)
|
|||
void *list_remove_last(list_t *list)
|
||||
{
|
||||
struct list_item *l;
|
||||
void *ptr;
|
||||
|
||||
assert(list);
|
||||
ptr = list_get_last(list);
|
||||
void *ptr = list_get_last(list);
|
||||
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
@ -475,8 +365,8 @@ void *list_remove_if_exists(list_t *list, const void *ptr)
|
|||
int debug = 0;
|
||||
void *ret = 0;
|
||||
|
||||
assert(list);
|
||||
assert_msg(list->cmp, "list does not have a cmp function");
|
||||
if (!list->cmp)
|
||||
fatal("list_remove: list does not have a cmp function\n");
|
||||
|
||||
for (list_it_init(list, &li); list_it_item(&li); list_it_next(&li)) {
|
||||
if (list->cmp(list_it_item(&li), ptr) == 0) {
|
||||
|
@ -503,7 +393,8 @@ void *list_get(list_t *list, const void *ptr)
|
|||
{
|
||||
struct list_item *it;
|
||||
|
||||
assert_msg(list->cmp, "list_get: list does not have a cmp function");
|
||||
if (!list->cmp)
|
||||
fatal("list_get: list does not have a cmp function\n");
|
||||
|
||||
for (it = list->first; it; it = it->next) {
|
||||
if (list->cmp(it->ptr, ptr) == 0)
|
||||
|
@ -514,13 +405,11 @@ void *list_get(list_t *list, const void *ptr)
|
|||
|
||||
int list_is_empty(list_t *l)
|
||||
{
|
||||
assert(l);
|
||||
return (l->first ? 0 : 1);
|
||||
}
|
||||
|
||||
void list_it_init(list_t *list, list_iterator_t *ti)
|
||||
{
|
||||
assert(list && ti);
|
||||
ti->list = list;
|
||||
ti->cur = list->first;
|
||||
ti->next = NULL;
|
||||
|
@ -528,7 +417,6 @@ void list_it_init(list_t *list, list_iterator_t *ti)
|
|||
|
||||
void list_it_init_last(list_t *list, list_iterator_t *ti)
|
||||
{
|
||||
assert(list && ti);
|
||||
ti->list = list;
|
||||
ti->cur = list->last;
|
||||
ti->next = NULL;
|
||||
|
@ -536,7 +424,6 @@ void list_it_init_last(list_t *list, list_iterator_t *ti)
|
|||
|
||||
void *list_it_remove(list_iterator_t *li)
|
||||
{
|
||||
assert(li);
|
||||
if (!li->cur)
|
||||
return NULL;
|
||||
|
||||
|
@ -560,14 +447,13 @@ void *list_it_remove(list_iterator_t *li)
|
|||
|
||||
void list_free(list_t *t)
|
||||
{
|
||||
assert(t);
|
||||
assert(list_is_empty(t));
|
||||
if (t->first != NULL)
|
||||
fprintf(stderr, "Warning, freeing non empty list\n");
|
||||
free(t);
|
||||
}
|
||||
|
||||
void list_append(list_t *dest, list_t *src)
|
||||
{
|
||||
assert(dest && src);
|
||||
if (src->last == NULL)
|
||||
return;
|
||||
if (dest->first == NULL) {
|
||||
|
@ -605,19 +491,18 @@ void hash_init(hash_t *h, int options)
|
|||
{
|
||||
int i;
|
||||
|
||||
assert(h);
|
||||
memset(h, 0, sizeof(hash_t));
|
||||
for (i = 0; i < 256; i++) {
|
||||
switch (options) {
|
||||
case HASH_NOCASE:
|
||||
list_init(&h->lists[i],
|
||||
(int (*)(const void *,
|
||||
const void *))hash_item_nocase_cmp);
|
||||
(int (*)(const void*, const void*))
|
||||
hash_item_nocase_cmp);
|
||||
break;
|
||||
case HASH_DEFAULT:
|
||||
list_init(&h->lists[i],
|
||||
(int (*)(const void *,
|
||||
const void *))hash_item_cmp);
|
||||
(int (*)(const void*,const void*))
|
||||
hash_item_cmp);
|
||||
break;
|
||||
default:
|
||||
fatal("wrong hash option %d", options);
|
||||
|
@ -630,7 +515,6 @@ void hash_clean(hash_t *h)
|
|||
int i;
|
||||
struct hash_item *hi;
|
||||
|
||||
assert(h);
|
||||
for (i = 0; i < 256; i++) {
|
||||
while ((hi = list_remove_first(&h->lists[i]))) {
|
||||
free(hi->key);
|
||||
|
@ -641,7 +525,6 @@ void hash_clean(hash_t *h)
|
|||
|
||||
void hash_free(hash_t *h)
|
||||
{
|
||||
assert(h);
|
||||
hash_clean(h);
|
||||
free(h);
|
||||
}
|
||||
|
@ -660,9 +543,8 @@ static unsigned char hash_func(const char *pkey)
|
|||
char c;
|
||||
unsigned long hash = 5381; /* 5381 & 0xff makes more sense */
|
||||
|
||||
// toupper should not return negative values (only char compatible int)
|
||||
while ((c = *pkey++))
|
||||
hash = ((hash << 5) + hash) ^ (long unsigned)toupper(c);
|
||||
hash = ((hash << 5) + hash) ^ toupper(c);
|
||||
return (unsigned char)hash;
|
||||
}
|
||||
|
||||
|
@ -670,7 +552,6 @@ void hash_insert(hash_t *hash, const char *key, void *ptr)
|
|||
{
|
||||
struct hash_item *it;
|
||||
|
||||
assert(hash && key);
|
||||
if (hash_get(hash, key))
|
||||
fatal("Element with key %s already in hash %x\n", key, hash);
|
||||
|
||||
|
@ -683,10 +564,7 @@ void hash_insert(hash_t *hash, const char *key, void *ptr)
|
|||
int hash_includes(hash_t *hash, const char *key)
|
||||
{
|
||||
struct hash_item *hi;
|
||||
list_t *list;
|
||||
|
||||
assert(hash && key);
|
||||
list = &hash->lists[hash_func(key)];
|
||||
list_t *list = &hash->lists[hash_func(key)];
|
||||
hi = list_get(list, key);
|
||||
return hi != NULL;
|
||||
}
|
||||
|
@ -694,10 +572,7 @@ int hash_includes(hash_t *hash, const char *key)
|
|||
void *hash_get(hash_t *hash, const char *key)
|
||||
{
|
||||
struct hash_item *hi;
|
||||
list_t *list;
|
||||
|
||||
assert(hash && key);
|
||||
list = &hash->lists[hash_func(key)];
|
||||
list_t *list = &hash->lists[hash_func(key)];
|
||||
hi = list_get(list, key);
|
||||
if (!hi)
|
||||
return NULL;
|
||||
|
@ -706,7 +581,6 @@ void *hash_get(hash_t *hash, const char *key)
|
|||
|
||||
void *hash_remove_if_exists(hash_t *hash, const char *key)
|
||||
{
|
||||
assert(hash && key);
|
||||
if (hash_get(hash, key) == NULL)
|
||||
return NULL;
|
||||
return hash_remove(hash, key);
|
||||
|
@ -716,8 +590,6 @@ void *hash_remove(hash_t *hash, const char *key)
|
|||
{
|
||||
struct hash_item *it;
|
||||
void *ptr;
|
||||
|
||||
assert(hash && key);
|
||||
it = (struct hash_item *)list_remove(&hash->lists[hash_func(key)], key);
|
||||
if (!it)
|
||||
return NULL;
|
||||
|
@ -731,7 +603,6 @@ int hash_is_empty(hash_t *h)
|
|||
{
|
||||
int i;
|
||||
|
||||
assert(h);
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (!list_is_empty(&h->lists[i]))
|
||||
return 0;
|
||||
|
@ -741,7 +612,6 @@ int hash_is_empty(hash_t *h)
|
|||
|
||||
void hash_it_init(hash_t *h, hash_iterator_t *hi)
|
||||
{
|
||||
assert(h);
|
||||
memset(hi, 0, sizeof(hash_iterator_t));
|
||||
hi->hash = h;
|
||||
|
||||
|
@ -753,7 +623,6 @@ void hash_it_init(hash_t *h, hash_iterator_t *hi)
|
|||
|
||||
void hash_it_next(hash_iterator_t *hi)
|
||||
{
|
||||
assert(hi);
|
||||
list_it_next(&hi->lit);
|
||||
if (!list_it_item(&hi->lit)) {
|
||||
do {
|
||||
|
@ -769,7 +638,6 @@ void *hash_it_item(hash_iterator_t *h)
|
|||
{
|
||||
struct hash_item *hi;
|
||||
|
||||
assert(h);
|
||||
hi = list_it_item(&h->lit);
|
||||
if (!hi)
|
||||
return NULL;
|
||||
|
@ -779,8 +647,6 @@ void *hash_it_item(hash_iterator_t *h)
|
|||
const char *hash_it_key(hash_iterator_t *h)
|
||||
{
|
||||
struct hash_item *hi;
|
||||
|
||||
assert(h);
|
||||
hi = list_it_item(&h->lit);
|
||||
if (!hi)
|
||||
return NULL;
|
||||
|
@ -792,7 +658,6 @@ void *hash_it_remove(hash_iterator_t *hi)
|
|||
struct hash_item *hitem;
|
||||
void *ptr;
|
||||
|
||||
assert(hi);
|
||||
hitem = list_it_remove(&hi->lit);
|
||||
|
||||
ptr = hitem->item;
|
||||
|
@ -804,8 +669,7 @@ void *hash_it_remove(hash_iterator_t *hi)
|
|||
void hash_dump(hash_t *h)
|
||||
{
|
||||
hash_iterator_t it;
|
||||
assert(h);
|
||||
for (hash_it_init(h, &it); hash_it_key(&it); hash_it_next(&it))
|
||||
for (hash_it_init(h, &it); hash_it_key(&it) ;hash_it_next(&it))
|
||||
printf("%s => %p\n", hash_it_key(&it), hash_it_item(&it));
|
||||
}
|
||||
|
||||
|
@ -814,7 +678,6 @@ list_t *hash_keys(hash_t *hash)
|
|||
hash_iterator_t hi;
|
||||
list_t *ret;
|
||||
|
||||
assert(hash);
|
||||
ret = list_new(NULL);
|
||||
|
||||
for (hash_it_init(hash, &hi); hash_it_item(&hi); hash_it_next(&hi))
|
||||
|
@ -825,9 +688,6 @@ list_t *hash_keys(hash_t *hash)
|
|||
|
||||
void hash_rename_key(hash_t *h, const char *oldk, const char *newk)
|
||||
{
|
||||
assert(h && oldk && newk);
|
||||
if (strcmp(oldk, newk) == 0)
|
||||
return;
|
||||
hash_insert(h, newk, hash_remove(h, oldk));
|
||||
}
|
||||
|
||||
|
@ -841,7 +701,7 @@ char *bip_strmaydup(char *s)
|
|||
void strucase(char *s)
|
||||
{
|
||||
while (*s) {
|
||||
*s = (char)toupper(*s); // toupper, safe to cast to char
|
||||
*s = toupper(*s);
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
@ -867,37 +727,21 @@ array_t *array_new(void)
|
|||
|
||||
void array_ensure(array_t *a, int index)
|
||||
{
|
||||
assert(a && index >= 0);
|
||||
assert(index >= 0);
|
||||
|
||||
if (array_includes(a, index))
|
||||
return;
|
||||
a->elemv = bip_realloc(a->elemv, sizeof(void *) * (size_t)(index + 1));
|
||||
// a->elemc should be lower than index + 1
|
||||
memset(a->elemv + a->elemc, 0,
|
||||
sizeof(void *) * (size_t)(index + 1 - a->elemc));
|
||||
a->elemv = bip_realloc(a->elemv, sizeof(void *) * (index + 1));
|
||||
memset(a->elemv + a->elemc, 0, sizeof(void *) * (index + 1 - a->elemc));
|
||||
a->elemc = index + 1;
|
||||
}
|
||||
|
||||
const void *array_drop(array_t *a, int index)
|
||||
{
|
||||
int i;
|
||||
const void *ret;
|
||||
|
||||
assert(a && array_includes(a, index));
|
||||
|
||||
ret = a->elemv[index];
|
||||
for (i = index; i < array_count(a) - 1; i++)
|
||||
a->elemv[i] = a->elemv[i + 1];
|
||||
a->elemc--;
|
||||
return ret;
|
||||
}
|
||||
|
||||
array_t *array_extract(array_t *a, int index, int upto)
|
||||
{
|
||||
array_t *ret;
|
||||
int i;
|
||||
|
||||
assert(a && array_includes(a, index));
|
||||
assert(array_includes(a, index));
|
||||
if (upto == -1)
|
||||
upto = a->elemc;
|
||||
assert((index == 0 && upto == 0) || array_includes(a, upto - 1));
|
||||
|
@ -916,7 +760,6 @@ array_t *array_extract(array_t *a, int index, int upto)
|
|||
|
||||
void array_deinit(array_t *a)
|
||||
{
|
||||
assert(a);
|
||||
if (a->elemv)
|
||||
free(a->elemv);
|
||||
array_init(a);
|
||||
|
@ -924,7 +767,6 @@ void array_deinit(array_t *a)
|
|||
|
||||
void array_free(array_t *a)
|
||||
{
|
||||
assert(a);
|
||||
if (a->elemv)
|
||||
free(a->elemv);
|
||||
free(a);
|
||||
|
|
100
src/util.h
100
src/util.h
|
@ -2,8 +2,7 @@
|
|||
* $Id: util.h,v 1.35 2005/04/12 19:34:35 nohar Exp $
|
||||
*
|
||||
* This file is part of the bip project
|
||||
* Copyright (C) 2004,2005 Arnaud Cornet
|
||||
* Copyright (C) 2004,2005,2022 Loïc Gomez
|
||||
* Copyright (C) 2004 2005 Arnaud Cornet and Loïc Gomez
|
||||
*
|
||||
* 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
|
||||
|
@ -31,9 +30,6 @@
|
|||
#define HASH_NOCASE 1
|
||||
#define HASH_DEFAULT 0
|
||||
|
||||
#define SOFT_FAIL 0
|
||||
#define HARD_FAIL 1
|
||||
|
||||
void mylog(int level, char *fmt, ...);
|
||||
void _mylog(int level, char *fmt, va_list ap);
|
||||
void fatal(char *fmt, ...);
|
||||
|
@ -46,14 +42,11 @@ struct list_item {
|
|||
void *ptr;
|
||||
};
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
|
||||
typedef struct list {
|
||||
struct list_item *first;
|
||||
struct list_item *last;
|
||||
int (*cmp)();
|
||||
} list_t;
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
typedef struct list_iterator {
|
||||
list_t *list;
|
||||
|
@ -74,45 +67,39 @@ typedef struct hash_iterator {
|
|||
|
||||
typedef struct array {
|
||||
int elemc;
|
||||
const void **elemv;
|
||||
void **elemv;
|
||||
} array_t;
|
||||
|
||||
#define MOVE_STRING(dest, src) \
|
||||
do { \
|
||||
if (dest) \
|
||||
free(dest); \
|
||||
(dest) = (src); \
|
||||
(src) = NULL; \
|
||||
} while (0)
|
||||
#define MOVE_STRING(dest, src) do {\
|
||||
if (dest)\
|
||||
free(dest);\
|
||||
(dest) = (src);\
|
||||
(src) = NULL;\
|
||||
} while(0)
|
||||
|
||||
#define FREE(a) \
|
||||
free(a); \
|
||||
(a) = NULL;
|
||||
#define FREE(a) free(a); (a) = NULL;
|
||||
|
||||
#define MAYFREE(a) \
|
||||
do { \
|
||||
if (a) { \
|
||||
free(a); \
|
||||
(a) = NULL; \
|
||||
} \
|
||||
} while (0);
|
||||
#define MAYFREE(a) do { \
|
||||
if (a) { \
|
||||
free(a); \
|
||||
(a) = NULL; \
|
||||
} \
|
||||
} while(0);
|
||||
|
||||
#define assert(condition) \
|
||||
do { \
|
||||
if (!(condition)) \
|
||||
fatal("Failed assertion in " __FILE__ \
|
||||
"(%d): " #condition, \
|
||||
__LINE__); \
|
||||
} while (0)
|
||||
#define assert(condition) \
|
||||
do { \
|
||||
if (!(condition)) \
|
||||
fatal("Failed assetion in " __FILE__ "(%d): " \
|
||||
#condition, __LINE__); \
|
||||
} while(0)
|
||||
|
||||
#define assert_msg(condition, msg) \
|
||||
do { \
|
||||
if (!(condition)) \
|
||||
fatal("%s in " __FILE__ "(%d): " #condition, (msg), \
|
||||
__LINE__); \
|
||||
} while (0)
|
||||
#define assert_msg(condition, msg) \
|
||||
do { \
|
||||
if (!(condition)) \
|
||||
fatal(msg); \
|
||||
} while(0)
|
||||
|
||||
void list_init(list_t *list, int (*cmp)(const void *, const void *));
|
||||
void list_init(list_t *list, int (*cmp)(const void*, const void*));
|
||||
int list_ptr_cmp(const void *a, const void *b);
|
||||
list_t *list_new(int (*cmp)(const void *, const void *));
|
||||
void *list_remove(list_t *list, const void *ptr);
|
||||
|
@ -134,10 +121,9 @@ int list_is_empty(list_t *l);
|
|||
|
||||
static inline void list_it_next(list_iterator_t *ti)
|
||||
{
|
||||
assert(ti);
|
||||
if (ti->cur) {
|
||||
if (ti->next)
|
||||
fatal("list_it_next: inconsistent iterator state");
|
||||
fatal("list_it_next: inconsistent interator state");
|
||||
ti->cur = ti->cur->next;
|
||||
} else if (ti->next) {
|
||||
ti->cur = ti->next;
|
||||
|
@ -147,7 +133,6 @@ static inline void list_it_next(list_iterator_t *ti)
|
|||
|
||||
static inline void *list_it_item(list_iterator_t *ti)
|
||||
{
|
||||
assert(ti);
|
||||
if (!ti->cur)
|
||||
return NULL;
|
||||
return ti->cur->ptr;
|
||||
|
@ -186,15 +171,10 @@ char *checkmode2text(int v);
|
|||
void *bip_malloc(size_t size);
|
||||
void *bip_calloc(size_t nmemb, size_t size);
|
||||
void *bip_realloc(void *ptr, size_t size);
|
||||
void bip_cfree(const void *ptr);
|
||||
char *bip_strdup(const char *str);
|
||||
char *bip_strcat_fit(size_t *remaining, char *str, const char *str2);
|
||||
char *bip_strcatf_fit(size_t *remaining, char *str, const char *str2, ...);
|
||||
void bip_clock_gettime(clockid_t clockid, struct timespec *tp);
|
||||
#define array_each(a, idx, ptr) \
|
||||
for ((idx) = 0; (idx) < (a)->elemc \
|
||||
&& (((ptr) = bip_strdup(array_get((a), (idx)))) || 1); \
|
||||
(idx)++)
|
||||
#define array_each(a, idx, ptr) for ((idx) = 0; \
|
||||
(idx) < (a)->elemc && (((ptr) = array_get((a), (idx))) || 1); \
|
||||
(idx)++)
|
||||
|
||||
void array_init(array_t *a);
|
||||
array_t *array_new(void);
|
||||
|
@ -202,55 +182,49 @@ void array_ensure(array_t *a, int index);
|
|||
array_t *array_extract(array_t *a, int index, int upto);
|
||||
void array_deinit(array_t *a);
|
||||
void array_free(array_t *a);
|
||||
const void *array_drop(array_t *a, int index);
|
||||
static inline int array_count(array_t *a)
|
||||
{
|
||||
assert(a);
|
||||
return a->elemc;
|
||||
}
|
||||
|
||||
static inline int array_includes(array_t *a, int index)
|
||||
{
|
||||
assert(a && index >= 0);
|
||||
assert(index >= 0);
|
||||
return a->elemc > index;
|
||||
}
|
||||
|
||||
static inline void array_set(array_t *a, int index, void *ptr)
|
||||
{
|
||||
assert(a);
|
||||
array_ensure(a, index);
|
||||
a->elemv[index] = ptr;
|
||||
}
|
||||
|
||||
static inline const void *array_get(array_t *a, int index)
|
||||
static inline void *array_get(array_t *a, int index)
|
||||
{
|
||||
assert(a && array_includes(a, index));
|
||||
assert(array_includes(a, index));
|
||||
return a->elemv[index];
|
||||
}
|
||||
|
||||
static inline void array_push(array_t *a, void *ptr)
|
||||
{
|
||||
int idx;
|
||||
int idx = a->elemc;
|
||||
|
||||
assert(a);
|
||||
idx = a->elemc;
|
||||
array_ensure(a, idx);
|
||||
a->elemv[idx] = ptr;
|
||||
}
|
||||
|
||||
static inline void *array_pop(array_t *a)
|
||||
{
|
||||
assert(a);
|
||||
if (a->elemc == 0)
|
||||
return NULL;
|
||||
if (a->elemc == 1) {
|
||||
void *ptr = bip_strdup(a->elemv[0]);
|
||||
void *ptr = a->elemv[0];
|
||||
free(a->elemv);
|
||||
a->elemv = NULL;
|
||||
a->elemc = 0;
|
||||
return ptr;
|
||||
}
|
||||
return (void *)bip_strdup(a->elemv[--a->elemc]);
|
||||
return a->elemv[--a->elemc];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* Base64 encoding/decoding (RFC1341)
|
||||
* Copyright (c) 2005-2011, Jouni Malinen <j@w1.fi>
|
||||
* Copyright (c) 2022 Loïc Gomez
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "base64.h"
|
||||
|
||||
static const unsigned char base64_table[65] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
/**
|
||||
* base64_encode - Base64 encode
|
||||
* @src: Data to be encoded
|
||||
* @len: Length of the data to be encoded
|
||||
* @out_len: Pointer to output length variable, or %NULL if not used
|
||||
* Returns: Allocated buffer of out_len bytes of encoded data,
|
||||
* or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer. Returned buffer is
|
||||
* nul terminated to make it easier to use as a C string. The nul terminator is
|
||||
* not included in out_len.
|
||||
*
|
||||
* BIP change: remove line returns.
|
||||
*/
|
||||
unsigned char *base64_encode(const unsigned char *src, size_t len,
|
||||
size_t *out_len)
|
||||
{
|
||||
unsigned char *out, *pos;
|
||||
const unsigned char *end, *in;
|
||||
size_t olen;
|
||||
int line_len;
|
||||
|
||||
olen = len * 4 / 3 + 4; /* 3-byte blocks to 4-byte */
|
||||
olen += olen / 72; /* line feeds */
|
||||
olen++; /* nul termination */
|
||||
if (olen < len)
|
||||
return NULL; /* integer overflow */
|
||||
out = malloc(olen);
|
||||
if (out == NULL)
|
||||
return NULL;
|
||||
|
||||
end = src + len;
|
||||
in = src;
|
||||
pos = out;
|
||||
line_len = 0;
|
||||
while (end - in >= 3) {
|
||||
*pos++ = base64_table[in[0] >> 2];
|
||||
*pos++ = base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)];
|
||||
*pos++ = base64_table[((in[1] & 0x0f) << 2) | (in[2] >> 6)];
|
||||
*pos++ = base64_table[in[2] & 0x3f];
|
||||
in += 3;
|
||||
line_len += 4;
|
||||
/*
|
||||
* BIP change: remove line returns.
|
||||
if (line_len >= 72) {
|
||||
*pos++ = '\n';
|
||||
line_len = 0;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if (end - in) {
|
||||
*pos++ = base64_table[in[0] >> 2];
|
||||
if (end - in == 1) {
|
||||
*pos++ = base64_table[(in[0] & 0x03) << 4];
|
||||
*pos++ = '=';
|
||||
} else {
|
||||
*pos++ = base64_table[((in[0] & 0x03) << 4)
|
||||
| (in[1] >> 4)];
|
||||
*pos++ = base64_table[(in[1] & 0x0f) << 2];
|
||||
}
|
||||
*pos++ = '=';
|
||||
line_len += 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* BIP change: remove line returns.
|
||||
if (line_len)
|
||||
*pos++ = '\n';
|
||||
*/
|
||||
|
||||
*pos = '\0';
|
||||
if (out_len)
|
||||
*out_len = (size_t)(pos - out);
|
||||
return out;
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
* Base64 encoding/decoding (RFC1341)
|
||||
* Copyright (c) 2005, Jouni Malinen <j@w1.fi>
|
||||
* Copyright (c) 2022 Loïc Gomez
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef BASE64_H
|
||||
#define BASE64_H
|
||||
|
||||
unsigned char *base64_encode(const unsigned char *src, size_t len,
|
||||
size_t *out_len);
|
||||
|
||||
#endif /* BASE64_H */
|
|
@ -0,0 +1 @@
|
|||
#define BIP_VERSION "0.7.5-git"
|
|
@ -1,20 +0,0 @@
|
|||
Notes about systemd unit files for bip.
|
||||
|
||||
Distro specific commandline configuration is provided by installing a script
|
||||
named. A default script named bip_env.sh is provided.
|
||||
|
||||
This should write /run/sysconfig/bip based on configuration
|
||||
information such as in /etc/sysconfig/bip or /etc/defaults/bip. It is run once
|
||||
by bip-config.service.
|
||||
|
||||
Distro specific path for bip_env.sh script must be set using a
|
||||
bip-config.service.d/distrib.conf unit file drop-in:
|
||||
[Service]
|
||||
ExecStart=/path/to/bip_env.sh
|
||||
|
||||
bip_env.sh try some default paths for the default configuration file: either
|
||||
/etc/default/bip or /etc/sysconfig/bip.
|
||||
Optionaly, the default configuration file path can be set too:
|
||||
[Service]
|
||||
ExecStart=/path/to/bip_env.sh
|
||||
Environment=BIP_DEFAULT_CONFIG='/path/to/default/bip'
|
|
@ -1,12 +0,0 @@
|
|||
[Unit]
|
||||
Description=Preprocess Bip configuration
|
||||
After=local-fs.target
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=no
|
||||
# Packagers must define:
|
||||
# - ExecStart=/path/to/bip_env.sh
|
||||
# - Environment='BIP_DEFAULT_CONFIG=/path/to/default/bip'
|
||||
# using a unit file drop-in bip-config.service.d/<distrib>.conf
|
|
@ -1,24 +0,0 @@
|
|||
[Unit]
|
||||
Description=Bip IRC Proxy
|
||||
Documentation=man:bip(1) man:bip.conf(5)
|
||||
Requires=network.target
|
||||
|
||||
Wants=bip-config.service
|
||||
After=bip-config.service
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=/run/sysconfig/bip
|
||||
|
||||
Type=forking
|
||||
User=bip
|
||||
Group=bip
|
||||
ExecStartPre=/bin/sh -c '[ ${ENABLED:-1} != 0 ]'
|
||||
ExecStart=/usr/bin/bip $DAEMON_ARGS
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
RuntimeDirectory=bip
|
||||
RuntimeDirectoryMode=0750
|
||||
KillMode=process
|
||||
Restart=on-abnormal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -1,40 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Create /run/sysconfig/bip from default configuration file, for
|
||||
# bip-config.service
|
||||
|
||||
# BIP_DEFAULT_CONFIG environment variable can be defined by packagers in a
|
||||
# drop-in override of bip-config.service unit
|
||||
if [ -n "${BIP_DEFAULT_CONFIG}" ]; then
|
||||
# try some default paths
|
||||
if [ -r /etc/default/bip ]; then
|
||||
BIP_DEFAULT_CONFIG=/etc/default/bip
|
||||
. "${BIP_DEFAULT_CONFIG}"
|
||||
elif [ -r /etc/sysconfig/bip ]; then
|
||||
BIP_DEFAULT_CONFIG=/etc/sysconfig/bip
|
||||
. "${BIP_DEFAULT_CONFIG}"
|
||||
fi
|
||||
else
|
||||
. "${BIP_DEFAULT_CONFIG}"
|
||||
fi
|
||||
|
||||
ENABLED=${ENABLED:-1}
|
||||
|
||||
mkdir -p /run/sysconfig
|
||||
{
|
||||
echo ENABLED=${ENABLED}
|
||||
DAEMON_HOME=${DAEMON_HOME:-/var/lib/bip}
|
||||
DAEMON_CONFIG=${DAEMON_CONFIG:-/etc/bip/bip.conf}
|
||||
echo "DAEMON_ARGS=${DAEMON_ARGS:--f '${DAEMON_CONFIG}' -s '${DAEMON_HOME}'}"
|
||||
} > /run/sysconfig/bip
|
||||
|
||||
if [ ${ENABLED} = 0 ]; then
|
||||
echo "INFO: BIP is explicitely disabled (ENABLED == 0) in" \
|
||||
"'${BIP_DEFAULT_CONFIG}'."
|
||||
else
|
||||
if [ -n "${DAEMON_USER}" -o -n "${DAEMON_GROUP}" ]; then
|
||||
echo "ERROR: Using systemd, DAEMON_USER and DAEMON_GROUP could not" \
|
||||
"be defined using the default configuration file. A drop-in" \
|
||||
"override of bip-config.service unit need to be created instead."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
|
@ -1,5 +0,0 @@
|
|||
TESTS = check_line
|
||||
check_PROGRAMS = check_line
|
||||
check_line_SOURCES = check_line.c $(top_builddir)/src/line.h
|
||||
check_line_CFLAGS = @CHECK_CFLAGS@ $(OPENSSL_CFLAGS)
|
||||
check_line_LDADD = $(top_builddir)/src/libbip.a $(top_builddir)/src/libbiplex.a @CHECK_LIBS@ $(OPENSSL_LIBS)
|
|
@ -1,134 +0,0 @@
|
|||
#include <check.h>
|
||||
#include "../src/line.h"
|
||||
|
||||
START_TEST(test_line_init)
|
||||
{
|
||||
struct line line;
|
||||
irc_line_init(&line);
|
||||
irc_line_append(&line, "line");
|
||||
char *hi_string = irc_line_to_string(&line);
|
||||
ck_assert_str_eq(hi_string, "line\r\n");
|
||||
free(hi_string);
|
||||
_irc_line_deinit(&line);
|
||||
|
||||
struct line *line2 = irc_line_new();
|
||||
irc_line_append(line2, "line");
|
||||
hi_string = irc_line_to_string(line2);
|
||||
ck_assert_str_eq(hi_string, "line\r\n");
|
||||
free(hi_string);
|
||||
irc_line_free(line2);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_line_parse)
|
||||
{
|
||||
struct line *line = irc_line_new_from_string(
|
||||
":origin COMMAND parameter1 parameter2 "
|
||||
":multi word parameter\r\n");
|
||||
ck_assert_int_eq(irc_line_count(line), 4);
|
||||
ck_assert(irc_line_includes(line, 0));
|
||||
ck_assert(irc_line_includes(line, 3));
|
||||
ck_assert(!irc_line_includes(line, 4));
|
||||
ck_assert_str_eq(line->origin, "origin");
|
||||
ck_assert_str_eq(irc_line_elem(line, 0), "COMMAND");
|
||||
ck_assert_str_eq(irc_line_elem(line, 1), "parameter1");
|
||||
ck_assert_str_eq(irc_line_elem(line, 2), "parameter2");
|
||||
ck_assert_str_eq(irc_line_elem(line, 3), "multi word parameter\r\n");
|
||||
irc_line_free(line);
|
||||
|
||||
line = irc_line_new_from_string(
|
||||
"COMMAND parameter1 parameter2 :multi word parameter\r\n");
|
||||
ck_assert_int_eq(irc_line_count(line), 4);
|
||||
ck_assert(irc_line_includes(line, 0));
|
||||
ck_assert(irc_line_includes(line, 3));
|
||||
ck_assert(!irc_line_includes(line, 4));
|
||||
ck_assert_str_eq(irc_line_elem(line, 0), "COMMAND");
|
||||
ck_assert_str_eq(irc_line_elem(line, 1), "parameter1");
|
||||
ck_assert_str_eq(irc_line_elem(line, 2), "parameter2");
|
||||
ck_assert_str_eq(irc_line_elem(line, 3), "multi word parameter\r\n");
|
||||
irc_line_free(line);
|
||||
|
||||
line = irc_line_new_from_string(":origin COMMAND\r\n");
|
||||
ck_assert_str_eq(line->origin, "origin");
|
||||
ck_assert_int_eq(irc_line_count(line), 1);
|
||||
ck_assert(irc_line_includes(line, 0));
|
||||
ck_assert(!irc_line_includes(line, 1));
|
||||
ck_assert_str_eq(irc_line_elem(line, 0), "COMMAND\r\n");
|
||||
irc_line_free(line);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_elem_equals)
|
||||
{
|
||||
struct line *line = irc_line_new_from_string(
|
||||
":origin COMMAND parameter1 parameter2 "
|
||||
":multi word parameter\r\n");
|
||||
ck_assert(irc_line_elem_equals(line, 0, "COMMAND"));
|
||||
ck_assert(irc_line_elem_case_equals(line, 0, "command"));
|
||||
ck_assert(!irc_line_elem_equals(line, 0, "notcommand"));
|
||||
ck_assert(!irc_line_elem_case_equals(line, 0, "notcommand"));
|
||||
irc_line_free(line);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_line_pop)
|
||||
{
|
||||
struct line *line = irc_line_new_from_string(
|
||||
":origin COMMAND parameter1 parameter2 "
|
||||
":multi word parameter\r\n");
|
||||
char *top = irc_line_pop(line);
|
||||
ck_assert_str_eq(top, "multi word parameter\r\n");
|
||||
free(top);
|
||||
top = irc_line_pop(line);
|
||||
ck_assert_str_eq(top, "parameter2");
|
||||
free(top);
|
||||
irc_line_free(line);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_line_drop)
|
||||
{
|
||||
struct line *line = irc_line_new_from_string(
|
||||
":origin COMMAND parameter1 parameter2 "
|
||||
":multi word parameter\r\n");
|
||||
irc_line_drop(line, 1);
|
||||
ck_assert(irc_line_elem_equals(line, 0, "COMMAND"));
|
||||
ck_assert(irc_line_elem_equals(line, 1, "parameter2"));
|
||||
irc_line_drop(line, 0);
|
||||
ck_assert(irc_line_elem_equals(line, 0, "parameter2"));
|
||||
irc_line_free(line);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
Suite *money_suite(void)
|
||||
{
|
||||
Suite *s;
|
||||
TCase *tc_core;
|
||||
|
||||
s = suite_create("bip");
|
||||
|
||||
tc_core = tcase_create("core");
|
||||
|
||||
tcase_add_test(tc_core, test_line_init);
|
||||
tcase_add_test(tc_core, test_line_parse);
|
||||
tcase_add_test(tc_core, test_elem_equals);
|
||||
tcase_add_test(tc_core, test_line_pop);
|
||||
suite_add_tcase(s, tc_core);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int number_failed;
|
||||
Suite *s;
|
||||
SRunner *sr;
|
||||
|
||||
s = money_suite();
|
||||
sr = srunner_create(s);
|
||||
|
||||
srunner_run_all(sr, CK_NORMAL);
|
||||
number_failed = srunner_ntests_failed(sr);
|
||||
srunner_free(sr);
|
||||
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
Loading…
Reference in New Issue