diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | .travis.yml | 18 | ||||
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | configure.ac | 22 | ||||
-rw-r--r-- | docs/man5/Makefile.am | 8 | ||||
-rw-r--r-- | docs/man8/Makefile.am | 8 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/child.c | 3 | ||||
-rw-r--r-- | src/hashmap.c | 21 | ||||
-rw-r--r-- | src/hashmap.h | 5 | ||||
-rw-r--r-- | src/html-error.c | 25 |
11 files changed, 84 insertions, 32 deletions
@@ -18,5 +18,6 @@ stamp-h1 autom4te.cache cscope.files cscope.out +compile *~ tags diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c38a1d2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +language: C +dist: trusty +sudo: true + +before_install: +- sudo apt-get update -qq +- sudo apt-get install --assume-yes asciidoc valgrind + +script: +- ./autogen.sh +- ./configure +- make +- make test +- ./configure --enable-debug --enable-transparent --enable-reverse +- make +- make test +- make valgrind-test +- make distcheck @@ -59,6 +59,9 @@ Allow Tinyproxy to be used as a transparent proxy daemon. - `--enable-static`: Compile a static version of Tinyproxy. +- `--enable-reverse`: +Enable reverse proxying. + - `--with-stathost=HOST`: Set the default name of the stats host. diff --git a/configure.ac b/configure.ac index 39e303f..10036ca 100644 --- a/configure.ac +++ b/configure.ac @@ -188,7 +188,12 @@ if test x"$debug_enabled" != x"yes" ; then CFLAGS="-DNDEBUG $CFLAGS" fi +AS_ECHO_N(["checking to see if linker understands -z,defs... "]) +LDFLAGS_OLD="-Wl $LDFLAGS" LDFLAGS="-Wl,-z,defs $LDFLAGS" +AC_LINK_IFELSE([AC_LANG_PROGRAM()], + AS_ECHO("yes"), + AS_ECHO("no"); LDFLAGS="$LDFLAGS_OLD") dnl dnl Make sure we can actually handle the "--with-*" and "--enable-*" stuff. @@ -204,8 +209,6 @@ AC_SUBST(LIBS) AC_SUBST(ADDITIONAL_OBJECTS) # Check for xml tools -AC_PATH_PROG(XMLLINT, xmllint, no) -AM_CONDITIONAL(HAVE_XMLLINT, test "x$XMLLINT" != "xno") AC_PATH_PROG(XSLTPROC, xsltproc, no) AM_CONDITIONAL(HAVE_XSLTPROC, test "x$XSLTPROC" != "xno") @@ -213,6 +216,21 @@ AM_CONDITIONAL(HAVE_XSLTPROC, test "x$XSLTPROC" != "xno") AC_PATH_PROG(A2X, a2x, no) AM_CONDITIONAL(HAVE_A2X, test "x$A2X" != "xno") +# checking xmllint +AC_PATH_PROG(XMLLINT, xmllint, no) +if test "x$XMLLINT" != "xno"; then + AS_ECHO_N("testing xmllint... ") + echo "TEST" > conftest.txt + if $A2X -f docbook conftest.txt 2>/dev/null; then + AS_ECHO("ok") + else + AS_ECHO("failed") + XMLLINT="no" + fi + rm -f conftest.txt conftest.xml +fi +AM_CONDITIONAL(HAVE_XMLLINT, test "x$XMLLINT" != "xno") + AC_CONFIG_FILES([ Makefile src/Makefile diff --git a/docs/man5/Makefile.am b/docs/man5/Makefile.am index b2a9dd3..247b7ef 100644 --- a/docs/man5/Makefile.am +++ b/docs/man5/Makefile.am @@ -1,9 +1,11 @@ MAN5_FILES = \ tinyproxy.conf.txt -A2X_ARGS = \ - -d manpage \ - -f manpage +if HAVE_XMLLINT +A2X_ARGS = -d manpage -f manpage +else +A2X_ARGS = -d manpage -f manpage -L +endif man_MANS = \ $(MAN5_FILES:.txt=.5) diff --git a/docs/man8/Makefile.am b/docs/man8/Makefile.am index 9bc4955..1bd0ffa 100644 --- a/docs/man8/Makefile.am +++ b/docs/man8/Makefile.am @@ -1,9 +1,11 @@ MAN8_FILES = \ tinyproxy.txt -A2X_ARGS = \ - -d manpage \ - -f manpage +if HAVE_XMLLINT +A2X_ARGS = -d manpage -f manpage +else +A2X_ARGS = -d manpage -f manpage -L +endif man_MANS = \ $(MAN8_FILES:.txt=.8) diff --git a/src/Makefile.am b/src/Makefile.am index a1fe63d..c42b0dd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,7 +62,7 @@ authors.c: $(top_srcdir)/authors.xml $(srcdir)/authors.xsl if HAVE_XSLTPROC $(AM_V_GEN) $(XSLTPROC) $(srcdir)/authors.xsl $< > $(@) || rm -f $(@) else - @echo "*** xsltproc is required to regenerate $(@) ***"; exit 1; + @echo "*** xsltproc is required to regenerate $(@) ***"; exit 1; endif BUILT_SOURCES = \ diff --git a/src/child.c b/src/child.c index 2c4dc22..effb2ae 100644 --- a/src/child.c +++ b/src/child.c @@ -233,6 +233,9 @@ static void child_main (struct child_s *ptr) ret = select(maxfd + 1, &rfds, NULL, NULL, NULL); if (ret == -1) { + if (errno == EINTR) { + continue; + } log_message (LOG_ERR, "error calling select: %s", strerror(errno)); exit(1); diff --git a/src/hashmap.c b/src/hashmap.c index b99f838..7793d08 100644 --- a/src/hashmap.c +++ b/src/hashmap.c @@ -493,3 +493,24 @@ ssize_t hashmap_remove (hashmap_t map, const char *key) /* The key was not found, so return 0 */ return deleted; } + +/* + * Look up the value for a variable. + */ +char *lookup_variable (hashmap_t map, const char *varname) +{ + hashmap_iter result_iter; + char *key; + char *data; + + result_iter = hashmap_find (map, varname); + + if (hashmap_is_end (map, result_iter)) + return (NULL); + + if (hashmap_return_entry (map, result_iter, + &key, (void **) &data) < 0) + return (NULL); + + return (data); +} diff --git a/src/hashmap.h b/src/hashmap.h index e8fa819..9206737 100644 --- a/src/hashmap.h +++ b/src/hashmap.h @@ -117,4 +117,9 @@ extern ssize_t hashmap_search (hashmap_t map, const char *key); */ extern ssize_t hashmap_remove (hashmap_t map, const char *key); +/* + * Look up the value for a variable. + */ +extern char *lookup_variable (hashmap_t map, const char *varname); + #endif /* _HASHMAP_H */ diff --git a/src/html-error.c b/src/html-error.c index 972d265..38adf85 100644 --- a/src/html-error.c +++ b/src/html-error.c @@ -84,27 +84,6 @@ static char *get_html_file (unsigned int errornum) } /* - * Look up the value for a variable. - */ -static char *lookup_variable (struct conn_s *connptr, const char *varname) -{ - hashmap_iter result_iter; - char *key; - char *data; - - result_iter = hashmap_find (connptr->error_variables, varname); - - if (hashmap_is_end (connptr->error_variables, result_iter)) - return (NULL); - - if (hashmap_return_entry (connptr->error_variables, result_iter, - &key, (void **) &data) < 0) - return (NULL); - - return (data); -} - -/* * Send an already-opened file to the client with variable substitution. */ int @@ -126,7 +105,7 @@ send_html_file (FILE *infile, struct conn_s *connptr) if (in_variable) { *p = '\0'; varval = (const char *) - lookup_variable (connptr, + lookup_variable (connptr->error_variables, varstart); if (!varval) varval = "(unknown)"; @@ -212,7 +191,7 @@ int send_http_error_message (struct conn_s *connptr) error_file = get_html_file (connptr->error_number); if (!(infile = fopen (error_file, "r"))) { - char *detail = lookup_variable (connptr, "detail"); + char *detail = lookup_variable (connptr->error_variables, "detail"); return (write_message (connptr->client_fd, fallback_error, connptr->error_number, connptr->error_string, |