Commit Graph

547 Commits

Author SHA1 Message Date
Omar Polo 6edcfca97f try to preserve as much as possible CFLAGS and LDFLAGS from env
but still try to autodetect with pkg-config if they aren't provided.

Passing CFLAGS/LDFLAGS from the command line will still override the
guessed ones.
2021-07-06 13:01:11 +00:00
Omar Polo eb877bffaa explain the OpenBSD bit 2021-07-06 12:18:53 +00:00
Omar Polo ca3f67564c don't log too much by default 2021-07-06 11:53:24 +00:00
Omar Polo fb4102a5ff test macro expansion too 2021-07-06 11:52:28 +00:00
Omar Polo 3759d3eb56 show macro usage in the example 2021-07-06 11:41:24 +00:00
Omar Polo 7700ab07d3 fmt 2021-07-06 10:56:13 +00:00
Omar Polo 59c7ee13b4 fmt 2021-07-06 10:56:01 +00:00
Omar Polo 090b8a89fa gracefully shut down fastcgi backends
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-07-06 10:54:27 +00:00
Omar Polo ea976e8743 don't let CGI scripts inherit our stderr
our stderr could have been sent to the logger process, so it may be
invalid.  Furthermore, in the future we may want to capture also the
stderr of the processes.
2021-07-06 10:48:59 +00:00
Omar Polo ef945cf415 reset fcgi array in free_config
otherwise path, port and/or prog could become an invalid pointer.
2021-07-06 10:46:50 +00:00
Omar Polo 4aa1dd553a typo 2021-07-03 18:30:07 +00:00
Omar Polo b24021d4a2 fix seccomp filter for ppc64le
before we matched ppc64le as ppc64 (which is big ending I presume), so
the seccomp filter would always kill gmid

#4 related
2021-07-03 17:38:50 +00:00
Omar Polo 7322a054f5 use -subj /CN=name when generating the keys for the tests
`printf | openssl` is ugly :/
2021-07-03 08:13:42 +00:00
Omar Polo 8bb8cf2ad4 configure: add --disable-sandbox
Calling `configure' with --disable-sandbox will disable the sandbox
support *completely* at compile time.  gmid will still complain at
compile time and during the startup.

Users shouldn't disable the sandbox if possible, but instead report
problem upstream so they get fixed (hopefully.)

#4 related
2021-07-02 09:26:59 +00:00
Omar Polo 137def5ff4 reworked seccomp filter
* SECCOMP_AUDIT_ARCH extended to support more architectures
* relax fcntl policy: allow the syscall regardless of the flags
* wrap every syscall in a ifdef, and add some (statx, fcntl64, ...)
  used in x86

Some bits were taken from dhcpcd[0], thanks!

#4 related


[0]: https://roy.marples.name/git/dhcpcd/blob/HEAD:/src/privsep-linux.c
2021-07-02 09:11:40 +00:00
Omar Polo 4f9a27603c revert 2c16dbd548 -- macro names can't be reserved words
While one can define a macro using a reserved word as name using
-Dname=val, inside the configuration file it'll fail.
2021-07-02 09:05:22 +00:00
Omar Polo 2c16dbd548 macro names can be reserved words 2021-06-29 16:49:38 +00:00
Omar Polo 4ede0fe495 fix macro example 2021-06-29 16:45:09 +00:00
Omar Polo eaf7f776f1 document the c-like handling of strings 2021-06-29 16:44:17 +00:00
Omar Polo bfb076ed7e don't expand macros inside the quotes
Now that we have this auto concat string thingy, macros can simply
expand to standalone strings in place, as single words.

Forgot to point it out in previous commits, but now we can

	cert = "/etc/keys"

	server "foo" {
		cert $cert "/foo.crt"
		...
	}
2021-06-29 16:35:06 +00:00
Omar Polo 7252049dd7 align 2021-06-29 16:10:40 +00:00
Omar Polo 98f5217822 [config] concat two or more strings next to each others 2021-06-29 16:10:10 +00:00
Omar Polo 8b743ddacb document macros: both -D and syntax 2021-06-29 14:19:35 +00:00
Omar Polo 6b86655a10 don't require the strict order macro > options > servers 2021-06-29 12:42:44 +00:00
Omar Polo f98e9045ae add -D to define macros from the cmd line 2021-06-29 12:39:34 +00:00
Omar Polo 3b21cca385 allow to define macros in the config file
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-29 12:17:40 +00:00
Omar Polo fafc684957 trailing whitespaces 2021-06-29 11:21:32 +00:00
Omar Polo 8235a81c8f give a name to the anonymous union 2021-06-29 11:11:43 +00:00
Omar Polo 0be2a537e6 sync the usage; while there also change order and capitalize 2021-06-29 11:04:29 +00:00
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