summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES11
-rw-r--r--MCONFIG.in4
-rw-r--r--config.h15
-rw-r--r--configure.in10
-rw-r--r--lib/Makefile2
-rw-r--r--tftp/Makefile14
-rw-r--r--tftp/main.c1
-rw-r--r--tftpd/Makefile12
-rw-r--r--tftpd/tftpd.c41
-rw-r--r--version2
10 files changed, 81 insertions, 31 deletions
diff --git a/CHANGES b/CHANGES
index 5bbec51..b9c1b36 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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).
diff --git a/MCONFIG.in b/MCONFIG.in
index 5e1d8f1..85f2d40 100644
--- a/MCONFIG.in
+++ b/MCONFIG.in
@@ -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 =
diff --git a/config.h b/config.h
index edd6781..c07b4b8 100644
--- a/config.h
+++ b/config.h
@@ -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
diff --git a/configure.in b/configure.in
index cef754a..65ef114 100644
--- a/configure.in
+++ b/configure.in
@@ -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"
])
])
],:)
diff --git a/lib/Makefile b/lib/Makefile
index 4e20ad3..615a3fa 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -12,7 +12,7 @@ all: libxtra.a
install:
clean:
- -rm -f *.a *.o
+ -rm -f *.a *.o *.obj *.exe
distclean: clean
-rm -f *~
diff --git a/tftp/Makefile b/tftp/Makefile
index 9889b7c..0ff0451 100644
--- a/tftp/Makefile
+++ b/tftp/Makefile
@@ -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)
+
+all: tftp$(X) tftp.1
-tftp: $(OBJS)
+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 *~
diff --git a/tftp/main.c b/tftp/main.c
index 478f3ba..dfe9d22 100644
--- a/tftp/main.c
+++ b/tftp/main.c
@@ -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
diff --git a/tftpd/Makefile b/tftpd/Makefile
index 1deebf1..b30d4a0 100644
--- a/tftpd/Makefile
+++ b/tftpd/Makefile
@@ -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)
+
+all: tftpd$(X) tftpd.8
-tftpd: $(OBJS)
+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 *~
diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c
index 5d7eb55..16ce456 100644
--- a/tftpd/tftpd.c
+++ b/tftpd/tftpd.c
@@ -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.
diff --git a/version b/version
index 4950f07..eec15f9 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-0.28
+0.29