forked from mirrors/tftp-hpa-google
Portability improvements. Now compiles and works on Solaris 8, as well
as Linux.
This commit is contained in:
parent
4003a672ce
commit
266427bc5b
10 changed files with 78 additions and 29 deletions
5
README
5
README
|
@ -18,6 +18,11 @@ improvements.
|
||||||
===> IMPORTANT: SEE THE FILE "README.security" FOR IMPORTANT SECURITY
|
===> IMPORTANT: SEE THE FILE "README.security" FOR IMPORTANT SECURITY
|
||||||
===> CHANGES ENACTED IN VERSION 0.17!!!!!!!!!
|
===> CHANGES ENACTED IN VERSION 0.17!!!!!!!!!
|
||||||
|
|
||||||
|
Changes in 0.20:
|
||||||
|
Portability improvements. Now known to compile and run on
|
||||||
|
Solaris 8.
|
||||||
|
|
||||||
|
|
||||||
Changes in 0.19:
|
Changes in 0.19:
|
||||||
Fork before performing tcpwrappers check.
|
Fork before performing tcpwrappers check.
|
||||||
|
|
||||||
|
|
|
@ -23,4 +23,7 @@
|
||||||
#undef HAVE_SETREUID
|
#undef HAVE_SETREUID
|
||||||
#undef HAVE_SETREGID
|
#undef HAVE_SETREGID
|
||||||
#undef HAVE_SYSEXITS_H
|
#undef HAVE_SYSEXITS_H
|
||||||
|
#undef HAVE_STRINGS_H
|
||||||
|
#undef HAVE_LIBGEN_H
|
||||||
|
#undef HAVE_SYS_FILIO_H
|
||||||
#undef WITH_REGEX
|
#undef WITH_REGEX
|
||||||
|
|
14
configure.in
14
configure.in
|
@ -9,6 +9,16 @@ AC_PROG_CC
|
||||||
AC_C_CONST
|
AC_C_CONST
|
||||||
AC_C_INLINE
|
AC_C_INLINE
|
||||||
|
|
||||||
|
AC_CHECK_HEADERS(sysexits.h)
|
||||||
|
AC_CHECK_HEADERS(strings.h)
|
||||||
|
AC_CHECK_HEADERS(libgen.h)
|
||||||
|
AC_CHECK_HEADERS(sys/filio.h)
|
||||||
|
|
||||||
|
AC_SEARCH_LIBS(socket, socket, , [AC_MSG_ERROR(socket library not found)])
|
||||||
|
AC_SEARCH_LIBS(gethostbyname, [nsl resolv], , [AC_MSG_ERROR(gethostbyname not found)])
|
||||||
|
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(recvmsg)
|
AC_CHECK_FUNCS(recvmsg)
|
||||||
AC_CHECK_FUNCS(setreuid)
|
AC_CHECK_FUNCS(setreuid)
|
||||||
AC_CHECK_FUNCS(setregid)
|
AC_CHECK_FUNCS(setregid)
|
||||||
|
@ -50,14 +60,10 @@ PA_ADD_CFLAGS(-pipe)
|
||||||
|
|
||||||
PA_SIGSETJMP([AC_DEFINE(HAVE_SIGSETJMP)])
|
PA_SIGSETJMP([AC_DEFINE(HAVE_SIGSETJMP)])
|
||||||
|
|
||||||
AC_CHECK_HEADERS(sysexits.h)
|
|
||||||
|
|
||||||
LIBXTRA=false
|
LIBXTRA=false
|
||||||
|
|
||||||
AC_SEARCH_LIBS(xmalloc, iberty, , LIBXTRA=true LIBOBJS="$LIBOBJS xmalloc.o")
|
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(xstrdup, iberty, , LIBXTRA=true LIBOBJS="$LIBOBJS xstrdup.o")
|
||||||
AC_SEARCH_LIBS(bsd_signal, bsd, , LIBXTRA=true LIBOBJS="$LIBOBJS bsdsignal.o")
|
AC_SEARCH_LIBS(bsd_signal, bsd, , LIBXTRA=true LIBOBJS="$LIBOBJS bsdsignal.o")
|
||||||
|
|
||||||
if $LIBXTRA; then
|
if $LIBXTRA; then
|
||||||
LIBS="../lib/libxtra.a $LIBS"
|
LIBS="../lib/libxtra.a $LIBS"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -8,14 +8,23 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
void bsd_signal(int signum, void (*handler)(int))
|
void (*bsd_signal(int signum, void (*handler)(int)))(int);
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action, oldaction;
|
||||||
|
|
||||||
memset(&action, 0, sizeof action);
|
memset(&action, 0, sizeof action);
|
||||||
action.sa_handler = handler;
|
action.sa_handler = handler;
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
|
sigaddset(&act.sa_mask, signum);
|
||||||
action.sa_flags = SA_RESTART;
|
action.sa_flags = SA_RESTART;
|
||||||
|
|
||||||
sigaction(hander, action, NULL);
|
if (sigaction(hander, action, &oldaction) == -1) {
|
||||||
|
#ifdef SIG_ERR
|
||||||
|
return SIG_ERR;
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return oldaction.sa_handler;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,8 +68,13 @@ static const char *rcsid UNUSED =
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
#include "../config.h"
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
#include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TIMEOUT 5 /* secs between rexmt's */
|
#define TIMEOUT 5 /* secs between rexmt's */
|
||||||
#define LBUFLEN 200 /* size of input buffer */
|
#define LBUFLEN 200 /* size of input buffer */
|
||||||
|
|
|
@ -68,7 +68,9 @@ static const char *rcsid UNUSED =
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
|
||||||
void bsd_signal(int, void (*)(int));
|
#ifdef HAVE_STRINGS_H
|
||||||
|
#include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_SIGSETJMP
|
#ifndef HAVE_SIGSETJMP
|
||||||
#define sigsetjmp(x,y) setjmp(x)
|
#define sigsetjmp(x,y) setjmp(x)
|
||||||
|
@ -322,7 +324,7 @@ makerequest(int request, const char *name,
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
tp->th_opcode = htons((u_short)request);
|
tp->th_opcode = htons((u_short)request);
|
||||||
cp = tp->th_stuff;
|
cp = (char *) &(tp->th_stuff);
|
||||||
strcpy(cp, name);
|
strcpy(cp, name);
|
||||||
cp += strlen(name);
|
cp += strlen(name);
|
||||||
*cp++ = '\0';
|
*cp++ = '\0';
|
||||||
|
@ -397,7 +399,7 @@ tpacket(const char *s, struct tftphdr *tp, int n)
|
||||||
case RRQ:
|
case RRQ:
|
||||||
case WRQ:
|
case WRQ:
|
||||||
n -= 2;
|
n -= 2;
|
||||||
file = cp = tp->th_stuff;
|
file = cp = (char *) &(tp->th_stuff);
|
||||||
cp = strchr(cp, '\0');
|
cp = strchr(cp, '\0');
|
||||||
printf("<file=%s, mode=%s>\n", file, cp + 1);
|
printf("<file=%s, mode=%s>\n", file, cp + 1);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -59,12 +59,14 @@ static const char *rcsid UNUSED =
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/time.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/tftp.h>
|
#include <arpa/tftp.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "../config.h"
|
||||||
|
|
||||||
#define PKTSIZE MAX_SEGSIZE+4 /* should be moved to tftp.h */
|
#define PKTSIZE MAX_SEGSIZE+4 /* should be moved to tftp.h */
|
||||||
|
|
||||||
int segsize = SEGSIZE; /* Default segsize */
|
int segsize = SEGSIZE; /* Default segsize */
|
||||||
|
@ -254,20 +256,28 @@ skipit:
|
||||||
int
|
int
|
||||||
synchnet(int f) /* socket to flush */
|
synchnet(int f) /* socket to flush */
|
||||||
{
|
{
|
||||||
int i, j = 0;
|
int pktcount = 0;
|
||||||
char rbuf[PKTSIZE];
|
char rbuf[PKTSIZE];
|
||||||
struct sockaddr_in from;
|
struct sockaddr_in from;
|
||||||
int fromlen;
|
int fromlen;
|
||||||
|
fd_set socketset;
|
||||||
|
struct timeval notime;
|
||||||
|
|
||||||
|
while ( 1 ) {
|
||||||
|
notime.tv_sec = notime.tv_usec = 0;
|
||||||
|
|
||||||
|
FD_ZERO(&socketset);
|
||||||
|
FD_SET(f, &socketset);
|
||||||
|
|
||||||
|
if ( select(f, &socketset, NULL, NULL, ¬ime) <= 0 )
|
||||||
|
break; /* Nothing to read */
|
||||||
|
|
||||||
|
/* Otherwise drain the packet */
|
||||||
|
pktcount++;
|
||||||
|
fromlen = sizeof from;
|
||||||
|
(void) recvfrom(f, rbuf, sizeof (rbuf), 0,
|
||||||
|
(struct sockaddr *)&from, &fromlen);
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
return pktcount; /* Return packets drained */
|
||||||
(void) ioctl(f, FIONREAD, &i);
|
|
||||||
if (i) {
|
|
||||||
j++;
|
|
||||||
fromlen = sizeof from;
|
|
||||||
(void) recvfrom(f, rbuf, sizeof (rbuf), 0,
|
|
||||||
(struct sockaddr *)&from, &fromlen);
|
|
||||||
} else {
|
|
||||||
return(j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ extern char *xstrdup(const char *);
|
||||||
/*
|
/*
|
||||||
* Signal-related stuff
|
* Signal-related stuff
|
||||||
*/
|
*/
|
||||||
void bsd_signal(int, void (*)(int));
|
void (*bsd_signal(int, void (*)(int)))(int);
|
||||||
|
|
||||||
#ifndef HAVE_SIGSETJMP
|
#ifndef HAVE_SIGSETJMP
|
||||||
#define sigsetjmp(x,y) setjmp(x)
|
#define sigsetjmp(x,y) setjmp(x)
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
|
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "recvfrom.h"
|
#include "recvfrom.h"
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
#include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_RECVMSG) && defined(HAVE_MSGHDR_MSG_CONTROL)
|
#if defined(HAVE_RECVMSG) && defined(HAVE_MSGHDR_MSG_CONTROL)
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,12 @@ int allow_severity = -1; /* Don't log at all */
|
||||||
|
|
||||||
struct request_info wrap_request;
|
struct request_info wrap_request;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_LIBGEN_H
|
||||||
|
#include <libgen.h> /* Necessary for basename() on Solaris */
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_FILIO_H
|
||||||
|
#include <sys/filio.h> /* Necessary for FIONBIO on Solaris */
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TIMEOUT 5 /* Default timeout (seconds) */
|
#define TIMEOUT 5 /* Default timeout (seconds) */
|
||||||
#define TRIES 4 /* Number of attempts to send each packet */
|
#define TRIES 4 /* Number of attempts to send each packet */
|
||||||
|
@ -101,7 +107,7 @@ struct request_info wrap_request;
|
||||||
#define EOPTNEG 8
|
#define EOPTNEG 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern char *__progname;
|
char *__progname;
|
||||||
int peer;
|
int peer;
|
||||||
int timeout = TIMEOUT;
|
int timeout = TIMEOUT;
|
||||||
int rexmtval = TIMEOUT;
|
int rexmtval = TIMEOUT;
|
||||||
|
@ -444,7 +450,7 @@ tftp(struct tftphdr *tp, int size)
|
||||||
|
|
||||||
((struct tftphdr *)ackbuf)->th_opcode = ntohs(OACK);
|
((struct tftphdr *)ackbuf)->th_opcode = ntohs(OACK);
|
||||||
|
|
||||||
origfilename = cp = tp->th_stuff;
|
origfilename = cp = (char *) &(tp->th_stuff);
|
||||||
argn = 0;
|
argn = 0;
|
||||||
|
|
||||||
while ( cp < buf + size && *cp ) {
|
while ( cp < buf + size && *cp ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue