debian/0000755000000000000000000000000012263373537007201 5ustar debian/watch0000644000000000000000000000051611610274412010217 0ustar # Example watch control file for uscan # Rename this file to "watch" and then you can run the "uscan" command # to check for upstream updates and more. # See uscan(1) for format # Compulsory line, this is a version 3 file version=3 # http://www.fefe.de/gatling/ http://dl.fefe.de/gatling-(.*)\.tar\.bz2 debian/index.html0000644000000000000000000000035211610305725011163 0ustar Gatling Webserver

It works!

This is the default web page for this Gatling server.

The web server software is running but no content has been added, yet.

debian/clean0000644000000000000000000000017711657542233010210 0ustar gatling-bench gatling-bench.1 gatling-dl gatling-dl.1 tlsgatling.1 tlsgatling.BACKUP ptlsgatling.1 ptlsgatling.BACKUP writelog debian/init0000755000000000000000000000262511621741455010072 0ustar #!/bin/sh ### BEGIN INIT INFO # Provides: gatling # Required-Start: $network $remote_fs # Required-Stop: $network $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Gatling # Description: Gatling - High performance webserver and fileserver ### END INIT INFO . /lib/lsb/init-functions LOGFILE=/var/log/gatling.log DAEMON=tlsgatling # Include defaults if available if [ -f /etc/default/gatling ] ; then . /etc/default/gatling fi start() { if [ "$START_DAEMON" != "YES" ] ; then log_warning_msg "Not starting Gatling (edit /etc/default/gatling to enable)" exit 0 ; fi log_daemon_msg "Starting Gatling" "$DAEMON" start-stop-daemon --pidfile /var/run/gatling.pid --make-pidfile \ --background --exec /usr/bin/writelog --start -- \ /var/log/gatling.log /usr/bin/$DAEMON $DAEMON_OPTS log_end_msg 0 } stop() { log_daemon_msg "Stopping Gatling" "$DAEMON" start-stop-daemon --oknodo --pidfile /var/run/gatling.pid --stop --retry 10 log_end_msg 0 } hup() { log_daemon_msg "Stopping Gatling" "$DAEMON" start-stop-daemon --oknodo --pidfile /var/run/gatling.pid --stop --signal HUP --retry 10 log_end_msg 0 } restart() { stop start } reload() { hup start } case "$1" in start) start ;; stop) stop ;; restart|force-reload) restart ;; reload) reload ;; *) log_success_msg "Usage: $0 {start|stop|reload|restart}" exit 1 esac debian/default0000644000000000000000000000072511657744130010551 0ustar # Defaults for gatling initscript # sourced by /etc/init.d/gatling # installed at /etc/default/gatling by the maintainer scripts # # This is a POSIX shell fragment # # # uncomment the next line run gatling automatically at startup # #START_DAEMON="YES" # # Gatling options # DAEMON_OPTS="-e -v -D -S -F -U -u nobody -c /var/www" # # Choose daemon in use. Default is TLS-enabled tlsgatling # Alternatives: gatling, ptlsgatling (PolarSSL version) # #DAEMON="gatling" debian/debian/0000755000000000000000000000000011431535774010422 5ustar debian/debian/patches/0000755000000000000000000000000011431535774012051 5ustar debian/debian/patches/series0000644000000000000000000000003211431535774013261 0ustar fix-manpage-sections.diff debian/rules0000755000000000000000000000152612045455020010247 0ustar #!/usr/bin/make -f CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS) CFLAGS:=$(shell dpkg-buildflags --get CFLAGS) $(CPPFLAGS) CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS) $(CPPFLAGS) LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS) %: dh $@ writelog: writelog.c $(CC) $(CFLAGS) $(LDFLAGS) -Wall -o $@ $< override_dh_auto_build: writelog make DIET= ptlsgatling mv ptlsgatling ptlsgatling.BACKUP make clean make DIET= tlsgatling mv tlsgatling tlsgatling.BACKUP make clean make DIET= gatling bench dl mv tlsgatling.BACKUP tlsgatling mv ptlsgatling.BACKUP ptlsgatling cp -a bench gatling-bench cp -a bench.1 gatling-bench.1 cp -a dl gatling-dl cp -a dl.1 gatling-dl.1 cp -a gatling.1 tlsgatling.1 cp -a gatling.1 ptlsgatling.1 override_dh_installchangelogs: dh_installchangelogs CHANGES # empty targets override_dh_auto_install: debian/install0000644000000000000000000000024211657542265010572 0ustar gatling usr/bin tlsgatling usr/bin ptlsgatling usr/bin gatling-bench usr/bin gatling-dl usr/bin writelog usr/bin debian/index.html usr/share/gatling/default-site debian/README.Debian0000644000000000000000000000372511657746171011255 0ustar gatling for Debian ================== Startup ------- The daemon is started via "/etc/init.d/gatling start". To automatically start it on bootup, edit /etc/default/gatling and set "START_DAEMON" to "YES" (as documented there). You can also configure gatling options there. By default, gatling chroots to /var/www and serves a default index.html from /var/www/default. HTTP and HTTPS with tlsgatling ------------------------------ The following applies to tlsgatling, the SSL-enabled OpenSSL linked version of gatling. This is the default in Debian. By default, Gatling serves HTTP on port 80 and HTTPS on port 443 (defaults). HTTP should work out of the box when the daemon is first started up. However, the necessary certificates for HTTPS (via OpenSSL) are not available by default and you need to generate them yourself (or let some authority do it for you). For a self-signed server.pem certificate, you can do the following: $ dd if=/dev/random of=rand.dat bs=1024 count=1 $ openssl genrsa -out cakey.key -rand rand.dat 2048 $ openssl req -new -key cakey.key -out cakey.csr $ openssl x509 -req -days 1780 -set_serial 1 -in cakey.csr -signkey cakey.key -out cakey.pem $ cat cakey.key cakey.pem > server.pem You must copy server.pem to the web server root, (/var/www by default) Further, gatling chroots to the webserver root directory. When using HTTPS via libssl, it needs /dev/random and/or /dev/urandom. You can create this with for example (as root): # mkdir /var/www/dev # cp -a /dev/random /dev/urandom /var/www/dev At this point, HTTPS should be working. Besides tlsgatling, there is also gatling (Non-SSL version) and ptlsgatling (PolarSSL version) available. You can choose one of them in /etc/default/gatling. Other protocols (FTP, SMB) -------------------------- For the other protocols (FTP, SMB), you need to explicitly enable support via command line options in /etc/default/gatling. -- Roland Stigge , Sat, 16 Jul 2011 14:19:54 +0200 debian/logrotate0000644000000000000000000000037011626502272011114 0ustar /var/log/gatling.log { weekly missingok rotate 52 compress delaycompress notifempty create 640 root adm sharedscripts postrotate start-stop-daemon --oknodo --pidfile /var/run/gatling.pid --stop --signal USR1 >/dev/null 2>&1 endscript } debian/copyright0000644000000000000000000000322011621545711011121 0ustar This work was packaged for Debian by: Vedran Furač on Sun, 07 Feb 2010 20:20:35 +0100 Roland Stigge on Sat, 13 Aug 2011 21:08:46 +0200 It was downloaded from: http://www.fefe.de/gatling/ Upstream Author: Felix von Leitner Copyright: Copyright (C) 2010 Felix von Leitner License: This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see On Debian systems, the complete text of the GNU General Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". In the man page, the author notes: LICENSE GPLv2 (see http://www.gnu.org/copyleft/gpl.html) with an exception to allow linking against openssl. The Debian packaging is: Copyright (C) 2010 Vedran Furač Copyright (C) 2011 Roland Stigge you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. debian/postrm0000644000000000000000000000056111610310721010427 0ustar #!/bin/sh set -e if [ "$1" = remove ] ; then MD5SUM="`md5sum /var/www/default/index.html 2>/dev/null | cut -d ' ' -f 1`" case "$MD5SUM" in 4f264ae5fc7173e43656d985e833e213) rm -f /var/www/default/index.html rmdir --ignore-fail-on-non-empty /var/www/default ;; esac fi #DEBHELPER# exit 0 debian/docs0000644000000000000000000000037311604070636010047 0ustar README README.antidos README.bindbench README.cgi README.forkbench README.ftp README.htaccess README.http README.httpbench README.manymapbench README.mmapbench README.performance README.php README.prefetch README.proxy README.redirect README.tls TODO debian/source/0000755000000000000000000000000011356221253010466 5ustar debian/source/format0000644000000000000000000000001411333616700011674 0ustar 3.0 (quilt) debian/patches/0000755000000000000000000000000012236002117010607 5ustar debian/patches/06-cgi-fix.patch0000644000000000000000000000251711762443166013426 0ustar Description: CGI handling fix This patch fixes CGI issues like this: . ========================================================================= accept 8 192.168.32.2 38021 6 http POST/CGI 8 /configupload.cgi 0 Mozilla/5.0_(X11;_Linux_i686_on_x86_64;_rv:6.0.2)_Gecko/20100101_Firefox/6.0.2_Iceweasel/6.0.2 http://192.168.32.3/ 192.168.32.3 cgi_fork 8 9 3459 http_postdata_write_error 9 Broken pipe close/acceptfail 9 ========================================================================= . H->still_to_copy is synchronized with h->still_to_copy at a point where it contained 0 and the value of h->still_to_copy is more useful. The issue was forwarded upstream to gatling@fefe.de at 2011-12-06 Author: Roland Stigge Index: gatling-0.12cvs20120601/http.c =================================================================== --- gatling-0.12cvs20120601.orig/http.c 2012-04-11 01:07:01.000000000 +0200 +++ gatling-0.12cvs20120601/http.c 2012-06-02 18:59:21.000000000 +0200 @@ -2305,8 +2305,10 @@ /* we wrote everything we have in the buffer */ io_dontwantwrite(i); /* check if we need to copy more data */ - if (h->still_to_copy) + if (h->still_to_copy) { + H->still_to_copy = h->still_to_copy; io_wantread(h->buddy); + } } if (h->still_to_copy==0) { /* we got all we asked for */ debian/patches/09-new-libpolarssl.patch0000644000000000000000000000673712236002114015205 0ustar Description: Adjust pssl.c to new libpolarssl This patch adjusts gatling's polarssl support to polarssl 1.3.x Author: Roland Stigge --- gatling-0.13.orig/pssl.c +++ gatling-0.13/pssl.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include "mmap.h" @@ -28,95 +29,21 @@ havege_state hs; int my_ciphersuites[] = { - SSL_EDH_RSA_AES_256_SHA, - SSL_EDH_RSA_CAMELLIA_256_SHA, - SSL_EDH_RSA_AES_128_SHA, - SSL_EDH_RSA_CAMELLIA_128_SHA, - SSL_EDH_RSA_DES_168_SHA, - SSL_RSA_AES_256_SHA, - SSL_RSA_CAMELLIA_256_SHA, - SSL_RSA_AES_128_SHA, - SSL_RSA_CAMELLIA_128_SHA, - SSL_RSA_DES_168_SHA, - SSL_RSA_RC4_128_SHA, - SSL_RSA_RC4_128_MD5, + TLS_DHE_RSA_WITH_AES_256_CBC_SHA, + TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA, + TLS_DHE_RSA_WITH_AES_128_CBC_SHA, + TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA, + TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, + TLS_RSA_WITH_AES_256_CBC_SHA, + TLS_RSA_WITH_CAMELLIA_256_CBC_SHA, + TLS_RSA_WITH_AES_128_CBC_SHA, + TLS_RSA_WITH_CAMELLIA_128_CBC_SHA, + TLS_RSA_WITH_3DES_EDE_CBC_SHA, + TLS_RSA_WITH_RC4_128_SHA, + TLS_RSA_WITH_RC4_128_MD5, 0 }; -/* - * These session callbacks use a simple chained list - * to store and retrieve the session information. - */ -ssl_session *s_list_1st = NULL; -ssl_session *cur, *prv; - -static int my_get_session( ssl_context *ssl ) -{ - time_t t = time( NULL ); - - if( ssl->resume == 0 ) - return( 1 ); - - cur = s_list_1st; - prv = NULL; - - while( cur != NULL ) - { - prv = cur; - cur = cur->next; - - if( ssl->timeout != 0 && t - prv->start > ssl->timeout ) - continue; - - if( ssl->session->ciphersuite != prv->ciphersuite || - ssl->session->length != prv->length ) - continue; - - if( memcmp( ssl->session->id, prv->id, prv->length ) != 0 ) - continue; - - memcpy( ssl->session->master, prv->master, 48 ); - return( 0 ); - } - - return( 1 ); -} - -static int my_set_session( ssl_context *ssl ) -{ - time_t t = time( NULL ); - - cur = s_list_1st; - prv = NULL; - - while( cur != NULL ) - { - if( ssl->timeout != 0 && t - cur->start > ssl->timeout ) - break; /* expired, reuse this slot */ - - if( memcmp( ssl->session->id, cur->id, cur->length ) == 0 ) - break; /* client reconnected */ - - prv = cur; - cur = cur->next; - } - - if( cur == NULL ) - { - cur = (ssl_session *) malloc( sizeof( ssl_session ) ); - if( cur == NULL ) - return( 1 ); - - if( prv == NULL ) - s_list_1st = cur; - else prv->next = cur; - } - - memcpy( cur, ssl->session, sizeof( ssl_session ) ); - - return( 0 ); -} - static int my_net_recv( void *ctx, unsigned char *buf, size_t len ) { int sock=(int)(uintptr_t)ctx; return net_recv(&sock,buf,len); @@ -178,9 +105,8 @@ fail: ssl_set_authmode( ssl, SSL_VERIFY_NONE ); ssl_set_rng( ssl, havege_random, &hs ); ssl_set_bio( ssl, my_net_recv, (void*)(uintptr_t)sock, my_net_send, (void*)(uintptr_t)sock ); - ssl_set_scb( ssl, my_get_session, my_set_session ); ssl_set_ciphersuites( ssl, my_ciphersuites ); - ssl_set_session( ssl, 1, 0, ssn ); + ssl_set_session( ssl, ssn ); ssl_set_ca_chain( ssl, srvcert.next, NULL, NULL ); ssl_set_own_cert( ssl, &srvcert, &rsa ); debian/patches/08-cgi-post-fix.patch0000644000000000000000000000137111762443627014412 0ustar Description: CGI POST fix This patch fixes the issue that the first 0-Byte in the payload was always replaced with a space character (0x20) in the local CGI case, breaking CGI POST uploads. Therefore I removed the respective line from http.c. Author: Roland Stigge Index: gatling-0.12cvs20120601/http.c =================================================================== --- gatling-0.12cvs20120601.orig/http.c 2012-06-02 19:04:15.000000000 +0200 +++ gatling-0.12cvs20120601/http.c 2012-06-02 19:04:15.000000000 +0200 @@ -704,7 +704,6 @@ size_t reqlen; char* req=array_start(&ctx_for_sockfd->r); /* "GET /t.cgi/foo/bar?fnord HTTP/1.0\r\nHost: localhost:80\r\n\r\n"; */ char ra[IP6_FMT]; - req[strlen(req)]=' '; { char* tmp; debian/patches/05-manpage-dotfiles.patch0000644000000000000000000000140511664527434015313 0ustar Description: Add dotfile handling documentation to manpage This patch documents the way .dotfiles are handled to the manpage Author: Roland Stigge Bug-Debian: http://bugs.debian.org/649636 --- gatling-0.12cvs20111112.orig/gatling.1 +++ gatling-0.12cvs20111112/gatling.1 @@ -100,6 +100,10 @@ It is also possible to specify a Unix Do -\fB-O [flag/]|filename|regex\fR. Remember to put the argument in quotes when typing it in the shell. +Gatling will not serve or list dotfiles unless they are aliased with +:dotfile, e.g. to enable serving .dotfile, you have to ln -s .dotfile +":dotfile". + .SH "SIGNALS" Sending gatling SIGHUP will make it close all the server sockets (so you can start a new gatling process with different options on the same debian/patches/03-manpage-dl.patch0000644000000000000000000000103611610355245014065 0ustar Description: Man page for dl This patch adds the manpage for the "dl" utility Author: Roland Stigge --- /dev/null +++ gatling-0.12/dl.1 @@ -0,0 +1,14 @@ +.TH dl 1 +.SH NAME +dl \- download utility +.SH SYNOPSIS +.B dl [OPTIONS] URL +.SH DESCRIPTION +dl is a small utility to download files from HTTP, FTP and SMB URLs. + +.SH "AUTHOR" +Initially written by Felix von Leitner . + +.SH "LICENSE" +GPLv2 (see http://www.gnu.org/copyleft/gpl.html) with an exception to +allow linking against openssl. debian/patches/02-adjust-makefile.patch0000644000000000000000000000316412045460256015132 0ustar Description: Makefile fixes This patch changes the GNUmakefile to ignore local files lying around on build and adjusts to the standard Debian build, including optimization options and build error handling Author: Roland Stigge Index: gatling-0.13/GNUmakefile =================================================================== --- gatling-0.13.orig/GNUmakefile 2012-11-04 13:04:23.372453811 +0100 +++ gatling-0.13/GNUmakefile 2012-11-04 13:33:40.440500862 +0100 @@ -16,8 +16,8 @@ CROSS= #CROSS=i686-mingw32- CC=$(CROSS)gcc -CFLAGS=-pipe -Wall -LDFLAGS= +CFLAGS+=-pipe -Wall +#LDFLAGS= #CFLAGS+=-DSTATE_DEBUG -DMOREDEBUG -DDEBUG_EVENTS -DSMDEBUG @@ -36,16 +36,9 @@ # to build without diet libc support, use $ make DIET= # see http://www.fefe.de/dietlibc/ for details about the diet libc -ifneq ($(DEBUG),) -CFLAGS+=-g -LDFLAGS+=-g -else -CFLAGS+=-O2 -fomit-frame-pointer -I/usr/local/include -LDFLAGS+=-s ifneq ($(DIET),) DIET+=-Os endif -endif LDLIBS=-lowfat @@ -54,11 +47,12 @@ LDLIBS+=-lz endif -libowfat_path = $(strip $(foreach dir,../libowfat*,$(wildcard $(dir)/textcode.h))) -ifneq ($(libowfat_path),) -CFLAGS+=$(foreach fnord,$(libowfat_path),-I$(dir $(fnord))) -LDFLAGS+=$(foreach fnord,$(libowfat_path),-L$(dir $(fnord))) -endif +# Debian: don't depend on other source files lying around +#libowfat_path = $(strip $(foreach dir,../libowfat*,$(wildcard $(dir)/textcode.h))) +#ifneq ($(libowfat_path),) +#CFLAGS+=$(foreach fnord,$(libowfat_path),-I$(dir $(fnord))) +#LDFLAGS+=$(foreach fnord,$(libowfat_path),-L$(dir $(fnord))) +#endif ifneq ($(REDIRECT),) CFLAGS+="-DREDIRECT=\"$(REDIRECT)\"" debian/patches/series0000644000000000000000000000026712045443457012047 0ustar 01-fix-manpage-sections.patch 02-adjust-makefile.patch 03-manpage-dl.patch 05-manpage-dotfiles.patch 06-cgi-fix.patch 07-writelog.patch 08-cgi-post-fix.patch 09-new-libpolarssl.patch debian/patches/01-fix-manpage-sections.patch0000644000000000000000000000150311657532752016111 0ustar Description: Manpage fix This patch fixes the section of some man pages Author: Roland Stigge Index: gatling-0.12cvs20111112/bench.1 =================================================================== --- gatling-0.12cvs20111112.orig/bench.1 2011-11-12 19:05:07.000000000 +0100 +++ gatling-0.12cvs20111112/bench.1 2011-11-12 19:05:11.000000000 +0100 @@ -1,4 +1,4 @@ -.TH bench 8 +.TH bench 1 .SH NAME bench \- http benchmark .SH SYNOPSIS Index: gatling-0.12cvs20111112/gatling.1 =================================================================== --- gatling-0.12cvs20111112.orig/gatling.1 2011-11-12 19:05:07.000000000 +0100 +++ gatling-0.12cvs20111112/gatling.1 2011-11-12 19:05:11.000000000 +0100 @@ -1,4 +1,4 @@ -.TH gatling 8 +.TH gatling 1 .SH NAME gatling \- high performance file server .SH SYNOPSIS debian/patches/07-writelog.patch0000644000000000000000000001775411621773536013747 0ustar Description: Writelog utility This patch adds the C program writelog that takes care of gatling's logfile output from stdout, writing to a logfile that can be logrotated. Author: Roland Stigge --- /dev/null +++ gatling-0.12/writelog.c @@ -0,0 +1,291 @@ +/* + * writelog.c - writes output of a daemon to a logfile, logrotatable + * + * Copyright (C) 2011 Roland Stigge + * + * Writelog is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Writelog is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Writelog; if not, see . + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define WITH_TIMESTAMP +#define BUFSIZE 4096 + +int terminate_flag = 0; +int reopen_flag = 0; +int sighup_flag = 0; + +/* Handle signals: + SIGTERM (exit) + SIGUSR1 (reopen logfile by writelog) + SIGHUP (delegate to gatling - close listening sockets and exit after serving) + */ + +void sigterm_handler(int signum) { + terminate_flag = 1; +} + +struct sigaction sigterm = { + .sa_handler = sigterm_handler, + .sa_flags = SA_RESTART, +}; + +void sigusr1_handler(int signum) { + reopen_flag = 1; +} + +struct sigaction sigusr1 = { + .sa_handler = sigusr1_handler, + .sa_flags = SA_RESTART, +}; + +void sighup_handler(int signum) { + sighup_flag = 1; +} + +struct sigaction sighup = { + .sa_handler = sighup_handler, + .sa_flags = SA_RESTART, +}; + +void usage(void) { + printf("usage: writelog \n"); +} + +static void write_block(int fd, char* buffer, int size) { + int offset = 0; + int written; + + do { + written = write(fd, &buffer[offset], size - offset); + if (written == -1) { + fprintf(stderr, "Error on write(): %s\n", strerror(errno)); + exit(1); + } + offset += written; + } while (offset != size); +} + +#ifdef WITH_TIMESTAMP +static void write_timestamped(int fd, char* buffer, int size) { + int offset = 0; + time_t t; + int t_len; + char t_string[100]; + static int write_timestamp = 1; // flag; initially, write timestamp + + t = time(NULL); // current time + if (ctime_r(&t, t_string) != &t_string[0]) { // format it + fprintf(stderr, "Error on ctime_r(): %s\n", strerror(errno)); + exit(1); + } + + t_len = strlen(t_string); + t_string[t_len - 1] = ' '; // replace trailing newline with space + + while (offset != size) { + int chunksize = 0; + + // find end of line + while (offset + chunksize < size && buffer[offset + chunksize] != '\n') { + chunksize++; + } + if (offset + chunksize < size && buffer[offset + chunksize] == '\n') { + chunksize++; + } + + if (write_timestamp) + write_block(fd, t_string, t_len); + write_block(fd, &buffer[offset], chunksize); + write_timestamp = 1; + offset += chunksize; + } + + if (size) { + if (buffer[size - 1] == '\n') // write timestamp next time? + write_timestamp = 1; + else + write_timestamp = 0; + } +} +#endif + +int main(int argc, char* argv[]) { + int pipefds[2]; // read fd, write fd + int pid; + int res; + char buffer[BUFSIZE]; + int logfd; + + if (argc < 3) { + usage(); + exit(1); + } + + if (pipe(&pipefds[0])) { + fprintf(stderr, "Error on pipe(): %s\n", strerror(errno)); + exit(1); + } + + pid = fork(); + if (pid == (pid_t)0) { // child process + if (close(pipefds[0])) { + fprintf(stderr, "Error on close(): %s\n", strerror(errno)); + exit(1); + } + + res = dup2(pipefds[1], 1); // stdout of child redirects to pipe + if (res < 0) { + fprintf(stderr, "Error on dup2(): %s\n", strerror(errno)); + exit(1); + } + res = dup2(pipefds[1], 2); // stderr of child redirects to pipe + if (res < 0) { + fprintf(stderr, "Error on dup2(): %s\n", strerror(errno)); + exit(1); + } + + res = execvp(argv[2], &argv[2]); // normally, doesn't return + if (res == -1) { + fprintf(stderr, "Error on execvp(): %s\n", strerror(errno)); + } else { + fprintf(stderr, "Error: execvp() returned %d\n", res); + } + exit(1); + } else if (pid < 0) { // error + fprintf(stderr, "Error on fork(): %s\n", strerror(errno)); + exit(1); + } + + // parent + if (close(pipefds[1])) { + fprintf(stderr, "Error on close(): %s\n", strerror(errno)); + exit(1); + } + + // register signal handlers + res = sigaction(SIGTERM, &sigterm, NULL); + if (res == -1) { + fprintf(stderr, "Error on sigaction(): %s\n", strerror(errno)); + exit(1); + } + + res = sigaction(SIGUSR1, &sigusr1, NULL); + if (res == -1) { + fprintf(stderr, "Error on sigaction(): %s\n", strerror(errno)); + exit(1); + } + + res = sigaction(SIGHUP, &sighup, NULL); + if (res == -1) { + fprintf(stderr, "Error on sigaction(): %s\n", strerror(errno)); + exit(1); + } + + logfd = open(argv[1], O_WRONLY | O_APPEND | O_CREAT, + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + if (logfd < 0) { + fprintf(stderr, "Error on logfile open(): %s\n", strerror(errno)); + exit(1); + } + + // main loop + do { + fd_set set; + + FD_ZERO(&set); + FD_SET(pipefds[0], &set); + + res = select(FD_SETSIZE, &set, NULL, NULL, NULL); + if (res == 1) { // data + int got; + + got = read(pipefds[0], buffer, BUFSIZE); + if (got == -1) { + fprintf(stderr, "Error on read(): %s\n", strerror(errno)); + exit(1); + } else if (got > 0) { +#ifdef WITH_TIMESTAMP + write_timestamped(logfd, buffer, got); +#else + write_block(logfd, buffer, got); +#endif + } else { + fprintf(stderr, "Warning: Unhandled return value %d from read()\n", got); + } + } else if (res == -1) { // error + if (errno != EINTR) { // EINTR for signal is OK + fprintf(stderr, "Error on signal(): %s\n", strerror(errno)); + exit(1); + } + } else { // + fprintf(stderr, "Unknown return from on signal(): %d\n", res); + exit(1); + } + + if (terminate_flag) { + kill(pid, SIGTERM); + } + + if (sighup_flag) { + kill(pid, SIGHUP); + terminate_flag = 1; + } + + if (reopen_flag) { + if (close(logfd)) { + fprintf(stderr, "Error on logfd close(): %s\n", strerror(errno)); + exit(1); + } + logfd = open(argv[1], O_WRONLY | O_APPEND | O_CREAT, + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + if (logfd < 0) { + fprintf(stderr, "Error on logfile open(): %s\n", strerror(errno)); + exit(1); + } + + reopen_flag = 0; + } + } while (!terminate_flag); + + if (close(logfd)) { + fprintf(stderr, "Error on logfd close(): %s\n", strerror(errno)); + exit(1); + } + + if (!sighup_flag) { // on sighup, just leave old gatling process alone + res = wait(NULL); // wait for the child to terminate + if (res == -1) { + fprintf(stderr, "Error on wait(): %s\n", strerror(errno)); + exit(1); + } + } + + return 0; +} + --- /dev/null +++ gatling-0.12/writelog.1 @@ -0,0 +1,33 @@ +.TH writelog 1 "14 August 2011" "Version 1" "Writelog Manual" + +.SH NAME +writelog \- Logfile writing daemon for gatling + +.SH SYNOPSIS +writelog LOGFILE CMDLINE + +.SH DESCRIPTION +.B Writelog +is a daemon that writes the logfile of gatling. Gatling only writes to stdout, +so writelog enables logrotation of this data stream by providing a handler of +SIGUSR1 for closing and reopening the specified logfile. + +The following signals are handled by writelog: +.TP +.BR +SIGTERM +Terminates writelog and its child (gatling). +.TP +.BR +SIGUSR1 +Causes writelog to reopen the logfile. Useful for logrotation. +.TP +.BR +SIGHUP +Delegates SIGHUP to gatling. + +.SH EXAMPLES +writelog /var/log/gatling.log tlsgatling \-e \-v \-D \-S \-F \-U \-u nobody + +.SH AUTHOR +Roland Stigge debian/compat0000644000000000000000000000000212045454316010370 0ustar 9 debian/control0000644000000000000000000000206712142725062010577 0ustar Source: gatling Section: net Priority: optional Maintainer: Vedran Furač Uploaders: Roland Stigge Build-Depends: debhelper (>= 9), libowfat-dev (>= 0.29-2), procps, zlib1g-dev, libssl-dev, libpolarssl-dev (>= 1.2.0) Standards-Version: 3.9.4 Homepage: http://www.fefe.de/gatling/ Package: gatling Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, libowfat0 (>= 0.29-2) Description: high performance web server and file server Features: * Small (125k Linux-x86 binary with HTTP, FTP and SMB support) * Fast (measure for yourself, please) * Scalable * Uses platform-specific performance and scalability APIs * connection keep-alive * IPv6 support * transparent content negotiation * With optional directory index generation * Will only serve world readable files * Supports FTP and FTP upload as well * CGI support for HTTP, also SCGI and FastCGI (over IP sockets) * .htaccess support * Can detect some common mime types itself, like file(1) * Read-only SMB support debian/postinst0000644000000000000000000000034411610313556010776 0ustar #!/bin/sh set -e if [ "$1" = configure ] ; then if [ ! -e /var/www/default/index.* ] ; then mkdir -p /var/www/default cp /usr/share/gatling/default-site/index.html /var/www/default/index.html fi fi #DEBHELPER# exit 0 debian/changelog0000644000000000000000000001157612263373537011065 0ustar gatling (0.13-5build1) trusty; urgency=medium * No-change rebuild against libpolarssl5. -- Colin Watson Thu, 09 Jan 2014 01:11:56 +0000 gatling (0.13-5) unstable; urgency=low * Fix FTBFS by adjusting to new polarssl API (Closes: #728625) -- Roland Stigge Mon, 04 Nov 2013 21:29:38 +0100 gatling (0.13-4) unstable; urgency=low * Integrate new upstream version 0.13 into unstable, fixes build issue (Closes: #707370) -- Roland Stigge Thu, 09 May 2013 15:51:14 +0200 gatling (0.13-3) experimental; urgency=low * Fix symbol lookup error via versioned dependency on libowfat (Closes: #704697) -- Roland Stigge Fri, 05 Apr 2013 11:26:50 +0200 gatling (0.13-2) experimental; urgency=low * debian/control: Build-Depends: libpolarssl-dev (>= 1.2.0-1) -- Roland Stigge Sun, 04 Nov 2012 14:45:22 +0100 gatling (0.13-1) experimental; urgency=low * New upstream release -- Roland Stigge Sat, 03 Nov 2012 15:47:03 +0100 gatling (0.12cvs20120601-1) unstable; urgency=low * New upstream release - Removed 04-fix-ptlsgatling-usage.patch, fixed upstream now -- Roland Stigge Sat, 02 Jun 2012 19:00:17 +0200 gatling (0.12cvs20120114-2) unstable; urgency=low * Adding two patches to fix CGI POST uploads -- Roland Stigge Sun, 22 Jan 2012 17:51:40 +0100 gatling (0.12cvs20120114-1) unstable; urgency=low * New upstream CVS snapshot - Fixes PolarSSL usage (Closes: #655777) * Adding patch to fix bad polarssl usage (wrong argument order of md5_finish) -- Roland Stigge Sat, 14 Jan 2012 14:25:43 +0100 gatling (0.12cvs20111112-3) unstable; urgency=low * Fixed patch header of 05-manpage-dotfiles.patch -- Roland Stigge Sun, 27 Nov 2011 22:44:48 +0100 gatling (0.12cvs20111112-2) unstable; urgency=low * Included dotfile handling documentation into manpage, thanks to Benjamin Valentin (Closes: #649636) -- Roland Stigge Sun, 27 Nov 2011 22:12:24 +0100 gatling (0.12cvs20111112-1) unstable; urgency=low * New upstream CVS snapshot, including many bugfixes * Removed patches that are already present in upstream * Added ptlsgatling (PolarSSL version) in addition to tlsgatling (OpenSSL version), adding necessary build-dependencies -- Roland Stigge Sat, 12 Nov 2011 19:44:26 +0100 gatling (0.12-9) unstable; urgency=low * /etc/logrotate.d/gatling: Ignore errors on non-running daemon -- Roland Stigge Sun, 28 Aug 2011 20:11:22 +0200 gatling (0.12-8) unstable; urgency=low * Fixed /etc/logrotate.d/gatling: Group nobody -> adm -- Roland Stigge Mon, 15 Aug 2011 13:41:52 +0200 gatling (0.12-7) unstable; urgency=low * Added patch to fix setrlimit() bug (0 file descriptors available on VServers where EUID == 0, but no arbitrary setrlimit() allowed * Fixed init.d script output (missing newline) * debian/rules: Set -DSUPPORT_HTTPS for all objects in tlsgatling and separate out tlsgatling to separate "make" call (Closes: #634096) * Added writelog.c to provide a logrotatable alternative to former logsave from e2fsprogs * Added /etc/logrotate.d/gatling * Added CHANGES * Added patch from upstream CVS: - 08-fix-double-close-fd.patch from http.c rev 1.32 -- Roland Stigge Sat, 13 Aug 2011 20:44:08 +0200 gatling (0.12-6) unstable; urgency=low * Integrated ranges and FastCGI bugfixes from upstream (Closes: #636361) -- Roland Stigge Wed, 03 Aug 2011 21:56:23 +0200 gatling (0.12-5) unstable; urgency=low * Fixed debian/watch * Added /etc/init.d/gatling and /etc/default/gatling * Added default index.html, adapted from apache 2 package * Added postinst and postrm to add/remove default index.html * Added download tool "dl" as /usr/bin/gatling-dl -- Roland Stigge Sat, 16 Jul 2011 13:43:39 +0200 gatling (0.12-4) unstable; urgency=low * Removed temporary fix for tlsgatling since libowfat is a shared lib now -- Roland Stigge Sat, 09 Jul 2011 22:02:18 +0200 gatling (0.12-3) unstable; urgency=low * Added README.php from upstream to binary package * debian/control: Standards-Version: 3.9.2 -- Roland Stigge Sun, 03 Jul 2011 15:41:11 +0200 gatling (0.12-2) unstable; urgency=low * Plain and TLS version linked dynamically * Use debhelper instead of cdbs -- Roland Stigge Wed, 15 Dec 2010 18:09:54 +0100 gatling (0.12-1) unstable; urgency=low * New upstream release (Closes: #568039) -- Vedran Furač Sat, 14 Aug 2010 15:05:14 +0200 gatling (0.11-1) unstable; urgency=low * Initial release (Closes: #568039) -- Vedran Furač Sun, 07 Feb 2010 20:20:35 +0100 debian/dirs0000644000000000000000000000005711610310127010044 0ustar usr/bin usr/share/gatling/default-site var/www debian/manpages0000644000000000000000000000011511657542300010704 0ustar gatling.1 tlsgatling.1 ptlsgatling.1 gatling-bench.1 gatling-dl.1 writelog.1