+++ /dev/null
-#!/binaries/execlineb -WS1
-# `supported-hostname-test.execline hostname`
-#
-# tests if `hostname` is supported by this server, by checking if
-# a directory by that exact name exists in the current working directory
-# immediately 404s otherwise
-#
-# hard depends on these external `httpd.execline` subscripts:
-#
-# + ./http-error-response.execline: and thus,
-# + ./log.execline
-#
-
-# protect Special Subdirectories
-#
-# + `/binaries` is change root--available static binaries and helper scripts
-# + `tcp-access-rules` for the pseudo-firewall
-# + `.` and `..` are to disallow clients being Naughty
-# + the other directories are for process supervision things
-#
-# note: general policy for this server is to 404 where we "should" 403.
-#
-ifelse {
- s6-test \${1} = binaries -o
- \${1} = data -o
- \${1} = event -o
- \${1} = log -o
- \${1} = supervise -o
- \${1} = tcp-access-rules -o
- \${1} = . -o
- \${1} = ..
-}
-{
- if {
- http-error-response.execline
- 404
- "not found"
- "illegal host: \""${1}\"
- }
- exit 1
-}
-# reject unsupported hostnames
-#
-ifelse { s6-test ! -d \${1} }
-{
- if {
- http-error-response.execline
- 404
- "not found"
- "unsupported host: \""${1}\"
- }
- exit 1
-}
-exit 0
#!/binaries/execlineb -WS2
# http-error-response.execline STATUS_CODE STATUS_MESSAGE [LOG_MESSAGE]
#
-# if `data/status-code/table/${hostname}/${STATUS_CODE} exists, `cat(1)` that
+# if `configuration/status-code/table/${hostname}/${STATUS_CODE} exists, `cat(1)` that
# otherwise, fall back on a very generic error message
#
# TODO:
backtick -i -n Date { date -u "+%a, %d %b %Y %T GMT" }
-backtick -i -n extra_headers { cat data/extra_headers/default }
+backtick -i -n extra_headers { cat configuration/default_headers/default }
multisubstitute {
# TODO: importas -i -u Content-Length Content-Length
}
if {
- ifelse { s6-test -r data/status-code_table/${hostname}/${1} }
+ ifelse { s6-test -r configuration/error_response_pages/${hostname}/${1} }
{
# TODO: support `Content-Types`?? and `Content-Length`
- cat data/status-code_table/${hostname}/${1}
+ cat configuration/error_response_pages/${hostname}/${1}
}
s6-echo -n -- "<!DOCTYPE html>
<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">
#### 3. process requested resource ###
backtick -i -n resource {
+ cd supported_domains
+
backtick -i -n candidate_resource {
backtick -in with_dot_and_dot_dot {
pipeline { s6-echo -n -- ${requested_resource} }
s6-echo -n -- ${candidate_resource}
}
importas -i resource resource
- ifelse { s6-test ! -r \${resource} }
+
+ ifelse { s6-test ! -r supported_domains/${resource} }
{
http-error-response.execline
404
tr := ./
}
- # use `./data/Content-Type_table` as a key-value store: files with
+ # use `./configuration/Content-Type_table` as a key-value store: files with
# the name ${extension} map to the `Content-Type` embedded in
- # their contents. for example, `./data/Content-Type_table/xhtml`
+ # their contents. for example, `./configuration/Content-Type_table/xhtml`
# contains the text “application/xhtml+xml” (with no newline)
# (it is fine if the file contains a single newline at the end)
#
# if no key exists with the extension’s name, we fall back on
# “application/octet-stream”, as we should
importas -i -u extension extension
- ifelse { s6-test -r \\./data/Content-Type_table/${extension} }
+ ifelse { s6-test -r configuration/Content-Type_table/${extension} }
{
- cat ./data/Content-Type_table/${extension}
+ cat configuration/Content-Type_table/${extension}
}
s6-echo -n -- application/octet-stream
}
# TODO: separate this out, ideally make reusable
# file length in bytes: SHOULD be provided
- backtick -i -n Content-Length { stat -c%s -- ${resource} }
+ backtick -i -n Content-Length { stat -c%s -- supported_domains/${resource} }
# "[weekday], [month-day] [month] [year] [hours:minutes:seconds] GMT"
# (example: "Tue, 03 Mar 2020 21:06:08 GMT")
# the date the resource was last modified SHOULD be provided
backtick -i -n Last-Modified {
- backtick -i -n seconds_since_epoch { stat -c%Y -- ${resource} }
+ backtick -i -n seconds_since_epoch { stat -c %Y -- supported_domains/${resource} }
importas -i -u seconds_since_epoch seconds_since_epoch
date -d @${seconds_since_epoch} -u ${date_format}
}
# current time of response: SHOULD be provided (why?)
backtick -i -n Date { date -u ${date_format} }
-
# allow for arbitrary HTTP header and HTTP status code overrides.
# for an example where the former might be useful, consider Content
# Security Policy; for the latter, consider HTTP 301 redirects
#
# be warned!! we do not validate these overrides!
backtick -i -n extra_headers {
- ifelse { s6-test -r \\data/extra_headers/override/${resource} }
+ ifelse { s6-test -r configuration/default_headers/override/${resource} }
{
- cat data/extra_headers/override/${resource}
+ cat configuration/default_headers/override/${resource}
}
- cat data/extra_headers/default
+ cat configuration/default_headers/default
}
backtick -D "200 ok" -n status_code_and_message {
- if { s6-test -r \\data/status_override/${resource} }
- cat data/status_override/${resource}
+ if { s6-test -r configuration/overrides/${resource} }
+ cat configuration/overrides/${resource}
}
##### 4.3. send the response ###
}
foreground {
if -t { s6-test \${method} = GET }
- cat ${resource}
+ cat supported_domains/${resource}
}
# hack: write(3p) does not guarantee that all the
# content actually gets written before this process