GitLab's annual major release is around the corner. Along with a lot of new and exciting features, there will be a few breaking changes. Learn more here.

Commit f6dcdc19 authored by Peter Pentchev's avatar Peter Pentchev
Browse files

New upstream version 20190725+ds1

parent ab6a3a97
#
# Copyright (C) 2019, Thomas Maier-Komor
#
# This is source code of mbuffer.
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
cmake_minimum_required(VERSION 3.1.0)
include(CheckStructHasMember)
include(CheckLibraryExists)
include(CheckSymbolExists)
include(CMakePrintHelpers)
project(mbuffer C)
find_package(Threads)
set(PACKAGE_VERSION "20190625")
set(CMAKE_C_FLAGS_DEBUG "-g")
set(CMAKE_LD_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_RELEASE "-O2")
set(CMAKE_LD_FLAGS_RELEASE "-O2")
set(TESTTREE "..")
add_compile_options("-Wall")
add_definitions(-DDEBUG)
find_program(AWK NAMES gawk awk)
find_program(MT mt)
find_program(OPENSSL openssl)
find_program(NM NAMES gnm nm)
find_program(SH NAMES bash sh)
find_program(DIFF NAMES gdiff diff)
find_program(TAR NAMES gtar tar)
set(TESTFILE "test.tar" CACHE PATH "test input file")
#message(STATUS "testfile is ${TESTFILE}")
check_struct_has_member("struct stat" st_blksize sys/stat.h HAVE_STRUCT_STAT_ST_BLKSIZE LANGUAGE C)
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
check_library_exists(crypto MD5_Init "openssl/md5.h" HAVE_LIBCRYPTO)
if (HAVE_LIBCRYPTO)
set(LIBS ${LIBS} crypto)
endif()
check_include_file(alloca.h HAVE_ALLOCA_H)
check_include_file(md5.h HAVE_MD5_H)
check_include_file(sys/sendfile.h HAVE_SENDFILE_H)
check_symbol_exists(alloca stdlib.h;alloca.h HAVE_ALLOCA)
check_symbol_exists(sendfile "sendfile.h;sys/sendfile.h;sys/socket.h" HAVE_SENDFILE)
check_symbol_exists(hstrerror netdb.h HAVE_HSTRERROR)
check_symbol_exists(getaddrinfo "netdb.h;sys/socket.h" HAVE_GETADDRINFO)
check_symbol_exists(mmap sys/mman.h HAVE_MMAP)
check_symbol_exists(seteuid unistd.h HAVE_SETEUID)
find_library(LIBSENDFILE sendfile)
if (LIBSENDFILE)
set(LIBS ${LIBS} ${LIBSENDFILE})
endif()
find_library(LIBDL dl)
if (LIBDL)
set(LIBS ${LIBS} ${LIBDL})
endif()
find_library(LIBRT rt)
if (LIBRT)
set(LIBS ${LIBS} ${LIBRT})
endif()
find_library(LIBRESOLV resolv)
if (LIBRESOLV)
set(LIBS ${LIBS} ${LIBRESOLV})
endif()
find_library(LIBSOCKET socket)
if (LIBSOCKET)
set(LIBS ${LIBS} ${LIBSOCKET})
endif()
find_library(LIBNSL nsl)
if (LIBNSL)
set(LIBS ${LIBS} ${LIBNSL})
endif()
find_library(LIBM m)
if (LIBM)
set(LIBS ${LIBS} ${LIBM})
endif()
add_executable(mbuffer
mbuffer.c
input.c
network.c
hashing.c
common.c
globals.c
settings.c
log.c
)
target_link_libraries(
mbuffer
${LIBS}
${CMAKE_THREAD_LIBS_INIT}
)
target_compile_definitions(
mbuffer
PRIVATE PREFIX="${CMAKE_INSTALL_PREFIX}"
)
install(FILES
mbuffer
DESTINATION bin
)
# testing section
if (ENABLE_TESTING)
enable_testing()
try_compile(LFNAMES ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/lf_names.c COPY_FILE ${PROJECT_BINARY_DIR}/lf_names)
if (LFNAMES)
execute_process(
COMMAND ${NM} -u -P ${PROJECT_BINARY_DIR}/lf_names
OUTPUT_FILE "${PROJECT_BINARY_DIR}/lf_names.txt"
)
execute_process(
COMMAND ${AWK} "/open/ { sub(\"@.*\",\"\",$1); printf(\"%s\",\$1); }" ${PROJECT_BINARY_DIR}/lf_names.txt
OUTPUT_VARIABLE LF_OPEN
)
execute_process(
COMMAND ${AWK} "/fstat/ { sub(\"@.*\",\"\",$1); printf(\"%s\",\$1); }" ${PROJECT_BINARY_DIR}/lf_names.txt
OUTPUT_VARIABLE LF_FSTAT
)
execute_process(
COMMAND ${AWK} "/read/ { sub(\"@.*\",\"\",$1); printf(\"%s\",\$1); }" ${PROJECT_BINARY_DIR}/lf_names.txt
OUTPUT_VARIABLE LF_READ
)
execute_process(
COMMAND ${AWK} "/write/ { sub(\"@.*\",\"\",$1); printf(\"%s\",\$1); }" ${PROJECT_BINARY_DIR}/lf_names.txt
OUTPUT_VARIABLE LF_WRITE
)
cmake_print_variables(LF_OPEN)
endif()
add_executable(have-af have-af.c)
add_library(idev SHARED idev.c)
add_library(tapetest SHARED tapetest.c)
set_target_properties(idev tapetest
PROPERTIES
INTERFACE_POSITION_INDEPENDENT_CODE ON
)
add_test(NAME test0 COMMAND ${SH} -x test0.sh ${TESTFILE})
add_test(NAME test1 COMMAND ${SH} -x test1.sh ${TESTFILE})
add_test(NAME test2 COMMAND ${SH} -x test2.sh ${TESTFILE})
add_test(NAME test3 COMMAND ${SH} -x test3.sh ${TESTFILE})
add_test(NAME test4 COMMAND ${SH} -x test4.sh ${TESTFILE})
add_test(NAME test5 COMMAND ${SH} -x test5.sh ${TESTFILE})
add_test(NAME test6 COMMAND ${SH} -x test6.sh ${TESTFILE})
add_test(NAME test7 COMMAND ${SH} -x test7.sh ${TESTFILE})
set_tests_properties(test0 test1 test2 test3 test4 test5 test6 test7
PROPERTIES
ENVIRONMENT "DIFF=${DIFF};OPENSSL=${OPENSSL}"
WORKING_DIRECTORY tests
DEPENDS test.tar
)
set_tests_properties(test4 PROPERTIES DEPENDS tapetest)
set_tests_properties(test5 PROPERTIES DEPENDS tapetest)
#set_tests_properties(test6 PROPERTIES DEPENDS idev)
endif()
configure_file(config.h.cm config.h)
20190725:
- hashing infrastructure should also be enabled with libdl available
- report input file name in message for open failure
- fix: don't try to open network output as file after failure
- fix: potential issue related to inet6 hosts handling
- added complementary cmake based building and testing
- some cleanup work
20190127:
- fix: erronous empty file generation on network connection failure
......
#
# Copyright (C) 2000-2019, Thomas Maier-Komor
#
# This is the source code of mbuffer.
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
CC = @CC@
DEFS = @DEFS@ -DPREFIX=\"${prefix}\"
CFLAGS = @CFLAGS@ $(DEFS) -I@srcdir@ -I.
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
EXE = @EXEEXT@
SHELL = /bin/sh
SHELL = @SH@
CP = @CP@
AWK = @AWK@
OBJDUMP = @OBJDUMP@
......@@ -23,7 +42,7 @@ TAR = @TAR@
TARGET = mbuffer$(EXE)
SOURCES = log.c network.c mbuffer.c hashing.c input.c common.c settings.c globals.c
OBJECTS = $(SOURCES:.c=.o)
OBJECTS = $(SOURCES:%.c=build/%.o)
TESTTREE = /bin /usr/bin
......@@ -31,7 +50,13 @@ TESTTREE = /bin /usr/bin
all: $(TARGET) idev.so tapetest.so have-af
$(OBJECTS): config.h Makefile
$(OBJECTS): build config.h Makefile
build:
mkdir build
build/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
$(TARGET): $(OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@
......
/*
* Copyright (C) 2000-2019, Thomas Maier-Komor
*
* This is the source code of mbuffer.
* This file is part of mbuffer's source code.
*
* 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
......
/*
* Copyright (C) 2000-2017, Thomas Maier-Komor
*
* This is the source code of mbuffer.
* This file is part of mbuffer's source code.
*
* 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
......
/*
* Copyright (C) 2019, Thomas Maier-Komor
*
* This file is part of mbuffer's source code.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIG_H
#define CONFIG_H
/* package */
#cmakedefine PACKAGE
/* version of mbuffer */
#define PACKAGE_VERSION "@PACKAGE_VERSION@"
/* md5hashing is enabled by default,
default is libmhash fallback is libmd5 */
#cmakedefine HAVE_MD5_H
#cmakedefine HAVE_LIBMD5
#cmakedefine HAVE_LIBCRYPTO
/* Define if you have a working `mmap' system call. */
#cmakedefine HAVE_MMAP
/* Define if you have the hstrerror function. */
#cmakedefine HAVE_HSTRERROR
/* Define if you have the getaddrinfo function. */
#cmakedefine HAVE_GETADDRINFO
/* Define if `st_blksize' is member of `struct stat'. */
#cmakedefine HAVE_STRUCT_STAT_ST_BLKSIZE
/* Define if you have libsendfile. */
#cmakedefine HAVE_SENDFILE
#cmakedefine HAVE_SENDFILE_H
/* seteuid ? */
#cmakedefine HAVE_SETEUID
/* alloca in alloca.h */
#cmakedefine HAVE_ALLOCA_H
#define LIBC_OPEN @LF_OPEN@
#define LIBC_READ @LF_READ@
#define LIBC_WRITE @LF_WRITE@
#define LIBC_FSTAT @LF_FSTAT@
#endif
/*
* Copyright (C) 2000-2018, Thomas Maier-Komor
*
* This is the source code of mbuffer.
* This file is part of mbuffer's source code.
*
* 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
......@@ -34,10 +34,6 @@
/* md5hashing is enabled by default,
default is libmhash fallback is libmd5 */
#undef HAVE_GCRYPT_H
#undef HAVE_LIBGCRYPT
#undef HAVE_MHASH_H
#undef HAVE_LIBMHASH
#undef HAVE_MD5_H
#undef HAVE_LIBMD5
#undef HAVE_LIBCRYPTO
......@@ -71,18 +67,9 @@
/* seteuid ? */
#undef HAVE_SETEUID
/* atoll availble? */
#undef HAVE_ATOLL
/* alloca in alloca.h */
#undef HAVE_ALLOCA_H
/* largefile support */
#undef _LARGE_FILE
#undef _LARGEFILE_SOURCE
#undef _LARGEFILE64_SOURCE
#undef _FILE_OFFSET_BITS
#undef LIBC_OPEN
#undef LIBC_READ
#undef LIBC_WRITE
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for mbuffer 20190127.
# Generated by GNU Autoconf 2.69 for mbuffer 20190725.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
......@@ -577,8 +577,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='mbuffer'
PACKAGE_TARNAME='mbuffer'
PACKAGE_VERSION='20190127'
PACKAGE_STRING='mbuffer 20190127'
PACKAGE_VERSION='20190725'
PACKAGE_STRING='mbuffer 20190725'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
......@@ -634,6 +634,7 @@ TAR
MT
CP
RM
SH
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
......@@ -1262,7 +1263,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures mbuffer 20190127 to adapt to many kinds of systems.
\`configure' configures mbuffer 20190725 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1329,7 +1330,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of mbuffer 20190127:";;
short | recursive ) echo "Configuration of mbuffer 20190725:";;
esac
cat <<\_ACEOF
......@@ -1418,7 +1419,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
mbuffer configure 20190127
mbuffer configure 20190725
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -1894,7 +1895,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by mbuffer $as_me 20190127, which was
It was created by mbuffer $as_me 20190725, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
......@@ -4035,6 +4036,46 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
# Extract the first word of "bash sh", so it can be a program name with args.
set dummy bash sh; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_SH+:} false; then :
$as_echo_n "(cached) " >&6
else
case $SH in
[\\/]* | ?:[\\/]*)
ac_cv_path_SH="$SH" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_SH="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
;;
esac
fi
SH=$ac_cv_path_SH
if test -n "$SH"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SH" >&5
$as_echo "$SH" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
# Extract the first word of "rm", so it can be a program name with args.
set dummy rm; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
......@@ -4287,39 +4328,6 @@ fi
test -n "$OBJDUMP" && break
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5
$as_echo_n "checking return type of signal handlers... " >&6; }
if ${ac_cv_type_signal+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
#include <signal.h>
int
main ()
{
return *(signal (0, 0)) (0) == 1;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_type_signal=int
else
ac_cv_type_signal=void
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5
$as_echo "$ac_cv_type_signal" >&6; }
cat >>confdefs.h <<_ACEOF
#define RETSIGTYPE $ac_cv_type_signal
_ACEOF
# Check whether --enable-largefile was given.
if test "${enable_largefile+set}" = set; then :
enableval=$enable_largefile;
......@@ -5290,66 +5298,6 @@ $as_echo "#define HAVE_SETEUID 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing atoll" >&5
$as_echo_n "checking for library containing atoll... " >&6; }
if ${ac_cv_search_atoll+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char atoll ();
int
main ()
{
return atoll ();
;
return 0;
}
_ACEOF
for ac_lib in '' c; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_atoll=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
if ${ac_cv_search_atoll+:} false; then :
break
fi
done
if ${ac_cv_search_atoll+:} false; then :
else
ac_cv_search_atoll=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_atoll" >&5
$as_echo "$ac_cv_search_atoll" >&6; }
ac_res=$ac_cv_search_atoll
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
else
$as_echo "#define atoll atol" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing hstrerror" >&5
$as_echo_n "checking for library containing hstrerror... " >&6; }
if ${ac_cv_search_hstrerror+:} false; then :
......@@ -6597,7 +6545,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by mbuffer $as_me 20190127, which was
This file was extended by mbuffer $as_me 20190725, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -6659,7 +6607,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
mbuffer config.status 20190127
mbuffer config.status 20190725
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
......
......@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
AC_INIT([mbuffer],[20190127])
AC_INIT([mbuffer],[20190725])