diff options
author | Antonio Hernández Blas <hba.nihilismus@gmail.com> | 2011-10-23 20:17:46 -0200 |
---|---|---|
committer | Niels Horn <niels.horn@slackbuilds.org> | 2011-10-23 20:17:46 -0200 |
commit | 60b413b172340038ef538d20196e662d06ab3778 (patch) | |
tree | 7b4a90e32c6d239bc721d5de9afe3423c7036f11 | |
parent | 227bd3493f37901930ffb14c1ec45c34080e8830 (diff) |
network/thttpd: Added (the tiny/turbo/throttling HTTP server)
Signed-off-by: Niels Horn <niels.horn@slackbuilds.org>
-rw-r--r-- | network/thttpd/README | 19 | ||||
-rw-r--r-- | network/thttpd/doinst.sh | 24 | ||||
-rw-r--r-- | network/thttpd/patches/additional-input-validation-httpd.c.diff | 62 | ||||
-rw-r--r-- | network/thttpd/patches/fix-buffer-overflow.diff | 21 | ||||
-rw-r--r-- | network/thttpd/patches/fix-insecure-tmp-creation-CVE-2005-3124.diff | 19 | ||||
-rw-r--r-- | network/thttpd/patches/thttpd-2.25b-fix-illegal-path-info.patch | 17 | ||||
-rw-r--r-- | network/thttpd/patches/thttpd-2.25b-glibc-2.10.patch | 21 | ||||
-rw-r--r-- | network/thttpd/patches/thttpd-2.25b-monolithic-timer.patch | 126 | ||||
-rw-r--r-- | network/thttpd/patches/thttpd-2.25b-respect-CFLAGS--dont-link-static.patch | 55 | ||||
-rw-r--r-- | network/thttpd/patches/thttpd-2.25b-use-Status-header.patch | 12 | ||||
-rw-r--r-- | network/thttpd/patches/thttpd-2.25b-use-X-Forwarded-For-header.patch | 15 | ||||
-rw-r--r-- | network/thttpd/rc.thttpd | 79 | ||||
-rw-r--r-- | network/thttpd/slack-desc | 19 | ||||
-rw-r--r-- | network/thttpd/thttpd.SlackBuild | 169 | ||||
-rw-r--r-- | network/thttpd/thttpd.conf | 9 | ||||
-rw-r--r-- | network/thttpd/thttpd.info | 10 | ||||
-rw-r--r-- | network/thttpd/thttpd.logrotate | 12 |
17 files changed, 689 insertions, 0 deletions
diff --git a/network/thttpd/README b/network/thttpd/README new file mode 100644 index 0000000000000..786fa7a4aaaf7 --- /dev/null +++ b/network/thttpd/README @@ -0,0 +1,19 @@ +thttpd is a simple, small, portable, fast, and secure HTTP server. +Simple: It handles only the minimum necessary to implement HTTP/1.1. +Well, maybe a little more than the minimum. Small: It has a very +small run-time size, since it does not fork and is very careful about +memory allocation. Portable: It compiles cleanly on most any +Unix-like OS. Fast: In typical use it's about as fast as the best +full-featured servers. Secure: It goes to great lengths to protect +the web server machine against attacks and breakins from other sites. + +Notes: + +By default the directory to serve through HTTP will be '/var/www/thttpd', +if you want to change it execute the SalckBuild as: + # WEBDIR='/opt/www' sh thttpd.SlackBuild + +To build and use this package the user/group 'thttpd' is required to +exists in your system. You can add it with: + # groupadd -g 227 thttpd + # useradd -u 227 -g 227 -c "User for thttpd" -d / -s /bin/false thttpd diff --git a/network/thttpd/doinst.sh b/network/thttpd/doinst.sh new file mode 100644 index 0000000000000..21e47e39984de --- /dev/null +++ b/network/thttpd/doinst.sh @@ -0,0 +1,24 @@ +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + # If there's no config file by that name, mv it over: + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then + # toss the redundant copy + rm $NEW + fi + # Otherwise, we leave the .new copy for the admin to consider... +} + +preserve_perms() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + if [ -e $OLD ]; then + cp -a $OLD ${NEW}.incoming + cat $NEW > ${NEW}.incoming + mv ${NEW}.incoming $NEW + fi + config $NEW +} + diff --git a/network/thttpd/patches/additional-input-validation-httpd.c.diff b/network/thttpd/patches/additional-input-validation-httpd.c.diff new file mode 100644 index 0000000000000..04f59eac8e39f --- /dev/null +++ b/network/thttpd/patches/additional-input-validation-httpd.c.diff @@ -0,0 +1,62 @@ +--- thttpd-2.25b/extras/htpasswd.c.orig 2006-03-31 04:12:42.281317000 +0000 ++++ thttpd-2.25b/extras/htpasswd.c 2006-03-31 05:21:37.741632392 +0000 +@@ -151,6 +151,7 @@ void interrupted(int signo) { + int main(int argc, char *argv[]) { + FILE *tfp,*f; + char user[MAX_STRING_LEN]; ++ char pwfilename[MAX_STRING_LEN]; + char line[MAX_STRING_LEN]; + char l[MAX_STRING_LEN]; + char w[MAX_STRING_LEN]; +@@ -168,6 +169,25 @@ int main(int argc, char *argv[]) { + perror("fopen"); + exit(1); + } ++ if (strlen(argv[2]) > (sizeof(pwfilename) - 1)) { ++ fprintf(stderr, "%s: filename is too long\n", argv[0]); ++ exit(1); ++ } ++ if (((strchr(argv[2], ';')) != NULL) || ((strchr(argv[2], '>')) != NULL)) { ++ fprintf(stderr, "%s: filename contains an illegal character\n", ++ argv[0]); ++ exit(1); ++ } ++ if (strlen(argv[3]) > (sizeof(user) - 1)) { ++ fprintf(stderr, "%s: username is too long\n", argv[0], ++ sizeof(user) - 1); ++ exit(1); ++ } ++ if ((strchr(argv[3], ':')) != NULL) { ++ fprintf(stderr, "%s: username contains an illegal character\n", ++ argv[0]); ++ exit(1); ++ } + printf("Adding password for %s.\n",argv[3]); + add_password(argv[3],tfp); + fclose(tfp); +@@ -180,6 +200,25 @@ int main(int argc, char *argv[]) { + exit(1); + } + ++ if (strlen(argv[1]) > (sizeof(pwfilename) - 1)) { ++ fprintf(stderr, "%s: filename is too long\n", argv[0]); ++ exit(1); ++ } ++ if (((strchr(argv[1], ';')) != NULL) || ((strchr(argv[1], '>')) != NULL)) { ++ fprintf(stderr, "%s: filename contains an illegal character\n", ++ argv[0]); ++ exit(1); ++ } ++ if (strlen(argv[2]) > (sizeof(user) - 1)) { ++ fprintf(stderr, "%s: username is too long\n", argv[0], ++ sizeof(user) - 1); ++ exit(1); ++ } ++ if ((strchr(argv[2], ':')) != NULL) { ++ fprintf(stderr, "%s: username contains an illegal character\n", ++ argv[0]); ++ exit(1); ++ } + if(!(f = fopen(argv[1],"r"))) { + fprintf(stderr, + "Could not open passwd file %s for reading.\n",argv[1]); diff --git a/network/thttpd/patches/fix-buffer-overflow.diff b/network/thttpd/patches/fix-buffer-overflow.diff new file mode 100644 index 0000000000000..cacd7321486ab --- /dev/null +++ b/network/thttpd/patches/fix-buffer-overflow.diff @@ -0,0 +1,21 @@ +diff -Nrup thttpd-2.25b.orig/libhttpd.c thttpd-2.25b/libhttpd.c +--- thttpd-2.25b.orig/libhttpd.c 2003-12-25 19:06:05.000000000 +0000 ++++ thttpd-2.25b/libhttpd.c 2007-01-08 21:43:28.000000000 +0000 +@@ -1469,7 +1469,7 @@ expand_symlinks( char* path, char** rest + httpd_realloc_str( &checked, &maxchecked, checkedlen ); + (void) strcpy( checked, path ); + /* Trim trailing slashes. */ +- while ( checked[checkedlen - 1] == '/' ) ++ while ( checkedlen && checked[checkedlen - 1] == '/' ) + { + checked[checkedlen - 1] = '\0'; + --checkedlen; +@@ -1488,7 +1488,7 @@ expand_symlinks( char* path, char** rest + restlen = strlen( path ); + httpd_realloc_str( &rest, &maxrest, restlen ); + (void) strcpy( rest, path ); +- if ( rest[restlen - 1] == '/' ) ++ if ( restlen && rest[restlen - 1] == '/' ) + rest[--restlen] = '\0'; /* trim trailing slash */ + if ( ! tildemapped ) + /* Remove any leading slashes. */ diff --git a/network/thttpd/patches/fix-insecure-tmp-creation-CVE-2005-3124.diff b/network/thttpd/patches/fix-insecure-tmp-creation-CVE-2005-3124.diff new file mode 100644 index 0000000000000..c41ec46b9718d --- /dev/null +++ b/network/thttpd/patches/fix-insecure-tmp-creation-CVE-2005-3124.diff @@ -0,0 +1,19 @@ +diff -ru thttpd-2.23beta1.orig/extras/syslogtocern thttpd-2.23beta1/extras/syslogtocern +--- thttpd-2.23beta1.orig/extras/syslogtocern 1999-09-15 18:00:54.000000000 +0200 ++++ thttpd-2.23beta1/extras/syslogtocern 2005-10-26 01:45:34.000000000 +0200 +@@ -31,8 +31,8 @@ + exit 1 + fi + +-tmp1=/tmp/stc1.$$ +-rm -f $tmp1 ++tmp1=``mktemp -t stc1.XXXXXX` || { echo "$0: Cannot create temporary file" >&2; exit 1; } ++trap " [ -f \"$tmp1\" ] && /bin/rm -f -- \"$tmp1\"" 0 1 2 3 13 15 + + # Gather up all the thttpd entries. + egrep ' thttpd\[' $* > $tmp1 +@@ -65,4 +65,3 @@ + sed -e "s,\([A-Z][a-z][a-z] [0-9 ][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\) [^ ]* thttpd\[[0-9]*\]: \(.*\),[\1 ${year}] \2," > error_log + + # Done. +-rm -f $tmp1 diff --git a/network/thttpd/patches/thttpd-2.25b-fix-illegal-path-info.patch b/network/thttpd/patches/thttpd-2.25b-fix-illegal-path-info.patch new file mode 100644 index 0000000000000..d1688f1446810 --- /dev/null +++ b/network/thttpd/patches/thttpd-2.25b-fix-illegal-path-info.patch @@ -0,0 +1,17 @@ +diff -Naur thttpd-2.25b.orig/libhttpd.c thttpd-2.25b/libhttpd.c +--- thttpd-2.25b.orig/libhttpd.c 2007-10-14 10:09:55.000000000 +0000 ++++ thttpd-2.25b/libhttpd.c 2007-10-14 10:09:11.000000000 +0000 +@@ -2322,8 +2320,11 @@ + { + int i; + i = strlen( hc->origfilename ) - strlen( hc->pathinfo ); +- if ( i > 0 && strcmp( &hc->origfilename[i], hc->pathinfo ) == 0 ) +- hc->origfilename[i - 1] = '\0'; ++ if ( strcmp( &hc->origfilename[i], hc->pathinfo ) == 0 ) ++ { ++ if ( i == 0 ) hc->origfilename[0] = '\0'; ++ else hc->origfilename[i - 1] = '\0'; ++ } + } + + /* If the expanded filename is an absolute path, check that it's still diff --git a/network/thttpd/patches/thttpd-2.25b-glibc-2.10.patch b/network/thttpd/patches/thttpd-2.25b-glibc-2.10.patch new file mode 100644 index 0000000000000..c97227827e4b4 --- /dev/null +++ b/network/thttpd/patches/thttpd-2.25b-glibc-2.10.patch @@ -0,0 +1,21 @@ +diff -ur thttpd-2.25b.orig/extras/htpasswd.c thttpd-2.25b/extras/htpasswd.c +--- thttpd-2.25b.orig/extras/htpasswd.c 2001-12-19 02:08:08.000000000 +0200 ++++ thttpd-2.25b/extras/htpasswd.c 2009-08-09 16:40:06.000000000 +0300 +@@ -49,7 +49,7 @@ + while((line[y++] = line[x++])); + } + +-static int getline(char *s, int n, FILE *f) { ++static int get_line(char *s, int n, FILE *f) { + register int i=0; + + while(1) { +@@ -189,7 +189,7 @@ + strcpy(user,argv[2]); + + found = 0; +- while(!(getline(line,MAX_STRING_LEN,f))) { ++ while(!(get_line(line,MAX_STRING_LEN,f))) { + if(found || (line[0] == '#') || (!line[0])) { + putline(tfp,line); + continue; diff --git a/network/thttpd/patches/thttpd-2.25b-monolithic-timer.patch b/network/thttpd/patches/thttpd-2.25b-monolithic-timer.patch new file mode 100644 index 0000000000000..9ff38aec45749 --- /dev/null +++ b/network/thttpd/patches/thttpd-2.25b-monolithic-timer.patch @@ -0,0 +1,126 @@ +diff -Nru thttpd-2.25b.orig/configure.in thttpd-2.25b/configure.in +--- thttpd-2.25b.orig/configure.in 2003-12-25 20:41:13.000000000 +0200 ++++ thttpd-2.25b/configure.in 2010-07-08 00:04:25.000000000 +0300 +@@ -123,6 +123,8 @@ + ;; + esac + ++AC_CHECK_LIB(rt, clock_gettime) ++ + AC_ACME_TM_GMTOFF + AC_ACME_INT64T + AC_ACME_SOCKLENT +diff -Nru thttpd-2.25b.orig/thttpd.c thttpd-2.25b/thttpd.c +--- thttpd-2.25b.orig/thttpd.c 2003-12-25 21:06:52.000000000 +0200 ++++ thttpd-2.25b/thttpd.c 2010-07-08 00:41:28.000000000 +0300 +@@ -742,7 +742,7 @@ + } + + /* Main loop. */ +- (void) gettimeofday( &tv, (struct timezone*) 0 ); ++ tmr_prepare_timeval( &tv ); + while ( ( ! terminate ) || num_connects > 0 ) + { + /* Do we need to re-open the log file? */ +@@ -761,7 +761,7 @@ + syslog( LOG_ERR, "fdwatch - %m" ); + exit( 1 ); + } +- (void) gettimeofday( &tv, (struct timezone*) 0 ); ++ tmr_prepare_timeval( &tv ); + + if ( num_ready == 0 ) + { +diff -Nru thttpd-2.25b.orig/timers.c thttpd-2.25b/timers.c +--- thttpd-2.25b.orig/timers.c 2002-08-22 04:04:12.000000000 +0300 ++++ thttpd-2.25b/timers.c 2010-07-08 11:47:03.000000000 +0300 +@@ -41,7 +41,13 @@ + + ClientData JunkClientData; + +- ++#undef HAVE_LIBRT_MONO ++#if defined(HAVE_LIBRT) && defined(CLOCK_MONOTONIC) ++#define HAVE_LIBRT_MONO ++#include <time.h> ++static int use_monotonic = 0; /* monotonic clock runtime availability flag */ ++static struct timeval tv_diff; /* system time - monotonic difference at start */ ++#endif + + static unsigned int + hash( Timer* t ) +@@ -145,6 +151,26 @@ + timers[h] = (Timer*) 0; + free_timers = (Timer*) 0; + alloc_count = active_count = free_count = 0; ++ ++ /* Check for monotonic clock availability */ ++#ifdef HAVE_LIBRT_MONO ++ struct timespec ts; ++ struct timeval tv_start, tv; ++ ++ /* Try to get monotonic clock time */ ++ if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { ++ use_monotonic = 1; ++ ++ /* Get current system time */ ++ (void) gettimeofday( &tv_start , (struct timezone*) 0 ); ++ tv.tv_sec = ts.tv_sec; ++ tv.tv_usec = ts.tv_nsec / 1000L; ++ /* Calculate and save the difference: tv_start is since the Epoch, so tv_start > ts ++ tv_diff = tv_start - tv */ ++ timersub( &tv_start, &tv, &tv_diff ); ++ } ++#endif ++ + } + + +@@ -176,7 +202,7 @@ + if ( nowP != (struct timeval*) 0 ) + t->time = *nowP; + else +- (void) gettimeofday( &t->time, (struct timezone*) 0 ); ++ tmr_prepare_timeval( &t->time ); + t->time.tv_sec += msecs / 1000L; + t->time.tv_usec += ( msecs % 1000L ) * 1000L; + if ( t->time.tv_usec >= 1000000L ) +@@ -349,3 +375,27 @@ + if ( active_count + free_count != alloc_count ) + syslog( LOG_ERR, "timer counts don't add up!" ); + } ++ ++/* Fill timeval structure for further usage by the package. */ ++void ++tmr_prepare_timeval( struct timeval *tv ) ++{ ++#ifdef HAVE_LIBRT_MONO ++ struct timespec ts; ++ struct timeval tv0; ++ ++ if (use_monotonic) { /* use monotonic clock source ? */ ++ if (clock_gettime(CLOCK_MONOTONIC,&ts) < 0) { ++ perror("clock_gettime"); return; ++ } ++ tv0.tv_sec = ts.tv_sec; ++ tv0.tv_usec = ts.tv_nsec / 1000L; ++ /* Return system time value like it was running accurately */ ++ timeradd( &tv_diff, &tv0, tv ); ++ } else { ++#endif ++ (void) gettimeofday( tv , (struct timezone*) 0 ); ++#ifdef HAVE_LIBRT_MONO ++ } ++#endif ++} +diff -Nru thttpd-2.25b.orig/timers.h thttpd-2.25b/timers.h +--- thttpd-2.25b.orig/timers.h 2001-04-13 08:37:41.000000000 +0300 ++++ thttpd-2.25b/timers.h 2010-07-08 00:09:15.000000000 +0300 +@@ -106,4 +106,7 @@ + /* Generate debugging statistics syslog message. */ + extern void tmr_logstats( long secs ); + ++/* Fill timeval structure for further usage by the package. */ ++extern void tmr_prepare_timeval( struct timeval *tv ); ++ + #endif /* _TIMERS_H_ */ diff --git a/network/thttpd/patches/thttpd-2.25b-respect-CFLAGS--dont-link-static.patch b/network/thttpd/patches/thttpd-2.25b-respect-CFLAGS--dont-link-static.patch new file mode 100644 index 0000000000000..ce915c706b67c --- /dev/null +++ b/network/thttpd/patches/thttpd-2.25b-respect-CFLAGS--dont-link-static.patch @@ -0,0 +1,55 @@ +diff -Naur thttpd-2.25b.orig/cgi-src/Makefile.in thttpd-2.25b/cgi-src/Makefile.in +--- thttpd-2.25b.orig/cgi-src/Makefile.in 2010-10-28 23:33:28.000000000 +0200 ++++ thttpd-2.25b/cgi-src/Makefile.in 2010-10-29 00:05:43.000000000 +0200 +@@ -31,10 +31,9 @@ + MANDIR = @mandir@ + + CC = @CC@ +-CCOPT = @V_CCOPT@ + DEFS = @DEFS@ + INCLS = -I.. +-CFLAGS = $(CCOPT) $(DEFS) $(INCLS) ++CFLAGS += $(DEFS) $(INCLS) + LDFLAGS = @LDFLAGS@ @V_STATICFLAG@ + LIBS = @LIBS@ + NETLIBS = @V_NETLIBS@ +diff -Naur thttpd-2.25b.orig/extras/Makefile.in thttpd-2.25b/extras/Makefile.in +--- thttpd-2.25b.orig/extras/Makefile.in 2010-10-28 23:33:28.000000000 +0200 ++++ thttpd-2.25b/extras/Makefile.in 2010-10-29 00:06:36.000000000 +0200 +@@ -32,11 +32,9 @@ + MANDIR = @mandir@ + + CC = @CC@ +-CCOPT = @V_CCOPT@ + DEFS = @DEFS@ + INCLS = -I.. +-CFLAGS = $(CCOPT) $(DEFS) $(INCLS) +-STATICFLAG = @V_STATICFLAG@ ++CFLAGS += $(DEFS) $(INCLS) + LDFLAGS = @LDFLAGS@ + LIBS = @LIBS@ + NETLIBS = @V_NETLIBS@ +@@ -59,7 +57,7 @@ + $(CC) $(CFLAGS) -DWEBDIR=\"$(WEBDIR)\" -c makeweb.c + + htpasswd: htpasswd.o +- $(CC) $(LDFLAGS) $(STATICFLAG) htpasswd.o -o htpasswd $(LIBS) ++ $(CC) $(LDFLAGS) htpasswd.o -o htpasswd $(LIBS) + + htpasswd.o: htpasswd.c ../config.h + $(CC) $(CFLAGS) -DWEBDIR=\"$(WEBDIR)\" -c htpasswd.c +diff -Naur thttpd-2.25b.orig/Makefile.in thttpd-2.25b/Makefile.in +--- thttpd-2.25b.orig/Makefile.in 2010-10-28 23:33:28.000000000 +0200 ++++ thttpd-2.25b/Makefile.in 2010-10-29 00:05:43.000000000 +0200 +@@ -47,10 +47,9 @@ + # You shouldn't need to edit anything below here. + + CC = @CC@ +-CCOPT = @V_CCOPT@ + DEFS = @DEFS@ + INCLS = -I. +-CFLAGS = $(CCOPT) $(DEFS) $(INCLS) ++CFLAGS += $(DEFS) $(INCLS) + LDFLAGS = @LDFLAGS@ + LIBS = @LIBS@ + NETLIBS = @V_NETLIBS@ diff --git a/network/thttpd/patches/thttpd-2.25b-use-Status-header.patch b/network/thttpd/patches/thttpd-2.25b-use-Status-header.patch new file mode 100644 index 0000000000000..6aaae5a5d91cc --- /dev/null +++ b/network/thttpd/patches/thttpd-2.25b-use-Status-header.patch @@ -0,0 +1,12 @@ +diff -Naur thttpd-2.25b.orig/libhttpd.c thttpd-2.25b/libhttpd.c +--- thttpd-2.25b.orig/libhttpd.c 2007-10-14 10:09:11.000000000 +0000 ++++ thttpd-2.25b/libhttpd.c 2007-10-14 10:21:37.000000000 +0000 +@@ -3279,7 +3279,7 @@ + cp += strspn( cp, " \t" ); + status = atoi( cp ); + } +- if ( ( cp = strstr( headers, "Location:" ) ) != (char*) 0 && ++ else if ( ( cp = strstr( headers, "Location:" ) ) != (char*) 0 && + cp < br && + ( cp == headers || *(cp-1) == '\012' ) ) + status = 302; diff --git a/network/thttpd/patches/thttpd-2.25b-use-X-Forwarded-For-header.patch b/network/thttpd/patches/thttpd-2.25b-use-X-Forwarded-For-header.patch new file mode 100644 index 0000000000000..0fec25ef7c194 --- /dev/null +++ b/network/thttpd/patches/thttpd-2.25b-use-X-Forwarded-For-header.patch @@ -0,0 +1,15 @@ +--- thttpd-2.25b/libhttpd.c 2003-12-25 20:06:05.000000000 +0100 ++++ thttpd-2.25b-patched/libhttpd.c 2005-01-09 00:26:04.867255248 +0100 +@@ -2207,6 +2207,12 @@ + if ( strcasecmp( cp, "keep-alive" ) == 0 ) + hc->keep_alive = 1; + } ++ else if ( strncasecmp( buf, "X-Forwarded-For:", 16 ) == 0 ) ++ { // Use real IP if available ++ cp = &buf[16]; ++ cp += strspn( cp, " \t" ); ++ inet_aton( cp, &(hc->client_addr.sa_in.sin_addr) ); ++ } + #ifdef LOG_UNKNOWN_HEADERS + else if ( strncasecmp( buf, "Accept-Charset:", 15 ) == 0 || + strncasecmp( buf, "Accept-Language:", 16 ) == 0 || diff --git a/network/thttpd/rc.thttpd b/network/thttpd/rc.thttpd new file mode 100644 index 0000000000000..22a8bcc433a5c --- /dev/null +++ b/network/thttpd/rc.thttpd @@ -0,0 +1,79 @@ +#!/bin/sh + +# Start/stop/restart the thttpd daemon +# Copyright (c) 2009-2011 Antonio Hernández Blas <hba.nihilismus@gmail.com> + +# +# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +# Version 2, December 2004 +# +# Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> +# +# Everyone is permitted to copy and distribute verbatim or modified +# copies of this license document, and changing it is allowed as long +# as the name is changed. +# +# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +# +# 0. You just DO WHAT THE FUCK YOU WANT TO. +# + +CONF='/etc/thttpd.conf' +CMMD="/usr/sbin/thttpd -C $CONF" + +thttpd_start() { + if [ -x /usr/sbin/thttpd ]; then + if [ -f $CONF ]; then + PIDOF=$(pgrep -f "$CMMD") + if [ ! -z "$PIDOF" ]; then + echo "Error, thttpd is already running." + else + echo "Starting thttpd: $CMMD" + $CMMD + fi + else + echo "Error, file $CONF does not exist." + fi + fi +} + +thttpd_stop() { + THTTPDPID=$(pgrep -f "$CMMD") + if [ -z $THTTPDPID ]; then + echo "Error, thttpd is not running." + else + echo "Stoping thttpd: kill $THTTPDPID" + kill $THTTPDPID + fi +} + +thttpd_status() { + PIDOF=$(pgrep -f "$CMMD") + if [ ! -z "$PIDOF" ]; then + echo "thttpd is running." + else + echo "thttpd is not running." + fi +} + +case $1 in + start) + thttpd_start + ;; + stop) + thttpd_stop + ;; + restart) + thttpd_stop + sleep 3 + thttpd_start + ;; + status) + thttpd_status + ;; + *) + echo "Usage $0 {start|stop|restart|status}" + exit 1 + ;; +esac diff --git a/network/thttpd/slack-desc b/network/thttpd/slack-desc new file mode 100644 index 0000000000000..887cb37051e64 --- /dev/null +++ b/network/thttpd/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. Line +# up the first '|' above the ':' following the base package name, and the '|' +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':'. + + |-----handy-ruler------------------------------------------------------| +thttpd: thttpd (the tiny/turbo/throttling HTTP server) +thttpd: +thttpd: thttpd is a simple, small, portable, fast, and secure HTTP server. +thttpd: Simple: It handles only the minimum necessary to implement HTTP/1.1. +thttpd: Well, maybe a little more than the minimum. Small: It has a very +thttpd: small run-time size, since it does not fork and is very careful about +thttpd: memory allocation. Portable: It compiles cleanly on most any +thttpd: Unix-like OS. Fast: In typical use it's about as fast as the best +thttpd: full-featured servers. Secure: It goes to great lengths to protect +thttpd: the web server machine against attacks and breakins from other sites. +thttpd: Homepage: http://acme.com/software/thttpd/ diff --git a/network/thttpd/thttpd.SlackBuild b/network/thttpd/thttpd.SlackBuild new file mode 100644 index 0000000000000..784b7b141a85c --- /dev/null +++ b/network/thttpd/thttpd.SlackBuild @@ -0,0 +1,169 @@ +#!/bin/sh + +# Slackware build script for thttpd + +# Written by Antonio Hernández Blas <hba.nihilismus@gmail.com> + +# Copyright (c) 2008-2011, Antonio Hernández Blas <hba.nihilismus@gmail.com> +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1.- Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +PRGNAM=thttpd +VERSION=${VERSION:-2.25b} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i486 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +fi + +CWD=$(pwd) +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +if [ "$ARCH" = "i486" ]; then + SLKCFLAGS="-O2 -march=i486 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O2 -march=i686 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" + LIBDIRSUFFIX="64" +else + SLKCFLAGS="-O2" + LIBDIRSUFFIX="" +fi + +# Set the directory to serve through HTTP +WEBDIR=${WEBDIR:-/var/www/$PRGNAM} + +# Check for thttpd user account +if ! grep ^thttpd: /etc/passwd 2>&1 > /dev/null; then + echo " You must have a thttpd user/group to run this script." + echo " # groupadd -g 227 thttpd" + echo " # useradd -u 227 -g 227 -c \"User for thttpd\" -d / -s /bin/false thttpd" + exit 1 +fi + +# Check for thttpd group +if ! grep ^thttpd: /etc/group 2>&1 > /dev/null; then + echo " You must have a thttpd group to run this script." + echo " # groupadd -g 227 thttpd" + exit 1 +fi + +set -e + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $PRGNAM-$VERSION +tar xvf $CWD/$PRGNAM-$VERSION.tar.gz +cd $PRGNAM-$VERSION +chown -R root:root . +find . \ + \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ + -exec chmod 755 {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ + -exec chmod 644 {} \; + +# Apply some patches, from gentoo: +for i in $CWD/patches/*.diff $CWD/patches/*.patch +do + echo + echo "Appling patch $i ..." + cat $i | patch -p1 || exit 1 +done +echo + +CFLAGS="$SLKCFLAGS" \ +CXXFLAGS="$SLKCFLAGS" \ +./configure \ + --prefix=/usr \ + --libdir=/usr/lib${LIBDIRSUFFIX} \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --mandir=/usr/man \ + --build=$ARCH-slackware-linux + +# Fix 'DESTDIR' +sed -i \ + -e 's/$(DESTDIR)//g' \ + -e '/prefix =/ s/\/usr/$(DESTDIR)\/usr/' \ + -e '/MANDIR =/ s/\/usr\/man/$(DESTDIR)\/usr\/man/' \ + -e '/WEBDIR =/ s/$(prefix)\/www/$(DESTDIR)'$(echo $WEBDIR | sed 's/\//\\\//g')'/' \ + Makefile* extras/Makefile* cgi-src/Makefile* + +# Change the group to 'thttpd', rather than 'www' +sed -i '/WEBGROUP =/ s/www/'$PRGNAM'/' Makefile* extras/Makefile* cgi-src/Makefile* + +## Use this line ONLY if you are going to build thttpd as a normal user. +##sed -i '/WEBGROUP =/ s/www/'$(/bin/id -ng)'/' Makefile* extras/Makefile* cgi-src/Makefile* + +# Disable the use of bin as owner user and group. +sed -i 's/-o bin -g bin//' Makefile* extras/Makefile* cgi-src/Makefile* + +# Create required directories +mkdir -p $PKG/etc/rc.d $PKG/usr/man/man1 $PKG/etc/logrotate.d $PKG/var/log/$PRGNAM + +make +make install DESTDIR=$PKG + +find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ + | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true + +# Install default html file. +install -m 644 index.html $PKG/$WEBDIR +# Install default configuration file +install -m 644 $CWD/$PRGNAM.conf $PKG/etc/$PRGNAM.conf.new +# Edit the configuration file to reflect the value of $WEBDIR +sed -i 's/^dir=.*/dir='$(echo $WEBDIR | sed 's/\//\\\//g')'/' $PKG/etc/$PRGNAM.conf.new +# Install runtime script +install -m 755 $CWD/rc.$PRGNAM $PKG/etc/rc.d/rc.$PRGNAM.new +# Install lograte file +install -m 644 $CWD/$PRGNAM.logrotate $PKG/etc/logrotate.d/$PRGNAM.new + +find $PKG/usr/man -type f -exec gzip -9 {} \; +for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done + +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +cp -a FILES INSTALL README TODO scripts $PKG/usr/doc/$PRGNAM-$VERSION +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/doinst.sh > $PKG/install/doinst.sh +echo "preserve_perms etc/rc.d/rc.$PRGNAM.new" >> $PKG/install/doinst.sh +echo "config etc/$PRGNAM.conf.new" >> $PKG/install/doinst.sh +echo "config etc/logrotate.d/$PRGNAM.new" >> $PKG/install/doinst.sh + +# Fix permissions. +find $PKG/usr/doc/$PRGNAM-$VERSION -type f -exec chmod 644 {} \; + +# To avoid a conflict with httpd(apache) package. +mv $PKG/usr/man/man1/htpasswd.1.gz $PKG/usr/man/man1/htpasswd-$PRGNAM.1.gz +mv $PKG/usr/sbin/htpasswd $PKG/usr/sbin/htpasswd-$PRGNAM + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} diff --git a/network/thttpd/thttpd.conf b/network/thttpd/thttpd.conf new file mode 100644 index 0000000000000..22b9a9bb27f0b --- /dev/null +++ b/network/thttpd/thttpd.conf @@ -0,0 +1,9 @@ +# /etc/thttpd.conf +# Minimal configuration file for thttpd +# Check thttpd(8) for more options. +host=localhost +port=80 +user=thttpd +dir=/var/www/thttpd +logfile=/var/log/thttpd.log +pidfile=/var/run/thttpd.pid diff --git a/network/thttpd/thttpd.info b/network/thttpd/thttpd.info new file mode 100644 index 0000000000000..b83ce46192b1c --- /dev/null +++ b/network/thttpd/thttpd.info @@ -0,0 +1,10 @@ +PRGNAM="thttpd" +VERSION="2.25b" +HOMEPAGE="http://acme.com/software/thttpd/" +DOWNLOAD="http://acme.com/software/thttpd/thttpd-2.25b.tar.gz" +MD5SUM="156b249b3b0bcd48b06badd2db0d56c5" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +MAINTAINER="Antonio Hernández Blas" +EMAIL="hba.nihilismus@gmail.com" +APPROVED="Niels Horn" diff --git a/network/thttpd/thttpd.logrotate b/network/thttpd/thttpd.logrotate new file mode 100644 index 0000000000000..3c1cf98bea7bb --- /dev/null +++ b/network/thttpd/thttpd.logrotate @@ -0,0 +1,12 @@ +/var/log/thttpd.log { + daily + rotate 5 + compress + delaycompress + missingok + notifempty + sharedscripts + postrotate + /etc/rc.d/rc.thttpd restart + endscript +} |