diff --git a/MCONFIG.in b/MCONFIG.in index f2dac70..2cdbbd7 100644 --- a/MCONFIG.in +++ b/MCONFIG.in @@ -29,3 +29,9 @@ LDFLAGS = @LDFLAGS@ # Libraries LIBS = @LIBS@ +# Additional library we need to build +LIBOBJS = @LIBOBJS@ + +# ar and ranlib (for making libraries) +AR = ar cq +RANLIB = @RANLIB@ diff --git a/Makefile b/Makefile index 004e9fd..4d8a96e 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # You can do "make SUB=blah" to make only a few, or edit here, or both # You can also run make directly in the subdirs you want. -SUB = tftp tftpd +SUB = lib tftp tftpd %.build: $(MAKE) -C $(patsubst %.build, %, $@) diff --git a/README b/README index 4ff91f9..0eacb2f 100644 --- a/README +++ b/README @@ -1,6 +1,13 @@ -This is tftp-hpa-0.15; this version was put out by H. Peter Anvin +This is tftp-hpa-0.16; this version was put out by H. Peter Anvin . +Changes in 0.16: + + Correct massive lossage from 0.15: apparently 0.15 was based + on an out-of-date CVS repository, somehow. + + Fix for ACKs in TFTP PUT; patch by Roger Venning. + Changes in 0.15: If the operating system allows, try to obtain the local diff --git a/aclocal.m4 b/aclocal.m4 index 1a3cfef..fc82c1d 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -14,54 +14,17 @@ AC_DEFUN(PA_ADD_CFLAGS, CFLAGS="$pa_add_cflags__old_cflags")]) dnl -------------------------------------------------------------------------- -dnl PA_BSD_SIGNAL() +dnl PA_SIGSETJMP dnl -dnl Test for BSD signal semantics. Set shell variable BSD_SIGNAL=1 if OK. -dnl May modify CFLAGS and/or LIBS. +dnl Do we have sigsetjmp/siglongjmp? dnl -------------------------------------------------------------------------- -AC_DEFUN(PA_CHECK_BSD_SIGNAL, -[AC_TRY_RUN([ -#include -#include -int count=0; -handle() { count++; } -int main() { - int pid=getpid(); - signal(SIGINT, handle); - kill(pid,SIGINT); - kill(pid,SIGINT); - kill(pid,SIGINT); - if (count!=3) return 1; - return 0; -} -], BSD_SIGNAL=1)]) - -AC_DEFUN(PA_BSD_SIGNAL, -[AC_MSG_CHECKING([for BSD signal semantics]) -PA_CHECK_BSD_SIGNAL() -if test -z "$BSD_SIGNAL"; then - AC_MSG_RESULT([no]) - AC_MSG_CHECKING([if -D__USE_BSD_SIGNAL helps]) - pa_bsd_signal__old_cflags="$CFLAGS" - CFLAGS="$CFLAGS -D__USE_BSD_SIGNAL" - PA_CHECK_BSD_SIGNAL() - if test -z "$BSD_SIGNAL"; then - AC_MSG_RESULT([no]) - CFLAGS="$pa_bsd_signal__old_cflags" - AC_MSG_CHECKING([if -lbsd helps]) - pa_bsd_signal__old_libs="$LIBS" - LIBS="$LIBS -lbsd" - PA_CHECK_BSD_SIGNAL() - if test -z "$BSD_SIGNAL"; then - AC_MSG_RESULT([no]) - LIBS="$pa_bsd_signal__old_libs" - else - AC_MSG_RESULT([yes]) - fi - else - AC_MSG_RESULT([yes]) - fi -else - AC_MSG_RESULT([yes]) -fi -]) +AC_DEFUN(PA_SIGSETJMP, +[AC_MSG_CHECKING([for sigsetjmp]) + AC_TRY_LINK( + [#include ], + [sigjmp_buf buf; + sigsetjmp(buf,1);], + AC_MSG_RESULT([yes]) + $1, + AC_MSG_RESULT([no]) + $2)]) diff --git a/configure b/configure index de0e107..a91294c 100755 --- a/configure +++ b/configure @@ -860,110 +860,19 @@ EOF esac -for ac_func in recvmsg -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:867: 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 < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -$ac_func(); -#endif - -; return 0; } -EOF -if { (eval echo configure:895: \"$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 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 -fi -done - - -echo $ac_n "checking for msg_control in struct msghdr""... $ac_c" 1>&6 -echo "configure:921: checking for msg_control in struct msghdr" >&5 -cat > conftest.$ac_ext < -#include - -int main() { - - struct msghdr msg; - void *p = (void *) &msg.msg_control; - -; return 0; } -EOF -if { (eval echo configure:936: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - - cat >> confdefs.h <<\EOF -#define HAVE_MSGHDR_MSG_CONTROL 1 -EOF - - echo "$ac_t""yes" 1>&6 - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - - echo "$ac_t""no" 1>&6 - -fi -rm -f conftest* - echo $ac_n "checking if $CC accepts -Wall""... $ac_c" 1>&6 -echo "configure:956: checking if $CC accepts -Wall" >&5 +echo "configure:865: checking if $CC accepts -Wall" >&5 pa_add_cflags__old_cflags="$CFLAGS" CFLAGS="$CFLAGS -Wall" cat > conftest.$ac_ext < int main() { printf("Hello, World!\n"); ; return 0; } EOF -if { (eval echo configure:967: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:876: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -975,18 +884,18 @@ else fi rm -f conftest* echo $ac_n "checking if $CC accepts -W""... $ac_c" 1>&6 -echo "configure:979: checking if $CC accepts -W" >&5 +echo "configure:888: checking if $CC accepts -W" >&5 pa_add_cflags__old_cflags="$CFLAGS" CFLAGS="$CFLAGS -W" cat > conftest.$ac_ext < int main() { printf("Hello, World!\n"); ; return 0; } EOF -if { (eval echo configure:990: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:899: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -998,18 +907,18 @@ else fi rm -f conftest* echo $ac_n "checking if $CC accepts -Wpointer-arith""... $ac_c" 1>&6 -echo "configure:1002: checking if $CC accepts -Wpointer-arith" >&5 +echo "configure:911: checking if $CC accepts -Wpointer-arith" >&5 pa_add_cflags__old_cflags="$CFLAGS" CFLAGS="$CFLAGS -Wpointer-arith" cat > conftest.$ac_ext < int main() { printf("Hello, World!\n"); ; return 0; } EOF -if { (eval echo configure:1013: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:922: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -1021,18 +930,18 @@ else fi rm -f conftest* echo $ac_n "checking if $CC accepts -Wbad-function-cast""... $ac_c" 1>&6 -echo "configure:1025: checking if $CC accepts -Wbad-function-cast" >&5 +echo "configure:934: checking if $CC accepts -Wbad-function-cast" >&5 pa_add_cflags__old_cflags="$CFLAGS" CFLAGS="$CFLAGS -Wbad-function-cast" cat > conftest.$ac_ext < int main() { printf("Hello, World!\n"); ; return 0; } EOF -if { (eval echo configure:1036: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:945: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -1044,18 +953,18 @@ else fi rm -f conftest* echo $ac_n "checking if $CC accepts -Wcast-equal""... $ac_c" 1>&6 -echo "configure:1048: checking if $CC accepts -Wcast-equal" >&5 +echo "configure:957: checking if $CC accepts -Wcast-equal" >&5 pa_add_cflags__old_cflags="$CFLAGS" CFLAGS="$CFLAGS -Wcast-equal" cat > conftest.$ac_ext < int main() { printf("Hello, World!\n"); ; return 0; } EOF -if { (eval echo configure:1059: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:968: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -1067,18 +976,18 @@ else fi rm -f conftest* echo $ac_n "checking if $CC accepts -Wstrict-prototypes""... $ac_c" 1>&6 -echo "configure:1071: checking if $CC accepts -Wstrict-prototypes" >&5 +echo "configure:980: checking if $CC accepts -Wstrict-prototypes" >&5 pa_add_cflags__old_cflags="$CFLAGS" CFLAGS="$CFLAGS -Wstrict-prototypes" cat > conftest.$ac_ext < int main() { printf("Hello, World!\n"); ; return 0; } EOF -if { (eval echo configure:1082: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:991: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -1090,18 +999,18 @@ else fi rm -f conftest* echo $ac_n "checking if $CC accepts -Wmissing-prototypes""... $ac_c" 1>&6 -echo "configure:1094: checking if $CC accepts -Wmissing-prototypes" >&5 +echo "configure:1003: checking if $CC accepts -Wmissing-prototypes" >&5 pa_add_cflags__old_cflags="$CFLAGS" CFLAGS="$CFLAGS -Wmissing-prototypes" cat > conftest.$ac_ext < int main() { printf("Hello, World!\n"); ; return 0; } EOF -if { (eval echo configure:1105: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1014: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -1113,18 +1022,18 @@ else fi rm -f conftest* echo $ac_n "checking if $CC accepts -Wmissing-declarations""... $ac_c" 1>&6 -echo "configure:1117: checking if $CC accepts -Wmissing-declarations" >&5 +echo "configure:1026: checking if $CC accepts -Wmissing-declarations" >&5 pa_add_cflags__old_cflags="$CFLAGS" CFLAGS="$CFLAGS -Wmissing-declarations" cat > conftest.$ac_ext < int main() { printf("Hello, World!\n"); ; return 0; } EOF -if { (eval echo configure:1128: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1037: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -1136,18 +1045,18 @@ else fi rm -f conftest* echo $ac_n "checking if $CC accepts -Wnested-externs""... $ac_c" 1>&6 -echo "configure:1140: checking if $CC accepts -Wnested-externs" >&5 +echo "configure:1049: checking if $CC accepts -Wnested-externs" >&5 pa_add_cflags__old_cflags="$CFLAGS" CFLAGS="$CFLAGS -Wnested-externs" cat > conftest.$ac_ext < int main() { printf("Hello, World!\n"); ; return 0; } EOF -if { (eval echo configure:1151: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1060: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -1159,18 +1068,18 @@ else fi rm -f conftest* echo $ac_n "checking if $CC accepts -Winline""... $ac_c" 1>&6 -echo "configure:1163: checking if $CC accepts -Winline" >&5 +echo "configure:1072: checking if $CC accepts -Winline" >&5 pa_add_cflags__old_cflags="$CFLAGS" CFLAGS="$CFLAGS -Winline" cat > conftest.$ac_ext < int main() { printf("Hello, World!\n"); ; return 0; } EOF -if { (eval echo configure:1174: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1083: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -1182,18 +1091,18 @@ else fi rm -f conftest* echo $ac_n "checking if $CC accepts -Wcast-align""... $ac_c" 1>&6 -echo "configure:1186: checking if $CC accepts -Wcast-align" >&5 +echo "configure:1095: checking if $CC accepts -Wcast-align" >&5 pa_add_cflags__old_cflags="$CFLAGS" CFLAGS="$CFLAGS -Wcast-align" cat > conftest.$ac_ext < int main() { printf("Hello, World!\n"); ; return 0; } EOF -if { (eval echo configure:1197: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1106: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -1205,18 +1114,18 @@ else fi rm -f conftest* echo $ac_n "checking if $CC accepts -pipe""... $ac_c" 1>&6 -echo "configure:1209: checking if $CC accepts -pipe" >&5 +echo "configure:1118: checking if $CC accepts -pipe" >&5 pa_add_cflags__old_cflags="$CFLAGS" CFLAGS="$CFLAGS -pipe" cat > conftest.$ac_ext < int main() { printf("Hello, World!\n"); ; return 0; } EOF -if { (eval echo configure:1220: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1129: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -1228,130 +1137,254 @@ else fi rm -f conftest* -echo $ac_n "checking for BSD signal semantics""... $ac_c" 1>&6 -echo "configure:1233: checking for BSD signal semantics" >&5 -if test "$cross_compiling" = yes; then - { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +echo $ac_n "checking for sigsetjmp""... $ac_c" 1>&6 +echo "configure:1142: checking for sigsetjmp" >&5 + cat > conftest.$ac_ext < +int main() { +sigjmp_buf buf; + sigsetjmp(buf,1); +; return 0; } +EOF +if { (eval echo configure:1152: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + echo "$ac_t""yes" 1>&6 + CFLAGS="$CFLAGS -DHAVE_SIGSETJMP=1" else - cat > conftest.$ac_ext <&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo "$ac_t""no" 1>&6 + +fi +rm -f conftest* + +LIBXTRA=0 + + +echo $ac_n "checking for library containing xmalloc""... $ac_c" 1>&6 +echo "configure:1169: checking for library containing xmalloc" >&5 +if eval "test \"`echo '$''{'ac_cv_search_xmalloc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_func_search_save_LIBS="$LIBS" +ac_cv_search_xmalloc="no" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_search_xmalloc="none required" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +test "$ac_cv_search_xmalloc" = "no" && for i in iberty; do +LIBS="-l$i $ac_func_search_save_LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_search_xmalloc="-l$i" +break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done +LIBS="$ac_func_search_save_LIBS" +fi + +echo "$ac_t""$ac_cv_search_xmalloc" 1>&6 +if test "$ac_cv_search_xmalloc" != "no"; then + test "$ac_cv_search_xmalloc" = "none required" || LIBS="$ac_cv_search_xmalloc $LIBS" + +else : + LIBXTRA=1 LIBOBJS="$LIBOBJS xmalloc.o" +fi + +echo $ac_n "checking for library containing xstrdup""... $ac_c" 1>&6 +echo "configure:1231: checking for library containing xstrdup" >&5 +if eval "test \"`echo '$''{'ac_cv_search_xstrdup'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_func_search_save_LIBS="$LIBS" +ac_cv_search_xstrdup="no" +cat > conftest.$ac_ext < -#include -int count=0; -handle() { count++; } int main() { - int pid=getpid(); - signal(SIGINT, handle); - kill(pid,SIGINT); - kill(pid,SIGINT); - kill(pid,SIGINT); - if (count!=3) return 1; - return 0; -} - +xstrdup() +; return 0; } EOF -if { (eval echo configure:1256: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - BSD_SIGNAL=1 +if { (eval echo configure:1249: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_search_xstrdup="none required" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi -rm -fr conftest* -fi - -if test -z "$BSD_SIGNAL"; then - echo "$ac_t""no" 1>&6 - echo $ac_n "checking if -D__USE_BSD_SIGNAL helps""... $ac_c" 1>&6 -echo "configure:1269: checking if -D__USE_BSD_SIGNAL helps" >&5 - pa_bsd_signal__old_cflags="$CFLAGS" - CFLAGS="$CFLAGS -D__USE_BSD_SIGNAL" - if test "$cross_compiling" = yes; then - { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } -else - cat > conftest.$ac_ext < conftest.$ac_ext < -#include -int count=0; -handle() { count++; } int main() { - int pid=getpid(); - signal(SIGINT, handle); - kill(pid,SIGINT); - kill(pid,SIGINT); - kill(pid,SIGINT); - if (count!=3) return 1; - return 0; -} - +xstrdup() +; return 0; } EOF -if { (eval echo configure:1294: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - BSD_SIGNAL=1 +if { (eval echo configure:1271: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_search_xstrdup="-l$i" +break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi -rm -fr conftest* +rm -f conftest* +done +LIBS="$ac_func_search_save_LIBS" fi - if test -z "$BSD_SIGNAL"; then - echo "$ac_t""no" 1>&6 - CFLAGS="$pa_bsd_signal__old_cflags" - echo $ac_n "checking if -lbsd helps""... $ac_c" 1>&6 -echo "configure:1308: checking if -lbsd helps" >&5 - pa_bsd_signal__old_libs="$LIBS" - LIBS="$LIBS -lbsd" - if test "$cross_compiling" = yes; then - { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +echo "$ac_t""$ac_cv_search_xstrdup" 1>&6 +if test "$ac_cv_search_xstrdup" != "no"; then + test "$ac_cv_search_xstrdup" = "none required" || LIBS="$ac_cv_search_xstrdup $LIBS" + +else : + LIBXTRA=1 LIBOBJS="$LIBOBJS xstrdup.o" +fi + +echo $ac_n "checking for library containing bsd_signal""... $ac_c" 1>&6 +echo "configure:1293: checking for library containing bsd_signal" >&5 +if eval "test \"`echo '$''{'ac_cv_search_bsd_signal'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else - cat > conftest.$ac_ext < conftest.$ac_ext < -#include -int count=0; -handle() { count++; } int main() { - int pid=getpid(); - signal(SIGINT, handle); - kill(pid,SIGINT); - kill(pid,SIGINT); - kill(pid,SIGINT); - if (count!=3) return 1; - return 0; -} - +bsd_signal() +; return 0; } EOF -if { (eval echo configure:1333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - BSD_SIGNAL=1 +if { (eval echo configure:1311: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_search_bsd_signal="none required" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi -rm -fr conftest* +rm -f conftest* +test "$ac_cv_search_bsd_signal" = "no" && for i in bsd; do +LIBS="-l$i $ac_func_search_save_LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_search_bsd_signal="-l$i" +break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done +LIBS="$ac_func_search_save_LIBS" fi - if test -z "$BSD_SIGNAL"; then - echo "$ac_t""no" 1>&6 - LIBS="$pa_bsd_signal__old_libs" - else - echo "$ac_t""yes" 1>&6 +echo "$ac_t""$ac_cv_search_bsd_signal" 1>&6 +if test "$ac_cv_search_bsd_signal" != "no"; then + test "$ac_cv_search_bsd_signal" = "none required" || LIBS="$ac_cv_search_bsd_signal $LIBS" + +else : + LIBXTRA=1 LIBOBJS="$LIBOBJS bsdsignal.o" +fi + +if test "$LIBXTRA" -eq 1; then + LIBS="../lib/libxtra.a $LIBS" +fi + + + +# Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1363: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break fi - else - echo "$ac_t""yes" 1>&6 - fi -else - echo "$ac_t""yes" 1>&6 + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 fi - ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do @@ -1384,7 +1417,7 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1388: checking for a BSD compatible install" >&5 +echo "configure:1421: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1437,7 +1470,6 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - trap '' 1 2 15 cat > confcache <<\EOF # This file is a shell script that caches the results of configure @@ -1501,7 +1533,19 @@ fi trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 -DEFS=-DHAVE_CONFIG_H +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +cat > conftest.defs <<\EOF +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g +s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g +s%\[%\\&%g +s%\]%\\&%g +s%\$%$$%g +EOF +DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` +rm -f conftest.defs + # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} @@ -1539,7 +1583,7 @@ done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" -trap 'rm -fr `echo "MCONFIG config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +trap 'rm -fr `echo "MCONFIG" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF -fi -for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - echo creating $ac_file - - rm -f conftest.frag conftest.in conftest.out - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - cat $ac_file_inputs > conftest.in - -EOF - -# Transform confdefs.h into a sed script conftest.vals that substitutes -# the proper values into config.h.in to produce config.h. And first: -# Protect against being on the right side of a sed subst in config.status. -# Protect against being in an unquoted here document in config.status. -rm -f conftest.vals -cat > conftest.hdr <<\EOF -s/[\\&%]/\\&/g -s%[\\$`]%\\&%g -s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp -s%ac_d%ac_u%gp -s%ac_u%ac_e%gp -EOF -sed -n -f conftest.hdr confdefs.h > conftest.vals -rm -f conftest.hdr - -# This sed command replaces #undef with comments. This is necessary, for -# example, in the case of _POSIX_SOURCE, which is predefined and required -# on some systems where configure will not decide to define it. -cat >> conftest.vals <<\EOF -s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% -EOF - -# Break up conftest.vals because some shells have a limit on -# the size of here documents, and old seds have small limits too. - -rm -f conftest.tail -while : -do - ac_lines=`grep -c . conftest.vals` - # grep -c gives empty output for an empty file on some AIX systems. - if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi - # Write a limited-size here document to conftest.frag. - echo ' cat > conftest.frag <> $CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS - echo 'CEOF - sed -f conftest.frag conftest.in > conftest.out - rm -f conftest.in - mv conftest.out conftest.in -' >> $CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail - rm -f conftest.vals - mv conftest.tail conftest.vals -done -rm -f conftest.vals - -cat >> $CONFIG_STATUS <<\EOF - rm -f conftest.frag conftest.h - echo "/* $ac_file. Generated automatically by configure. */" > conftest.h - cat conftest.in >> conftest.h - rm -f conftest.in - if cmp -s $ac_file conftest.h 2>/dev/null; then - echo "$ac_file is unchanged" - rm -f conftest.h - else - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - fi - rm -f $ac_file - mv conftest.h $ac_file - fi -fi; done - EOF cat >> $CONFIG_STATUS < -#include -], -[ - struct msghdr msg; - void *p = (void *) &msg.msg_control; -], -[ - AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL) - AC_MSG_RESULT([yes]) -], -[ - AC_MSG_RESULT([no]) -]) - PA_ADD_CFLAGS(-Wall) PA_ADD_CFLAGS(-W) PA_ADD_CFLAGS(-Wpointer-arith) @@ -41,9 +21,21 @@ PA_ADD_CFLAGS(-Winline) PA_ADD_CFLAGS(-Wcast-align) PA_ADD_CFLAGS(-pipe) -PA_BSD_SIGNAL() +PA_SIGSETJMP(CFLAGS="$CFLAGS -DHAVE_SIGSETJMP=1", ) +LIBXTRA=0 + +AC_SEARCH_LIBS(xmalloc, iberty, , LIBXTRA=1 LIBOBJS="$LIBOBJS xmalloc.o") +AC_SEARCH_LIBS(xstrdup, iberty, , LIBXTRA=1 LIBOBJS="$LIBOBJS xstrdup.o") +AC_SEARCH_LIBS(bsd_signal, bsd, , LIBXTRA=1 LIBOBJS="$LIBOBJS bsdsignal.o") + +if test "$LIBXTRA" -eq 1; then + LIBS="../lib/libxtra.a $LIBS" +fi + +AC_SUBST(LIBOBJS) + +AC_PROG_RANLIB AC_PROG_INSTALL -AC_CONFIG_HEADER(config.h) AC_OUTPUT(MCONFIG) diff --git a/tftp/main.c b/tftp/main.c index 83da81d..1989b24 100644 --- a/tftp/main.c +++ b/tftp/main.c @@ -43,10 +43,6 @@ static const char *copyright = static const char *rcsid = "tftp-hpa $Id$"; #endif /* not lint */ -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 256 -#endif - /* Many bug fixes are from Jim Guyton */ /* @@ -72,6 +68,14 @@ static const char *rcsid = "tftp-hpa $Id$"; #include "extern.h" +void bsd_signal(int, void (*)(int)); + +#ifndef HAVE_SIGSETJMP +#define sigsetjmp(x,y) setjmp(x) +#define siglongjmp(x,y) longjmp(x,y) +#define sigjmp_buf jmp_buf +#endif + #define TIMEOUT 5 /* secs between rexmt's */ #define LBUFLEN 200 /* size of input buffer */ @@ -86,7 +90,7 @@ char line[LBUFLEN]; int margc; char *margv[20]; char *prompt = "tftp"; -jmp_buf toplevel; +sigjmp_buf toplevel; void intr(int); struct servent *sp; @@ -153,6 +157,8 @@ struct cmd cmdtab[] = { struct cmd *getcmd(char *); char *tail(char *); +char *xstrdup(const char *); + int main(int argc, char *argv[]) { @@ -175,13 +181,13 @@ main(int argc, char *argv[]) exit(1); } strcpy(mode, "netascii"); - signal(SIGINT, intr); + bsd_signal(SIGINT, intr); if (argc > 1) { - if (setjmp(toplevel) != 0) + if (sigsetjmp(toplevel,1) != 0) exit(0); setpeer(argc, argv); } - if (setjmp(toplevel) != 0) + if (sigsetjmp(toplevel,1) != 0) (void)putchar('\n'); command(); @@ -189,7 +195,7 @@ main(int argc, char *argv[]) return 0; /* Never reached */ } -char hostname[MAXHOSTNAMELEN]; +char *hostname; void setpeer(int argc, char *argv[]) @@ -210,8 +216,7 @@ setpeer(int argc, char *argv[]) } if (inet_aton(argv[1], &peeraddr.sin_addr) != 0) { peeraddr.sin_family = AF_INET; - (void) strncpy(hostname, argv[1], sizeof hostname); - hostname[sizeof(hostname)-1] = '\0'; + hostname = xstrdup(argv[1]); } else { host = gethostbyname(argv[1]); if (host == 0) { @@ -221,7 +226,7 @@ setpeer(int argc, char *argv[]) } peeraddr.sin_family = host->h_addrtype; bcopy(host->h_addr, &peeraddr.sin_addr, host->h_length); - (void) strcpy(hostname, host->h_name); + hostname = xstrdup(host->h_name); } port = sp->s_port; if (argc == 3) { @@ -349,7 +354,7 @@ put(int argc, char *argv[]) bcopy(hp->h_addr, (caddr_t)&peeraddr.sin_addr, hp->h_length); peeraddr.sin_family = hp->h_addrtype; connected = 1; - strcpy(hostname, hp->h_name); + hostname = xstrdup(hp->h_name); } if (!connected) { printf("No target machine specified.\n"); @@ -443,7 +448,7 @@ get(int argc, char *argv[]) hp->h_length); peeraddr.sin_family = hp->h_addrtype; connected = 1; - strcpy(hostname, hp->h_name); + hostname = xstrdup(hp->h_name); } if (argc < 4) { cp = argc == 3 ? argv[2] : tail(src); @@ -549,9 +554,9 @@ void intr(int sig) { - signal(SIGALRM, SIG_IGN); + bsd_signal(SIGALRM, SIG_IGN); alarm(0); - longjmp(toplevel, -1); + siglongjmp(toplevel, -1); } char * diff --git a/tftp/tftp.c b/tftp/tftp.c index f68984a..d089106 100644 --- a/tftp/tftp.c +++ b/tftp/tftp.c @@ -65,7 +65,13 @@ static const char *rcsid = "tftp-hpa $Id$"; #include "extern.h" #include "tftpsubs.h" -extern int errno; +void bsd_signal(int, void (*)(int)); + +#ifndef HAVE_SIGSETJMP +#define sigsetjmp(x,y) setjmp(x) +#define siglongjmp(x,y) longjmp(x,y) +#define sigjmp_buf jmp_buf +#endif extern struct sockaddr_in peeraddr; /* filled in by main */ extern int f; /* the opened socket */ @@ -84,8 +90,8 @@ extern int maxtimeout; #define PKTSIZE SEGSIZE+4 char ackbuf[PKTSIZE]; int timeout; -jmp_buf toplevel; -jmp_buf timeoutbuf; +sigjmp_buf toplevel; +sigjmp_buf timeoutbuf; static void nak(int); static int makerequest(int, const char *, struct tftphdr *, const char *); @@ -118,7 +124,7 @@ sendfile(int fd, char *name, char *mode) block = 0; amount = 0; - signal(SIGALRM, timer); + bsd_signal(SIGALRM, timer); do { if (block == 0) size = makerequest(WRQ, name, dp, mode) - 4; @@ -133,7 +139,7 @@ sendfile(int fd, char *name, char *mode) dp->th_block = htons((u_short)block); } timeout = 0; - (void) setjmp(timeoutbuf); + (void) sigsetjmp(timeoutbuf,1); send_data: if (trace) tpacket("sent", dp, size + 4); @@ -222,7 +228,7 @@ recvfile(int fd, char *name, char *mode) firsttrip = 1; amount = 0; - signal(SIGALRM, timer); + bsd_signal(SIGALRM, timer); do { if (firsttrip) { size = makerequest(RRQ, name, ap, mode); @@ -234,7 +240,7 @@ recvfile(int fd, char *name, char *mode) block++; } timeout = 0; - (void) setjmp(timeoutbuf); + (void) sigsetjmp(timeoutbuf,1); send_ack: if (trace) tpacket("sent", ap, size); @@ -446,8 +452,8 @@ timer(int sig) if (timeout >= maxtimeout) { printf("Transfer timed out.\n"); errno = save_errno; - longjmp(toplevel, -1); + siglongjmp(toplevel, -1); } errno = save_errno; - longjmp(timeoutbuf, 1); + siglongjmp(timeoutbuf, 1); }