Working on version 0.29.

Initial work for compiling on Win32/Cygwin.

Posixly correctness.
This commit is contained in:
hpa 2001-11-27 10:05:13 +00:00
parent f9e7950883
commit 98d7543721
10 changed files with 81 additions and 31 deletions

11
CHANGES
View file

@ -1,5 +1,16 @@
$Id$
Changes in 0.29:
Posixly correctness.
Some preliminary work for compiling under Cygwin (doesn't work
yet.)
Fixed a bug which could cause a standalone server to exit with
a "recvfrom: Interrupted system call" log message if signals
arrive at a particularly inopportune moment.
Changes in 0.28:
Fix stupid one-liner bug which broke standalone mode (-l).

View file

@ -28,6 +28,10 @@ MANDIR = @mandir@
# System binaries
SBINDIR = @sbindir@
# Binary suffixes
O = @OBJEXT@
X = @EXEEXT@
# Install into alternate root area, e.g. for package generation
INSTALLROOT =

View file

@ -89,11 +89,26 @@
#include <grp.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <errno.h>
#include <signal.h>
#include <sys/socket.h>
/* Test for EAGAIN/EWOULDBLOCK */
#ifdef EAGAIN
#if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
#define E_WOULD_BLOCK(x) ((x) == EAGAIN || (x) == EWOULDBLOCK)
#else
#define E_WOULD_BLOCK(x) ((x) == EAGAIN)
#endif
#else
#define E_WOULD_BLOCK(x) ((x) == EWOULDBLOCK)
#endif
/* If we don't have intmax_t, try creating it */
#ifndef HAVE_INTMAX_T

View file

