From 8ef5cf47d8f47c819b911ada94763367b8c5869d Mon Sep 17 00:00:00 2001 From: Mats Erik Andersson
Date: Tue, 23 Nov 2010 00:22:41 +0100 Subject: [PATCH 2/2] addrpeek: New test service for Inetd. --- ChangeLog | 6 ++ tests/Makefile.am | 4 ++ tests/addrpeek.c | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 0 deletions(-) create mode 100644 tests/addrpeek.c diff --git a/ChangeLog b/ChangeLog index 9829038..aec9d50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2010-11-22 Mats Erik Andersson + * tests/addrpeek.c: New file. + * tests/Makefile.am: Register `addrpeek' using + `check_PROGRAMS', but conditioned on `ENABLE_inetd'. + +2010-11-22 Mats Erik Andersson + * src/inetd.c (prepenv): New prototype: `prepenv(int, struct sockaddr *, socklen_t)'. (prepenv): Change type of IP to `char []' of fixed length. diff --git a/tests/Makefile.am b/tests/Makefile.am index cce19ee..1327c5e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -21,6 +21,10 @@ AM_CPPFLAGS = -I$(top_srcdir)/libinetutils -I$(top_srcdir)/lib LDADD = -L../libinetutils -linetutils ../lib/libgnu.a check_PROGRAMS = localhost +if ENABLE_inetd +check_PROGRAMS += addrpeek +endif + dist_check_SCRIPTS = if ENABLE_ping dist_check_SCRIPTS += ping-localhost.sh diff --git a/tests/addrpeek.c b/tests/addrpeek.c new file mode 100644 index 0000000..5eae6d1 --- /dev/null +++ b/tests/addrpeek.c @@ -0,0 +1,135 @@ +/* addrpeek - testing service for Inetd: remote address, environment vars + Copyright (C) 2010 Free Software Foundation, Inc. + + This file is part of GNU Inetutils. + + GNU Inetutils is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at + your option) any later version. + + GNU Inetutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see `http://www.gnu.org/licenses/'. */ + +/* Written by Mats Erik Andersson. */ + +/* Addrpeek is a test client for examining Inetd, primarily TCP traffic. + * The client executes all those tasks that were listed as server + * arguments in the configuration file for Inetd: + * + * addr : Reply with "Your address is $IP." + * env : Reply with all known environment variables and their values. + * + * Reasonable entries in `inetf.conf' could be + * + * # Return numerical address of the calling client. + * # + * 7890 stream tcp nowait nobody /tmp/addrpeek addrpeek addr + * 7890 stream tcp6 nowait nobody /tmp/addrpeek addrpeek addr + * # + * # Display all environment variables in use, and append + * # the client's address at the end. + * # + * tcpmux stream tcp nowait nobody internal + * tcpmux stream tcp6 nowait nobody internal + * tcpmux/env stream tcp nowait nobody /tmp/addrpeek addrkeep env addr + */ + +#include "config.h" +#include