aboutsummaryrefslogtreecommitdiff
path: root/server.c
AgeCommit message (Collapse)Author
2021-04-25don't save the directory fd in c->pfdOmar Polo
scandir_fd already calls closedir, which in turns closes the fd
2021-04-25sort the auto index alphabeticallyOmar Polo
2021-04-20rename reschedule_* to yield_*Omar Polo
2021-04-13define TLS_VERSION, TLS_CIPHER and TLS_CIPHER_STRENGTH for CGI scriptsOmar Polo
2021-03-31list instead of fixed-size array for vhosts and locationsOmar Polo
saves some bytes of memory and removes the limit on the maximum number of vhosts and location blocks.
2021-03-20move all sandbox-related code to sandbox.cOmar Polo
while there, add capsicum for the logger process
2021-03-19refactoring: imsg everywhereOmar Polo
use imsg to handle ALL kinds of IPC in gmid. This simplifies and shorten the code, and makes everything more uniform too.
2021-02-23move vhost_should_log call to server.cOmar Polo
log.o is linked to some regress/ stuff. Calling from there a vhost_* function means that we should link the regress/stuff to server.o too (and that would pull in other stuff...). Moving the call is easier, and also probably better.
2021-02-23add `log on/off' to enable/disable logs per-locationOmar Polo
2021-02-23tests and compat for imsgOmar Polo
2021-02-12mark reschedule_write inline & staticOmar Polo
2021-02-12other s/fnmatch/matchesOmar Polo
2021-02-12fix various compilation errorsOmar Polo
Include gmid.h as first header in every file, as it then includes config.h (that defines _GNU_SOURCE for instance). Fix also a warning about unsigned vs signed const char pointers in openssl.
2021-02-12accept4 -> acceptOmar Polo
accept4(2) isn't part of any standard (even though it'll be part in the future) and raises warnings on some linux distro. Moreover, we don't have thread that may fork at any time, so doing a mark_nonblock after isn't a big deal.
2021-02-12typoOmar Polo
2021-02-12fix occurrence of (killed) load_fileOmar Polo
2021-02-12don't mmapOmar Polo
Before we mmap(2) file for reading, and use a buffer to handle CGI scripts. Turns out, for sequential access over the whole mmap isn't better than our loop on read. This has also the additional advantage that we can use handle_cgi (now handle_copy) for both files and CGI, which is pretty cool. This also fixes a nasty bug where we could hang a connection forever, because we scheduled the wrong type of event (read on POLLOUT and write on POLLIN, it's the other way around!)
2021-02-12fix config reloadOmar Polo
the old server processes would stick around waiting on the signals events. While there, also drop the `struct server_events' and define events as globals.
2021-02-10fix "first location" bugOmar Polo
reported by devel at datenbrei dot de. The first location would overwrite the default value for a server, triggering the "`foo' rule specified more than once" error. This also needed a small tweak on how we match locations to avoid breaking other tests.
2021-02-09add `require client ca' rule to require certs signed by a CAOmar Polo
2021-02-08refactor apply_block_returnOmar Polo
move the strip and fmt logic to their own function
2021-02-08fix seccomp for the new event loopOmar Polo
add/remove syscalls from the BPF filter and move sandbox() after libevent initialisation
2021-02-08rewrite main loop using libeventOmar Polo
2021-02-07define TLS_CLIENT_NOT_BEFORE/NOT_AFTER in CGI scriptsOmar Polo
2021-02-07don't fprintfOmar Polo
2021-02-07improve logs managementOmar Polo
2021-02-07handle also EAGAIN together with EWOULDBLOCKOmar Polo
2021-02-06add the ``entrypoint'' optionOmar Polo
2021-02-06swap check in vhost_* fnsOmar Polo
it's faster (statistically speaking) to first compute if the option is set and then fnmatch than the inverse. This way we can avoid unnecessary fnmatch.
2021-02-06added ``block return'' and ``strip'' optionsOmar Polo
2021-02-06fix auto index precedenceOmar Polo
2021-02-04reload configuration on SIGHUPOmar Polo
2021-02-03use upper bound given by pollOmar Polo
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-03revert commit 346f28eeaa205d268d1e63c7ffd86cf041f6d1e6Omar Polo
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-02move mark_nonblock to utils.cOmar Polo
2021-02-02mark various functions as staticOmar Polo
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-02cgi now follows globbing rulesOmar Polo
2021-02-02print the header in the directory listingOmar Polo
2021-02-01simplify handle_cgiOmar Polo
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-01switch to handle_open_conn right after handshakeOmar Polo
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-01client state machine: function pointers instead of enum+switchOmar Polo
2021-02-01bring the CGI implementation in par with GLV-1.12556Omar Polo
2021-01-30typoOmar Polo
2021-01-30invert the location precedence: first match winsOmar Polo
It's how httpd(8) does it, and it allows us to call fnmatch less time
2021-01-29don't ignore punycode errors when decoding SNI-provided servnameOmar Polo
2021-01-29puny_decode: set an error stringOmar Polo
2021-01-28don't log the SNI & matchingOmar Polo
I'll re-enable this when i'll improve the logging
2021-01-27log info about SNI, punycode and matched vhostOmar Polo
2021-01-27some null checksOmar Polo
2021-01-27trim_req_iri: set error stringOmar Polo