From: single-right-quote <34298117+single-right-quote@users.noreply.github.com> Date: Mon, 23 Aug 2021 12:58:17 +0000 (-0400) Subject: update for breaking changes in execline X-Git-Tag: v1.0.0~41 X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=063e786dc1c2732e9344e33b1959d7b568b4ea85;p=httpd-execline.git update for breaking changes in execline + `backtick -i` is now the default behaviour + `backtick -I` is now the old default behaviour + `backtick -x` is now what `-I` used to be + `backtick -E` was added to automatically `import -i -u` + `trap` no longer supports timeouts; switch to timeout(1p) --- diff --git a/visible-to-httpd/binaries/get-line-from-client.execline b/visible-to-httpd/binaries/get-line-from-client.execline index f8c18c0..d0cdc26 100755 --- a/visible-to-httpd/binaries/get-line-from-client.execline +++ b/visible-to-httpd/binaries/get-line-from-client.execline @@ -2,11 +2,6 @@ # wrapper around plan 9 read(1) to timeout after 60 seconds # returns read(1)'s exit status -trap -x -t 60000 { - timeout { - importas -i -u ! ! - kill -- ${!} - } -} -pipeline -w { tr -d "\r" } -read +timeout --foreground --preserve-status 60 + pipeline -w { tr -d "\r" } + read diff --git a/visible-to-httpd/binaries/http-error-response.execline b/visible-to-httpd/binaries/http-error-response.execline index cc9f6db..d0e704f 100755 --- a/visible-to-httpd/binaries/http-error-response.execline +++ b/visible-to-httpd/binaries/http-error-response.execline @@ -10,8 +10,8 @@ foreground { log.execline "fatal: ??"${1}"??: "${3} } -backtick -i -n Date { date -u "+%a, %d %b %Y %T GMT" } -backtick -i -n extra_headers { http-get-extra-headers.execline ${1} } +backtick -n Date { date -u "+%a, %d %b %Y %T GMT" } +backtick -n extra_headers { http-get-extra-headers.execline ${1} } multisubstitute { importas -i -u Date Date @@ -19,7 +19,7 @@ multisubstitute { importas -D "?? no hostname ??" hostname http_header_parse_Host } -backtick -I -n error_response_directory { +backtick -x -n error_response_directory { ifelse { s6-test -d configuration/error_response_pages/${hostname}/${1} -a -r configuration/error_response_pages/${hostname}/${1} @@ -61,13 +61,12 @@ Date: "${Date}"\r \r " } - cat message_body } # default: no error status page on file; use a hardcoded default # (why does `hoc -e` not work?) - backtick -i -n Content-Length { + backtick -n -E Content-Length { backtick -i -n message_length { pipeline { s6-echo -n -- ${2} } wc -c @@ -77,7 +76,6 @@ Date: "${Date}"\r pipeline { s6-echo -- ${message_length}"*2 + 288" } hoc } - importas -i -u Content-Length Content-Length if { s6-echo -n -- "HTTP/1.1 "${1}" "${2}"\r diff --git a/visible-to-httpd/binaries/http-get-extra-headers.execline b/visible-to-httpd/binaries/http-get-extra-headers.execline index db792cf..45b56c3 100755 --- a/visible-to-httpd/binaries/http-get-extra-headers.execline +++ b/visible-to-httpd/binaries/http-get-extra-headers.execline @@ -21,7 +21,7 @@ multisubstitute { importas -i resource resource } -backtick -n header-directory { +backtick -x -n header-directory { # for status code pages specifically ifelse { s6-test \${#} != 0 diff --git a/visible-to-httpd/binaries/http-header-parse.execline b/visible-to-httpd/binaries/http-header-parse.execline index 09d9a58..26e6b0c 100755 --- a/visible-to-httpd/binaries/http-header-parse.execline +++ b/visible-to-httpd/binaries/http-header-parse.execline @@ -60,7 +60,7 @@ emptyenv -P # (deliberately) very underpowered) # -backtick -i -n current_line { get-line-from-client.execline } +backtick -n current_line { get-line-from-client.execline } ### terminating case: empty line # @@ -91,13 +91,13 @@ ifelse { # # after parsing, exec(3p) this script with the hostname validating # subscript, then the remaing program, as arguments -# -backtick -I -n header_name { +# +backtick -x -n header_name { pipeline { printenv current_line } pipeline { sed -n "s/^([^ :]+):.*/\\1/p" } read } -backtick -I -n header_contents { +backtick -x -n header_contents { pipeline { printenv current_line } # strip spaces or tabs from end of line # then print the second token verbatim diff --git a/visible-to-httpd/binaries/http-start-line-parse.execline b/visible-to-httpd/binaries/http-start-line-parse.execline index e76fd3c..a358a1a 100755 --- a/visible-to-httpd/binaries/http-start-line-parse.execline +++ b/visible-to-httpd/binaries/http-start-line-parse.execline @@ -17,18 +17,18 @@ # containing the request's method, requested resource, and http version # it then exec(3p)s into its command line -backtick -i -n start_line { get-line-from-client.execline } -backtick -I -n http_start_line_parse_method { +backtick -n start_line { get-line-from-client.execline } +backtick -x -n http_start_line_parse_method { pipeline { printenv start_line } pipeline { sed -n "s@^(CONNECT|DELETE|GET|HEAD|OPTIONS|PATCH|POST|PUT|TRACE) +.*@\\1@p" } read } -backtick -I -n http_start_line_parse_resource { +backtick -x -n http_start_line_parse_resource { pipeline { printenv start_line } pipeline { sed -n "s@^[^ ]+ +(/[^ ]*) +.*@\\1@p" } read } -backtick -I -n http_start_line_parse_version { +backtick -x -n http_start_line_parse_version { pipeline { printenv start_line } pipeline { sed -n "s@.*HTTP/([0-9]\.[0-9]) *@\\1@p" } read diff --git a/visible-to-httpd/binaries/httpd.execline b/visible-to-httpd/binaries/httpd.execline index ed8c6c0..f8ee575 100755 --- a/visible-to-httpd/binaries/httpd.execline +++ b/visible-to-httpd/binaries/httpd.execline @@ -103,11 +103,11 @@ if -X -n -t { } #### 3. process requested resource ### - backtick -i -n resource { + backtick -n resource { cd supported_domains - backtick -i -n candidate_resource { - backtick -in with_dot_and_dot_dot { + backtick -n candidate_resource { + backtick -n with_dot_and_dot_dot { pipeline { s6-echo -n -- ${requested_resource} } # # strip query string, or resource location @@ -195,7 +195,7 @@ if -X -n -t { # TODO: separate this out, ideally make reusable # file length in bytes: SHOULD be provided - backtick -i -n Content-Length { stat -c%s -- supported_domains/${resource} } + backtick -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") @@ -203,20 +203,19 @@ if -X -n -t { # the date the resource was last modified SHOULD be provided backtick -i -n Last-Modified { - backtick -i -n seconds_since_epoch { stat -c %Y -- supported_domains/${resource} } - importas -i -u seconds_since_epoch seconds_since_epoch + backtick -n -E seconds_since_epoch { stat -c %Y -- supported_domains/${resource} } date -d @${seconds_since_epoch} -u ${date_format} } # current time of response: SHOULD be provided (why?) - backtick -i -n Date { date -u ${date_format} } + backtick -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 { http-get-extra-headers.execline } + backtick -n extra_headers { http-get-extra-headers.execline } backtick -D "200 ok" -n status_code_and_message { if { s6-test -r configuration/overrides/${resource}/status_code }