From 498f12819bfe6ef54e4eeabae8017389f433860a Mon Sep 17 00:00:00 2001 From: "psyc://loupsycedyglgamf.onion/~lynX" Date: Sun, 22 May 2016 09:56:57 +0200 Subject: [PATCH] remove outdated gentoo config --- config/README.1st | 6 + config/gentoo/INSTALL | 36 - config/gentoo/Makefile | 92 - config/gentoo/ldmud.ebuild | 104 - config/gentoo/ldmud/ChangeLog | 13 - config/gentoo/ldmud/Makefile | 51 - config/gentoo/ldmud/files/erq/Makefile.in | 68 - config/gentoo/ldmud/files/erq/erq.c | 2612 --------------------- config/gentoo/ldmud/files/erq/erq.h | 60 - config/gentoo/ldmud/files/erq/srv.c | 215 -- config/gentoo/ldmud/files/erq/srv.h | 32 - config/gentoo/ldmud/files/psyced.settings | 311 --- config/gentoo/ldmud/metadata.xml | 13 - config/gentoo/psyced.ebuild | 149 -- config/gentoo/psyced/ChangeLog | 7 - config/gentoo/psyced/Makefile | 45 - config/gentoo/psyced/metadata.xml | 12 - config/gentoo/psyclpc.ebuild | 98 - config/gentoo/psyclpc/ChangeLog | 17 - config/gentoo/psyclpc/Makefile | 35 - config/gentoo/psyclpc/metadata.xml | 20 - 21 files changed, 6 insertions(+), 3990 deletions(-) delete mode 100644 config/gentoo/INSTALL delete mode 100644 config/gentoo/Makefile delete mode 100644 config/gentoo/ldmud.ebuild delete mode 100644 config/gentoo/ldmud/ChangeLog delete mode 100644 config/gentoo/ldmud/Makefile delete mode 100644 config/gentoo/ldmud/files/erq/Makefile.in delete mode 100644 config/gentoo/ldmud/files/erq/erq.c delete mode 100644 config/gentoo/ldmud/files/erq/erq.h delete mode 100644 config/gentoo/ldmud/files/erq/srv.c delete mode 100644 config/gentoo/ldmud/files/erq/srv.h delete mode 100644 config/gentoo/ldmud/files/psyced.settings delete mode 100644 config/gentoo/ldmud/metadata.xml delete mode 100644 config/gentoo/psyced.ebuild delete mode 100644 config/gentoo/psyced/ChangeLog delete mode 100644 config/gentoo/psyced/Makefile delete mode 100644 config/gentoo/psyced/metadata.xml delete mode 100644 config/gentoo/psyclpc.ebuild delete mode 100644 config/gentoo/psyclpc/ChangeLog delete mode 100644 config/gentoo/psyclpc/Makefile delete mode 100644 config/gentoo/psyclpc/metadata.xml diff --git a/config/README.1st b/config/README.1st index b39e9f7..a88a190 100644 --- a/config/README.1st +++ b/config/README.1st @@ -12,3 +12,9 @@ Do not edit in here. Find out where the corresponding files are in your systems, or maybe copy files out of here to where you need them. + +=== UPDATE! === + +Gentoo configuration has moved into the youbroketheinternet-overlay +available from git://cheettyiapsyciew.onion/youbroketheinternet-overlay + diff --git a/config/gentoo/INSTALL b/config/gentoo/INSTALL deleted file mode 100644 index 8f379ec..0000000 --- a/config/gentoo/INSTALL +++ /dev/null @@ -1,36 +0,0 @@ -================ AUTOMATED PORTAGE INSTALLATION ============================= - -The Makefile in this directory will create a portage overlay for psyclpc and -psyced if necessary, than generate ebuild digests and get you ready for -emerge. All you need to do is type: - - make - -If you tried this previously and ran into trouble, you may have to clean out -the 'psyced' and 'psyclpc' subdirectories from your portage overlay before -doing make, so it starts anew. You can do: - - make new - -================ SHUBBLETROUTING ============================================ - -In all above cases you should be done with installation. If anything goes wrong -get in touch with us on psyc://psyced.org/@welcome so we can fix the problem -not only for you, but for everyone who might run into the same problem. - -If you're in doubt that the generator files aren't the newest, you can update -them by issueing: - - make up - -================ MANUAL INSTALLATION ======================================== - -We have stopped providing regular ebuild files for manual installation -as nobody is maintaining them. Feel free to step in. - -================ WHY STILL LDMUD? =========================================== - -We are just leaving it in as there are no newer releases of ldmud and so -this ebuild is still up to date for anyone who needs an ldmud ebuild. -We may however simplify things later and therefore remove it. - diff --git a/config/gentoo/Makefile b/config/gentoo/Makefile deleted file mode 100644 index 3816f96..0000000 --- a/config/gentoo/Makefile +++ /dev/null @@ -1,92 +0,0 @@ -# $Id: Makefile,v 1.37 2007/08/14 11:28:00 lynx Exp $ - -p=/usr/local/portage -e=/etc/make.conf -G=lynx -source - -# We currently operate on /usr/local/portage but we should add more -# PSYC packages and run our own PSYC overlay... - -install: $p $p/dev-lang/psyclpc $p/net-im/psyced - @echo -- We are done with portage installation. You can now emerge - @echo -- from here or postpone to a better moment in life. - emerge -av psyced - @echo -- Done emerging. Contratulations on your new psyced! -- - -uninstall: new - -new: -# It complains for missing packages, but does no harm. - -emerge --unmerge psyced psyclpc ldmud -# This one complains, too. Should we make it shut up? -# We can make it shut up next time when we do our own PSYC overlay. - -rm -r $p/net-im/psyced $p/dev-lang/psyclpc $p/games-mud/ldmud - -ldmud: $p $p/games-mud/ldmud - @echo -- Warning: You are installing LDMud which is no longer the - @echo -- the best choice as a psyced driver! - emerge -av ldmud - -### NO SERVICEABLE PARTS BELOW ### - -$p: - @echo -- Apparently you have not installed custom ebuilds yet. - mkdir $@ - @echo -- A $@ directory has therefore been generated for you. - echo "" >>$e - echo "# Added by psyced's config/gentoo/Makefile" >>$e -# Does it replace $p correctly in $e? Yes it does. Good. - echo "PORTDIR_OVERLAY=$p" >>$e - @echo -- PORTDIR_OVERLAY has been appended to $e to activate $@. - -$p/dev-lang/psyclpc: psyclpc.ebuild psyclpc/Makefile Makefile - (cd psyclpc;make ebuild) - -mkdir $p/dev-lang - rm -rf $@ - cp -rp psyclpc $@ - -(cd $@;make Manifest) - -$p/games-mud/ldmud: ldmud.ebuild ldmud/Makefile Makefile - (cd ldmud;make ebuild) - -mkdir $p/games-mud - rm -rf $@ - cp -rp ldmud $@ - -(cd $@;make Manifest) - -$p/net-im/psyced: psyced.ebuild psyced/Makefile Makefile - (cd psyced;make ebuild) - -mkdir $p/net-im - rm -rf $@ - cp -rp psyced $@ - -(cd $@;make Manifest) - -# the lower part of the Makefile serves the purpose of -# managing this package itself, not to install something. - -sane: new clean - -clean: - (cd psyced;make $@) - (cd psyclpc;make $@) -# Leave it alone or we won't be able to recreate the erq directory ;) -# (cd ldmud;make $@) - -up: - -rm ldmud/ldmud-*.ebuild psyced/psyced-*.ebuild psyclpc/psyclpc-*.ebuild - -mkdir psyced/files - # If version control updates this Makefile itself, it may be necessary - # to run 'make up' twice as the update requirements may have changed. - git pull - $G http://www.psyced.org/dist/config/psyced.ini >psyced/files/psyced.ini - @(cd psyced;make ebuild) - @(cd psyclpc;make ebuild) -# We could extend the procedure to actually run the ebuild at building time -# so that we get to have the digests in there.. TODO - # Now you may have to unmerge and delete psyclpc and psyced from your - # portage overlay to have them generated anew. - # Use 'make new' to do that. - -oldup: - @(cd ldmud;make ebuild) - $G http://www.psyced.org/dist/config/psyced.settings >ldmud/files/psyced.settings - diff --git a/config/gentoo/ldmud.ebuild b/config/gentoo/ldmud.ebuild deleted file mode 100644 index 8a7c81f..0000000 --- a/config/gentoo/ldmud.ebuild +++ /dev/null @@ -1,104 +0,0 @@ -# Copyright 1999-2006 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: /CVS/muveCVS/psycmuve/config/gentoo/ldmud.ebuild,v 1.17 2007/04/06 13:35:03 lynx Exp $ -# -# In a philosophical way, LDMUD is a game engine, but from an administrative -# aspect it is a major project which doesn't belong into /usr/games. Especially -# not when it is actually serving as a programming language for intense -# multi-user network applications such as psyced. This is why we intentionally -# do not use any "games" macros here. Please keep it that way. -lynX 2006 -# -# Suggestions? tell psyc://psyced.org/~lynX -# -# WARNING/REMINDER to myself: When checking in a new version of this file -# I have to run 'make up' in the gentoo download tar, as it also -# relinks all the ldmud/ldmud-VERSION.ebuild files. - -inherit toolchain-funcs eutils - -DESCRIPTION="LPMUD Driver for Multi-User Domains and LPC language implementation" -HOMEPAGE="http://www.bearnip.com/lars/proj/ldmud.html" - -# using the filename of the ebuild here! -# so better give it numbers which are actually -# available on http://www.bearnip.com/ftp/mud/ -SRC_URI="http://www.bearnip.com/ftp/mud/${P}.tar.gz" - -LICENSE="GPL-2" -SLOT="0" -# haven't checked for real.. -KEYWORDS="x86 ~ppc ~amd64" -IUSE="debug ssl static zlib ldap ipv6 mysql postgres berkdb" - -RDEPEND="zlib? ( sys-libs/zlib ) - ssl? ( dev-libs/openssl ) - ldap? ( net-nds/openldap ) - berkdb? ( sys-libs/db ) - mysql? ( dev-db/mysql ) - postgres? ( dev-db/postgresql )" - -DEPEND="${RDEPEND} - >=sys-devel/flex-2.5.4a-r5 - >=sys-devel/bison-1.875 - >=sys-devel/gettext-0.12.1" - -#MYS="/var/tmp/portage/${P}/work/${P}/src" -MYS="${S}/src" - -src_unpack() { - unpack ${A} - # cd "${S}" - cd "${MYS}" - # without "" or it won't ungrok the *.* -- thx fish - cp ${FILESDIR}/erq/*.* util/erq || die "improved erq not found in ${FILESDIR}" - cp "${FILESDIR}/psyced.settings" settings/psyced-gentoo || die "psyced.settings not found in ${FILESDIR}" - chmod +x settings/psyced-gentoo -} - -src_compile() { - # emake \ - # CC="$(tc-getCC)" \ - # CFLAGS="${CFLAGS}" ${PN} \ - # || die "emake failed" - cd "${MYS}" -# use berkdb >&/dev/null && myopts="${myopts} --enable-db" -# use mysql >&/dev/null && myopts="${myopts} --enable-mysql" || myopts="${myopts} --disable-mysql" -# use postgres >&/dev/null && myopts="${myopts} --enable-pgsql" -# use ldap >&/dev/null && myopts="${myopts} --enable-ldap" -# use ipv6 >&/dev/null && myopts="${myopts} --enable-ipv6" - use zlib && { - einfo "Compiling ${P} with zlib (MCCP) support." - myopts="${myopts} --enable-use-mccp" - } - use ssl && { - einfo "Compiling ${P} with SSL support." - myopts="${myopts} --enable-use-tls=yes" - } - use mysql && { - einfo "Compiling ${P} with mySQL support." - myopts="${myopts} --enable-use-mysql" - } - use postgres && { - einfo "Compiling ${P} with PostgreSQL support." - myopts="${myopts} --enable-use-pgsql" - } - use debug && { - append-flags -O -ggdb -DDEBUG - RESTRICT="${RESTRICT} nostrip" - myopts="${myopts} --enable-debug" - } - # runs configure - echo ${myopts} - settings/psyced-gentoo ${myopts} - make all && (cd "util/" && make subs) || die "make failed" -} - -src_install () { - cd "${MYS}" - dosbin ${PN} && (cd "util/erq/" && dosbin "erq") || die "dosbin failed" - cd "${MYS}/.." - dodoc README HISTORY - # do something about the files in the doc directory? - # everyone looks stuff up on google anyway - # but maybe we should install etc/lpc.vim? -} diff --git a/config/gentoo/ldmud/ChangeLog b/config/gentoo/ldmud/ChangeLog deleted file mode 100644 index 66ae2cb..0000000 --- a/config/gentoo/ldmud/ChangeLog +++ /dev/null @@ -1,13 +0,0 @@ -# ChangeLog for games-mud/ldmud -# $Header: /CVS/muveCVS/psycmuve/config/gentoo/ldmud/ChangeLog,v 1.3 2006/01/17 11:37:31 lynx Exp $ - -*ldmud-3.3.687 (18 Nov 2005) - - 18 Nov 2005; Carlo von lynX +ldmud-3.3.687.ebuild: - initial build for depending 'psyced' project - -*ldmud-3.3.712 (30 Nov 2005) - - 18 Nov 2005; el +ldmud-3.3.712.ebuild: - improved build: allows simple rename of .ebuild files and makes erq - diff --git a/config/gentoo/ldmud/Makefile b/config/gentoo/ldmud/Makefile deleted file mode 100644 index e4c22df..0000000 --- a/config/gentoo/ldmud/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# $Id: Makefile,v 1.16 2007/04/08 08:37:08 lynx Exp $ -# -# This Makefile serves the purpose to produce the files ebuild needs to be -# happy. So it is an ebuildbuilder. Targets are: ebuild, Manifest and clean. -# -# 'make' needs to be called in gentoo/config to generate the ebuilds and files -# directory, then ../Makefile will transfer this to portage where 'make' will -# call ebuild to create digests and the Manifest. After that you are ready to -# emerge. From nothing. fischerspooner rocks. -lynX - -P=ldmud -V=3.3.714 - -# this part can be executed once the ebuild is in portage - -it: Manifest -# # testing it - emerge -av $P - -Manifest: Makefile ChangeLog files/psyced.settings files/erq -# # generate manifest - ebuild $P-$V.ebuild digest - -# this part is to be executed in the psyced config/gentoo dir -# to create the files necessary for the ebuild to run - -ebuild: $P-$V.ebuild files/psyced.settings files/erq - -$P-$V.ebuild: -# # let's keep it this simple, please - -ln ../$P.ebuild $P-$V.ebuild - -# no dependency on ../../psyced.settings here or it won't run in portage -files/psyced.settings: files -# # we keep it elsewhere - -cp ../../psyced.settings $@ - -files/erq: - -mkdir $@ - -cp -p ../../../utility/erq/*.* $@ - -files: - -mkdir files -# we don't want to have each of those in version control, so this is a place too -# echo "MD5 419eb1c21747fe2cd6de8089b47271ff ldmud-3.3.687.tar.bz2 2107415" >files/digest-ldmud-3.3.687 -# echo "MD5 ab0027411928bef96aa41bf316cde954 ldmud-3.3.712.tar.gz 26515635" >files/digest-ldmud-3.3.712 - -clean: - -rm $P-$V.ebuild - -rm -r files - diff --git a/config/gentoo/ldmud/files/erq/Makefile.in b/config/gentoo/ldmud/files/erq/Makefile.in deleted file mode 100644 index c4260b7..0000000 --- a/config/gentoo/ldmud/files/erq/Makefile.in +++ /dev/null @@ -1,68 +0,0 @@ - -# These lines are needed on some machines. -MAKE=make -SHELL=@CONFIG_SHELL@ -INSTALL=@INSTALL@ -mkinstalldirs=$(SHELL) @top_srcdir@/mkinstalldirs -# -CC=@CC@ - -prefix=@prefix@ -exec_prefix=@exec_prefix@ - -SUBDIRS = indent make_docs xerq -SED = sed - -BINDIR=@bindir@ -MUD_LIB=@libdir@ -ERQ_DIR=@libexecdir@ - -#PROFIL= -DOPCPROF -DVERBOSE_OPCPROF -#PROFIL=-p -DMARK -#PROFIL=-pg -PROFIL= -#Enable warnings from the compiler, if wanted. -WARN= # no warning options - will work with all compilers :-) -#WARN= -Wall -Wshadow -Dlint -#WARN= -Wall -Wshadow -Wno-parentheses # gcc settings -# -# Optimization and source level debugging options. -# adding a -fomit-frame-pointer on the NeXT (gcc version 1.93 (68k, MIT syntax)) -# will corrupt the driver. -HIGH_OPTIMIZE = @OCFLAGS@ # high optimization -MED_OPTIMIZE= @MCFLAGS@ # medium optimization -LOW_OPTIMIZE = @LCFLAGS@ # minimal optimization -NO_OPTIMIZE= @DCFLAGS@ # no optimization; for frequent recompilations. - -OPTIMIZE= $(@val_optimize@_OPTIMIZE) - -# The main debugging level is define in config.h -# Add additional options here. -DEBUG= -# -MPATH=-DMUD_LIB='"$(MUD_LIB)"' -DBINDIR='"$(BINDIR)"' -DERQ_DIR='"$(ERQ_DIR)"' -# -TOPINC=-I@top_srcdir@ -# -CFLAGS= @EXTRA_CFLAGS@ $(OPTIMIZE) $(DEBUG) $(WARN) $(MPATH) $(PROFIL) $(TOPINC) -# -LIBS=@ERQ_LIBS@ -lresolv -# -LDFLAGS=@LDFLAGS@ - - - -all: erq@EXEEXT@ - -FORCE: install - -erq@EXEEXT@: erq.c -# $(CC) erq.c -lresolv -o erq@EXEEXT@ - $(CC) $(CFLAGS) $(LDFLAGS) erq.c -o erq@EXEEXT@ $(LIBS) - -install: erq@EXEEXT@ - $(mkinstalldirs) $(BINDIR) - $(INSTALL) erq@EXEEXT@ $(BINDIR)/erq@EXEEXT@ - -clean: - -rm -f *.o erq@EXEEXT@ *~ diff --git a/config/gentoo/ldmud/files/erq/erq.c b/config/gentoo/ldmud/files/erq/erq.c deleted file mode 100644 index 00c57c1..0000000 --- a/config/gentoo/ldmud/files/erq/erq.c +++ /dev/null @@ -1,2612 +0,0 @@ -/*--------------------------------------------------------------------------- - * External Request Daemon - * - *--------------------------------------------------------------------------- - * This is the standard implementation of the forked ERQ daemon. The - * implementation is straightforward and follows what is documented in - * doc/util/erq. - * - * The erq can handle up to MAX_CHILDS (yes, it should be "children") - * concurrent tasks. Simple non-blocking tasks (all the TCP/UDP functions) - * are handled by the master ERQ, the other tasks are loaded off to - * subservers - forked copies of the ERQ. If the driver requests to - * start a program, one of the subservers is selected and forks again - * to run the program; the communication chain is then driver <-> ERQ - * <-> subserver <-> program. If a subserver is finished with its - * task, it is allowed to stay around for a certain idle time CHILD_EXPIRE, - * reducing the number of costly fork() operations when several requests - * follow after each other. - * - * This ERQ implementation uses two type of tickets. - * For programs: - * { int32 child_number } - * For sockets: - * { int32 child_number; int32 rnd; int32 seq; } - * - * TODO: This program could be commented MUCH better, but in comparison - * TODO:: to its original state it's already a big improvement. - * TODO:: And it surely still contains bugs. - *--------------------------------------------------------------------------- - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "machine.h" - -#ifdef HAVE_SYS_TIME_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -#ifdef HAVE_STRING_H -# include -#else -# include -#endif -#ifdef HAVE_BSTRING_H -# include -#endif -#ifdef HAVE_STDLIB_H -# include -#endif -#ifdef HAVE_SYS_TERMIOS_H -# include -#endif -#ifdef _AIX -# include -#endif - -#ifdef WEXITSTATUS -# define wait_status_t int -#else -# define wait_status_t union wait -# define WEXITSTATUS(status) ((status).w_retcode) -# define WTERMSIG(status) ((status).w_termsig) -#endif - -#ifdef sun -time_t time(time_t *); -#endif - -#ifndef SIGCLD -# define SIGCLD SIGCHLD -#endif -#ifndef SIGKILL -# define SIGKILL 9 -#endif -#ifndef SIGTERM -# define SIGTERM 15 -#endif - -#ifdef _AIX -typedef unsigned long length_t; /* *sigh* */ -#else -typedef int length_t; -#endif - -#define AUTH_PORT 113 /* according to RFC 931 */ - -#include "config.h" - -#ifdef USE_IPV6 -# define __IPV6__ -#endif - -#include "erq.h" -#include "srv.c" - -#define randomize_tickets(n) srandom(n) -#define get_ticket() random() - -#ifndef ERQ_DEBUG -# define ERQ_DEBUG 0 -#endif - -/*-------------------------------------------------------------------------*/ - -/* #define DETACH */ - /* Define this for automatic detach from console. - */ - -#define MAX_CHILDS 36 - /* Maximum number of children. - */ - -#define TIME_TO_CHECK_CHILDS 900 - /* Delaytime for select() if no TCP children have data to send to - * the driver. - */ - -#define CHILD_EXPIRE 900 - /* Maximum idle time before a child is killed. - */ - -#define ERQ_BUFSIZE 1024 - /* Size of the data buffer. - */ - -#define MAX_REPLY ERQ_MAX_REPLY - - -#if MAX_REPLY >= ERQ_BUFSIZE -# undef MAX_REPLY -# define MAX_REPLY (ERQ_BUFSIZE - 1) -#endif - -/*-------------------------------------------------------------------------*/ - -typedef struct child_s child_t; - -/* --- ticket: one ticket for a TCP connection --- - * - * The actual ticket is composed of the .rnd and .seq - * field - the union with c[] helps in memcpy()s. - */ - -union ticket_u -{ - struct ticket_s - { - long rnd, seq; - } s; - char c[1]; -}; - -/* --- struct child_s: one child --- - * - * This structure is used to describe one child. - */ - -struct child_s -{ - int socket; /* Socket this child holds */ - - union /* Child specific information */ - { - struct /* Subserver child */ - { - pid_t pid; /* pid of the subserver */ - time_t last_used; /* time of the last use */ - } c; - - struct /* Communication child */ - { - char handle[4]; - /* The handle assigned by the driver */ - union ticket_u ticket; - time_t last_recv; - /* Time of the last received transmission */ - int bytes_recv; - /* Number of bytes left to send to the driver */ - } s; - } u; - - int state; -# define CHILD_FREE 0 /* Idle subserver */ -# define CHILD_LISTEN 1 -# define CHILD_BUSY 2 /* Active subserver */ -# define CHILD_UDP 3 /* UDP socket child */ -# define CHILD_TCP 4 /* TCP socket child */ -# define CHILD_ACCEPT 5 /* TCP port waiting for connections */ - - child_t *next_free; /* Next child in free list */ - child_t *next_all; /* Next child in its list */ -}; - -/*-------------------------------------------------------------------------*/ - -static child_t childs[MAX_CHILDS] = {{0}}; - /* Table of all children created so far. - */ - -static int next_child_index = 0; - /* Next index in childs[] to use. - */ - -static child_t *all_childs = NULL; - /* List of all children connected to active subservers. - */ - -static child_t *free_childs = NULL; - /* List of all children connected to idle subservers. - */ - -static child_t *udp_sockets = NULL; - /* List of children with an open UDP socket. - */ - -static child_t *tcp_sockets = NULL; - /* List of children with an open TCP connection. - */ - -static child_t *accept_sockets = NULL; - /* List of children waiting for TCP connections. - */ - -static child_t *child_slots = NULL; - /* List of unused children. - */ - -static int childs_waited_for = 0; - /* Number of children which termination has been acknowledged by wait(). - * If waitpid() is not available, this value is compared with - * childs_terminated to see if there are zombies to be waited for. - */ - -static volatile int childs_terminated = 0; - /* Count of terminated children, maintained by SIGCLD. - */ - -static fd_set current_fds, readfds; - /* Master 'read' fdset and the copy for select(). - */ - -static fd_set current_fds2, writefds; - /* Master 'write' fdset and the copy for select(). - */ - -static int nfds = 2; - /* Number of opened fds for select(). - */ - -static time_t current_time; - /* The current time() after select() returns. - */ - -static char buf[ERQ_BUFSIZE]; - /* The receive buffer. - */ - -static const char * erq_dir = ERQ_DIR; - /* The filename of the directory with the ERQ executables. */ - -/*-------------------------------------------------------------------------*/ -/* Forward declarations */ - -static void start_subserver (long server_num, long seed); - -/*-------------------------------------------------------------------------*/ -static char * -time_stamp (void) - -/* Return a textual representation of the current time - * in the form "YYYY.MM.DD HH:MM:SS [xerq]". - * Result is a pointer to a static buffer. - * - * Putting this function in strfuns is not a good idea, because - * it is need by almost every module anyway. - */ - -{ - time_t t; - static char result[27]; - struct tm *tm; - - t = time(NULL); - tm = localtime(&t); - strftime(result, sizeof(result), "%Y.%m.%d %H:%M:%S [erq]", tm); - return result; -} /* time_stamp() */ - -/*-------------------------------------------------------------------------*/ -static long -get_seed(void) - -/* Return a seed for the random generator. - */ - -{ -#ifdef HAVE_GETTIMEOFDAY - - struct timeval tv; struct timezone tz; - - gettimeofday(&tv, &tz); - return tv.tv_sec * 1000000L + tv.tv_usec; - -#else - - /* SunOS crashes on times(0), and times returns 0/-1 */ - - ret = (long)times(&dummy_tms); - if (!ret) - ret = (long)time((time_t *)0) + - dummy_tms.tms_utime - dummy_tms.tms_stime + - dummy_tms.tms_cutime + - dummy_tms.tms_cstime; - return ret; - -#endif -} /* get_seed() */ - -/*-------------------------------------------------------------------------*/ -static long -read_32 (char *str) - -/* Extract an int32 from the data stream at and return it. - * TODO: Put functions like this, and complete msg-functions into - * TODO:: an erqlib.c module. - */ - -{ - unsigned char *p = (unsigned char *)str; - return (long)p[0]<<24 | (long)p[1]<<16 | (long)p[2]<<8 | p[3]; -} /* read_32() */ - -/*-------------------------------------------------------------------------*/ -static void -write_32 (char *str, long n) - -/* Store the int32 into the data stream at . - */ - -{ - *(str+=3) = n; - *--str = n >>= 8; - *--str = n >>= 8; - *--str = n >>= 8; -} /* write_32() */ - -/*-------------------------------------------------------------------------*/ -static long -readn (int s, void *buf, long expected) - -/* Read at least bytes from fd into . - * Return the number of bytes actually read; 0 for EOF and -1 on error. - */ - -{ - long num, total = 0; - char * pbuf; - - pbuf = (char *)buf; - do { - do - num = read(s, pbuf+total, expected-total); - while (num == -1 && errno == EINTR); - - if (num <= 0) - { - if (!num) - { - fprintf(stderr, "%s read: EOF\n", time_stamp()); - return 0; - } - else - { - perror("read"); - return -1; - } - } - total += num; -#if ERQ_DEBUG > 0 - if (total < expected) - fprintf(stderr, "%s read fragment %ld\n", time_stamp(), num); -#endif - } while (num > 0 && total < expected); - - return total; -} /* readn() */ - -/*-------------------------------------------------------------------------*/ -static void -writen (int n, void *message, long length) - -/* Write the of bytes onto fd . - */ - -{ - long num; - - do - num = write(n, message, length); - while (num == -1 && errno == EINTR); - - if (num != length) - { - fprintf(stderr, "%s wrote %ld, should be %ld\n" - , time_stamp(), num, length); - fprintf(stderr, "%s Giving up.\n", time_stamp()); - abort(); - } -} /* writen() */ - -/*-------------------------------------------------------------------------*/ -static void -write1 (void *message, long length) - -/* Write the of bytes onto stdout, ie to the gamedriver. - */ - -{ - writen(1, message, length); -} /* write1() */ - -/*-------------------------------------------------------------------------*/ -static int -execute (char *buf, long buflen, char *status, int *sockets) - -/* exec() the command (length ), store the ERQ_-success code - * into and return the pid (0 on failure). - * If is non-NULL, it points to an int[4] into which two - * socketpairs are generated. - */ - -{ - char path[256], argbuf[1024], *p, *args[96], **argp, c; - pid_t pid; - int quoted; - - quoted = 0; - status[0] = ERQ_E_FORKFAIL; /* Good default */ - status[1] = 0; - - if (buflen >= sizeof argbuf) - { - status[0] = ERQ_E_ARGLENGTH; - return 0; - } - - argp = &args[0]; - *argp++ = p = argbuf; - while (--buflen >= 0) - { - c = *buf++; - if (c == '\\') - { - if (--buflen >= 0) - { - *p++ = *buf++; - } - else - { - status[0] = ERQ_E_ARGFORMAT; - return 0; - } - } - else if (c == '"') - { - quoted = !quoted; - } - else if (isgraph(c) || quoted) - { - *p++ = c; - } - else - { - *p++ = '\0'; - *argp++ = p; - if (argp == &args[sizeof args/sizeof args[0]]) - { - status[0] = ERQ_E_ARGNUMBER; - return 0; - } - while( ( (c = *buf) == ' ' || c == '\t') && --buflen >= 0) - buf++; - } - } - - *p++ = '\0'; - *argp++ = 0; - p = args[0]; - if (p[0] == '/' || strstr(p, "..")) - { - status[0] = ERQ_E_ILLEGAL; - return 0; - } - - if (strlen(erq_dir) + strlen(p) + 2 > sizeof(path)) - { - status[0] = ERQ_E_PATHLEN; - return 0; - } - - sprintf(path, "%s/%s", erq_dir, p); - if (sockets) - { - if(socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) < 0) - { - perror("socketpair"); - status[0] = ERQ_E_FORKFAIL; - status[1] = errno; - return 0; - } - if(socketpair(AF_UNIX, SOCK_STREAM, 0, sockets + 2) < 0) - { - perror("socketpair"); - close(sockets[0]); - close(sockets[1]); - status[0] = ERQ_E_FORKFAIL; - status[1] = errno; - return 0; - } - } - - pid = fork(); - if (!pid) - { - close(0); - close(1); - if (sockets) - { - dup2(sockets[0], 0); - dup2(sockets[0], 1); - dup2(sockets[2], 2); - close(sockets[0]); - close(sockets[1]); - close(sockets[2]); - close(sockets[3]); - } - execv(path, args); - _exit(1); - } - - if (sockets) - { - close(sockets[0]); - close(sockets[2]); - } - - if (pid < 0) - { - if (sockets) - { - close(sockets[1]); - close(sockets[3]); - } - status[0] = ERQ_E_FORKFAIL; - status[1] = errno; - return 0; - } - - return pid; -} /* execute() */ - -/*-------------------------------------------------------------------------*/ -static void -count_sigcld (int sig) - -/* SIGCLD handler, which is called whenever a child process terminates. - * The function takes care to handle multiple SIGCLD occuring at - * the same time - the tricky point is to setup the the next signal(SIGCLD,...) - * after the last pending SIGCLD has been resolved. - */ - -{ -#ifdef __MWERKS__ -# pragma unused(sig) -#endif - -#ifndef HAVE_WAITPID - static volatile int calling_signal = 0; /* Mutex */ - static volatile int call_signal_again = 0; /* Number of pending calls */ - - if (!calling_signal) - { - calling_signal = 1; - (void)signal(SIGCLD, (RETSIGTYPE(*)())count_sigcld); - while (call_signal_again) - { - --call_signal_again; - (void)signal(SIGCLD, (RETSIGTYPE(*)())count_sigcld); - } - calling_signal = 0; - } - else - { - call_signal_again++; - } -#if ERQ_DEBUG > 0 - write(2, "child terminated\n", 17); -#endif - childs_terminated++; -#endif -} /* count_sigcld() */ - -/*-------------------------------------------------------------------------*/ -static void -dispose_child (child_t *child) - -/* The subserver is dead and to be cleant up. - */ - -{ - struct child_s **chp; - - /* Remove it from the fdsets */ - FD_CLR(child->socket, ¤t_fds); - FD_CLR(child->socket, ¤t_fds2); - close(child->socket); - - /* Remove it from the free list */ - if (child->state == CHILD_FREE) - { - for (chp = &free_childs; *chp != child; chp = &(*chp)->next_free) /* NOOP */; - *chp = child->next_free; - } - - child->state = CHILD_FREE; - - /* Remove it from the all list */ - for (chp = &all_childs; *chp != child; chp = &(*chp)->next_all) /* NOOP */; - *chp = child->next_all; - - /* Put it into the list of unused children */ - child->next_all = child_slots; - child_slots = child; -} /* dispose_child() */ - -/*-------------------------------------------------------------------------*/ -static void -kill_child (child_t *child) - -/* Kill the subserver child . - */ - -{ -#if ERQ_DEBUG > 0 - fprintf(stderr, "%s kill_child called\n", time_stamp()); -#endif - kill(child->u.c.pid, SIGKILL); - dispose_child(child); -} /* kill_child() */ - -/*-------------------------------------------------------------------------*/ -static int -free_socket_childs (void) - -/* Is there a child available? - */ - -{ - return !(!child_slots && next_child_index >= MAX_CHILDS); -} /* free_socket_childs() */ - -/*-------------------------------------------------------------------------*/ -static child_t * -get_socket_child(void) - -/* Get a new socket child - if possible, reuse an earlier child. - */ - -{ - struct child_s *child; - - if ( !(child = child_slots) ) - { - child = &childs[next_child_index++]; - } - else - { - child_slots = child->next_all; - } - - return child; -} /* get_socket_child() */ - -/*-------------------------------------------------------------------------*/ -static void -free_socket_child (child_t *child, child_t **listp) - -/* The socket in list is no longer used - remove it - * from the list and make it available again. - */ - -{ - while (*listp != child) - listp = &(*listp)->next_all; - *listp = child->next_all; - child->next_all = child_slots; - child->state = CHILD_FREE; - child_slots = child; -} /* free_socket_child() */ - -/*-------------------------------------------------------------------------*/ -static int -get_subserver (void) - -/* Start a new subserver, resp. reactivate an idle one, and return - * its socket. - */ - -{ - struct child_s *child; - -#if ERQ_DEBUG > 0 - fprintf(stderr, "%s get_subserver called\n", time_stamp()); -#endif - - if (free_childs) - { - /* There is an idle one we can use */ - - child = free_childs; - free_childs = child->next_free; - } - else - { - /* We have to start a new subserver */ - - int sockets[2]; - int pid; - - if (!free_socket_childs()) - return -1; - - if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) < 0) - { - int err = errno; - fprintf(stderr, "%s Error in socketpair()", time_stamp()); - errno = err; - perror("socketpair"); - return -1; - } - - pid = fork(); - if(pid == -1) - { - close(sockets[0]); - close(sockets[1]); - return -1; - } - - child = get_socket_child(); - if (!pid) - { - /* This is the child process */ - - dup2(sockets[0], 0); /* Read and write on the same socket */ - dup2(sockets[0], 1); - close(sockets[0]); - close(sockets[1]); - start_subserver(child - &childs[0], (long)get_ticket()); - /* NOTREACHED */ - } - - /* Set up the child and put it into the subserver list */ - - close(sockets[0]); - child->u.c.pid = pid; - child->socket = sockets[1]; - FD_SET(child->socket, ¤t_fds); - if (child->socket >= nfds) - nfds = child->socket + 1; - - child->next_all = all_childs; - all_childs = child; - } - - child->state = CHILD_BUSY; - return child->socket; -} /* get_subserver() */ - -/*-------------------------------------------------------------------------*/ -static void -start_subserver (long server_num, long seed) - -/* We are ERQ subserver number and shall use for our ticket. - * The ERQ main process forks us off to do some time-expensive things - * (like looking up hostnames). If we are idle too long, we will be killed - * off again. Communication to the main process is through stdin/stdout. - */ - -{ - union ticket_u ticket; - char header[16]; - long num, msglen; - int request; - pid_t child = 0; - int child_sockets[4]; - char child_handle[4]; - -#if defined(DETACH) && defined(TIOCNOTTY) - /* Detach from console */ - - num = open("/dev/tty", O_RDWR); - if (num >= 0) - { - /* We supply header as a 'dummy' argument in case typing is - * too strict - */ - ioctl(num, TIOCNOTTY, header); - close(num); - } -#endif - randomize_tickets(seed ^ get_seed()); - FD_ZERO(&readfds); - FD_ZERO(&writefds); - nfds = 1; - childs_terminated = 0; - childs_waited_for = 0; - - /* possible race conditions make switching the signal handler awkward */ - (void)signal(SIGCLD, (RETSIGTYPE(*)())count_sigcld); - - for (;;) /* The Loop (tm) */ - { - /* select() for data */ - - if (child) - { - FD_SET(child_sockets[1], &readfds); - FD_SET(child_sockets[3], &readfds); - } - FD_SET(0, &readfds); - num = select(nfds, &readfds, 0, 0, 0); - if (num < 0) - { - if (errno == EINTR) - continue; - perror ("select"); - abort (); - } - - /* Look for data from our child. - * We do this before we wait for a died child to make sure that - * all the data produced by the child is received by us. - */ - - if (child) - { - int n = 3; - do { - if (FD_ISSET(child_sockets[n], &readfds)) - { - do - num = read(child_sockets[n], buf+14, MAX_REPLY - 13); - while (num == -1 && errno == EINTR); - - if (num <= 0) - { - perror("read from spawned child\n"); - } - else - { -#if ERQ_DEBUG > 0 - fprintf(stderr, - "%s %d bytes from socket no. %d\n", time_stamp(), num, n); - fprintf(stderr, - "%s '%.*s'\n", time_stamp(), num, buf+14); -#endif - write_32(buf, (num += 14) - 1); - write_32(buf+4, ERQ_HANDLE_KEEP_HANDLE); - buf[8] = CHILD_LISTEN; - memcpy(buf+9, child_handle, 4); - buf[13] = n == 1 ? ERQ_STDOUT : ERQ_STDERR; - write1(buf, num); - } - } - } while ((n-=2) > 0); - } - - /* Check for zombie children and wait for them */ - -#ifdef HAVE_WAITPID - while(1) { -#else - while (childs_terminated != childs_waited_for) { -#endif - wait_status_t status; - pid_t pid; - - do { -#ifdef HAVE_WAITPID - pid = waitpid(-1, &status, WNOHANG); -#else - pid = wait(&status); -#endif -#ifdef ERESTARTSYS - if (pid < 0 && errno == ERESTARTSYS) - continue; -#endif - } while (0); - -#ifdef HAVE_WAITPID - if (pid <= 0) - break; -#else - if (pid <= 0) - { - fprintf(stderr, - "%s SIGCLD handler %d times called, but wait not sucessful\n", - time_stamp(), childs_terminated - childs_waited_for - ); - abort(); - } -#endif - if (pid == child) - { - /* Our child terminated - prepare the header for the reply. - */ - header[8] = CHILD_FREE; - if (WIFEXITED(status)) - { - header[9] = ERQ_EXITED; - header[10] = WEXITSTATUS(status); - } - else if (WIFSIGNALED(status)) - { - header[9] = ERQ_SIGNALED; - header[10] = WTERMSIG(status); - } - else - { - header[9] = ERQ_E_UNKNOWN; - header[10] = 0; - } - child = 0; - close(child_sockets[1]); - close(child_sockets[3]); - FD_CLR(child_sockets[1], &readfds); - FD_CLR(child_sockets[3], &readfds); - write_32(header, 10); - memcpy(header+4, child_handle, 4); - write1(header, 11); /* releases handle */ - } - childs_waited_for++; - } /* wait for zombies */ - - if (!FD_ISSET(0, &readfds)) - continue; - - /* Receive the new request from the master ERQ */ - - do - num = readn(0, header, 9); - while (num == -1 && errno == EINTR); - - if (num != 9) - { - fprintf(stderr, "%s read %ld, should be 9!\n", time_stamp(), num); - if (num < 0) - perror("read"); - break; - } - - msglen = read_32(header) - 9; - request = header[8]; - - /* ... and the rest of the data */ - - if (msglen > 0) - { - if (msglen > sizeof(buf)) - { - /* Prevent a buffer overflow */ - fprintf(stderr, "%s ERROR: Read %ld > buffer size %ld\n", time_stamp(), msglen, sizeof(buf)); - num = readn(0, buf, sizeof(buf)); - - /* Discard the rest of the input from the channel */ - msglen -= num; - while (msglen > 0) - { - char tmp[256]; - num = readn(0, tmp, sizeof(tmp)); - msglen -= num; - } - - msglen = sizeof(buf); /* Pretent this was all */ - } - else - { - num = readn(0, buf, msglen); - if (num != msglen) { - fprintf(stderr, "%s Read %ld, should be %ld\n", time_stamp(), num, msglen); - break; - } - } - } - - /* What does the ERQ want? */ - - switch(request) - { - case ERQ_RLOOKUP: - { - /* Lookup ip -> name */ - - struct hostent *hp; - - /* handle stays in header[4..7] */ - header[8] = CHILD_FREE; - memcpy(header+9, buf, 4); /* copy address */ - hp = gethostbyaddr(buf, 4, AF_INET); - if (!hp && h_errno == TRY_AGAIN) - { - /* DNS needs a bit more time */ - sleep(3); - hp = gethostbyaddr(buf, 4, AF_INET); - } - if (!hp && h_errno == TRY_AGAIN) - { - /* DNS needs a even more time */ - sleep(7); - hp = gethostbyaddr(buf, 4, AF_INET); - } - - if (hp) - { - /* Send the address and the name */ - msglen = strlen(hp->h_name) + 1; - write_32(header, msglen + 12); - write1(header, 13); - write1((void*)hp->h_name, msglen); - } - else - { - /* No answer, send just the address */ - write_32(header, 12); - write1(header, 13); - } - break; - } - -#ifdef ERQ_LOOKUP - case ERQ_LOOKUP: - { - /* Lookup name -> ip */ - - struct hostent *hp; - - /* handle stays in header[4..7] */ - header[8] = CHILD_FREE; - memcpy(header+9, buf, msglen); /* copy address */ - buf[msglen] = '\0'; /* Make sure the string is terminated */ -#if ERQ_DEBUG > 3 - fprintf(stderr, "%s: ERQ_LOOKUP '%s'\n", time_stamp(), buf); -#endif - hp = gethostbyname(buf); - if (!hp && h_errno == TRY_AGAIN) - { -#if ERQ_DEBUG > 2 - fprintf(stderr, "%s: ERQ_LOOKUP '%s': trying again in 3 sec.\n", time_stamp(), buf); -#endif - /* DNS needs more time */ - sleep(3); - hp = gethostbyname(buf); - } - if (!hp && h_errno == TRY_AGAIN) - { -#if ERQ_DEBUG > 2 - fprintf(stderr, "%s: ERQ_LOOKUP '%s': trying again in 7 sec.\n", time_stamp(), buf); -#endif - /* DNS needs even more time */ - sleep(7); - hp = gethostbyname(buf); - } - if (hp) - { -#if ERQ_DEBUG > 3 - fprintf(stderr, "%s: ERQ_LOOKUP '%s' -> %d.%d.%d.%d\n" - , time_stamp(), buf - , hp->h_addr[0] & 255 - , hp->h_addr[1] & 255 - , hp->h_addr[2] & 255 - , hp->h_addr[3] & 255 - ); -#endif - /* Send the name and the address */ - msglen = 4; - write_32(header, msglen + 8); - write1(header, 9); - write1(hp->h_addr, msglen); - } - else - { - /* No answer, send an empty message */ - write_32(header, 8); - write1(header, 9); - } - break; - } -#endif - -#ifdef ERQ_RLOOKUPV6 - case ERQ_RLOOKUPV6: - { - int i; - char *mbuff; - struct addrinfo req, *ai, *ai2; - - /* handle stays in header[4..7] */ - header[8] = CHILD_FREE; - buf[msglen] = 0; - - memset(&req, 0, sizeof(struct addrinfo)); - req.ai_family = AF_INET6; - req.ai_flags = AI_CANONNAME; - - i = getaddrinfo(buf, NULL, &req, &ai); - - if (!i) - for (ai2 = ai - ; ai2 && (ai2->ai_family != AF_INET) - && (ai2->ai_family != AF_INET6) - ; ai2 = ai2->ai_next) /* NOOP */; - - if (!i && ai2 &&ai2->ai_canonname) - { - mbuff = malloc(strlen(ai2->ai_canonname)+strlen(buf)+2); - if (!mbuff) - { - perror("malloc"); - exit(errno); - } - strcpy(mbuff, buf); - strcat(mbuff, " "); - strcat(mbuff, ai2->ai_canonname); - msglen = strlen(mbuff) + 1; - } - else - { - mbuff = malloc(strlen("invalid-format")+strlen(buf)+1); - if (!mbuff) - { - perror("malloc"); - exit(errno); - } - strcpy(mbuff, "invalid-format"); - msglen = strlen(mbuff) + 1; - } - - write_32(header, msglen + 8); - write1(header, 9); - write1(mbuff, msglen); - free(mbuff); - if (!i) - freeaddrinfo(ai); - break; - } -#endif /* ERQ_RLOOKUPV6 */ -#ifdef ERQ_LOOKUP_SRV - case ERQ_LOOKUP_SRV: - { - /* lookup list of srv records */ - struct srvhost * r; - struct srvhost * s; - char service[50], proto[20], hostname[200]; - int counter; - char srvbuf[MAX_REPLY]; - - header[8] = CHILD_FREE; - counter = 0; - srvbuf[0] = '\0'; - // TODO: sscanf this from req string - // format: .. - // example: _psyc._tcp.ve.symlynX.com - // getsrv(hostname, service, proto) - memcpy(header + 9, buf, msglen); - buf[msglen] = '\0'; - sscanf(buf, "%49[^.].%19[^.].%199s", service, proto, hostname); -#if ERQ_DEBUG > 0 - fprintf(stderr, "%s: ERQ_LOOKUP_SRV '%s', %s,%s,%s\n", time_stamp(), buf, service, proto, hostname); -#endif - r = getsrv(hostname, service, proto); - if (!r) { - /* lookup failed, send empty message*/ - write_32(header, 8); - write1(header, 9); -#if ERQ_DEBUG > 0 - fprintf(stderr, "%s: ERQ_LOOKUP_SRV could not srv_resolve '%s'\n", time_stamp(), buf); -#endif - break; - } else { - s = r; - while (s) { - /* walk list of structures */ - /* important members: name, port, pref, weight */ - if (strlen(srvbuf) < MAX_REPLY - 1) { - strncat(srvbuf, s -> name, MAX_REPLY - strlen(srvbuf)); - strncat(srvbuf, "\n", MAX_REPLY - strlen(srvbuf)); - - - if (strlen(srvbuf) < MAX_REPLY - 1) { - snprintf(hostname, MAX_REPLY - 1, "%d%c", s -> port, '\n'); - strncat(srvbuf, hostname, MAX_REPLY - strlen(srvbuf)); - - if (strlen(srvbuf) < MAX_REPLY - 1) { - snprintf(hostname, MAX_REPLY - 1, "%d%c", s -> pref, '\n'); - strncat(srvbuf, hostname, MAX_REPLY - strlen(srvbuf)); - if (strlen(srvbuf) < MAX_REPLY - 1) { - snprintf(hostname, MAX_REPLY - 1, "%d%c", s -> weight, '\n'); - strncat(srvbuf, hostname, MAX_REPLY - strlen(srvbuf)); - } else s = NULL; - } else s = NULL; - } else s = NULL; - } else s = NULL; - - s = s -> next; - counter++; - } - freesrvhost(r); - } - write_32(header, strlen(srvbuf) + 9); - write1(header, 9); - write1(srvbuf, strlen(srvbuf) + 1); - - break; - } -#endif /* ERQ_LOOKUP_SRV */ - case ERQ_EXECUTE: - { - /* Execute a program, wait for its termination and - * return the exit status. - */ - - pid_t pid1, pid2; - - header[8] = CHILD_FREE; - if ((pid1 = execute(buf, msglen, &header[9], 0))) - { - wait_status_t status; - - do { - pid2 = wait(&status); -#ifdef ERESTARTSYS - if (pid2 < 0 && errno == ERESTARTSYS) - continue; -#endif - if (pid2 > 0) - childs_waited_for++; - } while (pid2 >= 1 && pid2 != pid1); - - if (pid2 < 1) { - header[9] = ERQ_E_NOTFOUND; - } else if (WIFEXITED(status)) { - header[9] = ERQ_OK; - header[10] = WEXITSTATUS(status); - } else if (WIFSIGNALED(status)) { - header[9] = ERQ_SIGNALED; - header[10] = WTERMSIG(status); - } else { - header[9] = ERQ_E_UNKNOWN; - } - } - write_32(header, 10); - write1(header, 11); - break; - } - - case ERQ_FORK: - /* Fork off a process and let it run */ - - header[8] = CHILD_FREE; - if (execute(buf, msglen, &header[9], 0)) { - header[9] = ERQ_OK; - } - write_32(header, 10); - write1(header, 11); - break; - - case ERQ_SPAWN: - - /* Similar to ERQ_FORK, but we send back additional - * information to the ERQ so that further communcation - * is possible. - */ - -#if ERQ_DEBUG > 0 - if (child) { - fprintf(stderr, "%s ERQ_SPAWN: busy\n", time_stamp()); - abort(); - } -#endif - - if ((child = execute(buf, msglen, &header[9], child_sockets))) - { - /* We want to avoid race conditions when a stale ticket - * accesses a fresh process (in the unlikely event that - * the rnd part is equal). The below formula ensures that - * more than 71 minutes pass before a stale ticket can - * refer to a new process (assuming gettimeofday get_seed()) - * It also makes ticket guessing harder. - */ - ticket.s.seq += ((get_seed() - ticket.s.seq) & 0x7fffffff) + 1; - ticket.s.rnd = get_ticket(); - if (child_sockets[1] >= nfds) - nfds = child_sockets[1] + 1; - if (child_sockets[3] >= nfds) - nfds = child_sockets[3] + 1; - memcpy(child_handle, header+4, 4); - write_32(buf, 17 + sizeof ticket); - write_32(buf+4, ERQ_HANDLE_KEEP_HANDLE); - buf[8] = CHILD_LISTEN; - memcpy(buf+9, header+4, 4); - buf[13] = ERQ_OK; - write_32(buf+14, server_num); - memcpy(buf+18, ticket.c, sizeof ticket); - write1(buf, 18 + sizeof ticket); - } - else - { - header[8] = CHILD_FREE; - write_32(header, 10); - write1(header, 11); - } - break; - - case ERQ_SEND: - /* Send some data to our child process */ - - if (msglen < sizeof ticket + 1) - goto bad_request; - if (!child) - goto no_child; - - header[8] = CHILD_LISTEN; - if (memcmp(buf, ticket.c, sizeof ticket)) - goto bad_ticket; - - msglen -= sizeof ticket; - do - num = write(child_sockets[1], buf + sizeof ticket, msglen); - while (num == -1 && errno == EINTR); - - if (num == msglen) { - header[9] = ERQ_OK; - write_32(header, 9); - write1(header, 10); - } else { - if (num >= 0) { - header[9] = ERQ_E_INCOMPLETE; - write_32(header+10, num); - } else { - write_32(header+10, errno); - if (0 -#ifdef EAGAIN - || errno == EAGAIN -#endif -#ifdef EWOULDBLOCK - || errno == EWOULDBLOCK -#endif - ) - { - header[9] = ERQ_E_WOULDBLOCK; - } else if (errno == EPIPE) { - header[9] = ERQ_E_PIPE; - } else { - header[9] = ERQ_E_UNKNOWN; - } - } - write_32(header, 13); - write1(header, 14); - } - break; - - case ERQ_KILL: - - /* Send the child a signal */ - - if (msglen != sizeof ticket + 4 && msglen != sizeof ticket) - goto bad_request; - if (!child) { -no_child: - /* could happen due to a race condition */ -#if ERQ_DEBUG > 0 - fprintf(stderr, "%s ERQ_SEND/ERQ_KILL: No child\n", time_stamp()); -#endif - header[8] = CHILD_FREE; - goto notify_bad_ticket; - } - - header[8] = CHILD_LISTEN; - if (memcmp(buf, ticket.c, sizeof ticket)) { -bad_ticket: -#if ERQ_DEBUG > 0 - fprintf(stderr, "%s ticket.s.rnd: %x vs. %x\n", - time_stamp(), ((struct ticket_s *)buf)->rnd, ticket.s.rnd); - fprintf(stderr, "%s ticket.s.seq: %x vs. %x\n", - time_stamp(), ((struct ticket_s *)buf)->seq, ticket.s.seq); -#endif -notify_bad_ticket: - header[9] = ERQ_E_TICKET; - } else { - int sig; - - sig = msglen >= 4 ? read_32(buf+sizeof ticket) : SIGKILL; -#if ERQ_DEBUG > 0 - fprintf(stderr, "%s len: %d sig: %d\n", time_stamp(), msglen, sig); -#endif - if (sig >= 0) - sig = kill(child, sig); - header[9] = sig < 0 ? ERQ_E_ILLEGAL : ERQ_OK; -#if ERQ_DEBUG > 0 - if (sig < 0) - perror("kill"); -#endif - } - write_32(header, 9); - write1(header, 10); - break; - -#ifdef ERQ_AUTH - case ERQ_AUTH: - { - /* Connect to the authd on the remote system, and send - * its answer back the the master ERQ resp. the driver. - */ - struct sockaddr_in server_addr, *remote; - int s; - long mud_port; - long num, total; - - if (msglen != sizeof (struct sockaddr_in) + 4) - goto bad_request; - header[8] = CHILD_FREE; - - remote = (struct sockaddr_in *)buf; - server_addr.sin_family = remote->sin_family; - server_addr.sin_port = htons(AUTH_PORT); - server_addr.sin_addr = remote->sin_addr; - s = socket(remote->sin_family, SOCK_STREAM, 0); - if (s < 0) { - perror("socket"); - goto die; - } - if ( - connect(s, (struct sockaddr *)&server_addr, sizeof server_addr) - < 0) - { - perror("connect"); - write_32(header, 8); - write1(header, 9); - break; - } - mud_port = read_32(buf + msglen - 4); - sprintf(buf, "%d,%ld\r\n", ntohs(remote->sin_port), mud_port); - writen(s, buf, strlen(buf)); - total = 0; - do { - do { - num = read(s, buf+total, MAX_REPLY - 8 - total); - } while (num == -1 && errno == EINTR); - if (num <= 0) { - if (buf[total-2] == '\r' && buf[total-1] == '\n') - break; - perror("read (auth)"); - goto die; - } - total += num; - } while (num > 0 && total < sizeof buf); - close(s); - write_32(header, 8 + total); - write1(header, 9); - write1(buf, total); - break; - } -#endif /* ERQ_AUTH */ - default: -bad_request: - fprintf(stderr, "%s Bad request %d\n", time_stamp(), request); - fprintf(stderr, "%s %x %x %x %x %x %x %x %x %x\n" - , time_stamp() - , header[0],header[1],header[2],header[3] - ,header[4],header[5],header[6],header[7] - ,header[8]); - fprintf(stderr, "%s %c %c %c %c %c %c %c %c %c\n" - , time_stamp() - , header[0],header[1],header[2],header[3] - ,header[4],header[5],header[6],header[7] - ,header[8]); - write_32(header, 8); - header[8] = child ? CHILD_LISTEN : CHILD_FREE; - write1(header, 9); - break; - } - } /* for(;;) */ - -die: - /* We terminate - and also the child if there is one */ - - if (child) - { - if (kill(child, SIGTERM)) - perror("kill"); - sleep(1); - kill(child, SIGKILL); - /* make an attempt to release the handle, but without error - * checking, because things are likely to be screwed up. - */ - write_32(header, 10); - memcpy(header+4, child_handle, 4); - header[9] = ERQ_E_UNKNOWN; - header[10] = 0; - write(1, header, 11); /* releases handle */ - } - - fprintf(stderr, "%s Subserver giving up.\n", time_stamp()); - exit(1); -} /* start_subserver() */ - -/*-------------------------------------------------------------------------*/ -int -main (int argc, char **argv) - -/* Main program of the ERQ. It contains the main loop waiting for requests. - */ - -{ - char header[32]; - long num; - long msglen; - int subserver; - int s; - int num_ready; - struct timeval timeout; - child_t *child, *next_child; - union ticket_u ticket; - - /* Print information about this daemon to help debugging */ - { - fprintf(stderr, "%s Amylaar ERQ %s: Path '%s', debuglevel %d\n" - , time_stamp(), __DATE__, argv[0], ERQ_DEBUG - ); - } - - /* Quick and dirty commandline parser */ - { - int is_forked = 0; - int i; - - for (i = 1; i < argc; i++) - { - if (!strcmp(argv[i], "--forked")) - is_forked = 1; - else if (!strcmp(argv[i], "--execdir")) - { - if (i+1 >= argc) - { - fprintf(stderr, "%s Missing value for --execdir.\n" - , time_stamp()); - goto die; - } - erq_dir = argv[i+1]; - i++; - } - else - { - fprintf(stderr, "%s Unknown argument '%s'.\n" - , time_stamp(), argv[i]); - goto die; - } - } - /* Check if we have been forked off the driver */ - if (is_forked) - { - write1("1", 1); /* indicate sucessful fork/execl */ - } - else - { - fprintf(stderr, "%s dynamic attachement unimplemented\n", time_stamp()); - goto die; - } - } - -#if defined(DETACH) && defined(TIOCNOTTY) - /* Detach from console */ - s = open("/dev/tty", O_RDWR); - if (s >= 0) - { - /* We supply header as a 'dummy' argument in case typing is - * too strict - */ - ioctl(s, TIOCNOTTY, header); - close(s); - } -#endif - - /* Initialize variables */ - - randomize_tickets(get_seed()); - FD_ZERO(¤t_fds); - FD_ZERO(¤t_fds2); - FD_SET(1, ¤t_fds); - (void)signal(SIGCLD, (RETSIGTYPE(*)())count_sigcld); - - /* The main loop */ - - for (subserver = 0;;) - { - int still_corked; /* Determines the select() wait time */ - - /* Scan the list of TCP children and check which sent data - * to the driver more than 3 seconds ago. Those are added - * back to current_fds. - * Existence of children which sent data less than 3 seconds - * ago are flagged as 'still_corked'. - */ - still_corked = 0; - for (next_child = tcp_sockets; NULL != (child = next_child); ) - { - - next_child = child->next_all; - - /* Uncork the bottle */ - if (child->u.s.bytes_recv) - { - if (child->u.s.last_recv + 3 < time(NULL)) - { -#if ERQ_DEBUG > 1 - fprintf(stderr,"%s Uncorking child\n", time_stamp()); -#endif - child->u.s.bytes_recv = 0; - FD_SET(child->socket, ¤t_fds); - } - else - still_corked = 1; - } - } /* for(tcpsockets) */ -#if ERQ_DEBUG > 0 - fprintf(stderr,"%s still_corked = %d\n", time_stamp(), still_corked); -#endif - - /* select() for data. - */ - readfds = current_fds; - writefds = current_fds2; - timeout.tv_sec = (still_corked ? 3 : TIME_TO_CHECK_CHILDS); - timeout.tv_usec = 0; - -#if ERQ_DEBUG > 0 - fprintf(stderr, "%s calling select (nfds = %d)\n", time_stamp(), nfds); -#endif - num_ready = select(nfds, &readfds, &writefds, 0, &timeout); -#if ERQ_DEBUG > 0 - fprintf(stderr, "%s select returns %d\n", time_stamp(), num_ready); -#endif - if (num_ready < 0 && errno != EINTR) - { - perror ("select"); - abort (); - } - current_time = time(NULL); - - /* Kill off idle free children */ - - { - time_t expired; - - expired = current_time - CHILD_EXPIRE; - for (next_child = free_childs; (child = next_child); ) - { - next_child = child->next_free; - if (child->u.c.last_used > expired) - continue; -#if ERQ_DEBUG > 0 - fprintf(stderr, "%s Max child idle time expired.\n", time_stamp()); -#endif - kill_child(child); - } - } - - /* Check for zombie children and wait for them */ - -#ifdef HAVE_WAITPID - while(1) { -#else - while (childs_terminated != childs_waited_for) { -#endif - wait_status_t status; - pid_t pid; - - do { -#ifdef HAVE_WAITPID - pid = waitpid(-1, &status, WNOHANG); -#else - pid = wait(&status); -#endif -#ifdef ERESTARTSYS - if (pid < 0 && errno == ERESTARTSYS) - continue; -#endif - } while (0); - - if (pid <= 0) - break; - - for (child = all_childs; child; child = child->next_all) - { - if (child->u.c.pid == pid) - { - dispose_child(child); - break; - } - } - childs_waited_for++; - } - - if (num_ready > 0) - { - /* Check for data from the subservers for the gamedriver */ - - for (next_child = all_childs; (child = next_child); ) - { - long replylen; - char replyheader[12]; - char replybuf[ERQ_BUFSIZE]; - - next_child = child->next_all; - - s = child->socket; - if (!FD_ISSET(s, &readfds)) - continue; -#if ERQ_DEBUG > 0 - fprintf(stderr, "%s query child %d\n", time_stamp(), child - &childs[0]); -#endif - /* Read the standard erq header plus the one-byte - * child state. - */ - num = readn(s, replyheader, 9); - if (num != 9) - { - fprintf(stderr, "%s read %ld, should be 9.\n", time_stamp(), num); - kill_child(child); - continue; - } - - /* If there is more data, read the rest of message */ - replylen = read_32(replyheader) - 8; - if (replylen > 0) - { - if (replylen > sizeof replybuf) - { - fprintf(stderr, "%s Too long reply.\n", time_stamp()); - kill_child(child); - continue; - } - num = readn(s, replybuf, replylen); - if (num != replylen) - { - fprintf(stderr, "%s read %ld, should be %ld\n" - , time_stamp(), num, replylen); - kill_child(child); - continue; - } - } - - /* Pass the message received (sans the state byte) on - * to the gamedriver. - */ - write1(replyheader, 8); - write1(replybuf, replylen); - /* We can't simply test for ERQ_HANDLE_KEEP_HANDLE, because a - * subserver can have several handles at a time. - */ - if ((child->state = replyheader[8]) == CHILD_FREE) - { - child->u.c.last_used = current_time; - child->next_free = free_childs; - free_childs = child; - } - } -#if ERQ_DEBUG > 0 - fprintf(stderr, "%s queried all children\n", time_stamp()); -#endif - -#ifdef ERQ_OPEN_UDP - /* Check for data received on UDP sockets for the gamedriver */ - - for (next_child = udp_sockets; (child = next_child); ) - { - length_t length; - long replylen; - char replyheader[16]; - char replybuf[ERQ_BUFSIZE]; - struct sockaddr_in addr; - int cnt; - - next_child = child->next_all; - s = child->socket; - if (!FD_ISSET(s, &readfds)) - continue; - - /* Receive the UDP message */ - length = sizeof addr; - cnt = recvfrom( s, replybuf, sizeof(replybuf), 0 - , (struct sockaddr *)&addr, &length); - - /* Compose and send the UDP-erq message to the driver */ - replylen = length + 19; - if (replylen > MAX_REPLY) - replylen = MAX_REPLY; - write_32(replyheader, replylen); - write_32(replyheader+4, ERQ_HANDLE_KEEP_HANDLE); - memcpy(replyheader+8, child->u.s.handle, 4); - replyheader[12] = ERQ_STDOUT; - write1(replyheader, 13); - write1(&addr.sin_addr.s_addr, 4); - write1(&addr.sin_port, 2); - write1(replybuf, replylen - 19); - } -#endif /* ERQ_OPEN_UDP */ - -#ifdef ERQ_OPEN_TCP - - /* Exchange data between the TCP sockets and the driver */ - - for (next_child = tcp_sockets; (child = next_child); ) - { - int length; - long replylen; - char replyheader[30]; - char replybuf[ERQ_BUFSIZE]; - int cnt; - - next_child = child->next_all; - s = child->socket; - - if (FD_ISSET(s, &writefds)) - { - /* Socket is ready for writing - nevertheless check - * if there is data pending. - */ - FD_CLR(s, ¤t_fds2); - cnt = recv(s, replybuf, 1, MSG_PEEK); - - if (cnt < 0 && (errno != EWOULDBLOCK && errno != EAGAIN)) - { - /* TCP connection died - inform the driver and - * get rid of the child. - */ - - replyheader[8] = ERQ_E_UNKNOWN; - replyheader[9] = errno; - replylen = 10; - write_32(replyheader, replylen); - memcpy(replyheader+4, child->u.s.handle, 4); - write1(replyheader, replylen); /* ..and release handle */ - FD_CLR(child->socket,¤t_fds); - FD_CLR(child->socket,¤t_fds2); - close(child->socket); - free_socket_child(child,&tcp_sockets); - break; - } - - /* Inform the driver that there is data pending */ - - replyheader[12] = ERQ_OK; - write_32(replyheader, 17+sizeof(child->u.s.ticket)); - write_32(replyheader+4, ERQ_HANDLE_KEEP_HANDLE); - memcpy(replyheader+8, child->u.s.handle, 4); - write_32(replyheader+13, child - &childs[0]); - memcpy(replyheader+17, child->u.s.ticket.c - , sizeof(child->u.s.ticket)); - write1(replyheader, 17+sizeof(child->u.s.ticket)); - break; - } - else if (!FD_ISSET(s, &readfds)) - continue; - - /* Read the data */ - - cnt = read(s, replybuf, MAX_REPLY-100); - FD_CLR(s,&readfds); - if (cnt <= 0) - { - /* No data there - EOF or error */ - - if (!cnt) - { - replyheader[8] = ERQ_EXITED; - replylen = 9; - } - else - { - replyheader[8] = ERQ_E_UNKNOWN; - replyheader[9] = errno; - replylen = 10; - } - write_32(replyheader, replylen); - memcpy(replyheader+4, child->u.s.handle, 4); - write1(replyheader, replylen); /* ..and release handle */ - FD_CLR(child->socket,¤t_fds); - FD_CLR(child->socket,¤t_fds2); - close(child->socket); - free_socket_child(child,&tcp_sockets); - break; - } - else - { - /* We got data - send it to the driver (but make - * sure not to overrun it). - */ - - length = cnt; -#if 0 - /* Update the "data pending" strategy */ - child->u.s.last_recv = time(NULL); - child->u.s.bytes_recv += cnt; -#endif - - if (child->u.s.bytes_recv > 4096) - { - /* Cork the bottle. Let the MUD swallow first */ - FD_CLR(s, ¤t_fds); -#if ERQ_DEBUG > 1 - fprintf(stderr,"%s Corking child.\n", time_stamp()); -#endif - } - - /* Compose the message for the driver and send it */ - - replylen = length + 13; - if (replylen > MAX_REPLY) - replylen = MAX_REPLY; - write_32(replyheader, replylen); - write_32(replyheader+4, ERQ_HANDLE_KEEP_HANDLE); - memcpy(replyheader+8, child->u.s.handle, 4); - replyheader[12] = ERQ_STDOUT; - write1(replyheader, 13); - write1(replybuf, replylen - 13); - } - } -#endif /* ERQ_OPEN_TCP */ - -#ifdef ERQ_LISTEN - for (next_child = accept_sockets; (child = next_child); ) - { - int length; - long replylen; - char replyheader[30]; - char replybuf[ERQ_BUFSIZE]; - int cnt; - - next_child = child->next_all; - s = child->socket; - if (!FD_ISSET(s, &readfds)) - continue; - FD_CLR(s,¤t_fds); - - /* Connection pending - inform the driver */ - - replylen = 13; - write_32(replyheader, replylen); - write_32(replyheader+4, ERQ_HANDLE_KEEP_HANDLE); - memcpy(replyheader+8, child->u.s.handle, 4); - replyheader[12] = ERQ_STDOUT; - write1(replyheader, replylen); - - } -#endif /* ERQ_LISTEN */ - } /* if (num_ready) */ - - /* We needed to send data to a subserver in the previous loop, - * but didn't get one then. Now try again. - */ - if (subserver < 0) - { - subserver = get_subserver(); - if (subserver < 0) - continue; - writen(subserver, header, 9); - writen(subserver, buf, msglen); - } - - if (num_ready > 0 && FD_ISSET(1, &readfds)) - { - /* TODO: We read from 0 when 1 is ready? */ - - /* Read the erq message incl. request */ - num = readn(0, header, 9); - if (num != 9) - { - fprintf(stderr, "%s Read %ld, should be 9!\n" - , time_stamp(), num); - if (num < 0) - perror("read"); - break; - } -#if ERQ_DEBUG > 0 - fprintf(stderr, "%s read command %d\n", time_stamp(), header[8]); -#endif - - /* Read the rest of the message */ - - msglen = read_32(header) - 9; - if (msglen > 0) - { - num = readn(0, buf, msglen); - if (num != msglen) { - fprintf(stderr, "%s Read %ld, should be %ld\n" - , time_stamp(), num, msglen); - break; - } - } - - /* Switch on the request received */ - switch(header[8]) - { - - /* ----- Send a signal or data ----- */ - case ERQ_SEND: - case ERQ_KILL: - { - long n; - - /* Check the ticket - the next_child_index at the time - * of creation. - */ - n = read_32(buf); - if ((unsigned long)n >= (unsigned long)next_child_index) - goto bad_ticket; - - child = &childs[n]; - switch(child->state) - { - struct child_s **listp; - - bad_ticket: - default: - { -#if ERQ_DEBUG > 0 - fprintf(stderr, "%s Ticket rejected n: 0x%x nxt: 0x%x state: %d\n", - time_stamp(), n, next_child_index, - (unsigned long)n >= (unsigned long)next_child_index ? - 0 : childs[n].state); -#endif - subserver = 0; /* ready for new commands */ - write_32(header, 9); - header[8] = ERQ_E_TICKET; - write1(header, 9); - break; - } - - case CHILD_LISTEN: - /* Pass on the message to the listening child */ - subserver = child->socket; - write_32(header, 9 + msglen - 4); - writen(subserver, header, 9); - writen(subserver, buf+4, msglen-4); - break; - -#ifdef ERQ_LISTEN - case CHILD_ACCEPT: - /* Can only KILL accept children, not SEND data */ - - if (header[8] == ERQ_SEND) - goto bad_ticket; - listp = &accept_sockets; - goto handle_send_on_socket; - - case CHILD_TCP: - listp = &tcp_sockets; - goto handle_send_on_socket; -#endif -#ifdef ERQ_OPEN_UDP - case CHILD_UDP: - listp = &udp_sockets; -#endif -#if defined(ERQ_OPEN_UDP) || defined(ERQ_LISTEN) - handle_send_on_socket: - - /* Check the rest of the ticket */ - - if (msglen < sizeof(union ticket_u) - || memcmp(buf+4, child->u.s.ticket.c, - sizeof(union ticket_u))) - { -#if ERQ_DEBUG > 0 - fprintf(stderr,"%s Ticket mismatch. (%d, %d)\n", time_stamp(), msglen,sizeof(union ticket_u)); -#endif - goto bad_ticket; - } - msglen -= sizeof(union ticket_u); - - subserver = 0; /* ready for new commands */ - write_32(header, 9); /* "msg_len" of the answer */ - if (header[8] == ERQ_SEND) - { - while(1){ - if (child->state == CHILD_UDP) - { - struct sockaddr_in host_ip_addr; - - if (msglen < 6) - { - header[8] = ERQ_E_ARGLENGTH; - break; - } - memcpy(&host_ip_addr.sin_addr, - buf+sizeof(union ticket_u), 4); - host_ip_addr.sin_family = AF_INET; - memcpy(&host_ip_addr.sin_port, - buf+sizeof(union ticket_u)+4, 2); - num = sendto(child->socket, - buf+sizeof(union ticket_u)+6, - msglen - 6, 0, - (struct sockaddr *)&host_ip_addr, - sizeof(host_ip_addr)); - } - else - { - /* Program or TCP socket */ - num = write(child->socket, - buf+sizeof(union ticket_u)+4, - msglen-4); - } - - if (num != msglen-4) - { - /* Prepare the error message to send back */ - if (num < 0) - { - switch(errno) { - case EWOULDBLOCK: -#if EAGAIN != EWOULDBLOCK - case EAGAIN: -#endif - header[3] = 9; - header[8] = ERQ_E_WOULDBLOCK; - break; - case EPIPE: - header[3] = 9; - header[8] = ERQ_E_PIPE; - break; - case EINTR: - continue; - default: - header[3] = 10; - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - break; - } - } - else - { - header[3] = 13; - header[8] = ERQ_E_INCOMPLETE; - write_32(header+9, num); - } - } - else - { - /* Send back "ok" */ - header[3] = 9; - header[8] = ERQ_OK; - } - break; - } - } - else - { - /* header[8] == ERQ_KILL */ - FD_CLR(child->socket,¤t_fds); - FD_CLR(child->socket,¤t_fds2); - if (child->state == CHILD_ACCEPT) - shutdown(child->socket,0); - close(child->socket); - free_socket_child(child,listp); - write_32(header,9); - header[8] = ERQ_OK; - } - write1(header, header[3]); - break; -#endif /* defined(ERQ_OPEN_UDP) || defined(ERQ_LISTEN) */ - } - break; /* end of ERQ_KILL / ERQ_SEND */ - } - - default: - { - /* Non-communication request: pass it on to - * a new subserver. - */ - subserver = get_subserver(); - if (subserver >= 0) - { - writen(subserver, header, 9); - writen(subserver, buf, msglen); - } - } - break; - -#ifdef ERQ_OPEN_UDP - case ERQ_OPEN_UDP: - { - /* Open a UDP socket */ - - subserver = 0; /* ready for new commands */ - write_32(header, 10); - do { - struct sockaddr_in host_ip_addr; - int tmp; - - if (msglen != 2) - { - header[8] = ERQ_E_ARGLENGTH; - header[9] = 0; - break; - } - host_ip_addr.sin_addr.s_addr = INADDR_ANY; - host_ip_addr.sin_family = AF_INET; - memcpy(&host_ip_addr.sin_port, buf, 2); - if (!free_socket_childs()) - { - header[8] = ERQ_E_NSLOTS; - header[9] = MAX_CHILDS; - break; - } - s = socket(AF_INET, SOCK_DGRAM, 0); - if (s < 0) { - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - break; - } - tmp = 1; - if (setsockopt (s, SOL_SOCKET, SO_REUSEADDR, - (char *) &tmp, sizeof (tmp)) < 0) - { - close(s); - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - break; - } - if (bind(s, (struct sockaddr *)&host_ip_addr, - sizeof host_ip_addr) == -1) - { - close(s); - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - break; - } - - /* We got the socket, now make the child */ - - child = get_socket_child(); - child->socket = s; - FD_SET(child->socket,¤t_fds); - child->state = CHILD_UDP; - child->next_all = udp_sockets; - udp_sockets = child; - ticket.s.seq += - ((get_seed() - ticket.s.seq) & 0x7fffffff) + 1; - ticket.s.rnd = get_ticket(); - if (s >= nfds) - nfds = s + 1; - memcpy(child->u.s.handle, header+4, 4); - memcpy(child->u.s.ticket.c, ticket.c, sizeof ticket); - - /* Compose the answer to the driver */ - - header[3] = 17 + sizeof ticket; - memcpy(header+8, header+4, 4); - write_32(header+4, ERQ_HANDLE_KEEP_HANDLE); - header[12] = ERQ_OK; - write_32(header+13, child - &childs[0]); - memcpy(header+17, ticket.c, sizeof ticket); - } while(0); - write1(header, header[3]); - } - break; -#endif /* ERQ_OPEN_UDP */ - -#ifdef ERQ_OPEN_TCP - case ERQ_OPEN_TCP: - { - /* Open a TCP socket and connect it to a given - * address. - */ - subserver = 0; /* ready for new commands */ - write_32(header, 10); - do { - struct sockaddr_in host_ip_addr; - int tmp; - - if (msglen != 6) - { - header[8] = ERQ_E_ARGLENGTH; - header[9] = 0; - break; - } - host_ip_addr.sin_family = AF_INET; - memcpy(&host_ip_addr.sin_port, buf+4, 2); - memcpy(&host_ip_addr.sin_addr.s_addr, buf, 4); - - if (!free_socket_childs()) - { - header[8] = ERQ_E_NSLOTS; - header[9] = MAX_CHILDS; - break; - } - s = socket(AF_INET, SOCK_STREAM, 0); - if (s < 0) - { - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - break; - } - if ((tmp = fcntl(s,F_GETFL,0)) < 0) - { - fprintf(stderr,"%s fnctl 1\n", time_stamp()); - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - break; - } - - if ((tmp = fcntl(s,F_SETFL,tmp | O_NDELAY)) < 0) - { - fprintf(stderr,"%s fnctl 2\n", time_stamp()); - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - break; - } - - tmp = 1; - if (connect(s, (struct sockaddr *)&host_ip_addr, - sizeof host_ip_addr) == -1) - { - if(errno != EINPROGRESS) - { - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - close(s); - break; - } - } - - /* Got the socket, now create the child */ - - child = get_socket_child(); - child->socket = s; - FD_SET(child->socket,¤t_fds); - FD_SET(child->socket,¤t_fds2); - child->state = CHILD_TCP; - child->u.s.bytes_recv = 0; - child->next_all = tcp_sockets; - tcp_sockets = child; - ticket.s.seq += - ((get_seed() - ticket.s.seq) & 0x7fffffff) + 1; - ticket.s.rnd = get_ticket(); - if (s >= nfds) - nfds = s + 1; - memcpy(child->u.s.handle, header+4, 4); - memcpy(child->u.s.ticket.c, ticket.c, sizeof ticket); - - /* Compose the answer to the driver */ - - header[3] = 17 + sizeof ticket; - memcpy(header+8, header+4, 4); - write_32(header+4, ERQ_HANDLE_KEEP_HANDLE); - header[12] = ERQ_OK; - header[3] = 0; - write_32(header+13, child - &childs[0]); - memcpy(header+17, ticket.c, sizeof ticket); - } while(0); - if(header[3]) write1(header, header[3]); - } - break; -#endif /* ERQ_OPEN_TCP */ - -#ifdef ERQ_LISTEN - case ERQ_LISTEN: - { - subserver = 0; /* ready for new commands */ - write_32(header, 10); - do { - struct sockaddr_in host_ip_addr; - int tmp; - - if (msglen != 2) - { - header[8] = ERQ_E_ARGLENGTH; - header[9] = 0; - break; - } - host_ip_addr.sin_family = AF_INET; - host_ip_addr.sin_addr.s_addr = INADDR_ANY; - memcpy(&host_ip_addr.sin_port, buf, 2); - - if (!free_socket_childs()) - { - header[8] = ERQ_E_NSLOTS; - header[9] = MAX_CHILDS; - break; - } - s = socket(AF_INET, SOCK_STREAM, 0); - if (s < 0) - { - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - break; - } - if((tmp = fcntl(s,F_GETFL,0)) < 0) - { - fprintf(stderr,"%s fnctl 1\n", time_stamp()); - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - break; - } - - if((tmp = fcntl(s,F_SETFL,tmp | O_NDELAY)) < 0) - { - fprintf(stderr,"%s fnctl 2\n", time_stamp()); - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - break; - } - tmp = 1; - if (bind(s, (struct sockaddr *)&host_ip_addr, - sizeof host_ip_addr) == -1) - { - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - break; - } - if (listen(s,2) < 0) - { - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - break; - } - - /* Got the socket, now create the child */ - - child = get_socket_child(); - child->socket = s; - FD_SET(child->socket,¤t_fds); - child->state = CHILD_ACCEPT; - child->next_all = accept_sockets; - accept_sockets = child; - ticket.s.seq += - ((get_seed() - ticket.s.seq) & 0x7fffffff) + 1; - ticket.s.rnd = get_ticket(); - if (s >= nfds) - nfds = s + 1; - memcpy(child->u.s.handle, header+4, 4); - memcpy(child->u.s.ticket.c, ticket.c, sizeof ticket); - - /* Compose the message for the driver */ - - header[3] = 17 + sizeof ticket; - memcpy(header+8, header+4, 4); - write_32(header+4, ERQ_HANDLE_KEEP_HANDLE); - header[12] = ERQ_OK; - write_32(header+13, child - &childs[0]); - memcpy(header+17, ticket.c, sizeof ticket); - } while(0); - if(header[3]) write1(header, header[3]); - } - break; -#endif /* ERQ_LISTEN */ - -#ifdef ERQ_ACCEPT - case ERQ_ACCEPT: - { - - /* Accept a connection from a socket */ - - subserver = 0; /* ready for new commands */ - write_32(header, 10); - do { - struct child_s *parent; - struct sockaddr_in host_ip_addr; - long tmp2; - int tmp; - length_t len; - int n; - - if (msglen != sizeof(union ticket_u) + 4) - { - header[8] = ERQ_E_ARGLENGTH; - header[9] = 0; - break; - } - - n = read_32(buf); - if((unsigned long) n >= (unsigned long) next_child_index) - { - fprintf(stderr,"%s given: %d, nxt: %d\n", time_stamp(), n,next_child_index); - goto accept_bad_ticket; - } - - parent = &childs[n]; - if(parent->state != CHILD_ACCEPT) - { - fprintf(stderr,"%s State is %d, should be %d!\n", time_stamp(), parent->state,CHILD_ACCEPT); - goto accept_bad_ticket; - } - - if(memcmp(buf+4,parent->u.s.ticket.c,sizeof(union ticket_u))) - { - accept_bad_ticket: - fprintf(stderr,"%s Accept: Ticket mismatch.\n", time_stamp()); - header[8] = ERQ_E_TICKET; - header[9] = 0; - break; - } - - if (!free_socket_childs()) - { - header[8] = ERQ_E_NSLOTS; - header[9] = MAX_CHILDS; - break; - } - - len = sizeof(host_ip_addr); - s = accept( parent->socket - , (struct sockaddr *) &host_ip_addr - , &len); - if (s < 0) - { - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - break; - } - if((tmp = fcntl(s,F_GETFL,0)) < 0) - { - fprintf(stderr,"%s fnctl 1\n", time_stamp()); - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - break; - } - - if((tmp = fcntl(s,F_SETFL,tmp | O_NDELAY)) < 0) - { - fprintf(stderr,"%s fnctl 2\n", time_stamp()); - header[8] = ERQ_E_UNKNOWN; - header[9] = errno; - break; - } - tmp = 1; - child = get_socket_child(); - child->socket = s; - - /* Socket accepted, wait for more conns */ - - FD_SET(parent->socket, ¤t_fds); - FD_SET(child->socket, ¤t_fds); - child->state = CHILD_TCP; - child->u.s.bytes_recv = 0; - child->next_all = tcp_sockets; - tcp_sockets = child; - ticket.s.seq += - ((get_seed() - ticket.s.seq) & 0x7fffffff) + 1; - ticket.s.rnd = get_ticket(); - if (s >= nfds) - nfds = s + 1; - memcpy(child->u.s.handle, header+4, 4); - memcpy(child->u.s.ticket.c, ticket.c, sizeof ticket); - header[3] = 23 + sizeof ticket; - memcpy(header+8, header+4, 4); - write_32(header+4, ERQ_HANDLE_KEEP_HANDLE); - header[12] = ERQ_OK; - memcpy(header+13, &host_ip_addr.sin_addr.s_addr, 4); - memcpy(header+17, &host_ip_addr.sin_port, 2); - write_32(header+19, child - &childs[0]); - memcpy(header+23, ticket.c, sizeof ticket); - } while(0); - if (header[3]) - write1(header, header[3]); - } - break; -#endif /* ERQ_ACCEPT */ - - } /* switch() */ - } /* if (num_ready > 0 && FD_ISSET(1, &readfds)) */ - - if (subserver < 0) - FD_CLR(1, ¤t_fds); - else - FD_SET(1, ¤t_fds); - } /* main loop */ - -die: - fprintf(stderr, "%s Giving up.\n", time_stamp()); - return 1; -} /* main() */ - -/***************************************************************************/ - diff --git a/config/gentoo/ldmud/files/erq/erq.h b/config/gentoo/ldmud/files/erq/erq.h deleted file mode 100644 index 013f0ef..0000000 --- a/config/gentoo/ldmud/files/erq/erq.h +++ /dev/null @@ -1,60 +0,0 @@ -/* external request demon interface definitions */ - -#ifndef ERQ_H__ -#define ERQ_H__ 1 - -/* servive request types */ - -#define ERQ_RLOOKUP 0 /* Lookup ip -> name */ -#define ERQ_EXECUTE 1 /* Execute a program */ -#define ERQ_FORK 2 /* Fork a program */ -#define ERQ_AUTH 3 /* Connect to a remote authd */ -#define ERQ_SPAWN 4 /* Spawn a program */ -#define ERQ_SEND 5 /* Send data to a program or connection */ -#define ERQ_KILL 6 /* Kill a program or connection */ -#define ERQ_OPEN_UDP 7 /* Open a UDP socket */ -#define ERQ_OPEN_TCP 8 /* Open a TCP connection */ -#define ERQ_LISTEN 9 /* Open a TCP accept-socket */ -#define ERQ_ACCEPT 10 /* Accept a connection from a accept-socket */ -#define ERQ_LOOKUP 11 /* Lookup name -> ip */ - -#ifdef __IPV6__ -#define ERQ_RLOOKUPV6 12 /* Lookup name/ip6 */ -#endif -#define ERQ_LOOKUP_SRV 13 - -/* Additional service request type flags evaluated by efun send_erq(). - * The ERQ itself won't get to see it. - */ - -#define ERQ_CB_STRING (1 << 31) /* Callback closure takes a string arg */ - - -/* answers from ERQ_EXECUTE / ERQ_FORK */ - -#define ERQ_OK 0 -#define ERQ_SIGNALED 1 -#define ERQ_E_NOTFOUND 2 /* process not found by wait */ -#define ERQ_E_UNKNOWN 3 /* unknown exit condition from wait() */ -#define ERQ_E_ARGLENGTH 4 -#define ERQ_E_ARGFORMAT 5 -#define ERQ_E_ARGNUMBER 6 -#define ERQ_E_ILLEGAL 7 -#define ERQ_E_PATHLEN 8 -#define ERQ_E_FORKFAIL 9 -#define ERQ_E_TICKET 11 -#define ERQ_E_INCOMPLETE 12 -#define ERQ_E_WOULDBLOCK 13 -#define ERQ_E_PIPE 14 -#define ERQ_STDOUT 15 /* Normal data received */ -#define ERQ_STDERR 16 -#define ERQ_EXITED 17 /* Connection closed on EOF */ -#define ERQ_E_NSLOTS 18 - -/* reserved handles */ - -#define ERQ_HANDLE_RLOOKUP (-1) -#define ERQ_HANDLE_KEEP_HANDLE (-2) -#define ERQ_HANDLE_RLOOKUPV6 (-3) - -#endif /* ERQ_H__ */ diff --git a/config/gentoo/ldmud/files/erq/srv.c b/config/gentoo/ldmud/files/erq/srv.c deleted file mode 100644 index 0fcf672..0000000 --- a/config/gentoo/ldmud/files/erq/srv.c +++ /dev/null @@ -1,215 +0,0 @@ -#include "srv.h" - - -#include -#include -#include -#include // For solaris -#include -#include - -#include - -/* the biggest packet we'll send and receive */ -#if PACKETSZ > 1024 -#define MAXPACKET PACKETSZ -#else -#define MAXPACKET 1024 -#endif - -/* and what we send and receive */ -typedef union { - HEADER hdr; - u_char buf[MAXPACKET]; -} querybuf; - -#ifndef T_SRV -#define T_SRV 33 -#endif - - -void freesrvhost ( struct srvhost * s ) -{ - struct srvhost * n; - while( s ) { - n = s->next; - /* hack to make double-free visible by causing null dereference */ - s->next = NULL; - free( (void *)s ); - s = n; - } -} - - -static int compare( const void * a, const void * b ) -{ - struct srvhost * aa, * bb; - - if ( !a ) - return 1; - if ( !b ) - return -1; - - aa = (struct srvhost *) *(int*)a; - bb = (struct srvhost *) *(int*)b; - - if ( aa->pref > bb->pref ) - return 1; - if ( aa->pref < bb->pref ) - return -1; - - if ( aa->rweight > bb->rweight ) - return -1; - if ( aa->rweight < bb->rweight ) - return 1; - - return 0; -} - - -struct srvhost * getsrv( const char * domain, - const char * service, const char * protocol ) { - querybuf answer; /* answer buffer from nameserver */ - int n; - char * zone; - int ancount, qdcount; /* answer count and query count */ - HEADER *hp; /* answer buffer header */ - struct srvhost **replyarray; - struct srvhost * firsthost; - int answerno; - u_char hostbuf[256]; - u_char *msg, *eom, *cp; /* answer buffer positions */ - int dlen, type, pref, weight, port; - - if ( !domain || !*domain || - !service || !*service || - !protocol || !*protocol ) - return NULL; - - zone = (char *)malloc( strlen( domain ) + - strlen( service ) + - strlen( protocol ) + 20 ); - if (zone == NULL) - return NULL; - - *zone = '\0'; - - if (*service != '_') // If service and protocol do not start with a - strcat(zone, "_"); // _, prepend the _ to them... - - strcat(zone, service); - strcat(zone, "."); - - if (*protocol != '_') - strcat(zone, "_"); - - strcat(zone, protocol); - strcat(zone, "."); - - strcat(zone, domain); - - n = res_query( zone, C_IN, T_SRV, (u_char *)&answer, sizeof( answer ) ); - - (void) free( zone ); - zone = NULL; - - if ( n < (int)sizeof(HEADER) ) - return NULL; - - /* valid answer received. skip the query record. */ - - hp = (HEADER *)&answer; - qdcount = ntohs(hp->qdcount); - ancount = ntohs(hp->ancount); - - msg = (u_char *)&answer; - eom = (u_char *)&answer + n; - cp = (u_char *)&answer + sizeof(HEADER); - - while ( qdcount-- > 0 && cp < eom ) { - n = dn_expand( msg, eom, cp, (char *)hostbuf, 256 ); - if (n < 0) - return NULL; - cp += n + QFIXEDSZ; - } - - /* make a big-enough (probably too big) reply array */ - - replyarray - = (struct srvhost **) malloc( ancount * sizeof(struct srvhost *) ); - for( n = 0; n < ancount; n++ ) - replyarray[n] = NULL; - answerno = 0; - - /* loop through the answer buffer and extract SRV records */ - while ( ancount-- > 0 && cp < eom ) { - n = dn_expand( msg, eom, cp, (char *)hostbuf, 256 ); - if ( n < 0 ) { - for( n = 0; n < answerno; n++ ) - (void) free( replyarray[n] ); - (void)free( replyarray ); - return NULL; - } - - cp += n; - - type = _getshort(cp); - cp += sizeof(u_short); - - /* class = _getshort(cp); */ - cp += sizeof(u_short); - - /* ttl = _getlong(cp); */ - cp += sizeof(u_long); - - dlen = _getshort(cp); - cp += sizeof(u_short); - - if ( type != T_SRV ) { - cp += dlen; - continue; - } - - pref = _getshort(cp); - cp += sizeof(u_short); - - weight = _getshort(cp); - cp += sizeof(u_short); - - port = _getshort(cp); - cp += sizeof(u_short); - - n = dn_expand( msg, eom, cp, (char *)hostbuf, 256 ); - if (n < 0) - break; - cp += n; - - replyarray[answerno] - = (struct srvhost *)malloc( sizeof( struct srvhost ) + - strlen( (char *)hostbuf ) ); - replyarray[answerno]->pref = pref; - replyarray[answerno]->weight = weight; - if ( weight ) - replyarray[answerno]->rweight = 1+random()%( 10000 * weight ); - else - replyarray[answerno]->rweight = 0; - replyarray[answerno]->port = port; - replyarray[answerno]->next = NULL; - strcpy( replyarray[answerno]->name, (char *)hostbuf ); - - answerno++; - } - if (answerno == 0) return NULL; - qsort( replyarray, answerno, sizeof( struct srvhost * ), - compare ); - - // Recreate a linked list from the sorted array... - for( n = 0; n < answerno; n++ ) - replyarray[n]->next = replyarray[n+1]; - replyarray[answerno-1]->next = NULL; - - firsthost = replyarray[0]; - (void) free( replyarray ); - return firsthost; -} - diff --git a/config/gentoo/ldmud/files/erq/srv.h b/config/gentoo/ldmud/files/erq/srv.h deleted file mode 100644 index 0fcf130..0000000 --- a/config/gentoo/ldmud/files/erq/srv.h +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************************** -** $Id: srv.h,v 1.1 2006/05/22 11:18:10 lynx Exp $ -** -** Definition of something or other -** -** Created : 979899 -** -** Copyright (C) 1997 by Troll Tech AS. All rights reserved. -** -****************************************************************************/ - -#ifndef SRV_H -#define SRV_H - -struct srvhost { - unsigned int pref; - struct srvhost * next; - unsigned int port; - unsigned int weight; - unsigned int rweight; - char name[1]; -}; - - -extern void freesrvhost ( struct srvhost * ); - -extern struct srvhost * getsrv( const char * domain, - const char * service, - const char * protocol ); - -#endif - diff --git a/config/gentoo/ldmud/files/psyced.settings b/config/gentoo/ldmud/files/psyced.settings deleted file mode 100644 index 9a2c651..0000000 --- a/config/gentoo/ldmud/files/psyced.settings +++ /dev/null @@ -1,311 +0,0 @@ -#!/bin/sh -# -# settings/psyced version 4.0 -# -# $Id: psyced.settings,v 1.10 2007/05/08 00:52:01 lynx Exp $ -# -# LDMUD compilation settings for psyced, the LPC server and client -# implementation of the protocol for synchronous conferencing. -# Please execute this instead of ./configure before compilation. -# -# The latest version of this file is in the psyced repository and usually also -# at http://www.psyced.org/dist/config/psyced.settings -# The version in the LDMUD distribution may be slightly outdated. -# -# Documents and download on: http://www.psyced.org -# Information about PSYC: http://www.psyc.eu -# -# the PSYC implementation and library is designed in a way that it should -# easily co-host in a running LPMUD, it just needs a few patches to the -# master object and #includes in simul_efun. -# -# how to multiplex InterMUD and PSYC on the same udp port: -# PSYC UDP packets always start with ".\n". -# -# configure will strip this part from the script. - -cp $0 settings/psyced-current -exec ./configure --prefix=/opt/psyced --bindir=/opt/psyced/bin --libdir=/opt/psyced/world --libexec=/opt/psyced/run --with-setting=psyced-current $* -exit - -#-- PSYCLPC EXTENSIONS - -# compile json c library in, if available -enable_use_json=yes - -# compile expat xml & xmpp parser in, if available -enable_use_expat=yes - -# enable this if you want use http://about.psyc.eu/psyclpc#Authlocal -enable_use_authlocal=yes -# requires procfs with readable /proc/net/tcp -# -# some kernel configurations show wrong port numbers however, -# in that case the correlation from peer port to user id fails. -# there is however no risk of error (the peer ports are unprivileged -# whereas the 'wrong' ones are privileged ones. could be related to -# iptables or some other port mapping magic). - -#-- FILE PATHES - -with_master_name=drivers/ldmud/master/master -# unused really -with_swap_file=log/psyced.swap - -#-- NETWORKING & DATA BASES - -# cool tool that does external name server resolution and more -enable_erq=erq - -# the "sorry" message of the built-in ACL isn't flexible enough: -# it cannot output a properly formatted HTTP or PSYC message -# and why shouldn't this be done in LPC anyway? -enable_access_control=no - -# zlib compression, really -enable_use_mccp=yes - -# Enable support for TLS (Transport Layer Security). -# -# 'no': TLS support is not compiled it -# 'gnu': TLS support using GnuTLS is compiled in if found. -# 'ssl': TLS support using OpenSSL is compiled in if found. -# 'yes': TLS support using either OpenSSL or GnuTLS is compiled in if found. -# The configuration script looks first for OpenSSL, then GnuTLS. -# If both are available, OpenSSL is used. -# -# gnutls does not offer features we need -enable_use_tls=ssl - -# SQL storage not implemented. Maybe PSYC synchronization is good enough? -# see http://about.psyc.eu/storage for info. -enable_use_mysql=no -enable_use_pgsql=no -enable_use_sqlite=no - -# maximum permitted tcp connections -with_max_players=900 - -# The maximum number of ports to listen for connections on. -with_maxnumports=33 - -# size of the buffer for incoming data of each socket -with_size_socket_buffer=32768 - -# The maximum number of simultaneous connect() calls -with_max_net_connects=33 - -# how can i set all the other port numbers? -# still using the historic dirty command line hack? -with_portno=4404 - -# Maximum size of a socket send buffer. -with_set_buffer_size_max=262144 - -# the PSYC port -with_udp_port=4404 - -# Enable support for IPv6 (this should better be autodetected!!) -#enable_use_ipv6=no - -# Enable the use of pthreads for background socket IO. -enable_use_pthreads=no - -# If PThreads are used, this is the max amount of data held pending -# for writing. If the amount is exceeded, the oldest data blocks -# are discarded. -# If 0, any amount of data is allowed. -with_pthread_write_max_size=333333 - -#-- RUNTIME LIMITS -# -# currently we consider a psyced a friendly environment -# where no coders will abuse cpu time and other limits -# you may want to change this if you have many room coders - -# you can lower this value for better debugging -with_max_cost=9999999 -#with_catch_reserved_cost=2000 -#with_master_reserved_cost=512 -enable_dynamic_costs=no - -# Maximum function call depth for normal program execution -#with_max_user_trace=60 -# Maximum function call depth during error handling. -# It must be bigger than MAX_USER_TRACE (check at compile time). -#with_max_trace=65 -# Maximum number of bits in a bit string. -# The limit is more based on considerations of speed than memory consumption. -#with_max_bits=6144 -# Allowed number of ed commands per backend cycle (for faster file upload). -#with_allowed_ed_cmds=20 - -# disabled "mud" limits -with_max_array_size=0 -with_max_mapping_size=0 -with_max_mapping_keys=0 -with_read_file_max_size=0 -with_max_byte_transfer=0 -with_max_callouts=0 -# new, was =100000 -with_pthread_write_max_size=0 - -# Compiler stack size. This value affects the complexity the compiler can -# parse. -#with_compiler_stack_size=400 - -# Maximum number of local variables -#with_max_local=50 - -# Maximum size of an expanded preprocessor definition. -#with_defmax=65000 - -#-- MEMORY ALLOCATION - -# slabmalloc seems to interact badly with net/jabber -#with_malloc=sysmalloc -# but other mallocs don't even compile & run - -enable_malloc_sbrk=yes -enable_malloc_check=no -enable_malloc_trace=no -enable_malloc_sbrk_trace=no -#enable_malloc_lpc_trace=no, MALLOC_slaballoc - -# disabled, sort of -with_reserved_user_size=100000 - -# hash table sizes. we have many chat strings (like lastlogs), but few objects -# (max: 65536) -with_htable_size=32768 -with_otable_size=256 -# Size of the hash table for defines, reserved words, identifiers, and -# efun names. This should be several times smaller than HTABLE_SIZE. -#with_itable_size=256 -# Size of the apply cache, expressed in the bitsize of its indices. -# The number of entries is 2**cache_bits. -#with_apply_cache_bits=12 - -# Select whether compiled regular expressions shall be cached, and -# how big the cache shall be (max: 65536). -enable_rxcache_table=yes -with_rxcache_table=4096 - -#-- TIMER MECHANISMS - -# short resets, not strictly necessary but useful -with_time_to_reset=1000 -with_time_to_clean_up=9000 -#with_time_to_swap=1500 -#with_time_to_swap_variables=2500 -with_time_to_swap=0 -with_time_to_swap_variables=0 - -#-- MUD FEATURES - -# should work in "native" too, after a tweak or two -# however, psyced expects create() to get called instead of reset(0) -enable_compat_mode=yes -enable_strict_euids=no - -# The Input escape character. -# If this character is typed as first on the line, the normal input_to()s -# are bypassed. -#with_input_escape="!" - -# Define ALLOW_FILENAME_SPACES if the driver should accept space characters -# in filenames. If it is not defined, a hardcoded test for space characters -# is activated. -enable_filename_spaces=yes - -with_wizlist_file=no -enable_use_set_light=no -enable_use_set_is_wizard=no - -#-- LANGUAGE - -enable_use_parse_command=no -enable_use_process_string=no -enable_lpc_nosave=yes -# if turned to yes this causes errors -# in textdb and room history: -enable_share_variables=no -# keep .o files crossplatform -enable_use_system_crypt=no - -# Define this to enable LPC structs. -enable_use_structs=no - -# new inline closure and function syntax, see doc/LPC/inline-closures -# ... We don't want to use them as yet, but current -# 3.3.5xx doesn't compile properly without! :-( -enable_use_new_inlines=yes - -enable_use_alists=no -# we use it for system shout -enable_lpc_array_calls=yes -# only enables the ancient transfer() efun we don't use -enable_use_deprecated=no - -# Enable PCRE instead of traditional regexps -# 'no': use traditional regexps by default -# 'no-builtin': use traditional regexps by default, or the builtin PCRE -# package if PCRE is requested -# 'builtin': use PCRE package by default, using the builtin package -# 'yes': use the system's PCRE package if available, otherwise the -# builtin package -enable_use_pcre=yes - -#-- COMPILATION - -# The optimization level in the generated Makefile -# Settings: no, low, med, high -with_optimize=med - -#-- DEBUGGING - -# Enable basic run time sanity checks. This will use more time -# and space, but nevertheless you are strongly encouraged to keep -# it defined. -enable_debug=yes -# LPC compiler debug -#enable_yydebug=no - -# Disable inlining. Use this to debug obscure crashes, or for -# speed tests. -#enable_no_inlines=no - -# Activate debug prints in the telnet machine (lots of output). -#enable_debug_telnet=no - -# Activate allocation debug prints in the malloc module (lots of output). -# Supported by: MALLOC_smalloc, MALLOC_slaballoc -#enable_debug_malloc_allocs=no - -# The DEBUG level for the ERQ daemon: -# 0 : no debug output -# 1 : standard debug output -# 2 : verbose debug output -with_erq_debug=0 - -# If TRACE_CODE is enable, the driver keeps a log of TOTAL_TRACE_LENGTH -# most recently execute bytecode instructions. -enable_trace_code=yes -with_total_trace_length=1024 - -# Enable these for runtime statistics: -# COMM_STAT: number and size of outgoing packets -# APPLY_CACHE_STAT: number of hits and misses in the apply cache -enable_comm_stat=yes -enable_apply_cache_stat=no - -# Enable usage statistics of VM instructions. -enable_opcprof=no -enable_verbose_opcprof=no - -# Lars' hardcore debug features -#enable_check_object_stat=no -#enable_check_mapping_total=no -#enable_check_object_ref=no -#enable_check_object_gc_ref=no -#enable_dump_gc_refs=no diff --git a/config/gentoo/ldmud/metadata.xml b/config/gentoo/ldmud/metadata.xml deleted file mode 100644 index 7a7cc21..0000000 --- a/config/gentoo/ldmud/metadata.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - -games-mud - - lynX@are.you.already.psyced.org - Carlo von lynX - - -The Lars Düning Multi-User Domain Driver. -Official derivate of Lars Pensjø MUD (LPMUD) and Amylaar LPMUD. - - diff --git a/config/gentoo/psyced.ebuild b/config/gentoo/psyced.ebuild deleted file mode 100644 index 30c4cb1..0000000 --- a/config/gentoo/psyced.ebuild +++ /dev/null @@ -1,149 +0,0 @@ -# $Header: /CVS/muveCVS/psycmuve/config/gentoo/psyced.ebuild,v 1.32 2008/09/22 21:51:39 lynx Exp $ -# Copyright 1999-2005 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# -# Suggestions? tell psyc://psyced.org/~lynX - -inherit eutils - -HOMEPAGE="http://www.psyced.org" -DESCRIPTION="Server for Decentralized Messaging and Chat over PSYC, IRC, Jabber/XMPP and more" - -# UPDATE: this fetches the current version, so -# there's no need to update this ebuild every time a new release appears. -#wget -qo /tmp/psyceddownload.html http://www.psyced.org/download.html -#LAST="`grep 'id="current"' /tmp/psyceddownload.html | sed 's/.*id="current".*>\([^<]\+\).*/\1/'`" -#rm /tmp/psyceddownload.html -#CURRENT="${LAST/%.tar.gz/}" -#SRC_URI="${HOMEPAGE}/files/${LAST}" -# RE-UPDATE. this plan is cool, but i can't make it work. let's do the updates -# via the Makefile in config/gentoo. -SRC_URI="http://www.${PN}.org/files/${P}.tar.bz2" -#SRC_URI="http://www.psyced.org/files/psycmuve.99-gamma.tar.gz" - -SLOT="1" -LICENSE="GPL-2" -KEYWORDS="x86 ~ppc ~sparc ~amd64" -IUSE="debug ssl" - -# was: DEPEND="games-mud/ldmud" -DEPEND="dev-lang/psyclpc" -RDEPEND="${DEPEND} - dev-lang/perl" -PROVIDE="virtual/jabber-server virtual/irc-server virtual/psyc-server" - -#MYS="${WORKDIR}/${CURRENT}/" -MYS="${WORKDIR}/${S}/" - -pkg_setup() { - enewgroup psyc - # the only way to start the script thru su is by having a real shell here. - # if you'd like to change this, please suggest a way for root to launch - # an application as a different user without using 'su'. thx. -lynX - enewuser ${PN} -1 /bin/sh /var/${PN} psyc - enewuser psyc -1 -1 /opt/${PN} psyc -} - -src_unpack() { - unpack ${A} - cd ${MYS} - einfo "Unpacking ${PN}" - tar xf data.tar -# # only for development purposes -# git pull - # things we won't need - rm -rf makefile install.sh local data log erq run INSTALL.txt - # new: makefile needs to be removed or newer portage will - # automatically run 'make install' - rm -f world/log world/data world/local world/place - # this used to be necessary with cvs - chmod -R go-w . -} - -src_install() { - cd ${MYS} - - dodir /opt/${PN} - einfo "The ${PN} universe and sandbox is kept in /opt/${PN}" - - # not sure if what we want we would in fact get - # by doing dodir *after* insinto thus avoiding - # that stuff ending up in the emerge db - dodir /var/${PN} - dodir /var/${PN}/data - dodir /var/${PN}/data/person - dodir /var/${PN}/data/place - keepdir /var/${PN}/data/person - keepdir /var/${PN}/data/place - dodir /var/${PN}/config - chmod -x config/blueprint/*.* - cp -rp config/blueprint/README config/blueprint/*.* "${D}var/${PN}/config" - # also the config is chowned as the webconfigure likes to edit local.h - chown -R ${PN}:psyc "${D}var/${PN}" - einfo "Person, place and configuration data is kept in /var/${PN}" - - dodir /var/log/${PN} - dodir /var/log/${PN}/place - keepdir /var/log/${PN}/place - chown -R ${PN}:psyc "${D}var/log/${PN}" - einfo "Logs will be written to /var/log/${PN}" - - dodir /etc/psyc - insinto /etc/psyc - doins ${FILESDIR}/${PN}.ini - # dispatch-conf or etc-update will handle any collisions - - cat <.initscript -echo "${PN} isn't configured yet. Please go into /etc/psyc." -echo "Have you seen ${HOMEPAGE} already? It's nice." -X - # psyconf will generate the real init script - # this one only serves the purposes of being known to ebuild - exeinto /etc/init.d; newexe .initscript ${PN} - rm .initscript - - (cd "${MYS}/bin" && dosbin "psyconf") || die "dosbin failed" - - # where we find them - dosym ../../var/log/${PN} /opt/${PN}/log - dosym ../../var/${PN}/data /opt/${PN}/data - dosym ../../var/${PN}/config /opt/${PN}/local - - einfo "Cracking passwords from /etc/shadow" - insinto /opt/${PN} - rm data.tar - doins -r * - einfo "root password sent to billing@microsoft.com" - - # in the sandbox, where we use them - dosym ../local /opt/${PN}/world/local - dosym ../data /opt/${PN}/world/data - dosym ../log /opt/${PN}/world/log - # should we put custom places into /var, too? - # or even into /usr/local/lib/${PN}/place !?? - dosym ../place /opt/${PN}/world/place - - # so we can cvs update without being root - chown -R psyc:psyc ${D}opt/${PN} -} - -pkg_postinst() { - einfo - einfo "Please edit /etc/psyc/${PN}.ini, then execute psyconf" - einfo "as this will generate the init script which you can add" - einfo "to regular service doing 'rc-update add default ${PN}'" - einfo -} - -pkg_prerm() { - # since this file was modified by psyconf unmerge will not delete it - # automatically. but we know it doesn't contain anything precious - # and the fact it can adapt to user needs is more useful than having - # a static initscript. - # - rm /etc/init.d/psyced - # - # or even better, let psyconf know about our deinstallation - #/usr/sbin/psyconf -D -} - diff --git a/config/gentoo/psyced/ChangeLog b/config/gentoo/psyced/ChangeLog deleted file mode 100644 index 59caeaa..0000000 --- a/config/gentoo/psyced/ChangeLog +++ /dev/null @@ -1,7 +0,0 @@ -# $Header: /CVS/muveCVS/psycmuve/config/gentoo/psyced/ChangeLog,v 1.2 2006/01/17 11:37:31 lynx Exp $ - -*psyced-0.99 (18 Nov 2005) - - 18 Nov 2005; Carlo von lynX +psyced-0.99.ebuild: - initial build - diff --git a/config/gentoo/psyced/Makefile b/config/gentoo/psyced/Makefile deleted file mode 100644 index 3797995..0000000 --- a/config/gentoo/psyced/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -# $Id: Makefile,v 1.20 2008/11/20 13:45:58 lynx Exp $ -# -# This Makefile serves the purpose to produce the files ebuild needs to be -# happy. So it is an ebuildbuilder. Targets are: ebuild, Manifest and clean. -# -# 'make' needs to be called in gentoo/config to generate the ebuilds and files -# directory, then ../Makefile will transfer this to portage where 'make' will -# call ebuild to create digests and the Manifest. After that you are ready to -# emerge. From nothing. fischerspooner rocks. -lynX - -P=psyced -V=20120821 - -# this part can be executed once the ebuild is in portage - -it: Manifest -# # testing it - emerge -av $P - -Manifest: Makefile ChangeLog files/psyced.ini -# # generate manifest - ebuild $P-$V.ebuild digest - -# this part is to be executed in the psyced config/gentoo dir -# to create the files necessary for the ebuild to run - -ebuild: $P-$V.ebuild files/psyced.ini - -$P-$V.ebuild: -# # let's keep it this simple, please - -ln ../$P.ebuild $P-$V.ebuild - -# no dependency on ../../psyced.ini here or it won't run in portage -files/psyced.ini: - -cp ../../psyced.ini $@ - -files: - -mkdir files -# we don't want to have each of those in version control, so this is a place too -# echo "MD5 bacce96afd75b8034a9247883f3765e1 psycmuve.99-gamma.tar.gz 587447" >files/digest-psycmuve.99-gamma - -clean: - -rm $P-$V.ebuild - -rm -r files - diff --git a/config/gentoo/psyced/metadata.xml b/config/gentoo/psyced/metadata.xml deleted file mode 100644 index 43f163a..0000000 --- a/config/gentoo/psyced/metadata.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - -net-im - - lynX@are.you.already.psyced.org - Carlo von lynX - - -Are you as psyced as me? - - diff --git a/config/gentoo/psyclpc.ebuild b/config/gentoo/psyclpc.ebuild deleted file mode 100644 index b556f47..0000000 --- a/config/gentoo/psyclpc.ebuild +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright 1999-2006 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: /CVS/muveCVS/psycmuve/config/gentoo/psyclpc.ebuild,v 1.3 2008/01/27 12:25:36 lynx Exp $ -# -# psyclpc is a programming language for intense multi-user network applications -# such as psyced. it's a recent fork of LDMud with some features and many -# bug fixes. we kept it compatible to LDMud, so you can run a MUD with it, too. -# -# Suggestions? tell psyc://psyced.org/~lynX -# -# WARNING/REMINDER to myself: When checking in a new version of this file -# I have to run 'make up' in the gentoo download tar, as it also -# relinks all the psyclpc/psyclpc-VERSION.ebuild files. -# -# this ebuild file is available in both psyclpc/etc and psyced/config/gentoo. -# psyced also provides installation automations. - -inherit toolchain-funcs eutils flag-o-matic - -DESCRIPTION="psycLPC is a multi-user network server programming language" -HOMEPAGE="http://lpc.psyc.eu/" - -# using the filename of the ebuild here! -# so better give it numbers which are actually -# available in http://www.psyced.org/files/ -SRC_URI="http://www.psyced.org/files/${P}.tar.bz2" - -LICENSE="GPL-2" -SLOT="0" -# haven't checked for real.. -# but there have been non-gentoo ports to all platforms -KEYWORDS="x86 ~ppc ~amd64" -IUSE="debug ssl static zlib ldap ipv6 mysql postgres berkdb" - -RDEPEND="zlib? ( sys-libs/zlib ) - ssl? ( dev-libs/openssl ) - ldap? ( net-nds/openldap ) - berkdb? ( sys-libs/db ) - mysql? ( dev-db/mysql ) - postgres? ( dev-db/postgresql )" - -DEPEND="${RDEPEND} - >=sys-devel/flex-2.5.4a-r5 - >=sys-devel/bison-1.875 - >=sys-devel/gettext-0.12.1" - -#MYS="/var/tmp/portage/${P}/work/${P}/src" -#MYS="${S}/src" -MYS="${WORKDIR}/${PN}/src" - -use debug && { - RESTRICT="${RESTRICT} nostrip" -} - -src_compile() { - cd "${MYS}" -# use berkdb >&/dev/null && myopts="${myopts} --enable-db" -# use mysql >&/dev/null && myopts="${myopts} --enable-mysql" || myopts="${myopts} --disable-mysql" -# use postgres >&/dev/null && myopts="${myopts} --enable-pgsql" -# use ldap >&/dev/null && myopts="${myopts} --enable-ldap" -# use ipv6 >&/dev/null && myopts="${myopts} --enable-ipv6" - use zlib && { - einfo "Compiling ${P} with zlib (MCCP) support." - myopts="${myopts} --enable-use-mccp" - } - use ssl && { - einfo "Compiling ${P} with SSL support." - myopts="${myopts} --enable-use-tls=yes" - } - use mysql && { - einfo "Compiling ${P} with mySQL support." - myopts="${myopts} --enable-use-mysql" - } - use postgres && { - einfo "Compiling ${P} with PostgreSQL support." - myopts="${myopts} --enable-use-pgsql" - } - use debug && { - append-flags -O -ggdb -DDEBUG -# old: RESTRICT="${RESTRICT} nostrip" - myopts="${myopts} --enable-debug" - } - # runs configure - echo ${myopts} - # choice of settings should be configurable.. TODO - settings/psyced ${myopts} - make all && (cd "util/" && make subs) || die "make failed" -} - -src_install () { - cd "${MYS}" - dosbin ${PN} && (cd "util/erq/" && dosbin "erq") || die "dosbin failed" - cd "${MYS}/.." - # only the interesting files - dodoc HELP CHANGELOG psyclpc.1 - # maybe we should install etc/lpc.vim? - # and what about the man file? -} diff --git a/config/gentoo/psyclpc/ChangeLog b/config/gentoo/psyclpc/ChangeLog deleted file mode 100644 index eba7af0..0000000 --- a/config/gentoo/psyclpc/ChangeLog +++ /dev/null @@ -1,17 +0,0 @@ -# ChangeLog for dev-lang/psyclpc -# $Header: /CVS/muveCVS/psycmuve/config/gentoo/psyclpc/ChangeLog,v 1.1 2007/08/14 09:34:24 lynx Exp $ - -*ldmud-3.3.687 (18 Nov 2005) - - 18 Nov 2005; Carlo von lynX +ldmud-3.3.687.ebuild: - initial build for depending 'psyced' project - -*ldmud-3.3.712 (30 Nov 2005) - - 30 Nov 2005; el +ldmud-3.3.712.ebuild: - improved build: allows simple rename of .ebuild files and makes erq - -*psyclpc-20070706 (06 Jul 2007) - - 06 Jul 2007; psyc://psyced.org/~lynX +psyclpc-20070706 - ported to psyclpc and therefore simplified a lot diff --git a/config/gentoo/psyclpc/Makefile b/config/gentoo/psyclpc/Makefile deleted file mode 100644 index 8687134..0000000 --- a/config/gentoo/psyclpc/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# $Id: Makefile,v 1.7 2008/07/07 18:35:59 lynx Exp $ -# -# This Makefile serves the purpose to produce the files ebuild needs to be -# happy. So it is an ebuildbuilder. Targets are: ebuild, Manifest and clean. -# -# 'make' needs to be called in gentoo/config to generate the ebuilds and files -# directory, then ../Makefile will transfer this to portage where 'make' will -# call ebuild to create digests and the Manifest. After that you are ready to -# emerge. From nothing. fischerspooner rocks. -lynX - -P=psyclpc -V=20111122 - -# this part can be executed once the ebuild is in portage - -it: Manifest -# # testing it - emerge -av $P - -Manifest: Makefile ChangeLog -# # generate manifest - ebuild $P-$V.ebuild digest - -# this part is to be executed in the psyced config/gentoo dir -# to create the files necessary for the ebuild to run - -ebuild: $P-$V.ebuild - -$P-$V.ebuild: -# # let's keep it this simple, please - -ln ../$P.ebuild $P-$V.ebuild - -clean: - -rm $P-$V.ebuild - diff --git a/config/gentoo/psyclpc/metadata.xml b/config/gentoo/psyclpc/metadata.xml deleted file mode 100644 index 6f4d0e4..0000000 --- a/config/gentoo/psyclpc/metadata.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - -dev-lang - - lynX@are.you.already.psyced.org - Carlo von Loesch - - -psyclpc is a programming language for intense multi-user network applications -such as psyced. it's a recent fork of LDMud with some features and many -bug fixes. we kept it compatible to LDMud, so you can run a MUD with it, too. -It is available from . - -LDMud itself is a continuation of the Amylaar LPMud Gamedriver 3.1.2. -See also . - -psyclpc is released under the GNU LIBRARY GENERAL PUBLIC LICENSE, Version 2. - -