Commit Graph

518 Commits

Author SHA1 Message Date
Omar Polo ba65dcc8fa mention -V/--version and --help in the manpage 2021-06-29 11:00:28 +00:00
Omar Polo fdb43a4c0e define GMID_STRING and reuse-it
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-29 10:56:07 +00:00
Omar Polo 0233b0f6b9 add version in usage 2021-06-29 10:51:42 +00:00
Omar Polo 9327bc045a use getprogname() in usage() 2021-06-29 10:50:39 +00:00
Omar Polo 5777923bb0 use getopt_long, add --help as synonym of -h and -V/--version 2021-06-29 10:49:59 +00:00
Omar Polo 2c43dcceb6 document `log' option 2021-06-17 09:27:09 +00:00
Omar Polo 1b78bd563a strncpy -> strlcpy
quoting strncpy(3)

     strncpy() only NUL terminates the destination string when the
     length of the source string is less than the length parameter.

strlcpy is more intuitive.

this is another warning gcc 8 found that clang didn't.
2021-06-16 15:06:10 +00:00
Omar Polo 80fbf1e934 make sure l is always initialized
I can't think of cases where we reach serialize_iri and path is NULL,
but let's keep the safe side and initialize l.  gcc 8 found this,
clang didn't.
2021-06-16 15:04:42 +00:00
Omar Polo 2d383cbd5f remove last occurrences of lex 2021-06-16 15:00:52 +00:00
Omar Polo 9e659275b0 remove now unused lex.l 2021-06-16 14:58:48 +00:00
Omar Polo ef129b08ef move lineno/colno into the token struct 2021-06-16 14:51:57 +00:00
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 984c46a82e kill unused variable
leftover from the handle_imsg_log -> do_log transition.
2021-06-16 14:38:47 +00:00
Omar Polo 89c110fe7b be quieter
nobody really cares if must_read fails, as it normally shouldn't.  It
only clutters the regression tests with scary messages that looks like
failure but are, in fact, expected.
2021-06-15 08:07:44 +00:00
Omar Polo e952c5052a allow sending fd to log on to the logger process
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-15 08:06:10 +00:00
Omar Polo 0f2124e291 add some simple test for fastcgi
and while there reorder the targets in the Makefile a bit
2021-06-12 13:47:01 +00:00
Omar Polo 03fcfb79d6 add simple fcgi application for test purposes 2021-06-12 13:46:05 +00:00
Omar Polo 24d362cd67 explicitly use c->fd instead of fd
Yep, fd should be the file descriptor, but for lazyness when manually
calling the function sometimes we supply 0 as fd and event.  Instead of
fixing the usage, do as other of such functions do in this
circumstances: use c->fd.
2021-06-12 13:42:43 +00:00
Omar Polo 89c88caa3c mark backend as FCGI_READY when getting a fd
otherwise clients will remain stuck waiting for a pending request that
doesn't exist (see apply_fastcgi switch.)
2021-06-12 13:41:33 +00:00
Omar Polo e18b070da8 indentation 2021-06-12 12:35:15 +00:00
Omar Polo ab1e0169b9 free fastcgi param list 2021-06-12 10:20:36 +00:00
Omar Polo 3b33eab3ad TAILQ_REMOVE env and aliases during config_free
it's not technically required, since a couple of lines below we free
whole host struct, and we don't have code that may use
h->{env,aliases} afterwards, but it's nice not to have invalid
pointers around.  it may bite in the future.
2021-06-12 10:19:17 +00:00
Omar Polo a6c809551e mention FastCGI in the README.md 2021-06-11 16:11:58 +00:00
Omar Polo fd1ae83d20 fix warnings in manpage
man -Tlint
2021-06-11 16:06:24 +00:00
Omar Polo ada16f8731 document fastcgi and the new `param' options 2021-06-11 16:04:22 +00:00
Omar Polo c92b802b6a add `param' keyword 2021-06-11 15:49:46 +00:00
Omar Polo f740b61b03 more params from and send a custom list 2021-06-11 15:48:56 +00:00
Omar Polo 6957a8c27f reword last sentence 2021-06-04 07:14:50 +00:00
Omar Polo 0c7a1d3cf3 improve docker example 2021-06-04 07:13:37 +00:00
Omar Polo 3a1bd9ab49 sync 2021-05-27 09:46:00 +00:00
Omar Polo f48e3b85a9 move gg to regress 2021-05-24 13:48:55 +00:00
Omar Polo 0d047efcb4 refactor fastcgi block 2021-05-24 09:09:10 +00:00
Omar Polo 8ff40039e8 document `fastcgi' config option 2021-05-24 09:07:28 +00:00
Omar Polo ce2c9edbc2 define and use GMID_VERSION 2021-05-15 11:11:56 +00:00
Omar Polo d1051bfaa0 define some more fcgi param 2021-05-15 11:10:55 +00:00
Omar Polo 1feaf2a618 use the correct document root
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-15 10:31:43 +00:00
Omar Polo 91b9f2a8f9 const-ify strip_path 2021-05-15 10:07:21 +00:00
Omar Polo 571d20fbb3 fmt 2021-05-15 10:04:58 +00:00
Omar Polo 0773413c1d correct the description of `strip'
now it's also used in the path lookup process
2021-05-15 09:51:45 +00:00
Omar Polo 1eb3631d10 certificate generation (bugfix and improvement)
don't add gmid as organisation when generating the certificate, and
set the version to 3, so it's compatible with java/android clients.

Found by Gnuserland, thanks!
2021-05-12 17:37:22 +00:00
Omar Polo 58d51f2c11 gmid don't enforce anymore that a root is specified 2021-05-11 20:20:02 +00:00
Omar Polo 23a5aab4ce drop forward declaration of struct client
it's been since the switch to libevent that is no longer needed.
2021-05-11 19:41:16 +00:00
Omar Polo 84821dc0ac sync 2021-05-09 18:31:18 +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 50310aff33 added missing prototype 2021-05-04 18:19:47 +00:00
Omar Polo 419e32b05e sync 2021-05-03 16:12:53 +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 7b2d743260 move pidfile & cgi to global vars 2021-05-01 12:17:42 +00:00
Omar Polo 7aa9258633 make more explicit the per-location roots test 2021-04-30 19:08:27 +00:00
Omar Polo 737a6b50c5 ensure %p (path) is always absolute
with the recent changes, sometimes the path may not start with a '/'.
This ensures that %s is ALWAYS an absolute path.
2021-04-30 19:07:37 +00:00