From e2f3b5bb424d135afb31af195ac5af45be7b75eb Mon Sep 17 00:00:00 2001 From: sgunderson Date: Sat, 2 Sep 2000 15:08:30 +0000 Subject: [PATCH] Multiple fixes for sendfile() where running kernel is not the same on the compilation machine and the running machine (mainly packages): sendfile() support is checked more thoroughly for (a runtime check at configure checking that we just don't have a libc wrapper). A sendfile()-enabled version can now also survive without sendfile(). There is a new flag (--with(out)-linux-sendfile) that forces the status to on/off (both RH and Debian packages now supply this flag). --- betaftpd.spec | 5 +- configure | 325 ++++++++++++++++++++++++++++++++------------------ configure.in | 76 +++++++++++- debian/rules | 2 +- ftpd.c | 21 +++- 5 files changed, 305 insertions(+), 124 deletions(-) diff --git a/betaftpd.spec b/betaftpd.spec index 4cc67a6..9e2dcfe 100644 --- a/betaftpd.spec +++ b/betaftpd.spec @@ -21,7 +21,7 @@ easier for other programmers to contribute. %setup -q %build -./configure --enable-xferlog --enable-ascii --enable-fork --enable-upload --enable-dcache --enable-message --enable-shadow +./configure --enable-xferlog --enable-ascii --enable-fork --enable-upload --enable-dcache --enable-message --enable-shadow --with-linux-sendfile make %install @@ -36,6 +36,9 @@ rm -rf %{buildroot} /usr/sbin/betaftpd %changelog +* Wed Aug 30 2000 Steinar H. Gunderson +- gave --with-linux-sendfile to configure (see main ChangeLog for rationale) + * Thu Aug 17 2000 Steinar H. Gunderson - added some flags to configure that the average user would expect - increased version number again diff --git a/configure b/configure index 20d663d..ab01c51 100755 --- a/configure +++ b/configure @@ -31,6 +31,8 @@ ac_help="$ac_help --enable-shadow Enable shadow password support" ac_help="$ac_help --enable-nonroot Do not need root access (EXPERIMENTAL)" +ac_help="$ac_help + --with-linux-sendfile Force sendfile() support" # Initialize some variables set by options. # The variables have the same names as the options, with @@ -546,7 +548,7 @@ echo $ac_n "checking for prefix by $ac_c" 1>&6 # Extract the first word of "ftpd", so it can be a program name with args. set dummy ftpd; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:550: checking for $ac_word" >&5 +echo "configure:552: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_FTPD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -587,7 +589,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:591: checking for $ac_word" >&5 +echo "configure:593: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -617,7 +619,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:621: checking for $ac_word" >&5 +echo "configure:623: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -668,7 +670,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:672: checking for $ac_word" >&5 +echo "configure:674: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -700,7 +702,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:704: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:706: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -711,12 +713,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 715 "configure" +#line 717 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:720: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -742,12 +744,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:746: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:748: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:751: checking whether we are using GNU C" >&5 +echo "configure:753: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -756,7 +758,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:760: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:762: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -775,7 +777,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:779: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:781: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -811,12 +813,12 @@ LIBS="" echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:815: checking for working const" >&5 +echo "configure:817: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:871: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -886,7 +888,7 @@ EOF fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:890: checking how to run the C preprocessor" >&5 +echo "configure:892: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -901,13 +903,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:911: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:913: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -918,13 +920,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:928: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:930: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -935,13 +937,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:945: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:947: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -969,17 +971,17 @@ for ac_hdr in unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:973: checking for $ac_hdr" >&5 +echo "configure:975: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:983: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:985: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1008,12 +1010,12 @@ done for ac_func in getpagesize do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1012: checking for $ac_func" >&5 +echo "configure:1014: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1042: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1061,7 +1063,7 @@ fi done echo $ac_n "checking for working mmap""... $ac_c" 1>&6 -echo "configure:1065: checking for working mmap" >&5 +echo "configure:1067: checking for working mmap" >&5 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1069,7 +1071,7 @@ else ac_cv_func_mmap_fixed_mapped=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1215: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_mmap_fixed_mapped=yes else @@ -1232,12 +1234,12 @@ EOF fi echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:1236: checking return type of signal handlers" >&5 +echo "configure:1238: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1254,7 +1256,7 @@ int main() { int i; ; return 0; } EOF -if { (eval echo configure:1258: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1260: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -1275,12 +1277,12 @@ EOF for ac_func in snprintf vsnprintf do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1279: checking for $ac_func" >&5 +echo "configure:1281: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1309: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1329,7 +1331,7 @@ done echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 -echo "configure:1333: checking for socket in -lsocket" >&5 +echo "configure:1335: checking for socket in -lsocket" >&5 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1337,7 +1339,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1354: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1373,7 +1375,7 @@ if test "$result" = "yes"; then LIBS="$LIBS -lsocket" else echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 -echo "configure:1377: checking for connect in -lsocket" >&5 +echo "configure:1379: checking for connect in -lsocket" >&5 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1381,7 +1383,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1398: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1419,7 +1421,7 @@ fi fi echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6 -echo "configure:1423: checking for crypt in -lcrypt" >&5 +echo "configure:1425: checking for crypt in -lcrypt" >&5 ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1427,7 +1429,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lcrypt $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1444: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1467,7 +1469,7 @@ fi echo $ac_n "checking whether to enable xferlog""... $ac_c" 1>&6 -echo "configure:1471: checking whether to enable xferlog" >&5 +echo "configure:1473: checking whether to enable xferlog" >&5 # Check whether --enable-xferlog or --disable-xferlog was given. if test "${enable_xferlog+set}" = set; then enableval="$enable_xferlog" @@ -1490,7 +1492,7 @@ echo "$ac_t""$enableval" 1>&6 echo $ac_n "checking whether to enable ascii""... $ac_c" 1>&6 -echo "configure:1494: checking whether to enable ascii" >&5 +echo "configure:1496: checking whether to enable ascii" >&5 # Check whether --enable-ascii or --disable-ascii was given. if test "${enable_ascii+set}" = set; then enableval="$enable_ascii" @@ -1513,7 +1515,7 @@ echo "$ac_t""$enableval" 1>&6 echo $ac_n "checking whether to enable fullscreen""... $ac_c" 1>&6 -echo "configure:1517: checking whether to enable fullscreen" >&5 +echo "configure:1519: checking whether to enable fullscreen" >&5 # Check whether --enable-fullscreen or --disable-fullscreen was given. if test "${enable_fullscreen+set}" = set; then enableval="$enable_fullscreen" @@ -1538,7 +1540,7 @@ echo "$ac_t""$enableval" 1>&6 if test "$enableval" = "no"; then echo $ac_n "checking whether to enable fork""... $ac_c" 1>&6 -echo "configure:1542: checking whether to enable fork" >&5 +echo "configure:1544: checking whether to enable fork" >&5 # Check whether --enable-fork or --disable-fork was given. if test "${enable_fork+set}" = set; then enableval="$enable_fork" @@ -1563,7 +1565,7 @@ fi echo $ac_n "checking whether to enable upload""... $ac_c" 1>&6 -echo "configure:1567: checking whether to enable upload" >&5 +echo "configure:1569: checking whether to enable upload" >&5 # Check whether --enable-upload or --disable-upload was given. if test "${enable_upload+set}" = set; then enableval="$enable_upload" @@ -1586,7 +1588,7 @@ echo "$ac_t""$enableval" 1>&6 echo $ac_n "checking whether to enable stat""... $ac_c" 1>&6 -echo "configure:1590: checking whether to enable stat" >&5 +echo "configure:1592: checking whether to enable stat" >&5 # Check whether --enable-stat or --disable-stat was given. if test "${enable_stat+set}" = set; then enableval="$enable_stat" @@ -1609,7 +1611,7 @@ echo "$ac_t""$enableval" 1>&6 echo $ac_n "checking whether to enable dcache""... $ac_c" 1>&6 -echo "configure:1613: checking whether to enable dcache" >&5 +echo "configure:1615: checking whether to enable dcache" >&5 # Check whether --enable-dcache or --disable-dcache was given. if test "${enable_dcache+set}" = set; then enableval="$enable_dcache" @@ -1632,7 +1634,7 @@ echo "$ac_t""$enableval" 1>&6 echo $ac_n "checking whether to enable message""... $ac_c" 1>&6 -echo "configure:1636: checking whether to enable message" >&5 +echo "configure:1638: checking whether to enable message" >&5 # Check whether --enable-message or --disable-message was given. if test "${enable_message+set}" = set; then enableval="$enable_message" @@ -1656,7 +1658,7 @@ echo "$ac_t""$enableval" 1>&6 echo $ac_n "checking whether to enable shadow""... $ac_c" 1>&6 -echo "configure:1660: checking whether to enable shadow" >&5 +echo "configure:1662: checking whether to enable shadow" >&5 # Check whether --enable-shadow or --disable-shadow was given. if test "${enable_shadow+set}" = set; then enableval="$enable_shadow" @@ -1685,17 +1687,17 @@ if test "$enableval" = "yes"; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1689: checking for $ac_hdr" >&5 +echo "configure:1691: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1699: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1701: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1729,7 +1731,7 @@ fi if test "$nonroot_support" = "yes"; then echo $ac_n "checking whether to enable nonroot""... $ac_c" 1>&6 -echo "configure:1733: checking whether to enable nonroot" >&5 +echo "configure:1735: checking whether to enable nonroot" >&5 # Check whether --enable-nonroot or --disable-nonroot was given. if test "${enable_nonroot+set}" = set; then enableval="$enable_nonroot" @@ -1761,7 +1763,7 @@ if test "$enableval" = "yes"; then else echo $ac_n "checking how to get effective uid""... $ac_c" 1>&6 -echo "configure:1765: checking how to get effective uid" >&5 +echo "configure:1767: checking how to get effective uid" >&5 if test -n "$EUID"; then B_UID=$EUID echo "$ac_t""\$EUID ($EUID)" 1>&6 @@ -1794,12 +1796,12 @@ echo "configure:1765: checking how to get effective uid" >&5 fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1798: checking for ANSI C header files" >&5 +echo "configure:1800: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1807,7 +1809,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1811: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1813: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1824,7 +1826,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1842,7 +1844,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1863,7 +1865,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1874,7 +1876,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:1878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1880: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1898,12 +1900,12 @@ EOF fi echo $ac_n "checking for uid_t""... $ac_c" 1>&6 -echo "configure:1902: checking for uid_t" >&5 +echo "configure:1904: checking for uid_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -1931,12 +1933,12 @@ EOF fi echo $ac_n "checking for gid_t""... $ac_c" 1>&6 -echo "configure:1935: checking for gid_t" >&5 +echo "configure:1937: checking for gid_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_gid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -1968,17 +1970,17 @@ for ac_hdr in crypt.h unistd.h time.h sys/time.h errno.h netinet/in.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1972: checking for $ac_hdr" >&5 +echo "configure:1974: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1982: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1984: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2008,17 +2010,17 @@ for ac_hdr in netinet/ip.h stropts.h sys/conf.h arpa/inet.h sys/filio.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2012: checking for $ac_hdr" >&5 +echo "configure:2014: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2022: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2024: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2048,17 +2050,17 @@ for ac_hdr in netinet/tcp.h sys/types.h netdb.h glob.h stdio.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2052: checking for $ac_hdr" >&5 +echo "configure:2054: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2062: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2064: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2088,17 +2090,17 @@ for ac_hdr in stdlib.h stdarg.h stdlib.h string.h strings.h fcntl.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2092: checking for $ac_hdr" >&5 +echo "configure:2094: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2102: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2104: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2128,17 +2130,17 @@ for ac_hdr in sys/ioctl.h sys/socket.h sys/stat.h sys/param.h signal.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2132: checking for $ac_hdr" >&5 +echo "configure:2134: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2142: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2144: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2168,17 +2170,17 @@ for ac_hdr in sys/signal.h dirent.h pwd.h grp.h netinet/in_systm.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2172: checking for $ac_hdr" >&5 +echo "configure:2174: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2182: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2184: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2208,17 +2210,17 @@ for ac_hdr in assert.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2212: checking for $ac_hdr" >&5 +echo "configure:2214: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2222: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2224: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2247,17 +2249,17 @@ done ac_safe=`echo "netinet/tcp.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for netinet/tcp.h""... $ac_c" 1>&6 -echo "configure:2251: checking for netinet/tcp.h" >&5 +echo "configure:2253: checking for netinet/tcp.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2261: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2263: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2283,9 +2285,9 @@ fi if test "$result" = "yes"; then echo $ac_n "checking if netinet/tcp.h is enough""... $ac_c" 1>&6 -echo "configure:2287: checking if netinet/tcp.h is enough" >&5 +echo "configure:2289: checking if netinet/tcp.h is enough" >&5 cat > conftest.$ac_ext < #ifndef TCP_NODELAY @@ -2309,17 +2311,17 @@ fi if test "$result" = "no"; then ac_safe=`echo "linux/socket.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for linux/socket.h""... $ac_c" 1>&6 -echo "configure:2313: checking for linux/socket.h" >&5 +echo "configure:2315: checking for linux/socket.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2323: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2325: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2346,17 +2348,17 @@ for ac_hdr in sys/poll.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2350: checking for $ac_hdr" >&5 +echo "configure:2352: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2360: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2362: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2384,9 +2386,9 @@ done echo $ac_n "checking for poll()""... $ac_c" 1>&6 -echo "configure:2388: checking for poll()" >&5 +echo "configure:2390: checking for poll()" >&5 cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2409: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* enableval=yes else @@ -2426,17 +2428,17 @@ for ac_hdr in sys/sendfile.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2430: checking for $ac_hdr" >&5 +echo "configure:2432: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2440: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2442: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2466,9 +2468,9 @@ done if test "$result" = "yes"; then echo $ac_n "checking for Linux sendfile()""... $ac_c" 1>&6 -echo "configure:2470: checking for Linux sendfile()" >&5 +echo "configure:2472: checking for Linux sendfile()" >&5 cat > conftest.$ac_ext <&5 #include #endif +#if HAVE_ERRNO_H +#include +#endif + #if HAVE_SYS_UIO_H #include #endif + int main() { int out_fd = 1, in_fd = 0; @@ -2504,7 +2511,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2508: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2515: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* enableval=yes else @@ -2517,26 +2524,108 @@ rm -f conftest* echo "$ac_t""$enableval" 1>&6 if test "$enableval" = "yes"; then - cat >> confdefs.h <<\EOF + echo $ac_n "checking that sendfile() really is implemented""... $ac_c" 1>&6 +echo "configure:2529: checking that sendfile() really is implemented" >&5 + + if test "$cross_compiling" = yes; then + enableval="cross-compiling, not checked" +else + cat > conftest.$ac_ext < +#endif + +#if HAVE_SYS_LIMITS_H +#include +#endif + +#if HAVE_UNISTD_H +#include +#endif + +#if HAVE_SYS_SENDFILE_H +#include +#endif + +#if HAVE_SYS_TYPES_H +#include +#endif + +#if HAVE_ERRNO_H +#include +#endif + +#if HAVE_SYS_UIO_H +#include +#endif + +int main() { + int out_fd = 1, in_fd = 0; + off_t offset = 0; + size_t size = 1024; + + errno = 0; + sendfile(out_fd, in_fd, &offset, size); + if (errno == ENOSYS) + return 0; + else + return 1; +} +EOF +if { (eval echo configure:2579: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + enableval=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + enableval=yes +fi +rm -fr conftest* +fi + + echo "$ac_t""$enableval" 1>&6 + + has_sendfile=$enableval + + # Check whether --with-linux-sendfile or --without-linux-sendfile was given. +if test "${with_linux_sendfile+set}" = set; then + withval="$with_linux_sendfile" + has_sendfile=$withval +fi + + + if test $has_sendfile != "no"; then + cat >> confdefs.h <<\EOF #define HAVE_LINUX_SENDFILE 1 EOF + has_sendfile=enabled + else + has_sendfile=disabled + fi + echo $ac_n "checking final status of Linux sendfile() support""... $ac_c" 1>&6 +echo "configure:2612: checking final status of Linux sendfile() support" >&5 + echo "$ac_t""$has_sendfile" 1>&6 fi fi ac_safe=`echo "sys/uio.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for sys/uio.h""... $ac_c" 1>&6 -echo "configure:2530: checking for sys/uio.h" >&5 +echo "configure:2619: checking for sys/uio.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2540: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2629: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2560,9 +2649,9 @@ fi if test "$result" = "yes"; then echo $ac_n "checking for BSD sendfile()""... $ac_c" 1>&6 -echo "configure:2564: checking for BSD sendfile()" >&5 +echo "configure:2653: checking for BSD sendfile()" >&5 cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2696: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* enableval=yes else diff --git a/configure.in b/configure.in index cddb6a1..10286bb 100644 --- a/configure.in +++ b/configure.in @@ -194,6 +194,9 @@ dnl dnl sendfile() is not standard -- we'll have to check the different dnl versions one by one :-) dnl +dnl Unfortunately, we'll have to run the program too -- this is a +dnl problem with newer libc's and not-so-new kernels :-) +dnl AC_CHECK_HEADERS(sys/sendfile.h,result=yes,result=no) if test "$result" = "yes"; then @@ -219,9 +222,14 @@ if test "$result" = "yes"; then #include #endif +#if HAVE_ERRNO_H +#include +#endif + #if HAVE_SYS_UIO_H #include -#endif],[ +#endif +],[ int out_fd = 1, in_fd = 0; off_t offset = 0; size_t size = 1024; @@ -231,7 +239,71 @@ if test "$result" = "yes"; then AC_MSG_RESULT($enableval) if test "$enableval" = "yes"; then - AC_DEFINE(HAVE_LINUX_SENDFILE, 1, [Define if you have sendfile() with the Linux semantics.]) + dnl + dnl If the compile fails now, we assume sendfile() exists (since this + dnl is by far the most common case) + dnl + AC_MSG_CHECKING([that sendfile() really is implemented]) + + AC_TRY_RUN([ +#if HAVE_SYS_SOCKET_H +#include +#endif + +#if HAVE_SYS_LIMITS_H +#include +#endif + +#if HAVE_UNISTD_H +#include +#endif + +#if HAVE_SYS_SENDFILE_H +#include +#endif + +#if HAVE_SYS_TYPES_H +#include +#endif + +#if HAVE_ERRNO_H +#include +#endif + +#if HAVE_SYS_UIO_H +#include +#endif + +int main() { + int out_fd = 1, in_fd = 0; + off_t offset = 0; + size_t size = 1024; + + errno = 0; + sendfile(out_fd, in_fd, &offset, size); + if (errno == ENOSYS) + return 0; + else + return 1; +}], + enableval=no,enableval=yes,[enableval="cross-compiling, not checked"]) + AC_MSG_RESULT($enableval) + + has_sendfile=$enableval + + dnl + dnl Force sendfile() `state' if the user tells us to + dnl + AC_ARG_WITH(linux-sendfile,[ --with-linux-sendfile Force sendfile() support],has_sendfile=$withval) + + if test $has_sendfile != "no"; then + AC_DEFINE(HAVE_LINUX_SENDFILE, 1, [Define if you have sendfile() with the Linux semantics.]) + has_sendfile=enabled + else + has_sendfile=disabled + fi + AC_MSG_CHECKING([final status of Linux sendfile() support]) + AC_MSG_RESULT($has_sendfile) fi fi diff --git a/debian/rules b/debian/rules index ad05851..59864ad 100755 --- a/debian/rules +++ b/debian/rules @@ -6,7 +6,7 @@ package=betaftpd build: $(checkdir) - CFLAGS="-O6 -Wall" ./configure --prefix=/usr --enable-xferlog --enable-ascii --enable-fork --enable-upload --enable-dcache --enable-message --enable-shadow + CFLAGS="-O6 -Wall" ./configure --prefix=/usr --enable-xferlog --enable-ascii --enable-fork --enable-upload --enable-dcache --enable-message --enable-shadow --with-linux-sendfile $(MAKE) CFLAGS="-O6 -Wall" touch build diff --git a/ftpd.c b/ftpd.c index 637469b..3982a74 100644 --- a/ftpd.c +++ b/ftpd.c @@ -198,6 +198,10 @@ fd_set master_fds, master_send_fds; FILE *xferlog = NULL; #endif +#if HAVE_LINUX_SENDFILE +int sendfile_supported = 1; +#endif + /* * This variable specifies if it's soon time to check for timed out * clients, and timed out directory listing cache entries. It is @@ -790,7 +794,7 @@ int do_download(struct ftran *f) * Here we use a rather simplified sending `algorithm', * leaving most of the quirks to the system calls. */ - if (f->dir_listing == 0) { + if (sendfile_supported == 1 && f->dir_listing == 0) { int err; size = f->size - f->pos; @@ -997,6 +1001,19 @@ int main(void) alarm(60); signal(SIGALRM, handle_alarm); +#if HAVE_LINUX_SENDFILE + /* check that sendfile() is really implemented (same check as configure does) */ + { + int out_fd = 1, in_fd = 0; + off_t offset = 0; + size_t size = 1024; + + errno = 0; + sendfile(out_fd, in_fd, &offset, size); + if (errno == ENOSYS) sendfile_supported = 0; + } +#endif + for ( ;; ) { int i; #ifndef HAVE_POLL @@ -1373,7 +1390,7 @@ void init_file_transfer(struct ftran * const f) #if HAVE_MMAP if (f->dir_listing == 0) { #if HAVE_LINUX_SENDFILE - int do_mmap = 0; + int do_mmap = (sendfile_supported) ? 0 : 1; #else int do_mmap = 1; #endif -- 2.39.2