diff options
author | bptato <nincsnevem662@gmail.com> | 2024-03-28 01:36:29 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-03-28 01:36:29 +0100 |
commit | b530ccc899a8cc8c63bad29abe1e479eb999b167 (patch) | |
tree | 07062947dfda3ac4356b0ce26de1cbe4e4c87ebd /src/local/client.nim | |
parent | 52c415762fda7b9369ed4cf88783a6639574e3ea (diff) | |
download | chawan-b530ccc899a8cc8c63bad29abe1e479eb999b167.tar.gz |
Add capsicum support
It's the sandboxing system of FreeBSD. Quite pleasant to work with. (Just trying to figure out the basics with this one before tackling the abomination that is seccomp.) Indeed, the only non-trivial part was getting newSelector to work with Capsicum. Long story short it doesn't, so we use an ugly pointer cast + assignment. But even that is stdlib's "fault", not Capsicum's. This also gets rid of that ugly SocketPath global.
Diffstat (limited to 'src/local/client.nim')
-rw-r--r-- | src/local/client.nim | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/local/client.nim b/src/local/client.nim index c63a18db..c4aad504 100644 --- a/src/local/client.nim +++ b/src/local/client.nim @@ -407,7 +407,8 @@ proc acceptBuffers(client: Client) = client.selector.registerHandle(fd, {Read, Write}, 0) for item in pager.procmap: let container = item.container - let stream = connectSocketStream(container.process) + let stream = connectSocketStream(client.config.external.tmpdir, + client.loader.sockDirFd, container.process) if stream == nil: pager.alert("Error: failed to set up buffer") continue @@ -812,12 +813,14 @@ proc newClient*(config: Config; forkserver: ForkServer; jsctx: JSContext; let jsrt = JS_GetRuntime(jsctx) JS_SetModuleLoaderFunc(jsrt, normalizeModuleName, clientLoadJSModule, nil) let pager = newPager(config, forkserver, jsctx, warnings) - let loader = forkserver.newFileLoader(LoaderConfig( + let loaderPid = forkserver.forkLoader(LoaderConfig( urimethodmap: config.external.urimethodmap, w3mCGICompat: config.external.w3m_cgi_compat, cgiDir: seq[string](config.external.cgi_dir), tmpdir: config.external.tmpdir )) + let loader = FileLoader(process: loaderPid, clientPid: getCurrentProcessId()) + loader.setSocketDir(config.external.tmpdir) pager.setLoader(loader) let client = Client(config: config, jsrt: jsrt, jsctx: jsctx, pager: pager) jsrt.setInterruptHandler(interruptHandler, cast[pointer](client)) |