Commit Graph

306 Commits

Author SHA1 Message Date
Omar Polo
1e3ef7ab4f use upper bound given by poll
it's a waste to loop through all fds.  We know the *exact* number of
clients that needs attention, so use that information to limit the
looping.
2021-02-03 21:14:48 +00:00
Omar Polo
e824d03efa drop unnecessary check around close 2021-02-03 16:53:34 +00:00
Omar Polo
4e2e2ab1d3 refactor executor_main
now it's symmetrical to listener_main().
2021-02-03 16:37:53 +00:00
Omar Polo
d672b8fba1 refactoring startup logic 2021-02-03 16:28:00 +00:00
Omar Polo
9b8f5ed2c0 revert commit 346f28eeaa
keep mark_nonblock in utils.c, as otherwise the build for the regress
suite will fail (mark_nonblock needs fatal which is in gmid.c, and
we can't link gmid.o with the regress suite...)
2021-02-03 14:16:39 +00:00
Omar Polo
9edb828251 drop privileges after the fork 2021-02-03 14:13:32 +00:00
Omar Polo
4ee08bd148 fix location example 2021-02-03 14:01:00 +00:00
Omar Polo
346f28eeaa move mark_nonblock to utils.c 2021-02-02 23:03:33 +00:00
Omar Polo
fe40638928 mark various functions as static
By marking all those function as static, the compiler is free to do
more optimizations.  In addition, those functions are not used outside
server.c
2021-02-02 23:01:09 +00:00
Omar Polo
87f2b68b58 cgi now follows globbing rules 2021-02-02 22:38:35 +00:00
Omar Polo
5b4a641893 let LEX and YACC be customizable via args 2021-02-02 09:58:05 +00:00
Omar Polo
b1d52c3105 ignore clangd' compile_flags.txt 2021-02-02 09:55:11 +00:00
Omar Polo
5f715ce43f print the header in the directory listing 2021-02-02 09:48:32 +00:00
Omar Polo
3c680bddab configless: fixing the case of the implicit "."
I got bitten by the scope visibility rules.  After the end of the
block, the path variable is no longer valid, and in fact later
load_vhosts fails to open that (because the buffer gets invalidated)
2021-02-02 09:30:24 +00:00
Omar Polo
35744950aa simplify handle_cgi
Now that I got rid of the enum+switch, adding more state is easier.
Before, we used an hack to remember if we had read the CGI reply or
not (c->code = -1).

This introduces a new state, handle_cgi_reply that reads the CGI
script reply, logs it, and only then switches to handle_cgi.
handle_cgi itself is cleaner, now it only reads into c->sbuf and send
what it had red.

We even get, almost for free, the 42 error.  If read exists with -1 or
0 from in handle_cgi_reply, we return a proper error to the client.
We can extend this further in the future and also try to validate the
CGI reply (for now we're only looking for a \n).
2021-02-01 22:04:51 +00:00
Omar Polo
b06f80cdf4 switch to handle_open_conn right after handshake
So we don't re-enter the handle_handsahke and re-do the loop on
fnmatch etc.  This way, once we're successfully past the handshake,
we'll re-enter no handle_open_conn.
2021-02-01 20:27:08 +00:00
Omar Polo
92da82858b document the DFA 2021-02-01 20:24:14 +00:00
Omar Polo
112802ea31 client state machine: function pointers instead of enum+switch 2021-02-01 20:00:33 +00:00
Omar Polo
1e7591a922 parse_err is a const pointer 2021-02-01 19:58:04 +00:00
Omar Polo
ad58806e30 drop unused target iri_test 2021-02-01 19:30:55 +00:00
Omar Polo
d5f4d615cf generate compile_flags for clangd 2021-02-01 19:30:38 +00:00
Omar Polo
3e5418099f [cgi] always set some variables 2021-02-01 13:48:23 +00:00
Omar Polo
ee655e64d7 sync CGI section with actual implementation 2021-02-01 13:19:06 +00:00
Omar Polo
38f8a798b1 mention v1.5 2021-02-01 12:30:34 +00:00
Omar Polo
67528c1f82 don't add the query to argv
FRC3875 says that if the query does not contain any unecnoded "="
characters, we SHOULD treat the query string as a "search-string",
split in on "+" and add every word to the CGI argv.

In launch_cgi it's too late because iri->query is the *decoded* query!

I have in mind some refactoring around how we decode things, so this
is postponed.
2021-02-01 12:28:30 +00:00
Omar Polo
2fafa2d23e bring the CGI implementation in par with GLV-1.12556 2021-02-01 11:11:43 +00:00
Omar Polo
e17642a7bb require absolute paths in config file 2021-02-01 11:08:57 +00:00
Omar Polo
bcf5d929e6 ensure absolute paths in config-less mode 2021-02-01 11:07:57 +00:00
Omar Polo
6ff23c6739 use absolute paths in the regression suite 2021-02-01 11:04:21 +00:00
Omar Polo
7808978667 fix computed offset
Oh my, this is such a stupid mistake.  It went undiscovered only
because I always used CGI scripts on the first vhost (and hence the
offset would be 0) and never on the others.
2021-02-01 08:38:48 +00:00
Omar Polo
57d0d0adba ensure iri.host isn't NULL 2021-01-31 11:50:01 +00:00
Omar Polo
ee29b5a63b sync 2021-01-31 11:09:15 +00:00
Omar Polo
8503a1431d set cloexec status on the socketpair fds
the executor forks to spawn the cgi scripts, and they inherit the
socket for communication with the listener process.  Make that
impossible.
2021-01-31 11:07:12 +00:00
Omar Polo
91d7870bb7 typo 2021-01-30 14:38:32 +00:00
Omar Polo
1b246dbd3c remove unused target
"test" was replaced by "regress" a while ago
2021-01-30 14:37:57 +00:00
Omar Polo
39a7b61145 sync date 2021-01-30 12:16:18 +00:00
Omar Polo
e99923477a sync 2021-01-30 12:13:49 +00:00
Omar Polo
b59f3cdd27 typo 2021-01-30 12:12:37 +00:00
Omar Polo
6016a593a3 invert the location precedence: first match wins
It's how httpd(8) does it, and it allows us to call fnmatch less time
2021-01-30 12:04:20 +00:00
Omar Polo
601bc1cc37 readme updates 2021-01-30 11:49:48 +00:00
Omar Polo
714685c10c manpage improvements 2021-01-30 11:49:27 +00:00
Omar Polo
e7c7f19c4e more IRI tests
ensure non-encoded and pct-encoded hostnames are parsed correctly
2021-01-29 18:52:36 +00:00
Omar Polo
cef60084e6 fix puny-test build 2021-01-29 18:51:35 +00:00
Omar Polo
dceca3b69d sync 2021-01-29 17:29:21 +00:00
Omar Polo
a8d4a89770 don't ignore punycode errors when decoding SNI-provided servname 2021-01-29 17:29:14 +00:00
Omar Polo
4a3ab60928 const-ify var + missing argument 2021-01-29 17:26:56 +00:00
Omar Polo
117ac52cdd accept a wider range of UNICODE codepoints while parsing hostnames 2021-01-29 17:26:23 +00:00
Omar Polo
a2fd801327 puny_decode: set an error string 2021-01-29 17:11:03 +00:00
Omar Polo
22a742e4cb typo 2021-01-29 17:07:26 +00:00
Omar Polo
32693ee6db include string.h
openbsd and freebsd yacc include string.h in the generated sources,
bison (tested on alpine at least) don't
2021-01-28 17:50:22 +00:00