@ -56,6 +56,7 @@ AC_HEADER_STDC
AC_CHECK_HEADERS(inttypes.h)
AC_CHECK_HEADERS(stdint.h)
PA_CHECK_INTTYPES_H_SANE
AC_CHECK_HEADERS(fcntl.h)
AC_CHECK_HEADERS(grp.h)
AC_CHECK_HEADERS(libgen.h)
AC_CHECK_HEADERS(memory.h)
@ -92,6 +93,7 @@ AC_SEARCH_LIBS(gethostbyname, [nsl resolv], , [AC_MSG_ERROR(gethostbyname not fo
AC_SEARCH_LIBS(inet_aton, [nsl resolv], , [AC_MSG_ERROR(inet_aton not found)])
AC_SEARCH_LIBS(herror, [nsl resolv], , [AC_MSG_ERROR(herror not found)])
AC_CHECK_FUNCS(fcntl)
AC_CHECK_FUNCS(setsid)
AC_CHECK_FUNCS(recvmsg)
AC_CHECK_FUNCS(ftruncate)
@ -112,9 +114,9 @@ AH_TEMPLATE([HAVE_SIGSETJMP],
PA_SIGSETJMP([AC_DEFINE(HAVE_SIGSETJMP)])
LIBXTRA=false
AC_SEARCH_LIBS(xmalloc, iberty, , LIBXTRA=true LIBOBJS="$LIBOBJS xmalloc.o")
AC_SEARCH_LIBS(xstrdup, iberty, , LIBXTRA=true LIBOBJS="$LIBOBJS xstrdup.o")
AC_SEARCH_LIBS(bsd_signal, bsd, , LIBXTRA=true LIBOBJS="$LIBOBJS bsdsignal.o")
AC_SEARCH_LIBS(xmalloc, iberty, , LIBXTRA=true LIBOBJS="$LIBOBJS xmalloc.${OBJEXT}")
AC_SEARCH_LIBS(xstrdup, iberty, , LIBXTRA=true LIBOBJS="$LIBOBJS xstrdup.${OBJEXT}")
AC_SEARCH_LIBS(bsd_signal, bsd, , LIBXTRA=true LIBOBJS="$LIBOBJS bsdsignal.${OBJEXT}")
if $LIBXTRA; then
LIBS="../lib/libxtra.a $LIBS"
fi
@ -148,7 +150,7 @@ PA_WITH_BOOL(remap, 1,
AC_SEARCH_LIBS(regcomp, [regex rx],
[
AC_DEFINE(WITH_REGEX)
TFTPDOBJS="remap.o $TFTPDOBJS"
TFTPDOBJS="remap.${OBJEXT} $TFTPDOBJS"
])
])
],:)

View file

@ -12,7 +12,7 @@ all: libxtra.a
install:
clean:
-rm -f *.a *.o
-rm -f *.a *.o *.obj *.exe
distclean: clean
-rm -f *~

View file

@ -1,14 +1,14 @@
all: tftp tftp.1
SRCROOT = ..
VERSION = $(shell cat ../version)
-include ../MCONFIG
include ../MRULES
OBJS = tftp.o main.o tftpsubs.o
OBJS = tftp.$(O) main.$(O) tftpsubs.$(O)
tftp: $(OBJS)
all: tftp$(X) tftp.1
tftp$(X): $(OBJS)
$(CC) $(LDFLAGS) $^ $(TFTP_LIBS) -o $@
$(OBJS): tftpsubs.h
@ -18,11 +18,11 @@ tftp.1: tftp.1.in ../version
install: all
mkdir -p $(INSTALLROOT)$(BINDIR) $(INSTALLROOT)$(MANDIR)/man1
$(INSTALL_PROGRAM) tftp $(INSTALLROOT)$(BINDIR)
$(INSTALL_DATA) tftp.1 $(INSTALLROOT)$(MANDIR)/man1
$(INSTALL_PROGRAM) tftp$(X) $(INSTALLROOT)$(BINDIR)
$(INSTALL_DATA) tftp.1 $(INSTALLROOT)$(MANDIR)/man1
clean:
rm -f *.o tftp tftp.1
rm -f *.o *.obj *.exe tftp tftp.1
distclean: clean
rm -f *~

View file

@ -54,7 +54,6 @@ static const char *rcsid UNUSED =
#include <sys/file.h>
#include <ctype.h>
#include <netdb.h>
#include <fcntl.h>
#ifdef WITH_READLINE
#include <readline/readline.h>
#ifdef HAVE_READLINE_HISTORY_H

View file

@ -1,14 +1,14 @@
all: tftpd tftpd.8
SRCROOT = ..
VERSION = $(shell cat ../version)
-include ../MCONFIG
include ../MRULES
OBJS = tftpd.o tftpsubs.o recvfrom.o misc.o $(TFTPDOBJS)
OBJS = tftpd.$(O) tftpsubs.$(O) recvfrom.$(O) misc.$(O) $(TFTPDOBJS)
tftpd: $(OBJS)
all: tftpd$(X) tftpd.8
tftpd$(X): $(OBJS)
$(CC) $(LDFLAGS) $^ $(TFTPD_LIBS) -o $@
tftpsubs.c:
@ -23,12 +23,12 @@ tftpd.8: tftpd.8.in ../version
install: all
mkdir -p $(INSTALLROOT)$(SBINDIR) $(INSTALLROOT)$(MANDIR)/man8
$(INSTALL_PROGRAM) tftpd $(INSTALLROOT)$(SBINDIR)/in.tftpd
$(INSTALL_PROGRAM) tftpd$(X) $(INSTALLROOT)$(SBINDIR)/in.tftpd
$(INSTALL_DATA) tftpd.8 $(INSTALLROOT)$(MANDIR)/man8/in.tftpd.8
cd $(INSTALLROOT)$(MANDIR)/man8 && ln -sf in.tftpd.8 tftpd.8
clean:
rm -f *.o tftpd tftpsubs.c tftpsubs.h tftpd.8
rm -f *.o *.obj *.exe tftpd tftpsubs.c tftpsubs.h tftpd.8
distclean: clean
rm -f *~

View file

@ -56,7 +56,6 @@ static const char *rcsid UNUSED =
#include <sys/ioctl.h>
#include <signal.h>
#include <fcntl.h>
#include <netdb.h>
#include <ctype.h>
#include <pwd.h>
@ -180,7 +179,6 @@ main(int argc, char **argv)
struct sockaddr_in myaddr;
struct sockaddr_in bindaddr;
int n;
int on = 1;
int fd = 0;
int standalone = 0; /* Standalone (listen) mode */
char *address = NULL; /* Address to listen to */
@ -298,10 +296,26 @@ main(int argc, char **argv)
if ( spec_umask || !unixperms )
umask(my_umask);
if (ioctl(fd, FIONBIO, &on) < 0) {
syslog(LOG_ERR, "ioctl(FIONBIO): %m");
exit(EX_OSERR);
#if defined(HAVE_FCNTL) && defined(O_NONBLOCK)
/* Posixly correct */
{
int flags;
if ( (flags = fcntl(fd, F_GETFL, 0) < 0) ||
(fcntl(fd, F_SETFL, flags|O_NONBLOCK)) ) {
syslog(LOG_ERR, "Cannot set nonblocking socket: %m");
exit(EX_OSERR);
}
}
#else
/* Old BSD version */
{
int on = 1;
if ( ioctl(fd, FIONBIO, &on) < 0 ) {
syslog(LOG_ERR, "Cannot set nonblocking socket: %m");
exit(EX_OSERR);
}
}
#endif
#ifdef WITH_REGEX
if ( rewrite_file )
@ -421,7 +435,7 @@ main(int argc, char **argv)
continue; /* Signal caught, reloop */
if ( rv == -1 ) {
syslog(LOG_ERR, "select loop: %m");
exit(EX_OSERR);
exit(EX_IOERR);
} else if ( rv == 0 ) {
exit(0); /* Timeout, return to inetd */
}
@ -431,17 +445,22 @@ main(int argc, char **argv)
(struct sockaddr *)&from, &fromlen,
&myaddr);
if ( n < 0 ) {
if ( E_WOULD_BLOCK(errno) || errno == EINTR ) {
continue; /* Again, from the top */
} else {
syslog(LOG_ERR, "recvfrom: %m");
exit(EX_IOERR);
}
}
if ( standalone && myaddr.sin_addr.s_addr == INADDR_ANY ) {
/* myrecvfrom() didn't capture the source address; but we might
have bound to a specific address, if so we should use it */
memcpy(&myaddr.sin_addr, &bindaddr.sin_addr, sizeof bindaddr.sin_addr);
}
if (n < 0) {
syslog(LOG_ERR, "recvfrom: %m");
exit(EX_IOERR);
}
/*
* Now that we have read the request packet from the UDP
* socket, we fork and go back to listening to the socket.

View file

@ -1 +1 @@
0.28
0.29