summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Serve CA full chain (Let's Encrypt), TLS 1.3, fix handshake buffer overflowHEADmainGab Virebent7 days2-17/+40
| | | | | | | | - tls.c/config.h: read full PEM chain into STACK_OF(X509), send via SSL_set1_chain - tls.c: minimum protocol TLS 1.2 -> TLS 1.3 - server.c: drain handshake output via local buffer loop instead of staging into the fixed 4 KB client buffer (a full CA chain overflowed it -> assert) - FORK.md: describe the fork
* Close some files when too many are openRemy Noulin2022-12-191-0/+11
|
* notify clients about malformed requestsJulian Maingot2022-08-151-1/+4
| | | | | | | I think this has been broken for a while and I came across it while implementing my own client. The server should notify the client that the request is malformed but wasn't sending the response when SSL_read returned SSL_ERROR_WANT_READ.
* serve: make hostname matching case-insensitiveWilliam Casarin2021-11-151-1/+2
| | | | | Reported-by: James Tomasino <james@tomasino.org> Signed-off-by: William Casarin <jb55@jb55.com>
* set session id contextmbays2021-08-271-0/+1
| | | | | | This is necessary now client certificates are supported. Without it, an attempt to resume a session fails with "ssl_get_prev_session:session id context uninitialized".
* Check index before serving autoindexKarmanyaah Malhotra2021-06-211-6/+6
| | | | if a directory is being served.
* Support REMOTE_USER in CGIdece2021-06-171-1/+17
|
* Support TLS_CLIENT_SERIAL_NUMBER in CGIdece2021-06-171-2/+15
|
* Use strncpy to build TLS_CLIENT_HASHdece2021-06-171-1/+1
| | | | strncat on an uninitialized array leads to issues.
* disconnect_client: fix index calculationEyal Sawady2021-05-161-1/+1
| | | | | | This was sometimes causing a gmnisrv_client to be overwritten by the deinitialized client, which occasionally lead to a segfault when we later tried to use it.
* Create certificates which last 68 years (INT32_MAX seconds)Thomas Karpiniec2021-05-161-1/+2
| | | | This avoids integer overflow on 32-bit architectures.
* Revert "Routing: Fix non-ascii paths"Drew DeVault2021-05-041-12/+3
| | | | | | This causes a security issue (path traversal) This reverts commit ea360fa4c10791c3c720c33470c86923424348fe.
* Fix integer overflow error in tls.cbacardi552021-03-241-1/+1
|
* Move certificate expiration into the far futureDrew DeVault2021-03-041-1/+1
|
* Send client certificate hash for CGI scripts.nytpu2021-02-112-1/+41
| | | | | | | | | | | | Set SSL_VERIFY_PEER to request a client certificate from the server, when available. Have to shim the certificate verification function or else it will fail on self-signed client certs. In serve_cgi retrieve client certificate, create a fingerprint, and set proper environment variables. It's pretty barebones, it doesn't parse the certificate to give any other useful info like the common name, but it's acceptable IMO. For most CGI uses the fingerprint is the only thing that is needed anyways.
* ignore SIGCHLD to prevent CGI zombiesNolan Prescott2021-02-071-0/+2
| | | | | | | | with nothing waiting on the forked processes there is no reason not to reap the CGI process on exit intended to address issue from mailing list "gmnisrv uses too many tasks" <163806E8-A16A-463E-8C62-43E903EF1E35@librem.one>
* Use v3 X509 certificateMatt Keeter2021-02-051-1/+14
| | | | | | | | | | This fixes an issue where rustls failed to validate the X509v1 certificate. Tested with Amfora, av-98, and titan (https://github.com/mkeeter/titan) This requires fresh certificates, which could break clients with strict trust-on-first-use policies; unfortunately, it doesn't appear to be possible to migrate v1 certificates to v3.
* implement handling of ROUTE_EXACT definitionsRené Wagner2021-01-292-1/+13
| | | | | This patchset implements the handling of exact routes as described in gmnisrvini(5).
* Routing: Fix non-ascii pathsZach DeCook2021-01-221-3/+12
|
* autoindex: fix off-by-one buffer sizeZach DeCook2020-12-271-0/+1
|
* autoindex: end directories with trailing slashZach DeCook2020-12-241-2/+9
|
* Fix IP address loggingNolan Prescott2020-12-191-4/+20
| | | | | | | | Cast generic sockaddr to the appropriate sockaddr_ AF and switch inet_ntop argument accordingly. Intended to fix issue reported on ~sircmpwn/gmni-discuss: "Logged IPv4 addresses are wrong"
* Switch to using ECDSA (secp384r1) keysMark Dain2020-11-211-9/+4
|
* serve: handle return value from chdirWilliam Casarin2020-11-201-1/+2
| | | | | | | | | | | | Fixes a compile error on gcc 9.3.0: src/serve.c: In function 'serve_cgi': src/serve.c:150:3: error: ignoring return value of 'chdir', declared with attribute warn_unused_result [-Werror=unused-result] 150 | chdir(dirname(cwd)); | ^~~~~~~~~~~~~~~~~~~ Signed-off-by: William Casarin <jb55@jb55.com>
* CGI: Don't hang on directory with no indexEyal Sawady2020-11-151-0/+8
|
* CGI: Fix paths which end in '/'Eyal Sawady2020-11-151-8/+21
|
* Fix use of wrong index during pollfd refreshKenny Levinsen2020-11-101-1/+1
| | | | | | The right side of the refresh ended up using the index of the deleted client instead of the index from the loop, which happens to work when the destroyed client is either last or second-last.
* Update pollfd pointers when destroying a clientKenny Levinsen2020-11-081-0/+4
| | | | | | | | The client pollfd pointer would go stale when the server pollfd array was moved to compensate for a destroyed client, which in turn led to poll breakage. Refresh the pollfd pointers after memmove.
* Prevent double free of client resourcesDrew DeVault2020-11-081-0/+4
|
* Set CWD to cgi-bin when executing scriptsDrew DeVault2020-11-081-0/+4
|
* Fix double freeDrew DeVault2020-11-081-0/+1
|
* check if file served as cgi is executableRené Wagner2020-11-081-0/+6
| | | | | if not, send a response 50 to the client fixes ~sircmpwn/gmni#47
* fix typo in GATEWAY_INTERFACE valuedbandstra2020-11-081-1/+1
|
* Set POLLOUT only when there's something to writembays2020-11-081-1/+1
|
* tls: fix crash when opening priv key for writingWilliam Casarin2020-11-081-1/+1
| | | | | | | | | | | | | | | | | | | The open syscall will return a negative value if the call fails. Switch the check to look for this instead of 0. before: [gmnisrv] generating certificate for localhost gmnisrv: src/tls.c:68: tls_host_gencert: Assertion `pf' failed. abort (core dumped) ./gmnisrv -C config.ini after: [gmnisrv] generating certificate for localhost [gmnisrv] opening private key for writing failed: No such file or directory [gmnisrv] TLS initialization failed Signed-off-by: William Casarin <jb55@jb55.com>
* Don't memmove one past clientsTom Lebreux2020-11-081-1/+3
|
* Fix not moving all fdsTom Lebreux2020-11-081-1/+1
|
* Fix memory leaksTom Lebreux2020-11-082-0/+5
|
* config/routing: fix maybe-uninitialized errorsWilliam Casarin2020-11-021-0/+2
| | | | | | | | | | | | | | | | | Trivial fix to silence compilation errors on gcc 9.3.0: src/config.c: In function ‘conf_ini_handler’: src/config.c:154:23: error: ‘routing’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 154 | enum gmnisrv_routing routing; | ^~~~~~~ src/config.c:197:18: error: ‘spec’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 197 | route->path = strdup(spec); | ^~~~~~~~~~~~ Signed-off-by: William Casarin <jb55@jb55.com>
* Implement URL rewrites with regex capture groupsDrew DeVault2020-11-013-18/+132
|
* Change meaning of root (backwards incompatible!)Drew DeVault2020-11-011-9/+10
| | | | | | | | | This takes the nginx approach to the "root" directive, which is simpler to implement and more consistent with more complex routing behaviors like regexp. The path component of the URL is now simply appended to the root to form the path to the file which should be served to the client.
* regexp.c: ditch unused test codeDrew DeVault2020-11-011-170/+0
|
* Implement regex route matchingDrew DeVault2020-11-011-2/+16
|
* Initial pass on regex routing supportDrew DeVault2020-10-292-2/+3058
| | | | | | | | | All this does is parse the regexes out of the config file. I've vendored libregexp from Bellard's quickjs project, because it's reasonably small and self-contained, and POSIX regexes don't support captures. We're eventually going to want captures for URL rewrites, so this'll do for now.
* Fail gracefully if mime database is not presentDrew DeVault2020-10-281-1/+7
|
* config: free more routing information on finishDrew DeVault2020-10-281-0/+11
|
* Implement MIME database supportDrew DeVault2020-10-283-12/+102
|
* server: handle write errorsDrew DeVault2020-10-281-1/+5
|
* CGI: Fix SCRIPT_NAME variableDrew DeVault2020-10-261-3/+6
|
* CGI: set PATH_INFODrew DeVault2020-10-251-16/+48
|