Quentin Rameau
947b5a6a0a
Register signal handlers in handlesignals()
2017-07-24 16:49:24 +02:00
Quentin Rameau
3373992ca5
Get rid of atexit()
...
This was a bad idea in a forking model where exit() is called from
children.
2017-07-24 16:49:24 +02:00
Quentin Rameau
0fed1d5bd2
Use die() instead of fprintf+exit
2017-07-24 16:49:24 +02:00
Quentin Rameau
820f644fe3
Don't ignore SIGCHLD in the main thread
...
We are waiting on the child process.
2017-07-24 16:49:24 +02:00
Quentin Rameau
da8a3d2e29
Fix typo in signal handler, SIGINT -> SIGCHLD
2017-07-24 16:49:24 +02:00
Quentin Rameau
b04ba86f9d
Fix sending of zero-size files
2017-07-22 13:32:06 +02:00
Quentin Rameau
432898af71
Adjust last-byte-pos greater than files
2017-07-22 13:32:06 +02:00
Quentin Rameau
64e7dc3fda
Fix Content-Length calculation
2017-07-22 13:32:06 +02:00
Hiltjo Posthuma
2a5ab48294
use extended regex and fix example regex for realsies
2017-07-22 13:23:10 +02:00
Hiltjo Posthuma
0fc6b0cccd
don't allow named service->port translation
...
this will also mess up the redirect (to a named service otherwise).
2017-07-22 13:23:10 +02:00
Hiltjo Posthuma
4f2cc50416
if there is no matching vhost return 404 Not Found
2017-07-22 13:23:10 +02:00
Hiltjo Posthuma
c20aa17ae8
encode(): fix buffer-overflow and NUL terminate it
2017-07-22 13:23:10 +02:00
Laslo Hunhold
8ec042a1ba
Properly escape backslash in regex
2017-07-21 18:37:55 +02:00
Laslo Hunhold
10d2ffe53a
Fix example regex in vhosts
...
Thanks Hiltjo for noticing this!
2017-07-21 18:36:02 +02:00
Laslo Hunhold
a80f984ea3
Fix syntax error
2017-07-13 23:17:18 +02:00
Quentin Rameau
21115d4a1b
Fix logic error in vhost chrooting (from e592bbc
)
...
Thanks Hiltjo for having spotted it!
2017-07-13 21:11:06 +02:00
Laslo Hunhold
d7f5c6029e
Fix the style a bit and prevent out-of-bounds index access for vhost[]
2017-07-11 15:02:24 +02:00
Laslo Hunhold
d3c1091669
Allow switching vhosts using flags and rework the usage
2017-07-11 15:02:00 +02:00
Quentin Rameau
141bb88af1
Cleanup socket file at exit.
...
We can't unlink the file if it's outside the chroot, so we need to keep
a simple worker outside of it.
2017-07-11 14:09:27 +02:00
Quentin Rameau
260ef0a988
Make the socketfile accessible by clients
2017-07-11 14:09:27 +02:00
Quentin Rameau
3b3fdd00e2
Split synopsis to reflect the dual usage.
2017-07-11 14:09:27 +02:00
Quentin Rameau
e46344e449
Change -U udsname to -U sockfile for clarification.
2017-07-11 14:09:27 +02:00
Laslo Hunhold
d7cf0d7f57
Reorder config.def.h a bit
2017-07-11 13:52:41 +02:00
Laslo Hunhold
06eba20e9d
Add Quentin to LICENSE
2017-07-11 13:46:31 +02:00
Quentin Rameau
e592bbc0fe
Integrate compiled regex into vhost array
2017-07-11 13:45:57 +02:00
Laslo Hunhold
233bf68b4b
Style fix
...
Thanks Quentin!
2017-07-11 13:03:24 +02:00
Laslo Hunhold
000553d8c5
Add vhost support
...
As given in the config, we match a regex of hosts to a canonical host
which points to an internal directory.
Regexes are compiled on initialization, so we can error out early.
The rest is just modifications to use relative directories rather than
absolute ones, as we chdir() into the vhost directories dynamically.
Given we normalize the targets beforehand, there is no danger of
malformed requests escaping the vhost-context.
2017-07-11 12:55:39 +02:00
Laslo Hunhold
9e9facc9bf
Properly serve empty files
2017-07-11 12:33:21 +02:00
Laslo Hunhold
af61e37a3a
Check inet_pton() for system error
2017-07-09 00:11:30 +02:00
Laslo Hunhold
d598da3d52
Send absolute path when redirecting
...
The logic is a little more complicated, but we need it for some future
changes.
2017-07-07 13:33:43 +02:00
Hiltjo Posthuma
fc9f02cee3
memcpy regions may not overlap, use memmove
...
for example a path: "/../../" made quark abort().
2017-07-05 19:34:25 +02:00
Laslo Hunhold
bdff59a5f6
Check for UNIX-doman socket name truncation
2017-07-04 22:44:47 +02:00
Laslo Hunhold
d5a6e978b9
Small style fix
2017-07-04 22:26:17 +02:00
Laslo Hunhold
7f391b6134
Import strtonum() and get rid of atoi()
2017-07-04 22:21:36 +02:00
Laslo Hunhold
c0a2c5de0a
Improve timestamp() semantics
...
Thanks Hiltjo! We are now in the enterprise(tm)!
2017-07-04 21:47:28 +02:00
Hiltjo Posthuma
eda2c150e4
improve byte-range support
...
this fixes the lower and upper offset and adds a 416 (range not satisfiable
status). It returns the filesize if it cannot be satisfied as the standard
suggests so the client can do something.
2017-07-04 21:45:46 +02:00
Hiltjo Posthuma
9b8e2bdeb6
byte-range: fix range check for upper limit
...
the range check was done after the check lower > upper
so if it meets these conditions: lower <= upper and
lower > st.st_size then lower could still be > upper.
2017-07-04 21:01:44 +02:00
Hiltjo Posthuma
a092d9aa4b
the result of encode() and decode() is unused
2017-06-28 20:20:10 +02:00
Hiltjo Posthuma
e8dab1db94
config.mk: fix warning about strptime on glibc
2017-06-28 20:20:10 +02:00
Hiltjo Posthuma
f5270aa241
initialize request fields used as output in log
...
this could crash quark or print gibberish if the connection is closed
before parsing these fields: r->target is uninitialized, but printed
in the log.
2017-06-28 20:20:10 +02:00
Laslo Hunhold
5030846333
Rename filetype() to suffix()
2017-06-28 08:40:34 +02:00
Laslo Hunhold
1e65a4848e
Fix dir-check in dirent
...
We cannot do this, as it falsely added a / to a link pointing to a
socket.
2017-06-28 08:29:31 +02:00
Hiltjo Posthuma
c369738fa4
make directory listing a run-time flag
...
remove const in the config.h since it can be changed at run-time now.
2017-06-27 23:31:08 +02:00
Hiltjo Posthuma
434f2b3067
config.def.h: add jpeg alias, ogg audio mimetype
2017-06-27 23:31:08 +02:00
Hiltjo Posthuma
fc0873853c
minor code-style consistency fixes
...
:)
2017-06-27 23:31:08 +02:00
Hiltjo Posthuma
96d035b284
add myself to the license (contributor)
2017-06-27 23:31:08 +02:00
Hiltjo Posthuma
750f8381ce
in the directory listing add / as suffix to save a redirect check
2017-06-27 23:31:08 +02:00
Hiltjo Posthuma
b6559eb3e7
fix memleak in scandir()
2017-06-27 23:31:08 +02:00
Hiltjo Posthuma
d1589c96fa
header parsing: allow tabs are whitespace, compare case-insensitive
...
this is more conforming the HTTP spec
2017-06-27 23:31:08 +02:00
Hiltjo Posthuma
2021da9bed
send binary Content-Type by default (octet-stream)
2017-06-27 23:31:08 +02:00