From acb00a89f9e9b0b4febec544da2aca18d35eb638 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 10 Jan 2016 21:39:30 +0100 Subject: [PATCH] Use autoconf and automake and remove MSVC projects. This patch is imported from the rinetd Debian package. --- .gitignore | 16 ++++++ Makefile | 9 ---- Makefile.am | 13 +++++ bootstrap | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 32 ++++++++++++ match.c | 4 ++ rinetd.c | 22 ++++---- rinetd.conf | 25 +++++++++ rinetd.dsp | 97 ----------------------------------- rinetd.dsw | 29 ----------- 10 files changed, 241 insertions(+), 145 deletions(-) create mode 100644 .gitignore delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100755 bootstrap create mode 100644 configure.ac create mode 100644 rinetd.conf delete mode 100644 rinetd.dsp delete mode 100644 rinetd.dsw diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f7f075 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +.auto +.deps +Makefile +Makefile.in +stamp-* +aclocal.m4 +autom4te.cache +config.h +config.h.in +config.log +config.status +configure + +*.o +rinetd + diff --git a/Makefile b/Makefile deleted file mode 100644 index d598b18..0000000 --- a/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -CFLAGS=-DLINUX -g - -rinetd: rinetd.o match.o - gcc rinetd.o match.o -o rinetd - -install: rinetd - install -m 700 rinetd /usr/sbin - install -m 644 rinetd.8 /usr/man/man8 - diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..7dd3fbc --- /dev/null +++ b/Makefile.am @@ -0,0 +1,13 @@ + +AUTOMAKE_OPTIONS = foreign dist-bzip2 + +EXTRA_DIST = bootstrap CHANGES index.html \ + getopt.c getopt.h $(man_MANS) $(sysconf_DATA) + +man_MANS = rinetd.8 +sysconf_DATA = rinetd.conf + +sbin_PROGRAMS = rinetd +rinetd_SOURCES = rinetd.c match.c match.h +rinetd_CFLAGS = -Wall -Wwrite-strings -I. + diff --git a/bootstrap b/bootstrap new file mode 100755 index 0000000..35363e5 --- /dev/null +++ b/bootstrap @@ -0,0 +1,139 @@ +#! /bin/sh + +# bootstrap — generic bootstrap/autogen.sh script for autotools projects +# +# Copyright © 2002—2015 Sam Hocevar +# +# This program is free software. It comes without any warranty, to +# the extent permitted by applicable law. You can redistribute it +# and/or modify it under the terms of the Do What the Fuck You Want +# to Public License, Version 2, as published by the WTFPL Task Force. +# See http://www.wtfpl.net/ for more details. +# +# The latest version of this script can be found at the following place: +# http://caca.zoy.org/wiki/build + +# Die if an error occurs +set -e + +# Guess whether we are using configure.ac or configure.in +if test -f configure.ac; then + conffile="configure.ac" +elif test -f configure.in; then + conffile="configure.in" +else + echo "$0: could not find configure.ac or configure.in" + exit 1 +fi + +# Check for needed features +auxdir="`sed -ne 's/^[ \t]*A._CONFIG_AUX_DIR *([[ ]*\([^] )]*\).*/\1/p' $conffile`" +pkgconfig="`grep '^[ \t]*PKG_PROG_PKG_CONFIG' $conffile >/dev/null 2>&1 && echo yes || echo no`" +libtool="`grep '^[ \t]*A._PROG_LIBTOOL' $conffile >/dev/null 2>&1 && echo yes || echo no`" +header="`grep '^[ \t]*A._CONFIG_HEADER' $conffile >/dev/null 2>&1 && echo yes || echo no`" +automake="`grep '^[ \t]*AM_INIT_AUTOMAKE' $conffile >/dev/null 2>&1 && echo yes || echo no`" +aclocalflags="`sed -ne 's/^[ \t]*ACLOCAL_AMFLAGS[ \t]*=//p' Makefile.am 2>/dev/null || :`" + +# Check for automake +amvers="no" +for v in "" "-1.15" "-1.14" "-1.13" "-1.12" "-1.11"; do + if automake${v} --version > /dev/null 2>&1; then + amvers=${v} + break + fi +done + +if test "$amvers" = "no"; then + echo "$0: automake not found" + exit 1 +fi + +# Check for autoconf +acvers="no" +for v in "" "259" "253"; do + if autoconf${v} --version >/dev/null 2>&1; then + acvers="${v}" + break + fi +done + +if test "$acvers" = "no"; then + echo "$0: autoconf not found" + exit 1 +fi + +# Check for libtool +if test "$libtool" = "yes"; then + libtoolize="no" + if glibtoolize --version >/dev/null 2>&1; then + libtoolize="glibtoolize" + else + for v in "16" "15" "" "14"; do + if libtoolize${v} --version >/dev/null 2>&1; then + libtoolize="libtoolize${v}" + break + fi + done + fi + + if test "$libtoolize" = "no"; then + echo "$0: libtool not found" + exit 1 + fi +fi + +# Check for pkg-config +if test "$pkgconfig" = "yes"; then + if ! pkg-config --version >/dev/null 2>&1; then + echo "$0: pkg-config not found" + exit 1 + fi +fi + +# Remove old cruft +for x in aclocal.m4 configure config.guess config.log config.sub config.cache config.h.in config.h compile libtool.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 ltmain.sh libtool ltconfig missing mkinstalldirs depcomp install-sh; do rm -f $x autotools/$x; if test -n "$auxdir"; then rm -f "$auxdir/$x"; fi; done +rm -Rf autom4te.cache +if test -n "$auxdir"; then + if test ! -d "$auxdir"; then + mkdir "$auxdir" + fi + aclocalflags="-I $auxdir -I . ${aclocalflags}" +fi + +# Honour M4PATH because sometimes M4 doesn't +save_IFS=$IFS +IFS=: +tmp="$M4PATH" +for x in $tmp; do + if test -n "$x"; then + aclocalflags="-I $x ${aclocalflags}" + fi +done +IFS=$save_IFS + +# Explain what we are doing from now +set -x + +# Bootstrap package +if test "$libtool" = "yes"; then + ${libtoolize} --copy --force + if test -n "$auxdir" -a ! "$auxdir" = "." -a -f "ltmain.sh"; then + echo "$0: working around a minor libtool issue" + mv ltmain.sh "$auxdir/" + fi +fi + +aclocal${amvers} ${aclocalflags} +autoconf${acvers} +if test "$header" = "yes"; then + autoheader${acvers} +fi +if test "$automake" = "yes"; then + #add --include-deps if you want to bootstrap with any other compiler than gcc + #automake${amvers} --add-missing --copy --include-deps + automake${amvers} --foreign --add-missing --copy +fi + +# Remove cruft that we no longer want +rm -Rf autom4te.cache + diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..31bf542 --- /dev/null +++ b/configure.ac @@ -0,0 +1,32 @@ +# Process this file with autoconf to produce a configure script. +AC_PREREQ(2.52) +AC_INIT(rinetd, 0.62, sam@hocevar.net) +AC_CONFIG_AUX_DIR(.auto) +AC_CONFIG_SRCDIR([getopt.h]) +AC_CONFIG_HEADER([config.h]) +AM_INIT_AUTOMAKE([no-define tar-ustar silent-rules]) + +# Checks for programs. +AC_PROG_CC +AC_PROG_INSTALL + +# Checks for libraries. + +# Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([arpa/inet.h errno.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h syslog.h unistd.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_HEADER_TIME +AC_STRUCT_TM + +# Checks for library functions. +AC_FUNC_FORK +AC_FUNC_MALLOC +AC_TYPE_SIGNAL +AC_FUNC_STRFTIME +AC_CHECK_FUNCS([gethostbyname memset select socket strstr daemon sigaction]) + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/match.c b/match.c index e75f4c9..1eb605d 100644 --- a/match.c +++ b/match.c @@ -1,3 +1,7 @@ +#if HAVE_CONFIG_H +#include +#endif + #include #include #include "match.h" diff --git a/rinetd.c b/rinetd.c index cac7f4d..0985311 100644 --- a/rinetd.c +++ b/rinetd.c @@ -1,4 +1,6 @@ -#define VERSION "0.62" +#if HAVE_CONFIG_H +#include +#endif #ifdef WIN32 #include @@ -956,7 +958,7 @@ void handleCloseFromLocal(int i) closesocket(loFds[i]); loClosed[i] = 1; if (!reClosed[i]) { -#ifndef LINUX +#ifndef __linux__ #ifndef WIN32 /* Now set up the remote end for a polite closing */ @@ -967,7 +969,7 @@ void handleCloseFromLocal(int i) setsockopt(reFds[i], SOL_SOCKET, SO_SNDLOWAT, &arg, sizeof(arg)); #endif /* WIN32 */ -#endif /* LINUX */ +#endif /* __linux__ */ coLog[i] = logLocalClosedFirst; } } @@ -982,7 +984,7 @@ void handleCloseFromRemote(int i) closesocket(reFds[i]); reClosed[i] = 1; if (!loClosed[i]) { -#ifndef LINUX +#ifndef __linux__ #ifndef WIN32 /* Now set up the local end for a polite closing */ @@ -993,7 +995,7 @@ void handleCloseFromRemote(int i) setsockopt(loFds[i], SOL_SOCKET, SO_SNDLOWAT, &arg, sizeof(arg)); #endif /* WIN32 */ -#endif /* LINUX */ +#endif /* __linux__ */ loClosed[i] = 0; coLog[i] = logRemoteClosedFirst; } @@ -1270,13 +1272,13 @@ void openLocalFd(int se, int i) memcpy(&saddr.sin_addr, &seLocalAddrs[se], sizeof(struct in_addr)); saddr.sin_port = seLocalPorts[se]; #ifndef WIN32 -#ifdef LINUX +#ifdef __linux__ j = 0; setsockopt(loFds[i], SOL_SOCKET, SO_LINGER, &j, sizeof(j)); #else j = 1024; setsockopt(loFds[i], SOL_SOCKET, SO_SNDBUF, &j, sizeof(j)); -#endif /* LINUX */ +#endif /* __linux__ */ #endif /* WIN32 */ j = 1; ioctlsocket(loFds[i], FIONBIO, &j); @@ -1365,7 +1367,7 @@ void RegisterPID(void) pid_file_name = pidLogFileName; } /* add other systems with wherever they register processes */ -#if defined(LINUX) +#if defined(__linux__) pid_file = fopen(pid_file_name, "w"); if (pid_file == NULL) { /* non-fatal, non-Linux may lack /var/run... */ @@ -1376,7 +1378,7 @@ void RegisterPID(void) fprintf(pid_file, "%d\n", getpid()); fclose(pid_file); } -#endif /* LINUX */ +#endif /* __linux__ */ } unsigned char nullAddress[4] = { 0, 0, 0, 0 }; @@ -1509,7 +1511,7 @@ int readArgs (int argc, "manpage for more information.\n"); exit (0); case 'v': - printf ("rinetd %s\n", VERSION); + printf ("rinetd %s\n", PACKAGE_VERSION); exit (0); case '?': default: diff --git a/rinetd.conf b/rinetd.conf new file mode 100644 index 0000000..686a008 --- /dev/null +++ b/rinetd.conf @@ -0,0 +1,25 @@ +# +# this is the configuration file for rinetd, the internet redirection server +# +# you may specify global allow and deny rules here +# only ip addresses are matched, hostnames cannot be specified here +# the wildcards you may use are * and ? +# +# allow 192.168.2.* +# deny 192.168.2.1? + + +# +# forwarding rules come here +# +# you may specify allow and deny rules after a specific forwarding rule +# to apply to only that forwarding rule +# +# bindadress bindport connectaddress connectport + + +# logging information +logfile /var/log/rinetd.log + +# uncomment the following line if you want web-server style logfile format +# logcommon diff --git a/rinetd.dsp b/rinetd.dsp deleted file mode 100644 index d45592b..0000000 --- a/rinetd.dsp +++ /dev/null @@ -1,97 +0,0 @@ -# Microsoft Developer Studio Project File - Name="rinetd" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 5.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=rinetd - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "rinetd.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "rinetd.mak" CFG="rinetd - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "rinetd - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "rinetd - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "rinetd - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "rinetd - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "rinetd - Win32 Release" -# Name "rinetd - Win32 Debug" -# Begin Source File - -SOURCE=.\getopt.c -# End Source File -# Begin Source File - -SOURCE=.\match.c -# End Source File -# Begin Source File - -SOURCE=.\rinetd.c -# End Source File -# End Target -# End Project diff --git a/rinetd.dsw b/rinetd.dsw deleted file mode 100644 index 61dc1d1..0000000 --- a/rinetd.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 5.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "rinetd"=.\rinetd.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### -