From 1ab12ecd87cb0bcda2895889ee628236c73de724 Mon Sep 17 00:00:00 2001 From: Simon Wesp Date: Jan 25 2011 16:43:26 +0000 Subject: Merge branch 'master' into el5 --- diff --git a/.gitignore b/.gitignore index e69de29..38d4e9d 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/opentracker-0.tar.bz2 diff --git a/opentracker-0-Makefile.patch b/opentracker-0-Makefile.patch new file mode 100644 index 0000000..efa6734 --- /dev/null +++ b/opentracker-0-Makefile.patch @@ -0,0 +1,76 @@ +diff -Naur opentracker-0.orig/Makefile opentracker-0/Makefile +--- opentracker-0.orig/Makefile 2010-08-14 03:08:13.000000000 +0200 ++++ opentracker-0/Makefile 2010-11-14 15:53:28.280468540 +0100 +@@ -1,6 +1,6 @@ + # $Id: Makefile,v 1.68 2010/08/14 01:08:13 erdgeist Exp $ + +-CC?=gcc ++CC=gcc + + # Linux flavour + # PREFIX?=/opt/diet +@@ -13,9 +13,9 @@ + # LIBOWFAT_LIBRARY=$(PREFIX)/lib + + # Debug flavour +-PREFIX?=.. +-LIBOWFAT_HEADERS=$(PREFIX)/libowfat +-LIBOWFAT_LIBRARY=$(PREFIX)/libowfat ++PREFIX?=/usr ++LIBOWFAT_HEADERS=INPUTINCLUDEDIRHERE/libowfat ++LIBOWFAT_LIBRARY=INPUTINCLUDEDIRHERE/libowfat + + BINDIR?=$(PREFIX)/bin + +@@ -26,24 +26,24 @@ + + #FEATURES+=-DWANT_SYNC_LIVE + #FEATURES+=-DWANT_IP_FROM_QUERY_STRING +-#FEATURES+=-DWANT_COMPRESSION_GZIP ++FEATURES+=-DWANT_COMPRESSION_GZIP + #FEATURES+=-DWANT_LOG_NETWORKS +-#FEATURES+=-DWANT_RESTRICT_STATS ++FEATURES+=-DWANT_RESTRICT_STATS + #FEATURES+=-DWANT_IP_FROM_PROXY + #FEATURES+=-DWANT_FULLLOG_NETWORKS + #FEATURES+=-DWANT_LOG_NUMWANT + #FEATURES+=-DWANT_MODEST_FULLSCRAPES + #FEATURES+=-DWANT_SPOT_WOODPECKER +-#FEATURES+=-DWANT_SYSLOGS ++FEATURES+=-DWANT_SYSLOGS + FEATURES+=-DWANT_FULLSCRAPE + + #FEATURES+=-D_DEBUG_HTTPERROR + +-OPTS_debug=-D_DEBUG -g -ggdb # -pg -fprofile-arcs -ftest-coverage ++#OPTS_debug=-D_DEBUG -g -ggdb # -pg -fprofile-arcs -ftest-coverage + OPTS_production=-O3 + + CFLAGS+=-I$(LIBOWFAT_HEADERS) -Wall -pipe -Wextra #-ansi -pedantic +-LDFLAGS+=-L$(LIBOWFAT_LIBRARY) -lowfat -pthread -lpthread -lz ++LDFLAGS+=-L$(LIBOWFAT_LIBRARY) -lowfat -pthread -lpthread -lz -lc -lgcc + + BINARY =opentracker + HEADERS=trackerlogic.h scan_urlencoded_query.h ot_mutex.h ot_stats.h ot_vector.h ot_clean.h ot_udp.h ot_iovec.h ot_fullscrape.h ot_accesslist.h ot_http.h ot_livesync.h +@@ -57,14 +57,13 @@ + + .SUFFIXES: .debug.o .o .c + +-all: $(BINARY) $(BINARY).debug ++all: $(BINARY) + + CFLAGS_production = $(CFLAGS) $(OPTS_production) $(FEATURES) + CFLAGS_debug = $(CFLAGS) $(OPTS_debug) $(FEATURES) + + $(BINARY): $(OBJECTS) $(HEADERS) + $(CC) -o $@ $(OBJECTS) $(LDFLAGS) +- strip $@ + $(BINARY).debug: $(OBJECTS_debug) $(HEADERS) + $(CC) -o $@ $(OBJECTS_debug) $(LDFLAGS) + proxy: $(OBJECTS_proxy) $(HEADERS) +@@ -82,4 +81,4 @@ + rm -rf opentracker opentracker.debug *.o *~ + + install: +- install -m 755 opentracker $(BINDIR) ++ install -m 755 opentracker $(DESTDIR)$(BINDIR) diff --git a/opentracker-0-conf.patch b/opentracker-0-conf.patch new file mode 100644 index 0000000..bfe501c --- /dev/null +++ b/opentracker-0-conf.patch @@ -0,0 +1,28 @@ +diff -Naur opentracker-0.orig/opentracker.conf.sample opentracker-0/opentracker.conf.sample +--- opentracker-0.orig/opentracker.conf.sample 2010-04-09 12:15:51.000000000 +0200 ++++ opentracker-0/opentracker.conf.sample 2010-11-14 16:22:30.476458037 +0100 +@@ -24,8 +24,9 @@ + + # II) If opentracker runs in a non-open mode, point it to files containing + # all torrent hashes that it will serve (shell option -w) ++# The path must be relative to the chroot directory (tracker.rootdir)! + # +-# access.whitelist /path/to/whitelist ++# access.whitelist ./whitelist + # + # or, if opentracker was compiled to allow blacklisting (shell option -b) + # +@@ -84,11 +85,11 @@ + # list files must be put in that directory (shell option -d). + # + # +-# tracker.rootdir /usr/local/etc/opentracker ++tracker.rootdir /var/opentracker + # + # Tell opentracker which user to setuid to. + # +-# tracker.user nobody ++tracker.user opentracker + # + + # VI) opentracker can be told to answer to a "GET / HTTP"-request with a diff --git a/opentracker-0-daemon.patch b/opentracker-0-daemon.patch new file mode 100644 index 0000000..08b772c --- /dev/null +++ b/opentracker-0-daemon.patch @@ -0,0 +1,79 @@ +diff -Naur opentracker-0.orig/opentracker.c opentracker-0/opentracker.c +--- opentracker-0.orig/opentracker.c 2010-08-18 02:43:12.000000000 +0200 ++++ opentracker-0/opentracker.c 2010-11-14 16:11:23.342340079 +0100 +@@ -94,7 +94,7 @@ + } + + static void usage( char *name ) { +- fprintf( stderr, "Usage: %s [-i ip] [-p port] [-P port] [-r redirect] [-d dir] [-u user] [-A ip] [-f config] [-s livesyncport]" ++ fprintf( stderr, "Usage: %s [-i ip] [-p port] [-P port] [-r redirect] [-d dir] [-u user] [-A ip] [-f config] [-s livesyncport] [-m run as daemon]" + #ifdef WANT_ACCESSLIST_BLACK + " [-b blacklistfile]" + #elif defined ( WANT_ACCESSLIST_WHITE ) +@@ -113,8 +113,9 @@ + HELPLINE("-P port","specify udp port to bind to (default: 6969, you may specify more than one)"); + HELPLINE("-r redirecturl","specify url where / should be redirected to (default none)"); + HELPLINE("-d dir","specify directory to try to chroot to (default: \".\")"); +- HELPLINE("-u user","specify user under whose priviliges opentracker should run (default: \"nobody\")"); ++ HELPLINE("-u user","specify user under whose priviliges opentracker should run (default: \"opentracker\")"); + HELPLINE("-A ip","bless an ip address as admin address (e.g. to allow syncs from this address)"); ++ HELPLINE("-m ","run as deamon"); + #ifdef WANT_ACCESSLIST_BLACK + HELPLINE("-b file","specify blacklist file."); + #elif defined( WANT_ACCESSLIST_WHITE ) +@@ -535,7 +536,7 @@ + + int main( int argc, char **argv ) { + ot_ip6 serverip, tmpip; +- int bound = 0, scanon = 1; ++ int bound = 0, scanon = 1, pid = 0; + uint16_t tmpport; + char * statefile = 0; + +@@ -546,7 +547,7 @@ + #endif + + while( scanon ) { +- switch( getopt( argc, argv, ":i:p:A:P:d:u:r:s:f:l:v" ++ switch( getopt( argc, argv, ":i:p:A:P:d:u:r:s:f:l:v:m" + #ifdef WANT_ACCESSLIST_BLACK + "b:" + #elif defined( WANT_ACCESSLIST_WHITE ) +@@ -582,6 +583,7 @@ + accesslist_blessip( tmpip, 0xffff ); /* Allow everything for now */ + break; + case 'f': bound += parse_configfile( optarg ); break; ++ case 'm': pid = 1; break; + case 'h': help( argv[0] ); exit( 0 ); + case 'v': { + char buffer[8192]; +@@ -594,15 +596,28 @@ + } + } + ++ bound += parse_configfile( "INPUTCONFFILEHERE" ); + /* Bind to our default tcp/udp ports */ + if( !bound) { + ot_try_bind( serverip, 6969, FLAG_TCP ); + ot_try_bind( serverip, 6969, FLAG_UDP ); + } + +- if( drop_privileges( g_serveruser ? g_serveruser : "nobody", g_serverdir ) == -1 ) ++ if( drop_privileges( g_serveruser ? g_serveruser : "opentracker", g_serverdir ) == -1 ) + panic( "drop_privileges failed, exiting. Last error"); + ++ if (pid) { ++ pid = fork(); ++ if (pid == -1) { ++ perror("fork"); ++ exit(EXIT_FAILURE); ++ } else if (pid != 0) { ++ exit(EXIT_SUCCESS); ++ } ++ freopen("/dev/null", "a+", stdout); ++ freopen("/dev/null", "a+", stderr); ++ } ++ + g_now_seconds = time( NULL ); + + /* Create our self pipe which allows us to interrupt mainloops diff --git a/opentracker-ipv4.init b/opentracker-ipv4.init new file mode 100644 index 0000000..8ce8caa --- /dev/null +++ b/opentracker-ipv4.init @@ -0,0 +1,103 @@ +#!/bin/bash +# +# opentracker An open and free BitTorrent tracker +# +# chkconfig: - 55 45 +# description: An open and free BitTorrent tracker +# processname: /usr/bin/opentracker-ipv4 +# config: /etc/opentracker-ipv4/opentracker-ipv4.conf +# pidfile: /var/run/opentracker-ipv4.pid + +### BEGIN INIT INFO +# Provides: opentracker-ipv4 +# Required-Start: $local_fs $network $remote_fs +# Required-Stop: $local_fs $network $remote_fs +# Default-Start: +# Default-Stop: +# Short-Description: A BitTorrent tracker +# Description: An open and free BitTorrent tracker +### END INIT INFO + +# Source function library. +. /etc/rc.d/init.d/functions + +if [ -f /etc/sysconfig/opentracker-ipv4 ]; then + . /etc/sysconfig/opentracker-ipv4 +fi + +RETVAL=0 +prog=opentracker-ipv4 +lockfile=/var/lock/subsys/$prog +pidfile=/var/run/$prog.pid +binary=/usr/bin/$prog +chroot=/var/opentracker +conf=/etc/opentracker/opentracker-ipv4.conf + +start() { + echo -n $"Starting $prog: " + $binary -f $conf -m $OPTIONS + + # Horrible, but works + if [ $? -eq 0 ]; then + pidof -o $$ -o $PPID -o %PPID -x $binary > $pidfile + + if [ $? -eq 0 ]; then + echo_success + else + rm -f $pidfile + echo_failure + RETVAL=1 + fi + else + echo_failure + RETVAL=1 + fi + + echo + [ $RETVAL -eq 0 ] && touch $lockfile + + return $RETVAL +} + +stop() { + echo -n $"Stopping $prog: " + killproc $prog + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && rm -f $lockfile + + return $RETVAL +} + +restart() { + stop + start +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|force-reload|reload) + restart + ;; + status) + status $prog + RETVAL=$? + ;; + condrestart|try-restart) + if [ -f ${pidfile} ]; then + stop + start + fi + ;; + *) + echo $"Usage: $prog {start|stop|status|reload|restart|condrestart|force-reload|try-restart}" + RETVAL=1 +esac + +exit $RETVAL diff --git a/opentracker-ipv6.init b/opentracker-ipv6.init new file mode 100644 index 0000000..a07400e --- /dev/null +++ b/opentracker-ipv6.init @@ -0,0 +1,103 @@ +#!/bin/bash +# +# opentracker An open and free BitTorrent tracker +# +# chkconfig: - 55 45 +# description: An open and free BitTorrent tracker +# processname: /usr/bin/opentracker-ipv6 +# config: /etc/opentracker-ipv6/opentracker-ipv6.conf +# pidfile: /var/run/opentracker-ipv6.pid + +### BEGIN INIT INFO +# Provides: opentracker-ipv6 +# Required-Start: $local_fs $network $remote_fs +# Required-Stop: $local_fs $network $remote_fs +# Default-Start: +# Default-Stop: +# Short-Description: A BitTorrent tracker +# Description: An open and free BitTorrent tracker +### END INIT INFO + +# Source function library. +. /etc/rc.d/init.d/functions + +if [ -f /etc/sysconfig/opentracker-ipv6 ]; then + . /etc/sysconfig/opentracker-ipv6 +fi + +RETVAL=0 +prog=opentracker-ipv6 +lockfile=/var/lock/subsys/$prog +pidfile=/var/run/$prog.pid +binary=/usr/bin/$prog +chroot=/var/opentracker +conf=/etc/opentracker/opentracker-ipv6.conf + +start() { + echo -n $"Starting $prog: " + $binary -f $conf -m $OPTIONS + + # Horrible, but works + if [ $? -eq 0 ]; then + pidof -o $$ -o $PPID -o %PPID -x $binary > $pidfile + + if [ $? -eq 0 ]; then + echo_success + else + rm -f $pidfile + echo_failure + RETVAL=1 + fi + else + echo_failure + RETVAL=1 + fi + + echo + [ $RETVAL -eq 0 ] && touch $lockfile + + return $RETVAL +} + +stop() { + echo -n $"Stopping $prog: " + killproc $prog + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && rm -f $lockfile + + return $RETVAL +} + +restart() { + stop + start +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|force-reload|reload) + restart + ;; + status) + status $prog + RETVAL=$? + ;; + condrestart|try-restart) + if [ -f ${pidfile} ]; then + stop + start + fi + ;; + *) + echo $"Usage: $prog {start|stop|status|reload|restart|condrestart|force-reload|try-restart}" + RETVAL=1 +esac + +exit $RETVAL diff --git a/opentracker.spec b/opentracker.spec new file mode 100644 index 0000000..d6016fb --- /dev/null +++ b/opentracker.spec @@ -0,0 +1,195 @@ +Name: opentracker +Version: 0 +Release: 0.1.20101114cvs%{?dist} +Summary: BitTorrent Tracker + +Group: Applications/Internet +License: Beerware +URL: http://erdgeist.org/arts/software/opentracker/ +# cvs -d:pserver:anoncvs@cvs.erdgeist.org:/home/cvsroot co -D "2010-11-14" -d opentracker-0 opentracker +# tar cjf opentracker-0.tar.bz2 opentracker-0 +Source0: %{name}-%{version}.tar.bz2 +Source1: %{name}-ipv4.init +Source2: %{name}-ipv6.init +Source3: %{name}.sysconfig + +Patch0: %{name}-0-Makefile.patch +Patch1: %{name}-0-daemon.patch +Patch2: %{name}-0-conf.patch + +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +BuildRequires: libowfat-devel +BuildRequires: zlib-devel +Requires(pre): shadow-utils +Requires(post): chkconfig +Requires(preun): chkconfig +Requires(preun): initscripts +Requires(postun): initscripts + + +%description +opentracker is a open and free BitTorrent tracker project. It aims for minimal +resource usage. + +%package common +Summary: Common-Files for the BitTorrent-Tracker +Group: Applications/Internet +BuildArch: noarch + +%description common +Filesystem-package which provides the root-dir. + + +%package ipv4 +Summary: BitTorrent Tracker using ipv4 +Group: Applications/Internet +Requires: %{name}-common + + +%description ipv4 +opentracker is a open and free BitTorrent tracker project. It aims for minimal +resource usage. +This package provides IPv4 capability. + + +%package ipv6 +Summary: BitTorrent Tracker using ipv6 +Group: Applications/Internet +Requires: %{name}-common + + +%description ipv6 +opentracker is a open and free BitTorrent tracker project. It aims for minimal +resource usage. +This package provides IPv6 capability. + + +%prep +%setup -q + +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 + + +%build + +sed -i 's|INPUTCONFFILEHERE|%{_sysconfdir}/%{name}/%{name}-ipv4.conf|g' \ + opentracker.c + +sed -i 's|INPUTINCLUDEDIRHERE|%{_includedir}|g' \ + Makefile + +CFLAGS="%{optflags}" make %{name} %{?_smp_mflags} +mv %{name} %{name}-ipv4 + +make clean + +sed -e 's|#FEATURES+=-DWANT_V6|FEATURES+=-DWANT_V6|g' \ + -i Makefile + +sed -i 's|%{_sysconfdir}/%{name}/%{name}-ipv4.conf|%{_sysconfdir}/%{name}/%{name}-ipv6.conf|g' \ + opentracker.c + +CFLAGS="%{optflags}" make %{name} %{?_smp_mflags} +mv %{name} %{name}-ipv6 + + +%install +rm -rf %{buildroot} + +install -d %{buildroot}%{_bindir}/ +install -dm0755 %{buildroot}/var/%{name} + +# ipv4 +install -Dpm0755 %{name}-ipv4 \ + %{buildroot}%{_bindir}/ +install -Dpm0644 %{name}.conf.sample \ + %{buildroot}%{_sysconfdir}/%{name}/%{name}-ipv4.conf +install -Dpm0755 %{SOURCE1} \ + %{buildroot}%{_initrddir}/%{name}-ipv4 +install -Dpm0644 %{SOURCE3} \ + %{buildroot}%{_sysconfdir}/sysconfig/%{name}-ipv4 + +# ipv6 +install -Dpm0755 %{name}-ipv6 \ + %{buildroot}%{_bindir}/ +install -Dpm0644 %{name}.conf.sample \ + %{buildroot}%{_sysconfdir}/%{name}/%{name}-ipv6.conf +install -Dpm0755 %{SOURCE2} \ + %{buildroot}%{_initrddir}/%{name}-ipv6 +install -Dpm0644 %{SOURCE3} \ + %{buildroot}%{_sysconfdir}/sysconfig/%{name}-ipv6 + + +%pre common +getent group %{name} > /dev/null || %{_sbindir}/groupadd -r %{name} +getent passwd %{name} > /dev/null || %{_sbindir}/useradd -r -g %{name} -d / -s /sbin/nologin -c "Opentracker User" %{name} +exit 0 + + +%post ipv4 +/sbin/chkconfig --add %{name}-ipv4 + + +%post ipv6 +/sbin/chkconfig --add %{name}-ipv6 + + +%preun ipv4 +if [ $1 = 0 ] ; then + /sbin/service %{name}-ipv4 stop >/dev/null 2>&1 + /sbin/chkconfig --del %{name}-ipv4 +fi + + +%preun ipv6 +if [ $1 = 0 ] ; then + /sbin/service %{name}-ipv6 stop >/dev/null 2>&1 + /sbin/chkconfig --del %{name}-ipv6 +fi + + +%postun ipv4 +if [ "$1" -ge "1" ] ; then + /sbin/service %{name}-ipv4 condrestart >/dev/null 2>&1 || : +fi + +%postun ipv6 +if [ "$1" -ge "1" ] ; then + /sbin/service %{name}-ipv6 condrestart >/dev/null 2>&1 || : +fi + + +%clean +rm -rf %{buildroot} + + +%files common +%defattr(-,root,opentracker,-) +%dir %{_sysconfdir}/%{name}/ +%dir /var/%{name}/ + +%files ipv4 +%defattr(-,root,root,-) +%doc README +%{_bindir}/%{name}-ipv4 +%config(noreplace) %{_sysconfdir}/%{name}/%{name}-ipv4.conf +%{_initrddir}/%{name}-ipv4 +%config(noreplace) %{_sysconfdir}/sysconfig/%{name}-ipv4 + + +%files ipv6 +%defattr(-,root,root,-) +%doc README +%{_bindir}/%{name}-ipv6 +%config(noreplace) %{_sysconfdir}/%{name}/%{name}-ipv6.conf +%{_initrddir}/%{name}-ipv6 +%config(noreplace) %{_sysconfdir}/sysconfig/%{name}-ipv6 + + +# thx to Romain Wartel and Matt Domsch and Robert Scheck for the assistance in the review process. +%changelog +* Mon Jan 25 2011 Simon Wesp - 0-0.1.20101114cvs +- Initial import to the fedora package collection diff --git a/opentracker.sysconfig b/opentracker.sysconfig new file mode 100644 index 0000000..788daf7 --- /dev/null +++ b/opentracker.sysconfig @@ -0,0 +1,7 @@ +# Configuration file for the opentracker service + +# +# To pass additional options (parameters for instance) to the opentracker +# binary at startup, set OPTIONS here. +# +#OPTIONS=