Commit Graph

144 Commits

Author SHA1 Message Date
Omar Polo
74f0778b9a drop the dependency on lex by implementing yylex by ourselves
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-16 14:43:16 +00:00
Omar Polo
c92b802b6a add `param' keyword 2021-06-11 15:49:46 +00:00
Omar Polo
0d047efcb4 refactor fastcgi block 2021-05-24 09:09:10 +00:00
Omar Polo
8ad1c57024 fastcgi: a first implementation
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-09 18:23:36 +00:00
Omar Polo
c705ecb1ba factorize all "only once" checks
and while there add some more
2021-05-03 16:11:28 +00:00
Omar Polo
fdea6aa0bc allow ``root'' rule to be specified per-location block 2021-04-30 17:16:34 +00:00
Omar Polo
adbe6a6493 always use ensure_absolute_path and improve its error message 2021-04-30 16:17:07 +00:00
Omar Polo
d06d6f4bba sort tokens 2021-04-29 19:13:16 +00:00
Omar Polo
cc8c2901ad added ``alias'' option to define hostname aliases for a server 2021-04-29 18:23:35 +00:00
Omar Polo
48b69cb2dc fix some logging
- we can't use log_* or fatal() before logger_init
- err -> errx if errno isn't involved
2021-04-28 12:43:17 +00:00
Omar Polo
9cc630aa63 added ``env'' option to define environment vars for CGI scripts 2021-04-28 12:43:17 +00:00
Omar Polo
b8e64ccd44 list instead of fixed-size array for vhosts and locations
saves some bytes of memory and removes the limit on the maximum number
of vhosts and location blocks.
2021-03-31 16:32:18 +00:00
Omar Polo
2c3e53dac6 give each server process its own socket for the executor
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-03-03 17:22:01 +00:00
Omar Polo
793835cb26
add `log on/off' to enable/disable logs per-location 2021-02-23 13:43:24 +01:00
Omar Polo
49b73ba1ab fix "first location" bug
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-10 16:37:08 +00:00
Omar Polo
2d34f732f1 typo 2021-02-10 13:13:17 +00:00
Omar Polo
002a84a123 improve errors during config parsing 2021-02-10 11:53:05 +00:00
Omar Polo
eb59f87e67 sort 2021-02-09 22:38:10 +00:00
Omar Polo
02be96c6dd add `require client ca' rule to require certs signed by a CA 2021-02-09 22:30:04 +00:00
Omar Polo
d090dc8491 define config_path as global variable 2021-02-08 12:44:34 +00:00
Omar Polo
a13739138b add trailing \n in yyerror 2021-02-07 18:08:50 +00:00
Omar Polo
a709ddf5eb added prefork option 2021-02-07 12:05:32 +00:00
Omar Polo
eef0492e35 add missing declaration of TENTRYPOINT 2021-02-07 11:27:15 +00:00
Omar Polo
e3ddf39095 add the ``entrypoint'' option 2021-02-06 18:28:43 +00:00
Omar Polo
6abda252e9 added `block return'' and `strip'' options 2021-02-06 17:22:37 +00:00
Omar Polo
709f4c9447 alter the string, don't advance pointer
if we advance the pointer, we crash during reload due to an invalid
address given to free.  altering the string is the way.
2021-02-04 20:04:12 +00:00
Omar Polo
ca21e10043 reload configuration on SIGHUP 2021-02-04 13:23:15 +00:00
Omar Polo
e17642a7bb require absolute paths in config file 2021-02-01 11:08:57 +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
Omar Polo
415ac7a229 fix build 2021-01-28 16:33:20 +00:00
Omar Polo
cbeee4cad1 warn about punycode in server definition 2021-01-28 16:27:40 +00:00
Omar Polo
13ed2fb63f improve configuration parsing error 2021-01-27 16:45:45 +00:00
Omar Polo
fe5967cd02 const-ify strings in struct location 2021-01-27 15:53:30 +00:00
Omar Polo
46af8c6cfe drop the daemon config in favour of the -f flag
Now it daemonize by default when running with a config, unless the -f
flag is given.
2021-01-27 12:04:37 +00:00
Omar Polo
ae08ec7da5 chroot & drop privileges 2021-01-25 10:30:07 +00:00
Omar Polo
252908e6bb added support for location blocks 2021-01-24 18:53:26 +00:00
Omar Polo
c8b7433918 added support for location blocks 2021-01-24 14:11:40 +00:00
Omar Polo
e7a2a99b5a added index option 2021-01-24 09:14:01 +00:00
Omar Polo
b2a6b61371 rename mimes to mime ; pass config esplicitly to mime* functions 2021-01-21 15:01:37 +00:00
Omar Polo
6119e13e8a moving "default type" from global options to server options 2021-01-19 11:28:41 +00:00
Omar Polo
05c23a54ea add "lang" server option 2021-01-19 10:58:29 +00:00
Omar Polo
982069a120 add "mime" and "default type" option for the configuration 2021-01-18 18:43:47 +00:00
Omar Polo
5bc3c98ed4 add protocols to the config 2021-01-15 18:55:05 +00:00
Omar Polo
1590277007 conf & vhosts
* gmid.c (main): changed behaviour: daemon off by default
(main): changed -c in -C (cert option)
(main): changed -k in -K (key option, for consistency with -C)
(main): added -c to load a configuration
(main): certs, key and doc (-C -K and -d) doesn't have a default value anymore
(handle_handshake): add vhosts support
2021-01-15 09:17:43 +00:00