├── .gitignore ├── .travis.yml ├── Makefile.am ├── README.md ├── README.thttpd ├── TODO ├── autogen.sh ├── configure.ac ├── docs ├── Makefile.am ├── htpasswd.1 ├── makeweb.1 ├── redirect.8 ├── ssi.8 ├── syslogtocern.8 └── thttpd.8 ├── extras ├── Makefile.am ├── htpasswd.c ├── makeweb.c └── syslogtocern ├── scripts ├── 500.thttpd-rotate ├── Makefile.am ├── thttpd.sh └── thttpd_wrapper ├── src ├── Makefile.am ├── fdwatch.c ├── fdwatch.h ├── libhttpd.c ├── libhttpd.h ├── make_mime.pl ├── match.c ├── match.h ├── mime_encodings.h ├── mime_encodings.txt ├── mime_types.h ├── mime_types.txt ├── mmc.c ├── mmc.h ├── tdate_parse.c ├── tdate_parse.h ├── thttpd.c ├── thttpd.h ├── timers.c ├── timers.h └── version.h └── www ├── Makefile.am ├── cgi-bin ├── Makefile.am ├── phf.c ├── printenv ├── redirect.c └── ssi.c └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | aclocal.m4 2 | autom4te.cache 3 | config.h 4 | config.h.in 5 | config.log 6 | config.status 7 | configure 8 | depcomp 9 | install-sh 10 | missing 11 | stamp-h1 12 | # 13 | Makefile 14 | Makefile.in 15 | *.o 16 | # 17 | extras/.deps 18 | extras/htpasswd 19 | extras/makeweb 20 | src/.deps 21 | src/libmatch.a 22 | src/thttpd 23 | www/cgi-bin/.deps 24 | www/cgi-bin/phf 25 | www/cgi-bin/redirect 26 | www/cgi-bin/ssi 27 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | compiler: 3 | - gcc 4 | - clang 5 | before_install: 6 | - sudo apt-get update -qq 7 | - sudo apt-get install autotools-dev automake autoconf libtool 8 | script: ./autogen.sh && ./configure && make V=1 9 | notifications: 10 | irc: 11 | channels: 12 | - "irc.freenode.org#thttpd" 13 | on_success: change 14 | on_failure: always 15 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = src extras docs scripts www 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | sthttpd - a fork of thttpd, a tiny/turbo/throttling HTTP server 3 | version 2.27.0 Oct 3, 2014 4 | 5 | sthttpd is a fork of Jef Poskanzer's popular thttpd server. This fork aims to simply maintain the original codebase as bugs or security issues are found. 6 | 7 | Please read README.thttpd for more information. 8 | 9 | Credits: 10 | 11 | * The original codebase is by * Jef Poskanzer http://www.acme.com/jef/ Please send all kudos to him. 12 | 13 | * The fork is by Anthony G. Basile https://github.com/blueness/sthttpd Send all blame to him. 14 | 15 | * thttpd is released under a BSD license. Any extended code added by sthttpd is also released under the same license. Here's a copy of it from the src/thttpd.c file: 16 | 17 | 18 | Copyright � 1995,1998,1999,2000,2001 by Jef Poskanzer . 19 | All rights reserved. 20 | 21 | Redistribution and use in source and binary forms, with or without 22 | modification, are permitted provided that the following conditions 23 | are met: 24 | 1. Redistributions of source code must retain the above copyright 25 | notice, this list of conditions and the following disclaimer. 26 | 2. Redistributions in binary form must reproduce the above copyright 27 | notice, this list of conditions and the following disclaimer in the 28 | documentation and/or other materials provided with the distribution. 29 | 30 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 31 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 32 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 34 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 39 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40 | SUCH DAMAGE. 41 | 42 | ## Build status 43 | [![Build Status](https://travis-ci.org/blueness/sthttpd.svg?branch=master)](https://travis-ci.org/blueness/sthttpd) 44 | 45 | -------------------------------------------------------------------------------- /README.thttpd: -------------------------------------------------------------------------------- 1 | thttpd - tiny/turbo/throttling HTTP server 2 | version 2.25b of 29dec2003 3 | 4 | thttpd is a simple, small, portable, fast, and secure HTTP server. 5 | 6 | Simple: It handles only the minimum necessary to implement HTTP/1.1. 7 | 8 | Small: See the size comparison chart at 9 | http://www.acme.com/software/thttpd/notes.html#sizes. It also has a 10 | very small run-time size, since it does not fork and is very careful about 11 | memory allocation. 12 | 13 | Portable: It compiles cleanly on FreeBSD 2.x/3.x, SunOS 4.1.x, Solaris 2.x, 14 | BSD/OS 2.x, Linux 1.2.x, OSF/1 (on a 64-bit Alpha), and no doubt many others. 15 | 16 | Fast: In typical use it's about as fast as the best full-featured servers 17 | (Apache, NCSA, Netscape). Under extreme load it's much faster. 18 | 19 | Secure: It goes to great lengths to protect the web server machine 20 | against attacks and breakins from other sites. 21 | 22 | It also has one extremely useful feature (URL-traffic-based throttling) that 23 | no other server currently has. 24 | 25 | See the manual entry for more details. See the INSTALL file for 26 | configuration and installation instructions. Check the web page 27 | (http://www.acme.com/software/thttpd/) for updates, or add yourself to 28 | the mailing list by sending a "subscribe" to thttpd-announce-request@mail.acme.com. 29 | 30 | Comments to: 31 | Jef Poskanzer jef@mail.acme.com http://www.acme.com/jef/ 32 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | - - - - - - - - - - high priority - - - - - - - - - - 2 | 3 | IPv6 not working right. 4 | 5 | Problem with ACME News downloads. PATH_INFO interferes with the authorization. 6 | 7 | Why is the client's IP address showing up in paths? 8 | 9 | Fetches with numeric IP addresses and no Host: header are screwing up the 10 | vhost code? 11 | 143.90.193.229 - - [06/Apr/2000:09:21:34 -0700] "GET /209.133.38.22/software/thttpd/ HTTP/1.0" 200 12093 "http://www.dbphotography.demon.co.uk/index.html" "Mozilla/1.22 (compatible; MSIE 2.0; Windows 95)" 12 | 143.90.193.229 - - [06/Apr/2000:09:21:37 -0700] "GET /143.90.193.229/software/thttpd/anvil_thttpd.gif HTTP/1.0" 403 - "http://www.acme.com/software/thttpd/" "Mozilla/1.22 (compatible; MSIE 2.0; Windows 95)" 13 | 14 | Have directory indexing skip files that start with dot? Except ..? 15 | In libhttpd.c: 16 | + if (*(de->d_name) == '.' && *(de->d_name+1) != '.') 17 | + continue; 18 | namlen = NAMLEN(de); 19 | 20 | Add comment on INDEX_NAMES that it should be simple filenames only. 21 | 22 | The error page generated for non-local referers should include the 23 | original URL as an active link. 24 | 25 | Make open in mmc.c use O_NONBLOCK flag, to prevent DOS attack via 26 | a named pipe? 27 | 28 | - - - - - - - - - - later - - - - - - - - - - 29 | 30 | Document how symlinks interact with .htpasswd - authorization is checked 31 | on the result of the symlink, and not the origin. 32 | 33 | SIGHUP log re-opening doesn't work if you started as root. 34 | 35 | Change redirect to put the Refresh command in the HTTP headers, instead of 36 | a META tag. 37 | 38 | Add TCP_NODELAY, but after CGIs get spawned. 39 | 40 | Add stat cache? 1 minute expiry? 41 | 42 | Ifdef the un-close-on-exec CGI thing for Linux only. 43 | 44 | Add keep-alives, via a new state in thttpd.c. 45 | 46 | - - - - - - - - - - someday - - - - - - - - - - 47 | 48 | The special world-permissions checking is probably bogus. For one 49 | thing, it doesn't handle restrictive permissions on parent directories 50 | properly. It should probably just go away. 51 | 52 | redirect should interpret a path with a trailing / as /index.html 53 | 54 | ssi should change $cwd to the source document's location. 55 | 56 | Allow .throttle files in individual directories. 57 | 58 | Log-digesting scripts. 59 | 60 | Config web page. 61 | Common errors: 62 | Not realizing that -c overrides CGI_PATTERN instead of augmenting it. 63 | Using a directory name for the -c pattern. 64 | 65 | - - - - - - - - - - 3.x - - - - - - - - - - 66 | 67 | Tasklets re-write. 68 | 69 | - - - - - - - - - - general - - - - - - - - - - 70 | 71 | Release process: 72 | - update version number in version.h README INSTALL and 73 | contrib/redhat-rpm/thttpd.spec 74 | - do a tdiff and update the local installation 75 | - do an rcstreeinfo, and check in all files 76 | - make tar 77 | - mv it to .. 78 | - update version number in ../thttpd.html 79 | - update ~acmeweb/updates.html 80 | - mail announcement to thttpd-announce 81 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | aclocal && \ 4 | autoheader && \ 5 | autoconf && \ 6 | automake --add-missing --copy 7 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_PREREQ([2.68]) 2 | AC_INIT([sthttpd], [2.27.0], [http://opensource.dyc.edu/bugzilla3]) 3 | AC_CONFIG_SRCDIR([src/thttpd.c]) 4 | AC_CONFIG_HEADERS([config.h]) 5 | AM_INIT_AUTOMAKE([1.11 foreign]) 6 | 7 | # Checks for programs. 8 | AC_PROG_CC 9 | AC_PROG_INSTALL 10 | AN_MAKEVAR([AR], [AC_PROG_AR]) 11 | AN_PROGRAM([ar], [AC_PROG_AR]) 12 | AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)]) 13 | AC_PROG_AR 14 | 15 | # Checks for libraries. 16 | AC_CHECK_LIB(crypt, crypt) 17 | AC_CHECK_LIB(rt, clock_gettime) 18 | AC_CHECK_LIB(resolv, hstrerror) 19 | 20 | # Checks for header files. 21 | AC_CHECK_HEADERS([arpa/inet.h fcntl.h grp.h memory.h netdb.h netinet/in.h osreldate.h paths.h poll.h stdlib.h string.h sys/devpoll.h sys/event.h sys/param.h sys/poll.h sys/socket.h sys/time.h syslog.h unistd.h]) 22 | AC_HEADER_TIME 23 | AC_HEADER_DIRENT 24 | AC_PROG_RANLIB 25 | 26 | # Checks for typedefs, structures, and compiler characteristics. 27 | AC_TYPE_UID_T 28 | AC_TYPE_INT64_T 29 | AC_TYPE_OFF_T 30 | AC_TYPE_PID_T 31 | AC_TYPE_SIZE_T 32 | AC_TYPE_SSIZE_T 33 | 34 | # Checks for library functions. 35 | AC_FUNC_CHOWN 36 | AC_FUNC_FORK 37 | AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK 38 | AC_FUNC_MALLOC 39 | AC_FUNC_MMAP 40 | AC_FUNC_WAIT3 41 | AC_CHECK_FUNCS([alarm atoll bzero clock_gettime daemon dup2 gai_strerror getcwd getaddrinfo gethostbyname gethostname getnameinfo getpass gettimeofday hstrerror inet_ntoa kqueue memmove memset mkdir munmap poll select setlogin setsid sigset socket strcasecmp strchr strcspn strdup strerror strncasecmp strpbrk strrchr strspn strstr tzset vsnprintf waitpid]) 42 | 43 | AC_ARG_VAR(WEBDIR, [The document root directory of your web page]) 44 | 45 | if test "x${WEBDIR}" = "x" ; then 46 | WEBDIR='/usr/local/www' 47 | fi 48 | 49 | AC_ARG_VAR(WEBGROUP, [The group that the web server will run as]) 50 | 51 | if test "x${WEBGROUP}" = "x" ; then 52 | WEBGROUP='thttpd' 53 | fi 54 | 55 | AC_CONFIG_FILES([Makefile 56 | docs/Makefile 57 | extras/Makefile 58 | scripts/Makefile 59 | src/Makefile 60 | www/Makefile 61 | www/cgi-bin/Makefile]) 62 | 63 | AC_OUTPUT 64 | -------------------------------------------------------------------------------- /docs/Makefile.am: -------------------------------------------------------------------------------- 1 | dist_man_MANS = htpasswd.1 makeweb.1 redirect.8 ssi.8 syslogtocern.8 thttpd.8 2 | -------------------------------------------------------------------------------- /docs/htpasswd.1: -------------------------------------------------------------------------------- 1 | .TH htpasswd 1 "05 May 1998" 2 | .SH NAME 3 | htpasswd - manipulate HTTP-server password files 4 | .SH SYNOPSIS 5 | .B htpasswd 6 | .RB [ -c ] 7 | .I passwordfile 8 | .I username 9 | .SH DESCRIPTION 10 | .PP 11 | Sets a user's password in an httpd-style password file. 12 | The -c flag creates a new file. 13 | .SH AUTHOR 14 | Rob McCool. 15 | Modified 29aug97 by Jef Poskanzer to accept new password on stdin, 16 | if stdin is a pipe or file. This is necessary for use from CGI. 17 | -------------------------------------------------------------------------------- /docs/makeweb.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/docs/makeweb.1 -------------------------------------------------------------------------------- /docs/redirect.8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/docs/redirect.8 -------------------------------------------------------------------------------- /docs/ssi.8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/docs/ssi.8 -------------------------------------------------------------------------------- /docs/syslogtocern.8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/docs/syslogtocern.8 -------------------------------------------------------------------------------- /docs/thttpd.8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/docs/thttpd.8 -------------------------------------------------------------------------------- /extras/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -DWEBDIR='"$(WEBDIR)"' 2 | 3 | sbin_PROGRAMS = makeweb htpasswd 4 | makeweb_SOURCES = makeweb.c 5 | htpasswd_SOURCES = htpasswd.c 6 | 7 | dist_sbin_SCRIPTS = syslogtocern 8 | 9 | install-exec-hook: 10 | chgrp $(WEBGROUP) $(DESTDIR)$(sbindir)/makeweb 11 | chmod 2751 $(DESTDIR)$(sbindir)/makeweb 12 | -------------------------------------------------------------------------------- /extras/htpasswd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * htpasswd.c: simple program for manipulating password file for NCSA httpd 3 | * 4 | * Rob McCool 5 | */ 6 | 7 | /* Modified 29aug97 by Jef Poskanzer to accept new password on stdin, 8 | ** if stdin is a pipe or file. This is necessary for use from CGI. 9 | */ 10 | 11 | #include 12 | 13 | //system headers 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | extern char *crypt(const char *key, const char *setting); 23 | 24 | #define LF 10 25 | #define CR 13 26 | 27 | #define MAX_STRING_LEN 256 28 | 29 | int tfd; 30 | char temp_template[] = "/tmp/htp.XXXXXX"; 31 | 32 | void interrupted(int); 33 | 34 | static char * strd(char *s) { 35 | char *d; 36 | 37 | d=(char *)malloc(strlen(s) + 1); 38 | strcpy(d,s); 39 | return(d); 40 | } 41 | 42 | static void getword(char *word, char *line, char stop) { 43 | int x = 0,y; 44 | 45 | for(x=0;((line[x]) && (line[x] != stop));x++) 46 | word[x] = line[x]; 47 | 48 | word[x] = '\0'; 49 | if(line[x]) ++x; 50 | y=0; 51 | 52 | while((line[y++] = line[x++])); 53 | } 54 | 55 | static int get_line(char *s, int n, FILE *f) { 56 | register int i=0; 57 | 58 | while(1) { 59 | s[i] = (char)fgetc(f); 60 | 61 | if(s[i] == CR) 62 | s[i] = fgetc(f); 63 | 64 | if((s[i] == 0x4) || (s[i] == LF) || (i == (n-1))) { 65 | s[i] = '\0'; 66 | return (feof(f) ? 1 : 0); 67 | } 68 | ++i; 69 | } 70 | } 71 | 72 | static void putline(FILE *f,char *l) { 73 | int x; 74 | 75 | for(x=0;l[x];x++) fputc(l[x],f); 76 | fputc('\n',f); 77 | } 78 | 79 | 80 | /* From local_passwd.c (C) Regents of Univ. of California blah blah */ 81 | static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */ 82 | "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 83 | 84 | static void to64(register char *s, register long v, register int n) { 85 | while (--n >= 0) { 86 | *s++ = itoa64[v&0x3f]; 87 | v >>= 6; 88 | } 89 | } 90 | 91 | #ifdef MPE 92 | /* MPE lacks getpass() and a way to suppress stdin echo. So for now, just 93 | issue the prompt and read the results with echo. (Ugh). */ 94 | 95 | char *getpass(const char *prompt) { 96 | 97 | static char password[81]; 98 | 99 | fputs(prompt,stderr); 100 | gets((char *)&password); 101 | 102 | if (strlen((char *)&password) > 8) { 103 | password[8]='\0'; 104 | } 105 | 106 | return (char *)&password; 107 | } 108 | #endif 109 | 110 | static void 111 | add_password( char* user, FILE* f ) 112 | { 113 | char pass[100]; 114 | char* pw; 115 | char* cpw; 116 | char salt[3]; 117 | 118 | if ( ! isatty( fileno( stdin ) ) ) 119 | { 120 | (void) fgets( pass, sizeof(pass), stdin ); 121 | if ( pass[strlen(pass) - 1] == '\n' ) 122 | pass[strlen(pass) - 1] = '\0'; 123 | pw = pass; 124 | } 125 | else 126 | { 127 | pw = strd( (char*) getpass( "New password:" ) ); 128 | if ( strcmp( pw, (char*) getpass( "Re-type new password:" ) ) != 0 ) 129 | { 130 | (void) fprintf( stderr, "They don't match, sorry.\n" ); 131 | if ( tfd != -1 ) 132 | unlink( temp_template ); 133 | exit( 1 ); 134 | } 135 | } 136 | (void) srandom( (int) time( (time_t*) 0 ) ); 137 | to64( &salt[0], random(), 2 ); 138 | cpw = crypt( pw, salt ); 139 | if (cpw) 140 | (void) fprintf( f, "%s:%s\n", user, cpw ); 141 | else 142 | (void) fprintf( stderr, "crypt() returned NULL, sorry\n" ); 143 | } 144 | 145 | static void usage(void) { 146 | fprintf(stderr,"Usage: htpasswd [-c] passwordfile username\n"); 147 | fprintf(stderr,"The -c flag creates a new file.\n"); 148 | exit(1); 149 | } 150 | 151 | void interrupted(int signo) { 152 | fprintf(stderr,"Interrupted.\n"); 153 | if(tfd != -1) unlink(temp_template); 154 | exit(1); 155 | } 156 | 157 | int main(int argc, char *argv[]) { 158 | FILE *tfp,*f; 159 | char user[MAX_STRING_LEN]; 160 | char pwfilename[MAX_STRING_LEN]; 161 | char line[MAX_STRING_LEN]; 162 | char l[MAX_STRING_LEN]; 163 | char w[MAX_STRING_LEN]; 164 | char command[MAX_STRING_LEN]; 165 | int found; 166 | 167 | tfd = -1; 168 | signal(SIGINT,(void (*)(int))interrupted); 169 | if(argc == 4) { 170 | if(strcmp(argv[1],"-c")) 171 | usage(); 172 | if(!(tfp = fopen(argv[2],"w"))) { 173 | fprintf(stderr,"Could not open passwd file %s for writing.\n", 174 | argv[2]); 175 | perror("fopen"); 176 | exit(1); 177 | } 178 | if (strlen(argv[2]) > (sizeof(pwfilename) - 1)) { 179 | fprintf(stderr, "%s: filename is too long\n", argv[0]); 180 | exit(1); 181 | } 182 | if (((strchr(argv[2], ';')) != NULL) || ((strchr(argv[2], '>')) != NULL)) { 183 | fprintf(stderr, "%s: filename contains an illegal character\n", 184 | argv[0]); 185 | exit(1); 186 | } 187 | if (strlen(argv[3]) > (sizeof(user) - 1)) { 188 | fprintf(stderr, "%s: username is too long\n", argv[0]); 189 | exit(1); 190 | } 191 | if ((strchr(argv[3], ':')) != NULL) { 192 | fprintf(stderr, "%s: username contains an illegal character\n", 193 | argv[0]); 194 | exit(1); 195 | } 196 | printf("Adding password for %s.\n",argv[3]); 197 | add_password(argv[3],tfp); 198 | fclose(tfp); 199 | exit(0); 200 | } else if(argc != 3) usage(); 201 | 202 | tfd = mkstemp(temp_template); 203 | if(!(tfp = fdopen(tfd,"w"))) { 204 | fprintf(stderr,"Could not open temp file.\n"); 205 | exit(1); 206 | } 207 | 208 | if (strlen(argv[1]) > (sizeof(pwfilename) - 1)) { 209 | fprintf(stderr, "%s: filename is too long\n", argv[0]); 210 | exit(1); 211 | } 212 | if (((strchr(argv[1], ';')) != NULL) || ((strchr(argv[1], '>')) != NULL)) { 213 | fprintf(stderr, "%s: filename contains an illegal character\n", 214 | argv[0]); 215 | exit(1); 216 | } 217 | if (strlen(argv[2]) > (sizeof(user) - 1)) { 218 | fprintf(stderr, "%s: username is too long\n", argv[0]); 219 | exit(1); 220 | } 221 | if ((strchr(argv[2], ':')) != NULL) { 222 | fprintf(stderr, "%s: username contains an illegal character\n", 223 | argv[0]); 224 | exit(1); 225 | } 226 | if(!(f = fopen(argv[1],"r"))) { 227 | fprintf(stderr, 228 | "Could not open passwd file %s for reading.\n",argv[1]); 229 | fprintf(stderr,"Use -c option to create new one.\n"); 230 | exit(1); 231 | } 232 | strcpy(user,argv[2]); 233 | 234 | found = 0; 235 | while(!(get_line(line,MAX_STRING_LEN,f))) { 236 | if(found || (line[0] == '#') || (!line[0])) { 237 | putline(tfp,line); 238 | continue; 239 | } 240 | strcpy(l,line); 241 | getword(w,l,':'); 242 | if(strcmp(user,w)) { 243 | putline(tfp,line); 244 | continue; 245 | } 246 | else { 247 | printf("Changing password for user %s\n",user); 248 | add_password(user,tfp); 249 | found = 1; 250 | } 251 | } 252 | if(!found) { 253 | printf("Adding user %s\n",user); 254 | add_password(user,tfp); 255 | } 256 | fclose(f); 257 | fclose(tfp); 258 | sprintf(command,"cp %s %s",temp_template,argv[1]); 259 | system(command); 260 | unlink(temp_template); 261 | exit(0); 262 | } 263 | -------------------------------------------------------------------------------- /extras/makeweb.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/extras/makeweb.c -------------------------------------------------------------------------------- /extras/syslogtocern: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/extras/syslogtocern -------------------------------------------------------------------------------- /scripts/500.thttpd-rotate: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # thttpd-rotate - nightly script to rotate thttpd's log files on FreeBSD 4 | # 5 | # This goes in /etc/periodic/daily. It rotates the log files and then 6 | # tells thttpd to re-open its log file. 7 | 8 | cd /usr/local/www/chroot/logs 9 | rm -f thttpd_log.7 10 | mv thttpd_log.6 thttpd_log.7 11 | mv thttpd_log.5 thttpd_log.6 12 | mv thttpd_log.4 thttpd_log.5 13 | mv thttpd_log.3 thttpd_log.4 14 | mv thttpd_log.2 thttpd_log.3 15 | mv thttpd_log.1 thttpd_log.2 16 | mv thttpd_log thttpd_log.1 17 | kill -HUP `cat /var/run/thttpd.pid` 18 | -------------------------------------------------------------------------------- /scripts/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = 500.thttpd-rotate thttpd.sh thttpd_wrapper 2 | -------------------------------------------------------------------------------- /scripts/thttpd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # thttpd.sh - startup script for thttpd on FreeBSD 4 | # 5 | # This goes in /usr/local/etc/rc.d and gets run at boot-time. 6 | 7 | case "$1" in 8 | 9 | start) 10 | if [ -x /usr/local/sbin/thttpd_wrapper ] ; then 11 | echo -n " thttpd" 12 | /usr/local/sbin/thttpd_wrapper & 13 | fi 14 | ;; 15 | 16 | stop) 17 | kill -USR1 `cat /var/run/thttpd.pid` 18 | ;; 19 | 20 | *) 21 | echo "usage: $0 { start | stop }" >&2 22 | exit 1 23 | ;; 24 | 25 | esac 26 | -------------------------------------------------------------------------------- /scripts/thttpd_wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # thttpd_wrapper - wrapper script for thttpd on FreeBSD 4 | # 5 | # This goes in /usr/local/sbin. It runs thttpd in a loop. If thttpd 6 | # exits then the script restarts it automatically. 7 | # 8 | # The -D flag tells thttpd to *not* put itself into the background, 9 | # and the -C flag tells it to get the rest of its configuration from 10 | # the specified config file. 11 | 12 | while true ; do 13 | /usr/local/sbin/thttpd -D -C /usr/local/www/thttpd_config 14 | if [ -f /var/run/nologin ] ; then 15 | exit 16 | fi 17 | sleep 10 18 | egrep ' thttpd\[' /var/log/messages | 19 | tail -33 | 20 | mail -s "thttpd on `hostname` restarted" root 21 | done 22 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | sbin_PROGRAMS = thttpd 2 | thttpd_SOURCES = thttpd.c thttpd.h \ 3 | fdwatch.c fdwatch.h \ 4 | libhttpd.c libhttpd.h \ 5 | mmc.c mmc.h \ 6 | timers.c timers.h \ 7 | tdate_parse.c tdate_parse.h \ 8 | mime_encodings.h mime_types.h version.h 9 | thttpd_LDADD = libmatch.a 10 | 11 | noinst_LIBRARIES = libmatch.a 12 | libmatch_a_SOURCES = match.c match.h 13 | -------------------------------------------------------------------------------- /src/fdwatch.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/src/fdwatch.c -------------------------------------------------------------------------------- /src/fdwatch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/src/fdwatch.h -------------------------------------------------------------------------------- /src/libhttpd.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/src/libhttpd.c -------------------------------------------------------------------------------- /src/libhttpd.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/src/libhttpd.h -------------------------------------------------------------------------------- /src/make_mime.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | #Run this on developer side, whenever you update 4 | #your mime encodings, or mime types. 5 | 6 | open(ENCODINGS, '<', "mime_encodings.txt"); 7 | @encoding=; 8 | close(ENCODINGS); 9 | 10 | open(ENCHEADER, '>', "mime_encodings.h"); 11 | foreach (@encoding) 12 | { 13 | chomp($_); 14 | @element = split(/\t+/,$_); 15 | next if $element[0] =~ /#/ ; 16 | next if $element[1] =~ /#/ ; 17 | next if length($element[0]) == 0 || length($element[1]) == 0 ; 18 | print ENCHEADER '{ "', $element[0], '", 0, "', $element[1], '", 0 },', "\n"; 19 | } 20 | close(ENCHEADER); 21 | 22 | 23 | open(TYPES, '<', "mime_types.txt"); 24 | @type=; 25 | close(TYPES); 26 | 27 | open(TYPEHEADER, '>', "mime_types.h"); 28 | foreach (@type) 29 | { 30 | chomp($_); 31 | @element = split(/\t+/,$_); 32 | next if $element[0] =~ /#/ ; 33 | next if $element[1] =~ /#/ ; 34 | next if length($element[0]) == 0 || length($element[1]) == 0 ; 35 | print TYPEHEADER '{ "', $element[0], '", 0, "', $element[1], '", 0 },', "\n"; 36 | } 37 | close(TYPEHEADER); 38 | -------------------------------------------------------------------------------- /src/match.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/src/match.c -------------------------------------------------------------------------------- /src/match.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/src/match.h -------------------------------------------------------------------------------- /src/mime_encodings.h: -------------------------------------------------------------------------------- 1 | { "Z", 0, "compress", 0 }, 2 | { "gz", 0, "gzip", 0 }, 3 | { "svgz", 0, "gzip", 0 }, 4 | { "uu", 0, "x-uuencode", 0 }, 5 | -------------------------------------------------------------------------------- /src/mime_encodings.txt: -------------------------------------------------------------------------------- 1 | # mime_encodings.txt 2 | # 3 | # A list of file extensions followed by the corresponding MIME encoding. 4 | # Extensions not found in the table proceed to the mime_types table. 5 | 6 | Z compress 7 | gz gzip 8 | svgz gzip 9 | uu x-uuencode 10 | -------------------------------------------------------------------------------- /src/mime_types.h: -------------------------------------------------------------------------------- 1 | { "a", 0, "application/octet-stream", 0 }, 2 | { "aab", 0, "application/x-authorware-bin", 0 }, 3 | { "aam", 0, "application/x-authorware-map", 0 }, 4 | { "aas", 0, "application/x-authorware-seg", 0 }, 5 | { "ai", 0, "application/postscript", 0 }, 6 | { "aif", 0, "audio/x-aiff", 0 }, 7 | { "aifc", 0, "audio/x-aiff", 0 }, 8 | { "aiff", 0, "audio/x-aiff", 0 }, 9 | { "asc", 0, "text/plain", 0 }, 10 | { "asf", 0, "video/x-ms-asf", 0 }, 11 | { "asx", 0, "video/x-ms-asf", 0 }, 12 | { "au", 0, "audio/basic", 0 }, 13 | { "avi", 0, "video/x-msvideo", 0 }, 14 | { "bcpio", 0, "application/x-bcpio", 0 }, 15 | { "bin", 0, "application/octet-stream", 0 }, 16 | { "bmp", 0, "image/bmp", 0 }, 17 | { "cdf", 0, "application/x-netcdf", 0 }, 18 | { "class", 0, "application/x-java-vm", 0 }, 19 | { "cpio", 0, "application/x-cpio", 0 }, 20 | { "cpt", 0, "application/mac-compactpro", 0 }, 21 | { "crl", 0, "application/x-pkcs7-crl", 0 }, 22 | { "crt", 0, "application/x-x509-ca-cert", 0 }, 23 | { "csh", 0, "application/x-csh", 0 }, 24 | { "css", 0, "text/css", 0 }, 25 | { "dcr", 0, "application/x-director", 0 }, 26 | { "dir", 0, "application/x-director", 0 }, 27 | { "djv", 0, "image/vnd.djvu", 0 }, 28 | { "djvu", 0, "image/vnd.djvu", 0 }, 29 | { "dll", 0, "application/octet-stream", 0 }, 30 | { "dms", 0, "application/octet-stream", 0 }, 31 | { "doc", 0, "application/msword", 0 }, 32 | { "dtd", 0, "text/xml", 0 }, 33 | { "dump", 0, "application/octet-stream", 0 }, 34 | { "dvi", 0, "application/x-dvi", 0 }, 35 | { "dxr", 0, "application/x-director", 0 }, 36 | { "eps", 0, "application/postscript", 0 }, 37 | { "etx", 0, "text/x-setext", 0 }, 38 | { "exe", 0, "application/octet-stream", 0 }, 39 | { "ez", 0, "application/andrew-inset", 0 }, 40 | { "fgd", 0, "application/x-director", 0 }, 41 | { "fh", 0, "image/x-freehand", 0 }, 42 | { "fh4", 0, "image/x-freehand", 0 }, 43 | { "fh5", 0, "image/x-freehand", 0 }, 44 | { "fh7", 0, "image/x-freehand", 0 }, 45 | { "fhc", 0, "image/x-freehand", 0 }, 46 | { "gif", 0, "image/gif", 0 }, 47 | { "gtar", 0, "application/x-gtar", 0 }, 48 | { "hdf", 0, "application/x-hdf", 0 }, 49 | { "hqx", 0, "application/mac-binhex40", 0 }, 50 | { "htm", 0, "text/html; charset=%s", 0 }, 51 | { "html", 0, "text/html; charset=%s", 0 }, 52 | { "ice", 0, "x-conference/x-cooltalk", 0 }, 53 | { "ief", 0, "image/ief", 0 }, 54 | { "iges", 0, "model/iges", 0 }, 55 | { "igs", 0, "model/iges", 0 }, 56 | { "iv", 0, "application/x-inventor", 0 }, 57 | { "jar", 0, "application/x-java-archive", 0 }, 58 | { "jfif", 0, "image/jpeg", 0 }, 59 | { "jpe", 0, "image/jpeg", 0 }, 60 | { "jpeg", 0, "image/jpeg", 0 }, 61 | { "jpg", 0, "image/jpeg", 0 }, 62 | { "js", 0, "application/x-javascript", 0 }, 63 | { "kar", 0, "audio/midi", 0 }, 64 | { "latex", 0, "application/x-latex", 0 }, 65 | { "lha", 0, "application/octet-stream", 0 }, 66 | { "lzh", 0, "application/octet-stream", 0 }, 67 | { "m3u", 0, "audio/x-mpegurl", 0 }, 68 | { "man", 0, "application/x-troff-man", 0 }, 69 | { "mathml", 0, "application/mathml+xml", 0 }, 70 | { "me", 0, "application/x-troff-me", 0 }, 71 | { "mesh", 0, "model/mesh", 0 }, 72 | { "mid", 0, "audio/midi", 0 }, 73 | { "midi", 0, "audio/midi", 0 }, 74 | { "mif", 0, "application/vnd.mif", 0 }, 75 | { "mime", 0, "message/rfc822", 0 }, 76 | { "mml", 0, "application/mathml+xml", 0 }, 77 | { "mov", 0, "video/quicktime", 0 }, 78 | { "movie", 0, "video/x-sgi-movie", 0 }, 79 | { "mp2", 0, "audio/mpeg", 0 }, 80 | { "mp3", 0, "audio/mpeg", 0 }, 81 | { "mp4", 0, "video/mp4", 0 }, 82 | { "mpe", 0, "video/mpeg", 0 }, 83 | { "mpeg", 0, "video/mpeg", 0 }, 84 | { "mpg", 0, "video/mpeg", 0 }, 85 | { "mpga", 0, "audio/mpeg", 0 }, 86 | { "ms", 0, "application/x-troff-ms", 0 }, 87 | { "msh", 0, "model/mesh", 0 }, 88 | { "mv", 0, "video/x-sgi-movie", 0 }, 89 | { "mxu", 0, "video/vnd.mpegurl", 0 }, 90 | { "nc", 0, "application/x-netcdf", 0 }, 91 | { "o", 0, "application/octet-stream", 0 }, 92 | { "oda", 0, "application/oda", 0 }, 93 | { "ogg", 0, "application/ogg", 0 }, 94 | { "pac", 0, "application/x-ns-proxy-autoconfig", 0 }, 95 | { "pbm", 0, "image/x-portable-bitmap", 0 }, 96 | { "pdb", 0, "chemical/x-pdb", 0 }, 97 | { "pdf", 0, "application/pdf", 0 }, 98 | { "pgm", 0, "image/x-portable-graymap", 0 }, 99 | { "pgn", 0, "application/x-chess-pgn", 0 }, 100 | { "png", 0, "image/png", 0 }, 101 | { "pnm", 0, "image/x-portable-anymap", 0 }, 102 | { "ppm", 0, "image/x-portable-pixmap", 0 }, 103 | { "ppt", 0, "application/vnd.ms-powerpoint", 0 }, 104 | { "ps", 0, "application/postscript", 0 }, 105 | { "qt", 0, "video/quicktime", 0 }, 106 | { "ra", 0, "audio/x-realaudio", 0 }, 107 | { "ram", 0, "audio/x-pn-realaudio", 0 }, 108 | { "ras", 0, "image/x-cmu-raster", 0 }, 109 | { "rdf", 0, "application/rdf+xml", 0 }, 110 | { "rgb", 0, "image/x-rgb", 0 }, 111 | { "rm", 0, "audio/x-pn-realaudio", 0 }, 112 | { "roff", 0, "application/x-troff", 0 }, 113 | { "rpm", 0, "audio/x-pn-realaudio-plugin", 0 }, 114 | { "rss", 0, "application/rss+xml", 0 }, 115 | { "rtf", 0, "text/rtf", 0 }, 116 | { "rtx", 0, "text/richtext", 0 }, 117 | { "sgm", 0, "text/sgml", 0 }, 118 | { "sgml", 0, "text/sgml", 0 }, 119 | { "sh", 0, "application/x-sh", 0 }, 120 | { "shar", 0, "application/x-shar", 0 }, 121 | { "silo", 0, "model/mesh", 0 }, 122 | { "sit", 0, "application/x-stuffit", 0 }, 123 | { "skd", 0, "application/x-koan", 0 }, 124 | { "skm", 0, "application/x-koan", 0 }, 125 | { "skp", 0, "application/x-koan", 0 }, 126 | { "skt", 0, "application/x-koan", 0 }, 127 | { "smi", 0, "application/smil", 0 }, 128 | { "smil", 0, "application/smil", 0 }, 129 | { "snd", 0, "audio/basic", 0 }, 130 | { "so", 0, "application/octet-stream", 0 }, 131 | { "spl", 0, "application/x-futuresplash", 0 }, 132 | { "src", 0, "application/x-wais-source", 0 }, 133 | { "stc", 0, "application/vnd.sun.xml.calc.template", 0 }, 134 | { "std", 0, "application/vnd.sun.xml.draw.template", 0 }, 135 | { "sti", 0, "application/vnd.sun.xml.impress.template", 0 }, 136 | { "stw", 0, "application/vnd.sun.xml.writer.template", 0 }, 137 | { "sv4cpio", 0, "application/x-sv4cpio", 0 }, 138 | { "sv4crc", 0, "application/x-sv4crc", 0 }, 139 | { "svg", 0, "image/svg+xml", 0 }, 140 | { "svgz", 0, "image/svg+xml", 0 }, 141 | { "swf", 0, "application/x-shockwave-flash", 0 }, 142 | { "sxc", 0, "application/vnd.sun.xml.calc", 0 }, 143 | { "sxd", 0, "application/vnd.sun.xml.draw", 0 }, 144 | { "sxg", 0, "application/vnd.sun.xml.writer.global", 0 }, 145 | { "sxi", 0, "application/vnd.sun.xml.impress", 0 }, 146 | { "sxm", 0, "application/vnd.sun.xml.math", 0 }, 147 | { "sxw", 0, "application/vnd.sun.xml.writer", 0 }, 148 | { "t", 0, "application/x-troff", 0 }, 149 | { "tar", 0, "application/x-tar", 0 }, 150 | { "tcl", 0, "application/x-tcl", 0 }, 151 | { "tex", 0, "application/x-tex", 0 }, 152 | { "texi", 0, "application/x-texinfo", 0 }, 153 | { "texinfo", 0, "application/x-texinfo", 0 }, 154 | { "tif", 0, "image/tiff", 0 }, 155 | { "tiff", 0, "image/tiff", 0 }, 156 | { "tr", 0, "application/x-troff", 0 }, 157 | { "tsp", 0, "application/dsptype", 0 }, 158 | { "tsv", 0, "text/tab-separated-values", 0 }, 159 | { "txt", 0, "text/plain; charset=%s", 0 }, 160 | { "ustar", 0, "application/x-ustar", 0 }, 161 | { "vcd", 0, "application/x-cdlink", 0 }, 162 | { "vrml", 0, "model/vrml", 0 }, 163 | { "vx", 0, "video/x-rad-screenplay", 0 }, 164 | { "wav", 0, "audio/x-wav", 0 }, 165 | { "wax", 0, "audio/x-ms-wax", 0 }, 166 | { "wbmp", 0, "image/vnd.wap.wbmp", 0 }, 167 | { "wbxml", 0, "application/vnd.wap.wbxml", 0 }, 168 | { "wm", 0, "video/x-ms-wm", 0 }, 169 | { "wma", 0, "audio/x-ms-wma", 0 }, 170 | { "wmd", 0, "application/x-ms-wmd", 0 }, 171 | { "wml", 0, "text/vnd.wap.wml", 0 }, 172 | { "wmlc", 0, "application/vnd.wap.wmlc", 0 }, 173 | { "wmls", 0, "text/vnd.wap.wmlscript", 0 }, 174 | { "wmlsc", 0, "application/vnd.wap.wmlscriptc", 0 }, 175 | { "wmv", 0, "video/x-ms-wmv", 0 }, 176 | { "wmx", 0, "video/x-ms-wmx", 0 }, 177 | { "wmz", 0, "application/x-ms-wmz", 0 }, 178 | { "wrl", 0, "model/vrml", 0 }, 179 | { "wsrc", 0, "application/x-wais-source", 0 }, 180 | { "wvx", 0, "video/x-ms-wvx", 0 }, 181 | { "xbm", 0, "image/x-xbitmap", 0 }, 182 | { "xht", 0, "application/xhtml+xml", 0 }, 183 | { "xhtml", 0, "application/xhtml+xml", 0 }, 184 | { "xls", 0, "application/vnd.ms-excel", 0 }, 185 | { "xml", 0, "text/xml", 0 }, 186 | { "xpm", 0, "image/x-xpixmap", 0 }, 187 | { "xsl", 0, "text/xml", 0 }, 188 | { "xwd", 0, "image/x-xwindowdump", 0 }, 189 | { "xyz", 0, "chemical/x-xyz", 0 }, 190 | { "zip", 0, "application/zip", 0 }, 191 | -------------------------------------------------------------------------------- /src/mime_types.txt: -------------------------------------------------------------------------------- 1 | # mime_types.txt 2 | # 3 | # A list of file extensions followed by the corresponding MIME type. 4 | # Extensions not found in the table are returned as text/plain. 5 | 6 | a application/octet-stream 7 | aab application/x-authorware-bin 8 | aam application/x-authorware-map 9 | aas application/x-authorware-seg 10 | ai application/postscript 11 | aif audio/x-aiff 12 | aifc audio/x-aiff 13 | aiff audio/x-aiff 14 | asc text/plain 15 | asf video/x-ms-asf 16 | asx video/x-ms-asf 17 | au audio/basic 18 | avi video/x-msvideo 19 | bcpio application/x-bcpio 20 | bin application/octet-stream 21 | bmp image/bmp 22 | cdf application/x-netcdf 23 | class application/x-java-vm 24 | cpio application/x-cpio 25 | cpt application/mac-compactpro 26 | crl application/x-pkcs7-crl 27 | crt application/x-x509-ca-cert 28 | csh application/x-csh 29 | css text/css 30 | dcr application/x-director 31 | dir application/x-director 32 | djv image/vnd.djvu 33 | djvu image/vnd.djvu 34 | dll application/octet-stream 35 | dms application/octet-stream 36 | doc application/msword 37 | dtd text/xml 38 | dump application/octet-stream 39 | dvi application/x-dvi 40 | dxr application/x-director 41 | eps application/postscript 42 | etx text/x-setext 43 | exe application/octet-stream 44 | ez application/andrew-inset 45 | fgd application/x-director 46 | fh image/x-freehand 47 | fh4 image/x-freehand 48 | fh5 image/x-freehand 49 | fh7 image/x-freehand 50 | fhc image/x-freehand 51 | gif image/gif 52 | gtar application/x-gtar 53 | hdf application/x-hdf 54 | hqx application/mac-binhex40 55 | htm text/html; charset=%s 56 | html text/html; charset=%s 57 | ice x-conference/x-cooltalk 58 | ief image/ief 59 | iges model/iges 60 | igs model/iges 61 | iv application/x-inventor 62 | jar application/x-java-archive 63 | jfif image/jpeg 64 | jpe image/jpeg 65 | jpeg image/jpeg 66 | jpg image/jpeg 67 | js application/x-javascript 68 | kar audio/midi 69 | latex application/x-latex 70 | lha application/octet-stream 71 | lzh application/octet-stream 72 | m3u audio/x-mpegurl 73 | man application/x-troff-man 74 | mathml application/mathml+xml 75 | me application/x-troff-me 76 | mesh model/mesh 77 | mid audio/midi 78 | midi audio/midi 79 | mif application/vnd.mif 80 | mime message/rfc822 81 | mml application/mathml+xml 82 | mov video/quicktime 83 | movie video/x-sgi-movie 84 | mp2 audio/mpeg 85 | mp3 audio/mpeg 86 | mp4 video/mp4 87 | mpe video/mpeg 88 | mpeg video/mpeg 89 | mpg video/mpeg 90 | mpga audio/mpeg 91 | ms application/x-troff-ms 92 | msh model/mesh 93 | mv video/x-sgi-movie 94 | mxu video/vnd.mpegurl 95 | nc application/x-netcdf 96 | o application/octet-stream 97 | oda application/oda 98 | ogg application/ogg 99 | pac application/x-ns-proxy-autoconfig 100 | pbm image/x-portable-bitmap 101 | pdb chemical/x-pdb 102 | pdf application/pdf 103 | pgm image/x-portable-graymap 104 | pgn application/x-chess-pgn 105 | png image/png 106 | pnm image/x-portable-anymap 107 | ppm image/x-portable-pixmap 108 | ppt application/vnd.ms-powerpoint 109 | ps application/postscript 110 | qt video/quicktime 111 | ra audio/x-realaudio 112 | ram audio/x-pn-realaudio 113 | ras image/x-cmu-raster 114 | rdf application/rdf+xml 115 | rgb image/x-rgb 116 | rm audio/x-pn-realaudio 117 | roff application/x-troff 118 | rpm audio/x-pn-realaudio-plugin 119 | rss application/rss+xml 120 | rtf text/rtf 121 | rtx text/richtext 122 | sgm text/sgml 123 | sgml text/sgml 124 | sh application/x-sh 125 | shar application/x-shar 126 | silo model/mesh 127 | sit application/x-stuffit 128 | skd application/x-koan 129 | skm application/x-koan 130 | skp application/x-koan 131 | skt application/x-koan 132 | smi application/smil 133 | smil application/smil 134 | snd audio/basic 135 | so application/octet-stream 136 | spl application/x-futuresplash 137 | src application/x-wais-source 138 | stc application/vnd.sun.xml.calc.template 139 | std application/vnd.sun.xml.draw.template 140 | sti application/vnd.sun.xml.impress.template 141 | stw application/vnd.sun.xml.writer.template 142 | sv4cpio application/x-sv4cpio 143 | sv4crc application/x-sv4crc 144 | svg image/svg+xml 145 | svgz image/svg+xml 146 | swf application/x-shockwave-flash 147 | sxc application/vnd.sun.xml.calc 148 | sxd application/vnd.sun.xml.draw 149 | sxg application/vnd.sun.xml.writer.global 150 | sxi application/vnd.sun.xml.impress 151 | sxm application/vnd.sun.xml.math 152 | sxw application/vnd.sun.xml.writer 153 | t application/x-troff 154 | tar application/x-tar 155 | tcl application/x-tcl 156 | tex application/x-tex 157 | texi application/x-texinfo 158 | texinfo application/x-texinfo 159 | tif image/tiff 160 | tiff image/tiff 161 | tr application/x-troff 162 | tsp application/dsptype 163 | tsv text/tab-separated-values 164 | txt text/plain; charset=%s 165 | ustar application/x-ustar 166 | vcd application/x-cdlink 167 | vrml model/vrml 168 | vx video/x-rad-screenplay 169 | wav audio/x-wav 170 | wax audio/x-ms-wax 171 | wbmp image/vnd.wap.wbmp 172 | wbxml application/vnd.wap.wbxml 173 | wm video/x-ms-wm 174 | wma audio/x-ms-wma 175 | wmd application/x-ms-wmd 176 | wml text/vnd.wap.wml 177 | wmlc application/vnd.wap.wmlc 178 | wmls text/vnd.wap.wmlscript 179 | wmlsc application/vnd.wap.wmlscriptc 180 | wmv video/x-ms-wmv 181 | wmx video/x-ms-wmx 182 | wmz application/x-ms-wmz 183 | wrl model/vrml 184 | wsrc application/x-wais-source 185 | wvx video/x-ms-wvx 186 | xbm image/x-xbitmap 187 | xht application/xhtml+xml 188 | xhtml application/xhtml+xml 189 | xls application/vnd.ms-excel 190 | xml text/xml 191 | xpm image/x-xpixmap 192 | xsl text/xml 193 | xwd image/x-xwindowdump 194 | xyz chemical/x-xyz 195 | zip application/zip 196 | -------------------------------------------------------------------------------- /src/mmc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/src/mmc.c -------------------------------------------------------------------------------- /src/mmc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/src/mmc.h -------------------------------------------------------------------------------- /src/tdate_parse.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/src/tdate_parse.c -------------------------------------------------------------------------------- /src/tdate_parse.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/src/tdate_parse.h -------------------------------------------------------------------------------- /src/thttpd.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/src/thttpd.c -------------------------------------------------------------------------------- /src/thttpd.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/src/thttpd.h -------------------------------------------------------------------------------- /src/timers.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/src/timers.c -------------------------------------------------------------------------------- /src/timers.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/src/timers.h -------------------------------------------------------------------------------- /src/version.h: -------------------------------------------------------------------------------- 1 | /* version.h - version defines for thttpd and libhttpd */ 2 | 3 | #ifndef _VERSION_H_ 4 | #define _VERSION_H_ 5 | 6 | #define SERVER_SOFTWARE "sthttpd/2.27.0 03oct2014" 7 | #define SERVER_ADDRESS "http://localhost" 8 | 9 | #endif /* _VERSION_H_ */ 10 | -------------------------------------------------------------------------------- /www/Makefile.am: -------------------------------------------------------------------------------- 1 | wwwdir = $(WEBDIR) 2 | SUBDIRS = cgi-bin 3 | dist_www_DATA = index.html 4 | -------------------------------------------------------------------------------- /www/cgi-bin/Makefile.am: -------------------------------------------------------------------------------- 1 | cgidir = $(WEBDIR)/cgi-bin 2 | 3 | cgi_PROGRAMS = redirect ssi phf 4 | 5 | redirect_SOURCES = redirect.c 6 | redirect_CPPFLAGS = -I$(top_srcdir)/src 7 | 8 | ssi_SOURCES = ssi.c 9 | ssi_CPPFLAGS = -I$(top_srcdir)/src 10 | ssi_LDADD = ../../src/libmatch.a 11 | 12 | phf_SOURCES = phf.c 13 | phf_CPPFLAGS = -I$(top_srcdir)/src 14 | 15 | dist_cgi_DATA = printenv 16 | -------------------------------------------------------------------------------- /www/cgi-bin/phf.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/www/cgi-bin/phf.c -------------------------------------------------------------------------------- /www/cgi-bin/printenv: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | date=`date -u '+%a, %d %b %Y %H:%M:%S %Z'` 4 | 5 | cat << EOF 6 | Content-type: text/plain 7 | Expires: $date 8 | 9 | CGI printenv 10 | 11 | EOF 12 | 13 | echo 'Date:' 14 | date 15 | echo 16 | echo 'Id:' 17 | id 18 | echo 19 | echo 'Env:' 20 | printenv 21 | echo 22 | if [ "$CONTENT_LENGTH" != "" ] ; then 23 | if [ "$CONTENT_LENGTH" -ne 0 ] ; then 24 | echo 'Input:' 25 | echo 26 | dd bs=1 count=$CONTENT_LENGTH 27 | echo 28 | fi 29 | fi 30 | -------------------------------------------------------------------------------- /www/cgi-bin/redirect.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/www/cgi-bin/redirect.c -------------------------------------------------------------------------------- /www/cgi-bin/ssi.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueness/sthttpd/2845bf5bff2b820d2336c8c8061cbfc5f271e720/www/cgi-bin/ssi.c -------------------------------------------------------------------------------- /www/index.html: -------------------------------------------------------------------------------- 1 | 2 | sthttpd is running 3 | 4 |

sthttpd is working

5 | 6 |

sthttpd is working. Excellent! One step closer to total world domination!

7 |

sthttpd is a fork of, and drop in replacement of, thttpd.

8 | 9 |

sthttpd home page

10 | 11 |

thttpd home page

12 | 13 | 14 | 15 | --------------------------------------------------------------------------------