aboutsummaryrefslogtreecommitdiff
path: root/gmid.h
AgeCommit message (Collapse)Author
2021-07-19introduce IMSG_LOG_REQUESTOmar Polo
2021-07-10move version number to configure scriptOmar Polo
2021-07-09move parse_portno to gmid.cOmar Polo
it's used only to parse the -p flag. While there add check_port_num to check the range for the port.
2021-07-07style(9)-ifyOmar Polo
2021-07-06gracefully shut down fastcgi backendsOmar Polo
we need to delete the events associated with the backends, otherwise the server process won't ever quit. Here, we add a pending counter to every backend and shut down immediately if they aren't handling any client; otherwise we try to close them as soon as possible (i.e. when they close the connection to the last connected client.)
2021-06-29allow to define macros in the config fileOmar Polo
Macros can be defined at the top of the configuration file: dir = "/var/gemini" cert = "/etc/keys" and re-used later, for example server "foo" { root "$dir/foo" # -> /var/gemini/foo cert "$cert/foo.pem" # -> /etc/keys/foo.pem }
2021-06-29define GMID_STRING and reuse-itOmar Polo
GMID_VERSION follows the CGI/FastCGI style, i.e. project_name/version. Define GMID_STRING with a more "human" variant "project_name version", and reuse that in the --help and --version codepath.
2021-06-16drop the dependency on lex by implementing yylex by ourselvesOmar Polo
The actual implementation is based off doas' parse.y. This gave us various benefits, like cleaner code, \ to break long lines, better handling of quotes etc...
2021-06-15allow sending fd to log on to the logger processOmar Polo
the logger process now can receive a file descriptor to write logs to. At the moment the logic is simple, if it receives a file it logs there, otherwise it logs to syslog. This will allow to log on custom log files.
2021-06-11more params from and send a custom listOmar Polo
2021-05-15define and use GMID_VERSIONOmar Polo
2021-05-15use the correct document rootOmar Polo
pass the correct loc_off to the executor, so the various variables that depends on the matched location (like DOCUMENT_ROOT) are computed correctly.
2021-05-11drop forward declaration of struct clientOmar Polo
it's been since the switch to libevent that is no longer needed.
2021-05-09fastcgi: a first implementationOmar Polo
Not production-ready yet, but it's a start. This adds a third ``backend'' for gmid: until now there it served local files or CGI scripts, now FastCGI applications too. FastCGI is meant to be an improvement over CGI: instead of exec'ing a script for every request, it allows to open a single connection to an ``application'' and send the requests/receive the responses over that socket using a simple binary protocol. At the moment gmid supports three different methods of opening a fastcgi connection: - local unix sockets, with: fastcgi "/path/to/sock" - network sockets, with: fastcgi tcp "host" [port] port defaults to 9000 and can be either a string or a number - subprocess, with: fastcgi spawn "/path/to/program" the fastcgi protocol is done over the executed program stdin of these, the last is only for testing and may be removed in the future. P.S.: the fastcgi rule is per-location of course :)
2021-05-04added missing prototypeOmar Polo
2021-04-30allow ``root'' rule to be specified per-location blockOmar Polo
2021-04-29added ``alias'' option to define hostname aliases for a serverOmar Polo
2021-04-28added ``env'' option to define environment vars for CGI scriptsOmar Polo
2021-04-25sort the auto index alphabeticallyOmar 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-31fix mkdirs: create directories recursivelyOmar Polo
2021-03-29handle CGI scripts that replies with the maximum header length allowedOmar Polo
the 1024 bytes limits is for the META only, not for the whole response. That means that the maximum size for the header line is 1029!
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-03-03give each server process its own socket for the executorOmar Polo
this fixes a bug introduced with the prefork mechanics: every server process shared the same socket, and this would cause a race condition when multiple server processes asked for a script cgi being executed. This gives each server process its own socket to talk to the executor, so the race cannot happen.
2021-02-23move log_init & vars to gmid.c, retain logger_main in log.cOmar Polo
this is to let the regression suite compile
2021-02-23add `log on/off' to enable/disable logs per-locationOmar Polo
2021-02-23moving logging to its own processOmar 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-12BUFSIZ is variable, we need *exactly* 1024Omar Polo
Using BUFSIZ in sbuf is not OK. It's variable, and in various places we assume that sbuf is 1024 (like handle_cgi_reply). We could patch those, but we aren't sure BUFSIZ is >= 1024! Let's keep the hardcoded number. (found by debugging on arch on amd64, where BUFSIZ is bigger)
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-09add `require client ca' rule to require certs signed by a CAOmar Polo
2021-02-08define config_path as global variableOmar Polo
2021-02-08rewrite main loop using libeventOmar Polo
2021-02-07define TLS_CLIENT_NOT_BEFORE/NOT_AFTER in CGI scriptsOmar Polo
2021-02-07[cgi] split the query in words if needed and add them to the argvOmar Polo
2021-02-07improve logs managementOmar Polo
2021-02-07added prefork optionOmar Polo
2021-02-06add the ``entrypoint'' optionOmar Polo
2021-02-06added ``block return'' and ``strip'' optionsOmar Polo
2021-02-04reload configuration on SIGHUPOmar Polo
2021-02-03refactor executor_mainOmar Polo
now it's symmetrical to listener_main().
2021-02-03refactoring startup logicOmar Polo
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-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-01document the DFAOmar Polo