1
0
mirror of https://git.sr.ht/~sircmpwn/gmnisrv synced 2024-06-01 17:21:10 +00:00
Commit Graph

34 Commits

Author SHA1 Message Date
William Casarin
1925bc3e7a serve: make hostname matching case-insensitive
Reported-by: James Tomasino <james@tomasino.org>
Signed-off-by: William Casarin <jb55@jb55.com>
2021-11-15 21:07:23 +01:00
Karmanyaah Malhotra
32854b79c7 Check index before serving autoindex
if a directory is being served.
2021-06-21 08:42:29 -04:00
dece
9f2481dcdf Support REMOTE_USER in CGI 2021-06-17 09:52:50 -04:00
dece
d7bd3c6a0d Support TLS_CLIENT_SERIAL_NUMBER in CGI 2021-06-17 09:52:50 -04:00
dece
0bf3cde2a0 Use strncpy to build TLS_CLIENT_HASH
strncat on an uninitialized array leads to issues.
2021-06-17 09:52:49 -04:00
Drew DeVault
0dc0e4432a Revert "Routing: Fix non-ascii paths"
This causes a security issue (path traversal)

This reverts commit ea360fa4c1.
2021-05-04 09:43:23 -04:00
nytpu
ae7ca3db39 Send client certificate hash for CGI scripts.
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.
2021-02-11 09:19:16 -05:00
Nolan Prescott
6d9dd838e4 ignore SIGCHLD to prevent CGI zombies
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>
2021-02-07 08:07:05 -05:00
René Wagner
32913c35cd implement handling of ROUTE_EXACT definitions
This patchset implements the handling of exact routes
as described in gmnisrvini(5).
2021-01-29 08:55:43 -05:00
Zach DeCook
ea360fa4c1 Routing: Fix non-ascii paths 2021-01-22 08:15:03 -05:00
Zach DeCook
fbef1d34a1 autoindex: fix off-by-one buffer size 2020-12-27 08:13:09 -05:00
Zach DeCook
eac874b925 autoindex: end directories with trailing slash 2020-12-24 09:05:28 -05:00
William Casarin
10662cac46 serve: handle return value from chdir
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>
2020-11-20 11:17:43 -05:00
Eyal Sawady
cb042d6263 CGI: Don't hang on directory with no index 2020-11-15 11:33:16 -05:00
Eyal Sawady
0646fd020c CGI: Fix paths which end in '/' 2020-11-15 10:55:48 -05:00
Drew DeVault
ea2914efff Set CWD to cgi-bin when executing scripts 2020-11-08 12:16:59 -05:00
Drew DeVault
57f4fcdc41 Fix double free 2020-11-08 12:12:43 -05:00
René Wagner
02a386b568 check if file served as cgi is executable
if not, send a response 50 to the client
fixes ~sircmpwn/gmni#47
2020-11-08 10:59:35 -05:00
dbandstra
c145ac6a65 fix typo in GATEWAY_INTERFACE value 2020-11-08 09:38:52 -05:00
Tom Lebreux
4f12abfbc2 Fix memory leaks 2020-11-08 09:37:55 -05:00
Drew DeVault
dc6e4e80c0 Implement URL rewrites with regex capture groups 2020-11-01 11:19:51 -05:00
Drew DeVault
16e55c6262 Change meaning of root (backwards incompatible!)
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.
2020-11-01 10:32:44 -05:00
Drew DeVault
f15bea6583 Implement regex route matching 2020-11-01 09:43:46 -05:00
Drew DeVault
becc4460b6 Implement MIME database support 2020-10-28 12:38:32 -04:00
Drew DeVault
da6f7e9f05 CGI: Fix SCRIPT_NAME variable 2020-10-26 18:16:05 -04:00
Drew DeVault
5d725ff4ee CGI: set PATH_INFO 2020-10-25 23:55:42 -04:00
Drew DeVault
cc1bd152e3 Initial support for CGI scripts 2020-10-25 23:16:50 -04:00
Drew DeVault
8baeb5a51c Initial implementation of a routing table 2020-10-25 21:46:01 -04:00
Drew DeVault
1fe107875b Overhaul network I/O to be async for real
Had to totally cut off OpenSSL from the network fd because obviously
OpenSSL is just going to wreck our shit
2020-10-25 14:50:07 -04:00
io mintz
a22bec5149 add a missing "/" to autoindex paths
With the following directory structure:

/srv/gmni:
baz/  foo/

/srv/gmni/baz:
a

/srv/gmni/foo:
bar/

/srv/gmni/foo/bar:
b

trying to access gemini://somesite/ with autoindex=on works,
but accessing /foo fails because it tries to stat /srv/gmni/foobar
instead of /srv/gmni/foo/bar. This commit fixes that by adding a trailing slash.
2020-10-15 15:44:45 -04:00
William Casarin
e77f354ca3 serve: fix gcc-9.3.0 error in serve_autoindex
gcc 9.3.0 catches an off-by-one error with strncat in serve_autoindex
where it might not write a 0 byte:

  In function ‘strncat’,
      inlined from ‘serve_autoindex’ at src/serve.c:60:3:
  /nix/store/...glibc-2.31-dev/include/bits/string_fortified.h:136:10:
  error: ‘__builtin___strncat_chk’ specified bound 4097 equals destination size
  [-Werror=stringop-overflow=]

Signed-off-by: William Casarin <jb55@jb55.com>
2020-10-15 12:06:19 -04:00
Chris Vittal
9d17ce46b0 return false on request_validate errors
This will report proper errors to clients rather than continuing on with
request processing.
2020-10-12 21:25:45 -04:00
Drew DeVault
6bc9c4deb9 Implement autoindex option 2020-09-26 15:51:28 -04:00
Drew DeVault
165e3c02fc Rehome some logic from server.c -> serve.c 2020-09-26 15:08:25 -04:00