diff --git a/config/linuxconfig b/config/linuxconfig index 00aaa9081..757d0f75c 100644 --- a/config/linuxconfig +++ b/config/linuxconfig @@ -1,97 +1,101 @@ -# -# Automatically generated make config: don't edit -# -HAVE_DOT_CONFIG=y -CONFIG_PLATFORM_LINUX=y -# CONFIG_PLATFORM_CYGWIN is not set -# CONFIG_PLATFORM_SOLARIS is not set -# CONFIG_PLATFORM_WIN32 is not set - -# -# General Configuration -# -PREFIX="/usr/local" -# CONFIG_DEBUG is not set -# CONFIG_VISUAL_STUDIO_6_0 is not set -# CONFIG_VISUAL_STUDIO_7_0 is not set -# CONFIG_VISUAL_STUDIO_8_0 is not set -CONFIG_VISUAL_STUDIO_6_0_BASE="" -CONFIG_VISUAL_STUDIO_7_0_BASE="" -CONFIG_VISUAL_STUDIO_8_0_BASE="" -CONFIG_EXTRA_CFLAGS_OPTIONS="" -CONFIG_EXTRA_LDFLAGS_OPTIONS="" - -# -# SSL Library -# -# CONFIG_SSL_SERVER_ONLY is not set -# CONFIG_SSL_CERT_VERIFICATION is not set -# CONFIG_SSL_ENABLE_CLIENT is not set -CONFIG_SSL_FULL_MODE=y -# CONFIG_SSL_SKELETON_MODE is not set -# CONFIG_SSL_PROT_LOW is not set -CONFIG_SSL_PROT_MEDIUM=y -# CONFIG_SSL_PROT_HIGH is not set -# CONFIG_SSL_USE_DEFAULT_KEY is not set -CONFIG_SSL_ENABLE_V23_HANDSHAKE=y -CONFIG_SSL_HAS_PEM=y -CONFIG_SSL_USE_PKCS12=y -CONFIG_SSL_EXPIRY_TIME=24 -CONFIG_X509_MAX_CA_CERTS=4 -CONFIG_SSL_MAX_CERTS=2 -CONFIG_USE_DEV_URANDOM=y -# CONFIG_WIN32_USE_CRYPTO_LIB is not set -# CONFIG_PERFORMANCE_TESTING is not set -# CONFIG_SSL_TEST is not set -# CONFIG_AXHTTPD is not set -# CONFIG_HTTP_STATIC_BUILD is not set -CONFIG_HTTP_HTTPS_PORT=0 -CONFIG_HTTP_SESSION_CACHE_SIZE=0 -CONFIG_HTTP_WEBROOT="" -CONFIG_HTTP_PORT=0 -CONFIG_HTTP_TIMEOUT=0 -# CONFIG_HTTP_HAS_CGI is not set -CONFIG_HTTP_CGI_EXTENSION="" -# CONFIG_HTTP_DIRECTORIES is not set -# CONFIG_HTTP_PERM_CHECK is not set -# CONFIG_HTTP_HAS_IPV6 is not set -CONFIG_HTTP_ALL_MIME_TYPES=y -# CONFIG_HTTP_VERBOSE is not set -# CONFIG_HTTP_IS_DAEMON is not set - -# -# Language Bindings -# -# CONFIG_BINDINGS is not set -# CONFIG_CSHARP_BINDINGS is not set -# CONFIG_VBNET_BINDINGS is not set -CONFIG_DOT_NET_FRAMEWORK_BASE="" -# CONFIG_JAVA_BINDINGS is not set -CONFIG_JAVA_HOME="" -# CONFIG_PERL_BINDINGS is not set -CONFIG_PERL_CORE="" -CONFIG_PERL_LIB="" - -# -# Samples -# -CONFIG_SAMPLES=y -CONFIG_C_SAMPLES=y -# CONFIG_CSHARP_SAMPLES is not set -# CONFIG_VBNET_SAMPLES is not set -# CONFIG_JAVA_SAMPLES is not set -# CONFIG_PERL_SAMPLES is not set - -# -# BigInt Options -# -# CONFIG_BIGINT_CLASSICAL is not set -# CONFIG_BIGINT_MONTGOMERY is not set -CONFIG_BIGINT_BARRETT=y -CONFIG_BIGINT_CRT=y -# CONFIG_BIGINT_KARATSUBA is not set -MUL_KARATSUBA_THRESH=0 -SQU_KARATSUBA_THRESH=0 -CONFIG_BIGINT_SLIDING_WINDOW=y -CONFIG_BIGINT_SQUARE=y -# CONFIG_BIGINT_CHECK_ON is not set +# +# Automatically generated make config: don't edit +# +HAVE_DOT_CONFIG=y +CONFIG_PLATFORM_LINUX=y +# CONFIG_PLATFORM_CYGWIN is not set +# CONFIG_PLATFORM_SOLARIS is not set +# CONFIG_PLATFORM_WIN32 is not set + +# +# General Configuration +# +PREFIX="/usr/local" +# CONFIG_DEBUG is not set +# CONFIG_VISUAL_STUDIO_6_0 is not set +# CONFIG_VISUAL_STUDIO_7_0 is not set +# CONFIG_VISUAL_STUDIO_8_0 is not set +CONFIG_VISUAL_STUDIO_6_0_BASE="" +CONFIG_VISUAL_STUDIO_7_0_BASE="" +CONFIG_VISUAL_STUDIO_8_0_BASE="" +CONFIG_EXTRA_CFLAGS_OPTIONS="" +CONFIG_EXTRA_LDFLAGS_OPTIONS="" + +# +# SSL Library +# +# CONFIG_SSL_SERVER_ONLY is not set +# CONFIG_SSL_CERT_VERIFICATION is not set +# CONFIG_SSL_ENABLE_CLIENT is not set +CONFIG_SSL_FULL_MODE=y +# CONFIG_SSL_SKELETON_MODE is not set +# CONFIG_SSL_PROT_LOW is not set +CONFIG_SSL_PROT_MEDIUM=y +# CONFIG_SSL_PROT_HIGH is not set +CONFIG_SSL_USE_DEFAULT_KEY=y +CONFIG_SSL_ENABLE_V23_HANDSHAKE=y +CONFIG_SSL_HAS_PEM=y +CONFIG_SSL_USE_PKCS12=y +CONFIG_SSL_EXPIRY_TIME=24 +CONFIG_X509_MAX_CA_CERTS=4 +CONFIG_SSL_MAX_CERTS=2 +CONFIG_USE_DEV_URANDOM=y +# CONFIG_WIN32_USE_CRYPTO_LIB is not set +# CONFIG_PERFORMANCE_TESTING is not set +# CONFIG_SSL_TEST is not set +CONFIG_AXHTTPD=y + +# +# Axhttpd Configuration +# +# CONFIG_HTTP_STATIC_BUILD is not set +CONFIG_HTTP_HTTPS_PORT=443 +CONFIG_HTTP_SESSION_CACHE_SIZE=5 +CONFIG_HTTP_WEBROOT="../www" +CONFIG_HTTP_PORT=80 +CONFIG_HTTP_TIMEOUT=5 +# CONFIG_HTTP_HAS_CGI is not set +CONFIG_HTTP_CGI_EXTENSION="" +# CONFIG_HTTP_DIRECTORIES is not set +# CONFIG_HTTP_PERM_CHECK is not set +# CONFIG_HTTP_HAS_IPV6 is not set +CONFIG_HTTP_ALL_MIME_TYPES=y +# CONFIG_HTTP_VERBOSE is not set +# CONFIG_HTTP_IS_DAEMON is not set + +# +# Language Bindings +# +CONFIG_BINDINGS=y +# CONFIG_CSHARP_BINDINGS is not set +# CONFIG_VBNET_BINDINGS is not set +CONFIG_DOT_NET_FRAMEWORK_BASE="" +# CONFIG_JAVA_BINDINGS is not set +CONFIG_JAVA_HOME="" +# CONFIG_PERL_BINDINGS is not set +CONFIG_PERL_CORE="" +CONFIG_PERL_LIB="" + +# +# Samples +# +CONFIG_SAMPLES=y +CONFIG_C_SAMPLES=y +# CONFIG_CSHARP_SAMPLES is not set +# CONFIG_VBNET_SAMPLES is not set +# CONFIG_JAVA_SAMPLES is not set +# CONFIG_PERL_SAMPLES is not set + +# +# BigInt Options +# +# CONFIG_BIGINT_CLASSICAL is not set +# CONFIG_BIGINT_MONTGOMERY is not set +CONFIG_BIGINT_BARRETT=y +CONFIG_BIGINT_CRT=y +# CONFIG_BIGINT_KARATSUBA is not set +MUL_KARATSUBA_THRESH=0 +SQU_KARATSUBA_THRESH=0 +CONFIG_BIGINT_SLIDING_WINDOW=y +CONFIG_BIGINT_SQUARE=y +# CONFIG_BIGINT_CHECK_ON is not set diff --git a/httpd/main.c b/httpd/main.c index da2608652..b98a1dc44 100644 --- a/httpd/main.c +++ b/httpd/main.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "axhttp.h" // GLOBALS @@ -247,7 +248,8 @@ int main(int argc, char *argv[]) } active = select(wnum > rnum ? wnum+1 : rnum+1, - rnum != -1 ? &rfds : NULL, wnum != -1 ? &wfds : NULL, + rnum != -1 ? &rfds : NULL, + wnum != -1 ? &wfds : NULL, NULL, NULL); // New connection? @@ -271,44 +273,44 @@ int main(int argc, char *argv[]) to = tp; tp = tp->next; - if (to->state == STATE_WANT_TO_READ_HEAD) - if (FD_ISSET(to->networkdesc, &rfds)) - { - active--; - procreadhead(to); - } + if (to->state == STATE_WANT_TO_READ_HEAD && + FD_ISSET(to->networkdesc, &rfds)) + { + active--; + procreadhead(to); + } - if (to->state == STATE_WANT_TO_SEND_HEAD) - if (FD_ISSET(to->networkdesc, &wfds)) - { - active--; - procsendhead(to); - } + if (to->state == STATE_WANT_TO_SEND_HEAD && + FD_ISSET(to->networkdesc, &wfds)) + { + active--; + procsendhead(to); + } - if (to->state == STATE_WANT_TO_READ_FILE) - if (FD_ISSET(to->filedesc, &rfds)) - { - active--; - procreadfile(to); - } + if (to->state == STATE_WANT_TO_READ_FILE && + FD_ISSET(to->filedesc, &rfds)) + { + active--; + procreadfile(to); + } - if (to->state == STATE_WANT_TO_SEND_FILE) - if (FD_ISSET(to->networkdesc, &wfds)) - { - active--; - procsendfile(to); - } + if (to->state == STATE_WANT_TO_SEND_FILE && + FD_ISSET(to->networkdesc, &wfds)) + { + active--; + procsendfile(to); + } #if defined(CONFIG_HTTP_DIRECTORIES) - if (to->state == STATE_DOING_DIR) - if (FD_ISSET(to->networkdesc, &wfds)) - { - active--; - procdodir(to); - } + if (to->state == STATE_DOING_DIR && + FD_ISSET(to->networkdesc, &wfds)) + { + active--; + procdodir(to); + } #endif } - } + } return 0; } @@ -452,9 +454,7 @@ static void handlenewconnection(int listenfd, int is_ssl) ipbuf, sizeof(ipbuf)); } else - { *ipbuf = '\0'; - } addconnection(connfd, ipbuf, is_ssl); } @@ -500,9 +500,13 @@ static int openlistener(int port) #endif setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &tp, sizeof(tp)); - bind(sd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)); - listen(sd, BACKLOG); + if (bind(sd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1) + { + close(sd); + return -1; + } + listen(sd, BACKLOG); return sd; } diff --git a/httpd/misc.c b/httpd/misc.c deleted file mode 100644 index bca059b5b..000000000 --- a/httpd/misc.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright(C) 2006 Cameron Rich - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include "axhttp.h" - -void nada(int sigtype) { } - -void die(int sigtype) -{ - exit(0); -} - -#if defined(CONFIG_HTTP_HAS_CGI) -#ifndef WIN32 -void reaper(int sigtype) -{ - wait3(NULL,WNOHANG,NULL); -} -#endif -#endif - -void stripcrlf(char *p) -{ - while (p && *p) - { - if (*p=='\n' || *p=='\r') - { - *p='\0'; - return; - } - p++; - } -} - -/* Wrapper function for strncpy() that guarantees - a null-terminated string. This is to avoid any possible - issues due to strncpy()'s behaviour. Thanks to - Werner Almesberger for pointing out this potential - issue. Needless to say, make sure sizeof(dest) > 0 - and sizeof(dest) >= n. - */ -char *my_strncpy(char *dest, const char *src, size_t n) -{ - strncpy(dest, src, n); - dest[n-1] = '\0'; - return dest; -} - -/* strnlen is a GNU Extension */ -#ifndef __HAVE_ARCH_STRNLEN -size_t strnlen (const char * str, size_t maxlen) -{ - const char *p; - - for (p=str; maxlen-- && *p!='\0'; ++p); - return (p - str); -} -#endif - -int sanitizefile(char *buf) -{ - int len, i; - - // Don't accept anything not starting with a / - if (*buf != '/') - return 0; - - len = strlen(buf); - for (i = 0; i < len; i++) - { - // Check for "/." : In other words, don't send files starting with a . - // Notice, GOBBLES, that this includes ".." - if (buf[i] == '/' && buf[i+1] == '.') - return 0; - } - - return 1; -} - -int sanitizehost(char *buf) -{ - while(*buf != '\0') - { - // Handle the port - if (*buf == ':') - { - *buf = '\0'; - return 1; - } - - // Enforce some basic URL rules... - if (isalnum(*buf)==0 && *buf != '-' && *buf != '.') return 0; - if (*buf == '.' && *(buf+1) == '.') return 0; - if (*buf == '.' && *(buf+1) == '-') return 0; - if (*buf == '-' && *(buf+1) == '.') return 0; - buf++; - } - - return 1; -} - -void buildactualfile(struct connstruct *cn) -{ - snprintf(cn->actualfile, MAXREQUESTLENGTH, "%s%s", - webroot, - cn->filereq); - - /* Add directory slash if not there */ - if (isdir(cn->actualfile) && - cn->actualfile[strlen(cn->actualfile)-1] != '/') - strcat(cn->actualfile, "/"); - -#ifdef WIN32 - /* convert all the forward slashes to back slashes */ - { - char *t = cn->actualfile; - while ((t = strchr(t, '/'))) - { - *t++ = '\\'; - } - } -#endif -} - -#if defined(CONFIG_HTTP_DIRECTORIES) -int issockwriteable(int sd) -{ - fd_set wfds; - struct timeval tv; - - tv.tv_sec = 0; - tv.tv_usec = 0; - - FD_ZERO(&wfds); - FD_SET(sd, &wfds); - - select(FD_SETSIZE, NULL, &wfds, NULL, &tv); - - return FD_ISSET(sd, &wfds); -} -#endif - -int isdir(char *tpbuf) -{ - struct stat st; - - if (stat(tpbuf, &st) == -1) - return 0; - - if ((st.st_mode & S_IFMT) == S_IFDIR) - return 1; - - return 0; -} - -#if defined(CONFIG_HTTP_HAS_CGI) -int iscgi(char *fn) -{ - struct cgiextstruct *tp; - int fnlen, extlen; - - fnlen = strlen(fn); - tp = cgiexts; - - while (tp != NULL) - { - extlen = strlen(tp->ext); - - if (strcasecmp(fn+(fnlen-extlen), tp->ext) == 0) - return 1; - - tp = tp->next; - } - - return 0; -} - -void split(char *tp, char *sp[], int maxwords, char sc) -{ - int i = 0; - - while(1) - { - /* Skip leading whitespace */ - while(*tp == sc) tp++; - - if (*tp == '\0') - { - sp[i] = NULL; - break; - } - - if (i==maxwords-2) - { - sp[maxwords-2] = NULL; - break; - } - - sp[i] = tp; - - while(*tp != sc && *tp != '\0') - tp++; - - if (*tp == sc) - *tp++ = '\0'; - - i++; - } -} - -int trycgi_withpathinfo(struct connstruct *cn) -{ - char tpfile[MAXREQUESTLENGTH]; - char fr_str[MAXREQUESTLENGTH]; - char *fr_rs[MAXCGIARGS]; // filereq splitted - int i = 0, offset; - - my_strncpy(fr_str, cn->filereq, MAXREQUESTLENGTH); - split(fr_str, fr_rs, MAXCGIARGS, '/'); - - while (fr_rs[i] != NULL) - { - snprintf(tpfile, sizeof(tpfile), "%s/%s%s", - webroot, cn->virtualhostreq, fr_str); - - if (iscgi(tpfile) && isdir(tpfile) == 0) - { - /* We've found our CGI file! */ - my_strncpy(cn->actualfile, tpfile, MAXREQUESTLENGTH); - my_strncpy(cn->cgiscriptinfo, fr_str, MAXREQUESTLENGTH); - - offset = (fr_rs[i] + strlen(fr_rs[i])) - fr_str; - my_strncpy(cn->cgipathinfo, cn->filereq+offset, MAXREQUESTLENGTH); - - return 0; - } - - *(fr_rs[i]+strlen(fr_rs[i])) = '/'; - i++; - } - - /* Couldn't find any CGIs :( */ - *(cn->cgiscriptinfo) = '\0'; - *(cn->cgipathinfo) = '\0'; - return -1; -} -#endif diff --git a/httpd/proc.c b/httpd/proc.c index d4bde5d8c..0d3d7ba4c 100644 --- a/httpd/proc.c +++ b/httpd/proc.c @@ -284,7 +284,7 @@ void procreadhead(struct connstruct *cn) return; } - while(*next != '\r' && *next != '\n' && *next != '\0') + while (*next != '\r' && *next != '\n' && *next != '\0') next++; if (*next == '\r') diff --git a/ssl/Makefile b/ssl/Makefile index 28a900a21..45fb862e5 100644 --- a/ssl/Makefile +++ b/ssl/Makefile @@ -33,6 +33,8 @@ TARGET1=../$(STAGE)/libaxtls.a BASETARGET=libaxtls.so ifdef CONFIG_PLATFORM_CYGWIN TARGET2=../$(STAGE)/libaxtls.dll.a +else +TARGET2=../$(STAGE)/$(LIBMINOR) endif # shared library major/minor numbers @@ -47,7 +49,7 @@ endif libs: $(TARGET1) $(TARGET2) OBJ=\ - aes.o \ + aes.o \ asn1.o \ bigint.o \ crypto_misc.o \ diff --git a/www/crypto_files/crypto_2600des.gif b/www/index_files/crypto_2600des.gif similarity index 100% rename from www/crypto_files/crypto_2600des.gif rename to www/index_files/crypto_2600des.gif diff --git a/www/crypto_files/crypto_3ways.gif b/www/index_files/crypto_3ways.gif similarity index 100% rename from www/crypto_files/crypto_3ways.gif rename to www/index_files/crypto_3ways.gif diff --git a/www/crypto_files/crypto_backrsa.jpg b/www/index_files/crypto_backrsa.jpg similarity index 100% rename from www/crypto_files/crypto_backrsa.jpg rename to www/index_files/crypto_backrsa.jpg diff --git a/www/crypto_files/crypto_cert.gif b/www/index_files/crypto_cert.gif similarity index 100% rename from www/crypto_files/crypto_cert.gif rename to www/index_files/crypto_cert.gif diff --git a/www/crypto_files/crypto_des.gif b/www/index_files/crypto_des.gif similarity index 100% rename from www/crypto_files/crypto_des.gif rename to www/index_files/crypto_des.gif diff --git a/www/crypto_files/crypto_ecc.gif b/www/index_files/crypto_ecc.gif similarity index 100% rename from www/crypto_files/crypto_ecc.gif rename to www/index_files/crypto_ecc.gif diff --git a/www/crypto_files/crypto_sslv3.gif b/www/index_files/crypto_sslv3.gif similarity index 100% rename from www/crypto_files/crypto_sslv3.gif rename to www/index_files/crypto_sslv3.gif diff --git a/www/crypto_files/crypto_types.gif b/www/index_files/crypto_types.gif similarity index 100% rename from www/crypto_files/crypto_types.gif rename to www/index_files/crypto_types.gif diff --git a/www/crypto_files/kerberos.gif b/www/index_files/kerberos.gif similarity index 100% rename from www/crypto_files/kerberos.gif rename to www/index_files/kerberos.gif