Commit Graph
100 Commits
Author SHA1 Message Date
Michael Adam 69c348ce6d req: move a variable into the scope where it is used in extract_http_url()
Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-16 13:10:03 +01:00
Michael Adam bb2e894e0d BB#116: fix invalid free when connecting to ipv6 literal address
When removing the '[' and ']' characers from the ipv6 literal address, make sure
the pointer that is later free'd stays a malloced pointer by memmoving the
string one place left.

Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-16 13:07:19 +01:00
Michael Adam 7e1d8154de build: check for memmove
Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-16 13:07:09 +01:00
Michael Adam 836d4534d6 sock: add debug messages to opensock()
log entering opensock and successful return of getaddrinfo.
This allows to detect dns timeouts from looking at the logs.

Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-16 11:30:07 +01:00
Michael Adam e82080a5f6 [BB#63] conf: Allow multiple Listen statements in the config.
This introduces a list (vector) of addresses instead of
having just one address string.

Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam d0732f9ade [BB#81] allow listening on multiple families when no Listen is provided in config
This is achieved by not stopping at the first result of getaddrinfo
that we managed to listen on: Without "Listen" in the config, we
call getraddrinfo with NULL address. With AI_PASSIVE, this gives results
for both IPv4 and IPv6 wildcard addresses (if both are supported).

This lets tinyproxy listen on both IPv4 and IPv6 wildcard if the system
supports them.

Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam e40b91974a sock: add a starting debug message to listen_sock()
Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam 22587d3d41 sock: update introductory comment for listen_sock()
Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam 0698e4d180 sock: set IPV6_V6ONLY on the socket before binding an IPv6 address
so that we can bind wildcard for both IPv4 and IPv6.

Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam d7f67768eb sock: factor listening on one socket out of the gai-result-loop in listen_sock()
for clarity of the code

Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam 157879d4f6 sock: in listen_sock(), move variable for setsockopt() into scope
Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam a7898a2c98 sock: log each result of getaddrinfo() in listen_sock()
Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam 947e255d19 sock: in listen_sock(), add a log message for when bind() has failed
Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam b41d140984 sock: in listen_sock(), detect and log failure to call setsockopt()
Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam 5392e9829c sock: in listen_sock(), add debug message when socket() call failed.
Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam fa26ad4d56 sock: move listen() into the getaddrinfo result loop in listen_sock()
This also reverses the exit logic of the loop.
It prepares listening on multiple addresses.

Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam 2ebfd456ef child: use a list of listen_fds instead of one single listenfd.
This prepares listenting on multiple sockets, which will be ussed to
fix listening on the wildcard (listen on both ipv6 and ipv4) and
help add the support for multiple Listen statements in the config

Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam 070d621534 child: add addr argument to child_listening_sock().
Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam 2bd919f01e sock: add addr argument to listen_sock()
instead of using config.ipAddr internally.
This is in preparation to make it possible
to call it for multiple addresses.

Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam 7eea1638bc sock/child: remove global variable addrlen.
This changes listen_sock() to not return the
addrlen of the used address from getaddrinfo call
to the caller, stored in global addrlen in child.c.

This was only used to be able to allocate enough space for the
arguments to the later accept call depending on whether
IPv4 or IPv6 is used.

This removes the need to pass this info by always allocating
sizeof(struct sockaddr_storage) instead, which is enough
to carry both sockaddr_in and sockaddr_in6.

Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam 4bbd6e8626 [BB#109] Fix crash (infinite loop) when writing to log file fails.
Fall back to syslog logging in that case.

Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam d652681e8a log: remove extra newline characters in log messages.
Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam 3cc59ec3be [BB#112] build: fix build with autoconf >= 2.69
Use AC_CONFIG_HEADERS instead of obsolete AM_CONFIG_HEADER.

Signed-off-by: Michael Adam <obnox@samba.org>
2013-04-09 22:35:20 +02:00
Michael Adam 8fd3808ad3 [BB#95] remove two comments that have become wrong by the fix. 2010-12-01 22:25:44 +01:00
Michael Adam 58ac635a17 README: correctly list --enable-transparent
--enable-transparent-proxy was renamed to --enable-transparent
in August 2004... :-)
2010-12-01 21:40:07 +01:00
Michael Adam b672ca03fe [BB#91] Fix upstream proxy support.
Patch by Jordi Mallach.
2010-08-24 22:47:35 +02:00
Michael Adam 52cad36352 upstream: clarify debug messages
There are frequent questions "what does 'No proxy for ...' mean?"
on the mailing list and IRC. Be more specific. (No upstream proxy ...)
Correspondingly, log "Found upstream proxy ... for ..."
2010-08-24 22:46:10 +02:00
Michael Adam 243526d493 Comment out the LogFile and PidFile options in the example tinyproxy.conf.
These are compiled in defaults now.

Michael
2010-03-02 23:41:37 +01:00
Michael Adam e87c856487 change the default pid file location to "@LOCALSTATEDIR@/run/tinyproxy/tinyproxy.pid"
I.e., add a tinyproxy subdirectory.
This is meant to ease running tinyproxy as non-root user.
The subdirectory can be used to give the tinyproxy user
write permission.

Michael
2010-03-02 23:39:30 +01:00
Michael Adam cfa5792880 change the default log file location to "@LOCALSTATEDIR@/log/tinyproxy/tinyproxy.log"
i.e. add a tinyproxy subdirectory.
This is meant to ease running tinyproxy as non-root user
the subdirectory can be used to give the tinyproxy user
write permission.

Michael
2010-03-02 23:39:21 +01:00
Michael Adam f640c6fbb1 main: some tabs->spaces 2010-03-02 22:17:34 +01:00
Michael Adam fcf5fd2129 main: move a log message. 2010-03-02 22:05:28 +01:00
Michael Adam 7a9abc2a04 main: drop privileges right after reading the config
This is the second part of fixing bug #74.
I lets tinyproxy create its log and pid files as the
user as which it is running, so that later on at SIGHUP,
the log file can successfully be reopened.

Michael
2010-03-02 22:02:46 +01:00
Michael Adam 2235a97f05 main: separate loading of config and setup_logging at startup
This is the first part of a fix for bug #74
(making reloading of config work if running as non-privileged user)

Michael
2010-03-02 21:57:03 +01:00
Michael Adam f923649a11 tinyproxy.conf: fix LogFile to proper CamelCase for consistency 2010-02-23 08:06:55 +01:00
Michael Adam 3f1632603c tests: fix bug #80: keep track of errors in return codes
Michael
2010-02-23 00:18:29 +01:00
Michael Adam 7c15563430 tests: fix a typo in run_tests.sh 2010-02-23 00:17:21 +01:00
Michael Adam ee1f1e38f2 test: add make target "make valgrind-test-wait" 2010-02-22 23:31:40 +01:00
Michael Adam 752e4419a6 tests: add a new make target "make test-wait" 2010-02-22 23:17:39 +01:00
Michael Adam d133eee36b tests: Fix bug #79. Finish "make test" without waiting for user input.
Old behaviour is preserved by passing in the environment variable
TINYPROXY_TESTS_WAIT=yes.

Michael
2010-02-22 23:12:51 +01:00
Michael Adam 9c500d06f2 Fix bug #68: Allow all ports for CONNECT at absence of ConnectPort in config. 2010-01-17 13:41:02 +01:00
Michael Adam 8070023643 log: when opening the log file fails, fall back to syslog logging. 2010-01-17 01:10:21 +01:00
Michael Adam 54a613b9db conf: reduce indentation in load_config_file()
This replaces a do { ... } while (0) with break statements
ba gotos. Imho, this is much clearer.

Michael
2010-01-16 13:26:18 +01:00
Michael Adam 157a79216f NEWS: add David Shanks to the list of contributors. 2010-01-14 08:34:09 +01:00
Michael Adam a61f6018f2 NEWS: document some more new features in the release notes
Michael
2010-01-14 08:33:11 +01:00
Michael Adam a639f3fca2 NEWS: add list of bugs fixed since 1.7.1
Muks: please verify - thes are current the fixed bugs
with milestone 1.8.0 (i.e. the renamed 1.7.2).

I hope this is correct!
I also hope this was the intended scheme - have bug
lists per version section. Please feel free to edit...

Michael
2010-01-14 08:25:44 +01:00
Michael Adam 3baa5f6f7c NEWS: mention change of XTinyProxy to be a global bool
Michael
2010-01-14 08:14:01 +01:00
Michael Adam 8963c84dad NEWS: move the changes after 1.7.1 to new section 1.7.2
Michael
2010-01-13 23:26:20 +01:00
Michael Adam 7e9a022c74 NEWS: reformulate and elaborate some items.
Michael
2010-01-13 21:28:38 +01:00
Michael Adam 7ca792043c update NEWS
* mention config reload and upon HUP
* log-reopen (not trunc!) upon HUP
* file-logging as default

Michael
2010-01-13 21:25:03 +01:00
Michael Adam 028cad3c3b NEWS: add Mathew Mrosko as contributor. 2010-01-13 17:11:54 +01:00
Michael Adam 5e387e6ee7 log: turn tabs into spaces =)
Michael
2010-01-13 00:58:55 +01:00
Michael Adam dc86ebaf28 log: change internal logic to choose syslog over file logging.
Now that there is always a log file set, we just check for
syslog being set to TRUE and in that case use syslog logging,
file logging otherwiese.

Michael
2010-01-13 00:57:32 +01:00
Michael Adam fa0c4963e9 conf: add a default for PidFile: LOCALSTATEDIR/run/tinyproxy.pid
Michael
2010-01-13 00:30:50 +01:00
Michael Adam 9fec507daf log: remove a (now) useless fprintf in setup_logging.
Now that there is a default value for LogFile, the case
that neither the log file name nor syslog is configured
can not happen any more.

Michael
2010-01-13 00:23:48 +01:00
Michael Adam 74b0b63da8 conf: set default LogFile to LOCALSTATEDIR/log/tinyproxy.log
Michael
2010-01-13 00:21:39 +01:00
Michael Adam fb07cb380c Export configure variable localstatedir to C as define LOCALSTATEDIR.
So that it can be used for default values of some paths later on.

Michael
2010-01-13 00:16:02 +01:00
Michael Adam bcca20a3e6 log: remove an fprintf "not configured" error message in setup_logging().
Now that we exit early when !logging_initialized, this
can actually not happen anymore anyways: When logging is
initialized, it was also properly configured.

Michael
2010-01-10 19:29:33 +01:00
Michael Adam 1dd1c2796a log: shortcut return in shutdown_logging() if logging_initialized == false
This does for instance happen at startup when logging has not yet been set up.

Michael
2010-01-10 19:24:23 +01:00
Michael Adam b106091343 Happy new year 2010! 2010-01-10 13:53:03 +01:00
Michael Adam 594df6bf43 Happy new year 2010! 2010-01-10 13:52:17 +01:00
Michael Adam 52e333af0b Happy new year 2010! 2010-01-10 13:51:33 +01:00
Michael Adam 12026c32de Fix bug #55: Read request entity before sending error page to client.
https://www.banu.com/bugzilla/show_bug.cgi?id=55

This is achieved by streamlining handle_connection, adding
a common cleanup-and-exit poing ("done") and a common
failure exit point ("fail") that reads any pending data
from the client fd first before trying to send back
data (error page or stats page).

The new function get_request_entity that is used here,
does not honour any content-length header. It just calls
select on the client-fd and gets any data that is there
to read.

Michael
2010-01-10 02:17:37 +01:00
Michael Adam 6c9a647576 reqs:handle_connection: untangle assignment from check
Michael
2010-01-10 01:49:14 +01:00
Michael Adam e1e9e53d45 reqs:process_client_headers: polish logic flow a bit.
Michael
2010-01-10 01:49:14 +01:00
Michael Adam 0bfc0e90c1 reqs: simply process_request a bit: create common fail exit point
Michael
2010-01-10 01:49:14 +01:00
Michael Adam e0fabc6127 log: confess - add my (C) after substantial changes.
Michael
2009-12-23 00:33:31 +01:00
Michael Adam 5e8c8508ef conf: confess - add my (C) after substantial changes.
Michael
2009-12-23 00:33:21 +01:00
Michael Adam 4a11f9f08f log: remove unneeded truncate_log_file().
Michael
2009-12-23 00:31:56 +01:00
Michael Adam c07cd2e44e Use shutdown_logging() in main().
Michael
2009-12-23 00:31:56 +01:00
Michael Adam 71a035d619 Use reload_config() in main() to load config and init logging.
Michael
2009-12-23 00:31:55 +01:00
Michael Adam bc10479452 log: fix log_message so do only one write before the fsync.
This way the logging from the various child processes does not
get clobbered up. Formerly, the different write portions
(time stamp, message, newline) would get mixed from the
various child processes' log messages.

Michael
2009-12-23 00:31:55 +01:00
Michael Adam adf4640104 log: add start/end debug messages for "sending stored logs".
Michael
2009-12-23 00:31:55 +01:00
Michael Adam 0466526b1d Add warning comments to SIGHUP handlers, that we ignore the retrun code of reload_config().
This can actually fail, and we probably need some way to handle this.
Like an emergency error exit or so...

Michael
2009-12-23 00:31:55 +01:00
Michael Adam 8346a20aa0 Don't truncate the log file in the SIGHUP handler.
Logging is re-initialized by reload_config() now.
And truncation is wrong anyways: A syslog mechanism will
move the current log file and the reopen-action will just
create a new empty log file upon SIGHUP.

Michael
2009-12-23 00:31:55 +01:00
Michael Adam fb2e65f40b enhance reload_config to correctly re-initialize the logging subsystem.
This includes reopening the log file (in append mode).
Also switching from syslog to logfile and visa versa are included
when called from the SIGHUP handler.

Michael
2009-12-23 00:31:55 +01:00
Michael Adam c4b9454807 log: enhance close_log_file to reset logfile_fd to -1 after closing
Michael
2009-12-23 00:31:55 +01:00
Michael Adam f3c8424515 log.c: remove superfluous uses of #ifdef HAVE_SYSLOG_H
When this code is hit, availability of syslog has already
been checked (when reading the config file). So config.syslog == TRUE
only when HAVE_SYSLOG_H is defined.

So I remove the preprocessor checks which only clobber the logic
and make the code harder to read (IMHO).

Michael
2009-12-23 00:31:55 +01:00
Michael Adam 2c14f89bfc main: remove global bool processed_config_file.
This seemed out of place. Now the information is
stored in the correct places (as log.c:logging_initialized).

This way, we will be able to cleanly re-initialize
logging during config reload (SIGHUP) in subsequent
commits.

Michael
2009-12-23 00:27:32 +01:00
Michael Adam 210e82d08d log: call send_stored_logs in setup_logging instead of in main().
This is where it actually belongs.

Michael
2009-12-23 00:27:32 +01:00
Michael Adam 891846f23e log: add boolean local variable logging_initialized.
This controls whether log_messages should write to the
log file / syslog or rather to the log_message_storage.
This will make the global processed_config_file variable
from main unneccessary in the next step.

Michael
2009-12-23 00:27:26 +01:00
Michael Adam 649b2c0683 log: add function shutdown_logging().
Michael
2009-12-23 00:27:26 +01:00
Michael Adam 479562ad2b reload config upon SIGHUP
Michael
2009-12-22 00:15:00 +01:00
Michael Adam 91492773b1 conf: add a log messate ("reloading config file")
Michael
2009-12-22 00:15:00 +01:00
Michael Adam e9baa2977c conf: adapt a log message (add quotes to string value)
Michael
2009-12-22 00:15:00 +01:00
Michael Adam f7419c60be conf: elaborate a comment
Michael
2009-12-22 00:15:00 +01:00
Michael Adam 93dfb1ac5b conf: change a log message (to be more reasonable?)
Michael
2009-12-22 00:15:00 +01:00
Michael Adam 8bf91ce80f main: add convenience wrapper reload_config() for reload_config_file()
Michael
2009-12-22 00:14:59 +01:00
Michael Adam 72632f6569 conf.h: add "extern" to prototype of reload_config_file
Michael
2009-12-22 00:14:59 +01:00
Michael Adam 6ea160ffff conf: make free_config static
Michael
2009-12-22 00:14:59 +01:00
Michael Adam c15434df2b conf: make load_config_file static.
Michael
2009-12-22 00:14:59 +01:00
Michael Adam d3d31b434a conf: rename reload_config --> reload_config_file
Michael
2009-12-22 00:14:59 +01:00
Michael Adam d522221668 Fix restarting of tinyproxy: call setsockopt with REUSEADDR _before_ calling bind
Somehow this got moved too far down in the ipv6 changes.
Thanks to Mathew Mrosko for helping me debugging this.

Michael
2009-12-08 01:24:31 +01:00
Michael Adam 5bba62bcde Fix the build with --enable-transaparent after conf changes.
Michael
2009-12-07 23:42:55 +01:00
Michael Adam 0ba5cbea4f fix build with "--enable-reverse" after conf changes
Michael
2009-12-07 23:40:24 +01:00
Michael Adam 7290691142 Move definition of "struct config_s" from main.h to conf.h
Michael
2009-12-07 22:33:27 +01:00
Michael Adam 34e4be193e main.h: fix tabs ---> spaces
Michael
2009-12-07 22:33:27 +01:00
Michael Adam 4b54fc203f conf: remove direct use of config from reload_config()
The "conf" argument has to be used.

Michael
2009-12-07 22:33:27 +01:00
Michael Adam ad2f478c46 conf: remove direct reference to config from load_config_file()
This has to use the parameter "conf".

Michael
2009-12-07 22:33:26 +01:00
Michael Adam 947d85cefc Use reload_config() in main.
Michael
2009-12-07 01:11:35 +01:00