diff options
author | bptato <nincsnevem662@gmail.com> | 2024-12-29 17:59:47 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-12-29 17:59:47 +0100 |
commit | e60c82ec37b69ce82f40de5f66f079a9a0aee6be (patch) | |
tree | b2bd76e5da68ffaffea1bc8f6b4957d048991083 | |
parent | 5fb2c9c1a96da52fb392a8218f826f4381208b10 (diff) | |
download | chawan-e60c82ec37b69ce82f40de5f66f079a9a0aee6be.tar.gz |
config: clean up redundant CHA_DIR, update CGI docs
"No CGI dir configured" is no longer a common case, so it's OK to just return "CGI file not found".
-rw-r--r-- | doc/config.md | 5 | ||||
-rw-r--r-- | doc/localcgi.md | 26 | ||||
-rw-r--r-- | res/config.toml | 4 | ||||
-rw-r--r-- | src/server/connecterror.nim | 32 | ||||
-rw-r--r-- | src/server/loader.nim | 3 |
5 files changed, 23 insertions, 47 deletions
diff --git a/doc/config.md b/doc/config.md index 05b075f5..77e02f50 100644 --- a/doc/config.md +++ b/doc/config.md @@ -350,7 +350,7 @@ the line number.</td> <tr> <td>auto-mailcap</td> <td>path</td> -<td>"$CHA_DIR/auto.mailcap"</td> +<td>"auto.mailcap"</td> <td>Mailcap file for entries that are automatically executed.<br> The "Open as" prompt also saves entries in this file.</td> </tr> @@ -1624,7 +1624,8 @@ Rules for path handling are similar to how strings in the shell are handled. * Tilde-expansion is used to determine the user's home directory. So e.g. `~/whatever` works. * Environment variables can be used like `$ENV_VAR`. -* Relative paths are relative to the Chawan configuration directory. +* Relative paths are relative to the Chawan configuration directory + (i.e. `$CHA_DIR`). Some environment variables are also exported by Chawan: diff --git a/doc/localcgi.md b/doc/localcgi.md index 2d302313..0c41fbb9 100644 --- a/doc/localcgi.md +++ b/doc/localcgi.md @@ -10,8 +10,9 @@ used in the following way: * All local CGI scripts must be placed in a directory specified in `external.cgi-dir`. Multiple directories can be specified in an array too, and directories specified first have higher precedence. - By default, this is set to ~/.chawan/cgi-bin and - /usr/local/libexec/chawan/cgi-bin. + By default, this is set to `$CHA_DIR/cgi-bin` (i.e. + `~/.chawan/cgi-bin` or `~/.config/chawan/cgi-bin`, depending on + `config.toml`'s location) and `/usr/local/libexec/chawan/cgi-bin`. * Then, a CGI script in one of these directories can be executed by visiting the URL `cgi-bin:script-name`. $PATH_INFO and $QUERY_STRING are set as normal, i.e. `cgi-bin:script-name/abcd?defgh=ijkl` will set $PATH_INFO to @@ -194,27 +195,6 @@ slow down the browser in case of excessive logging. If this is not the desired behavior, we recommend wrapping your script into a shell script that redirects stderr to /dev/null. -### My script is returning a "no local-CGI directory configured" error message. - -Currently, the default setting includes a cgi-bin directory at -`$(which cha)/../libexec/chawan/cgi-bin`, which usually looks something like -`/usr/local/libexec/chawan/cgi-bin`. You only get the above message if you -intentionally set the cgi-dir setting to an empty array. (This will likely break -everything else too, so do not.) - -To change the default local-CGI directory, use the `external.cgi-dir` option. - -e.g. you could add this to your config.toml: - -```toml -[external] -cgi-dir = ["~/cgi-bin", "${%CHA_LIBEXEC_DIR}/cgi-bin"] -``` - -and then put your script in `$HOME/cgi-bin`. Note the second element in the -array; if you don't add it, the default CGI scripts (including http, https, -etc...) will not work. - ### My script is returning a "Failed to execute script" error message. This means the `execl` call to the script failed. Make sure that your CGI diff --git a/res/config.toml b/res/config.toml index 1f25da54..5119a7eb 100644 --- a/res/config.toml +++ b/res/config.toml @@ -37,7 +37,7 @@ mailcap = [ "/usr/etc/mailcap", "/usr/local/etc/mailcap" ] -auto-mailcap = "$CHA_DIR/auto.mailcap" +auto-mailcap = "auto.mailcap" mime-types = [ "~/.mime.types", "/etc/mime.types", @@ -56,7 +56,7 @@ history-size = 100 tmpdir = "${TMPDIR:-/tmp}/cha-tmp-$LOGNAME" sockdir = "${TMPDIR:-/tmp}/cha-sock-$LOGNAME" editor = "${EDITOR:-vi}" -cgi-dir = ["$CHA_DIR/cgi-bin", "$CHA_LIBEXEC_DIR/cgi-bin"] +cgi-dir = ["cgi-bin", "$CHA_LIBEXEC_DIR/cgi-bin"] download-dir = "${TMPDIR:-/tmp}/" w3m-cgi-compat = false copy-cmd = 'xsel -bi' diff --git a/src/server/connecterror.nim b/src/server/connecterror.nim index 5b428526..41e4c89e 100644 --- a/src/server/connecterror.nim +++ b/src/server/connecterror.nim @@ -1,20 +1,19 @@ type ConnectionError* = enum - ceCGICachedBodyUnavailable = -18 - ceCGIOutputHandleNotFound = -17 - ceCGIFailedToOpenCacheOutput = -16 - ceCGICachedBodyNotFound = -15 - ceFailedToRedirect = -14 - ceURLNotInCache = -13 - ceFileNotInCache = -12 - ceFailedToExecuteCGIScript = -11 - ceCGIMalformedHeader = -10 - ceCGIInvalidChaControl = -9 - ceTooManyRewrites = -8 - ceInvalidURIMethodEntry = -7 - ceCGIFileNotFound = -6 - ceInvalidCGIPath = -5 - ceFailedToSetUpCGI = -4 - ceNoCGIDir = -3 + ceCGICachedBodyUnavailable = -17 + ceCGIOutputHandleNotFound = -16 + ceCGIFailedToOpenCacheOutput = -15 + ceCGICachedBodyNotFound = -14 + ceFailedToRedirect = -13 + ceURLNotInCache = -12 + ceFileNotInCache = -11 + ceFailedToExecuteCGIScript = -10 + ceCGIMalformedHeader = -9 + ceCGIInvalidChaControl = -8 + ceTooManyRewrites = -7 + ceInvalidURIMethodEntry = -6 + ceCGIFileNotFound = -5 + ceInvalidCGIPath = -4 + ceFailedToSetUpCGI = -3 ceDisallowedURL = -2 ceUnknownScheme = -1 ceNone = 0 @@ -46,7 +45,6 @@ const ErrorMessages* = [ ceCGIFileNotFound: "CGI file not found", ceInvalidCGIPath: "invalid CGI path", ceFailedToSetUpCGI: "failed to set up CGI script", - ceNoCGIDir: "no local-CGI directory configured", ceDisallowedURL: "url not allowed by filter", ceUnknownScheme: "unknown scheme", ceNone: "connection successful", diff --git a/src/server/loader.nim b/src/server/loader.nim index ef32e455..93ecc1bb 100644 --- a/src/server/loader.nim +++ b/src/server/loader.nim @@ -780,9 +780,6 @@ proc parseCGIPath(ctx: LoaderContext; request: Request): CGIPath = proc loadCGI(ctx: LoaderContext; client: ClientData; handle: InputHandle; request: Request; prevURL: URL; config: LoaderClientConfig) = - if ctx.config.cgiDir.len == 0: - handle.sendResult(ceNoCGIDir) - return let cpath = ctx.parseCGIPath(request) if cpath.cmd == "" or cpath.basename in ["", ".", ".."] or cpath.basename[0] == '~': |