diff --git a/README.md b/README.md index 9fe49c3..aeb0a38 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ An implementation of [openkal](https://github.com/mcpplibs/openkal) for Windows. ```toml [dependencies] -openkal = "0.26.0" +openkal = "0.26.1" [target.'cfg(windows)'.dependencies] -openkal-windows = "0.23.1" +openkal-windows = "0.23.2" ``` Its purpose is as much to test the specification as to be used. openkal was @@ -15,6 +15,30 @@ drawn against systems that share an ancestry; a third implementation on a system that shares none of it is what turns "this interface is not Unix's shape" from a claim into an observation. +## What 0.23.2 changes + +**A started program is named as its starter spelled its directories** (mcpp#1032). +A start named the image's directory and the working directory by the final paths +the system reports for their handles, which are physical: under a substituted +drive a program started through `kal_process_spawn` read its module's name and its +working directory physically, while the same program started directly read them +under the drive its starter used, and an environment that authorises by spelling +refused it. A directory is now named, in order, by the name it was preopened under; +within the working directory, by the working directory's name and the rest of the +path; and otherwise by the final path, as before. A name from the first two is used +only when it opens the same object (volume serial number and file index), so a +directory renamed since it was preopened is named by its final path. No name is +kept for a handle (clause 7.1). `tests/a_started_program_is_named_as_its_starter_spelled_it.cpp` +substitutes a drive and observes both directories. + +**A start that states no preference leaves the environment as it was given** +(openkal 0.26.1, clause 7.17). A start removed every `KAL_RESOURCES` variable the +caller gave and wrote this process's own preference where it was not balanced; the +variable is now written only for a start that states a preference. The low memory +priority a starter sets for economy follows the same preference: the one the given +environment carries, so a caller that composes an environment naming economy holds +a program that does not read the preference to it. + ## What 0.23.1 corrects A program for whose arguments and variables there is no memory, or whose command diff --git a/mcpp.toml b/mcpp.toml index 0707a2a..b5669ff 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -1,7 +1,7 @@ [package] namespace = "mcpplibs" name = "openkal-windows" -version = "0.23.1" +version = "0.23.2" description = "An implementation of openkal for Windows, written on the Win32 interfaces and the object manager beneath them, using no C runtime symbol." license = "Apache-2.0" diff --git a/src/fs.cpp b/src/fs.cpp index b22287d..34ba350 100644 --- a/src/fs.cpp +++ b/src/fs.cpp @@ -579,6 +579,20 @@ void listing_give(listing* s, bool ended) { } // namespace +namespace okw { +// The two words of a node's identity (the volume's serial number and the file's +// index on it), by the enquiry `fill' makes: what a start compares to know that +// a name it gives opens the directory a handle is (process.cpp, `given_name'). +bool node_identity(void* h, kal_u64 out[2]) { + kal_node_info info{}; + info.self_size = sizeof info; + if (fill(h, KAL_INFO_IDENTITY, &info) != kal_ok || !(info.present & KAL_INFO_IDENTITY)) return false; + out[0] = info.identity[0]; + out[1] = info.identity[1]; + return true; +} +} // namespace okw + extern "C" { kal_uintptr kal_fs_preopen_count(void) { kal_uintptr n = 0; table(&n); return n; } diff --git a/src/process.cpp b/src/process.cpp index d6708f0..c37f6b9 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -5,6 +5,9 @@ #include #include #include +#include + +namespace okw { bool node_identity(void* h, kal_u64 out[2]); } // fs.cpp // A program image that has been started. // @@ -55,6 +58,102 @@ okw_uptr plain_name(wchar_t* s, okw_uptr n) { return n - drop; } +// THE NAME A DIRECTORY IS GIVEN AT A START (0.23.2, mcpp#1032). +// +// The final path the system reports for a handle is the physical one. Under a +// substituted drive a started program read its own module path and its working +// directory physically, while the same program started directly read them as +// its starter spelled them, and an environment that authorises by spelling --- +// a sandbox that admits one drive letter --- refused the compiler a build tool +// started. A name kept for every handle is the resolver clause 7.1 excludes, so +// a directory is named from what this process was given, in three steps: +// +// 1. a preopen, by the name it was preopened under; +// 2. a directory within this process's working directory (whose final path +// begins the directory's at a separator), by the working directory's name +// and the rest of the final path --- the name a program here reaches it by +// from where it was started; +// 3. otherwise the final path, as before. +// +// A name from the first two is used only when it opens the same object (the +// volume's serial number and the file's index); a directory renamed or moved +// since it was preopened is named by step 3. +okw_uptr utf8_to_wide(const char* s, okw_uptr len, wchar_t* out, okw_uptr cap) { + if (len == 0) return 0; + const int produced = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s, static_cast(len), + out, static_cast(cap - 1)); + if (produced <= 0) return 0; + for (int i = 0; i < produced; ++i) if (out[i] == L'/') out[i] = L'\\'; + okw_uptr n = static_cast(produced); + // A volume's preopen is named `X:', which as a path is the drive's current + // directory; the volume itself is `X:\'. + if (n == 2 && out[1] == L':' && n + 1 < cap) out[n++] = L'\\'; + out[n] = 0; + return n; +} + +bool same_directory(HANDLE dir, const wchar_t* name) { + kal_u64 a[2], b[2]; + if (!okw::node_identity(dir, a)) return false; + HANDLE h = CreateFileW(name, FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); + if (h == INVALID_HANDLE_VALUE) return false; + const bool same = okw::node_identity(h, b) && a[0] == b[0] && a[1] == b[1]; + CloseHandle(h); + return same; +} + +wchar_t lower(wchar_t c) { return (c >= L'A' && c <= L'Z') ? static_cast(c + 32) : c; } + +// `out' holds kMaxName characters. Returns the length written, 0 on failure. +okw_uptr given_name(HANDLE dir, wchar_t* out) { + // Step 1: a preopen, by its own name. + for (kal_uintptr i = 0; i < kal_fs_preopen_count(); ++i) { + kal_dir d{}; char name[1024]; kal_uintptr len = 0; + if (kal_fs_preopen(i, &d, name, sizeof name, &len) != kal_ok || len == 0 || len >= sizeof name) continue; + if (okw::unpack(d.h) != dir) continue; + const okw_uptr n = utf8_to_wide(name, len, out, okw::kMaxName); + if (n && same_directory(dir, out)) return n; + break; + } + // Step 3's name, which step 2 also reads. + const DWORD n = GetFinalPathNameByHandleW(dir, out, okw::kMaxName - 1, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS); + if (n == 0 || n >= okw::kMaxName - 1) return 0; + out[n] = 0; + okw_uptr final_len = plain_name(out, n); + // Step 2: within the working directory, by its name and the rest. + kal_dir work{}; char wname[1024]; kal_uintptr wlen = 0; + if (kal_fs_preopen(0, &work, wname, sizeof wname, &wlen) == kal_ok && wlen > 0 && wlen < sizeof wname) { + HANDLE wh = okw::unpack(work.h); + // On the stack, as every name buffer of this implementation: a + // thread-local one is emulated TLS under mingw (__emutls_get_address), + // which the implementation must not reference. + wchar_t wfinal[okw::kMaxName]; + wchar_t candidate[okw::kMaxName]; + const DWORD wn = wh ? GetFinalPathNameByHandleW(wh, wfinal, okw::kMaxName - 1, + FILE_NAME_NORMALIZED | VOLUME_NAME_DOS) : 0; + if (wn != 0 && wn < okw::kMaxName - 1) { + wfinal[wn] = 0; + const okw_uptr wf = plain_name(wfinal, wn); + bool within = wf > 0 && wf < final_len && (out[wf] == L'\\' || wfinal[wf - 1] == L'\\'); + for (okw_uptr k = 0; within && k < wf; ++k) within = lower(out[k]) == lower(wfinal[k]); + const okw_uptr base = within ? utf8_to_wide(wname, wlen, candidate, okw::kMaxName) : 0; + okw_uptr at = base; + if (at && candidate[at - 1] != L'\\' && out[wf] != L'\\') candidate[at++] = L'\\'; + if (at && candidate[at - 1] == L'\\' && out[wf] == L'\\') --at; + for (okw_uptr k = wf; at && k < final_len && at + 1 < okw::kMaxName; ++k) candidate[at++] = out[k]; + if (at && at + 1 < okw::kMaxName) { + candidate[at] = 0; + if (same_directory(dir, candidate)) { + for (okw_uptr k = 0; k <= at; ++k) out[k] = candidate[k]; + return at; + } + } + } + } + return final_len; +} + // A SPAWN INHERITS ONLY THE HANDLES IT PLACED. Version 0.13. // // `CreateProcessW' with inheritance enabled gives the started program EVERY @@ -420,9 +519,36 @@ bool named(const wchar_t* s, okw_uptr n, const char* key) { } return k < n && s[k] == L'='; } +// The preference of a start that states none: the one the environment it is +// given carries (openkal 0.26.1, clause 7.17) --- the caller's own where the +// caller passes its environment on, else what the composed one names, the +// default where it names none. Read as env.cpp reads KAL_RESOURCES. +int carried_preference(const char** envp, const kal_uintptr* lens, kal_uintptr envc) { + if (envc == 0) return kal_env_resources(); + constexpr okw_uptr kName = sizeof "KAL_RESOURCES=" - 1; + auto is = [](const char* v, kal_uintptr n, const char* word) { + kal_uintptr k = 0; + for (; word[k]; ++k) if (k >= n || v[k] != word[k]) return false; + return k == n; + }; + for (kal_uintptr i = 0; i < envc; ++i) { + if (!named(envp[i], lens[i], "KAL_RESOURCES")) continue; + const char* v = envp[i] + kName; + const kal_uintptr n = lens[i] - kName; + return is(v, n, "performance") ? KAL_RESOURCES_PERFORMANCE + : is(v, n, "economy") ? KAL_RESOURCES_ECONOMY + : KAL_RESOURCES_BALANCED; + } + return KAL_RESOURCES_BALANCED; +} +// KAL_RESOURCES is this start's only where the start states a preference; one +// that states none leaves the caller's variable where it is, so the preference +// is inherited through the environment the caller gives (openkal 0.26.1, clause +// 7.17) and a program that is not an openkal program receives that environment. template -bool conveyed_here(const C* s, okw_uptr n) { - return named(s, n, "KAL_PREOPENS") || named(s, n, "KAL_GRANT_RIGHTS") || named(s, n, "KAL_RESOURCES"); +bool conveyed_here(const C* s, okw_uptr n, bool resources) { + return named(s, n, "KAL_PREOPENS") || named(s, n, "KAL_GRANT_RIGHTS") + || (resources && named(s, n, "KAL_RESOURCES")); } char* put_decimal(char* o, unsigned long long v) { @@ -549,12 +675,12 @@ struct environment { bool ok = true; if (envc > 0) { for (kal_uintptr i = 0; i < envc && ok; ++i) - if (!conveyed_here(envp[i], lens[i])) ok = put_utf8(envp[i], lens[i]); + if (!conveyed_here(envp[i], lens[i], resources != nullptr)) ok = put_utf8(envp[i], lens[i]); } else if (own) { for (const wchar_t* p = own; *p;) { okw_uptr n = 0; while (p[n]) ++n; - if (!conveyed_here(p, n)) { for (okw_uptr k = 0; k <= n; ++k) w[at++] = p[k]; } + if (!conveyed_here(p, n, resources != nullptr)) { for (okw_uptr k = 0; k <= n; ++k) w[at++] = p[k]; } p += n + 1; } FreeEnvironmentStringsW(own); @@ -701,11 +827,10 @@ int kal_process_spawn(const kal_spawn* how, ~releaser() { if (p) kal_free(p, sizeof(scratch), alignof(scratch)); } } guard{ work }; wchar_t* image = work->image; - const DWORD n = GetFinalPathNameByHandleW(dir, image, okw::kMaxName - 2, - FILE_NAME_NORMALIZED | VOLUME_NAME_DOS); - if (n == 0 || n >= okw::kMaxName - 2) return okw::translate_win32(GetLastError()); + const okw_uptr n = given_name(dir, image); + if (n == 0 || n >= okw::kMaxName - 2) return n == 0 ? okw::translate_win32(GetLastError()) : kal_err_invalid; okw_uptr at = n; - image[at++] = L'\\'; + if (image[at - 1] != L'\\') image[at++] = L'\\'; okw::wide_name relative(path, path_len); if (!relative.ok) return kal_err_invalid; for (okw_uptr i = 0; i < relative.string.length / 2u; ++i) { @@ -713,15 +838,10 @@ int kal_process_spawn(const kal_spawn* how, image[at++] = relative.buffer[i]; } image[at] = 0; - (void)plain_name(image, at); - // The same enquiry the image path comes from, upon the other directory. + // The same naming the image's directory has, upon the other directory. wchar_t* cwd = work->cwd; - const DWORD cn = GetFinalPathNameByHandleW(run, cwd, okw::kMaxName - 1, - FILE_NAME_NORMALIZED | VOLUME_NAME_DOS); - if (cn == 0 || cn >= okw::kMaxName - 1) return okw::translate_win32(GetLastError()); - cwd[cn] = 0; - (void)plain_name(cwd, cn); + if (given_name(run, cwd) == 0) return okw::translate_win32(GetLastError()); // The vector, unaltered, including its first element. wchar_t* line = work->line; @@ -754,14 +874,13 @@ int kal_process_spawn(const kal_spawn* how, // they carry, the preference), and then the block is the caller's, less // any value of those names, and this start's. Made inside the start's // window below, because the grants' handles are made there. - const int own_preference = kal_env_resources(); const int asked_preference = preference == KAL_SPAWN_RESOURCES_PERFORMANCE ? KAL_RESOURCES_PERFORMANCE : preference == KAL_SPAWN_RESOURCES_ECONOMY ? KAL_RESOURCES_ECONOMY : preference == KAL_SPAWN_RESOURCES_BALANCED ? KAL_RESOURCES_BALANCED - : own_preference; - const char* resources = asked_preference == KAL_RESOURCES_PERFORMANCE ? "performance" - : asked_preference == KAL_RESOURCES_ECONOMY ? "economy" - : preference != 0 ? "balanced" : nullptr; + : carried_preference(envp, envp_lens, envc); + const char* resources = preference == KAL_SPAWN_RESOURCES_PERFORMANCE ? "performance" + : preference == KAL_SPAWN_RESOURCES_ECONOMY ? "economy" + : preference == KAL_SPAWN_RESOURCES_BALANCED ? "balanced" : nullptr; // THE NULL DEVICE (openkal 0.22): this system's `NUL', opened for this // start and released after it; the started program holds its own handle. diff --git a/tests/a_started_program_is_named_as_its_starter_spelled_it.cpp b/tests/a_started_program_is_named_as_its_starter_spelled_it.cpp new file mode 100644 index 0000000..95cbd48 --- /dev/null +++ b/tests/a_started_program_is_named_as_its_starter_spelled_it.cpp @@ -0,0 +1,224 @@ +// A started program is named as its starter spelled its directories (0.23.2, +// mcpp#1032; openkal clause 7.1). +// +// Under a substituted drive (`subst Q: ', made here as subst makes it, with +// DefineDosDeviceW) a program started directly reads its module's name and its +// working directory under the alias. One started through kal_process_spawn read +// both physically, because the start named its directories by their final +// paths, and an environment that authorises by spelling refused it. A start now +// names a preopen by its own name, and a directory within the working directory +// by the working directory's name and the rest. +// +// This program starts a copy of itself (the relay) with CreateProcessW under the +// alias, so the relay's preopens are made from the alias. The relay starts a +// third copy (the reporter) through kal_process_spawn twice: from its working +// directory and running there, where the module's name and the working +// directory both begin with the alias; and from its working directory running in +// a volume it was given outside it, where the module's name begins with the +// alias and the working directory is that volume's own name. +#include +#include +#include +#include +#include +#include "../src/win32.h" +#include +#include +#include +#include +#include +import mcpplibs.mtest; + +using namespace mcpplibs::mtest; + +extern "C" OKW_IMPORT BOOL OKW_API DefineDosDeviceW(DWORD, LPCWSTR, LPCWSTR); + +namespace { + +constexpr DWORD kRemoveDefinition = 0x2; // DDD_REMOVE_DEFINITION +constexpr kal_u64 kBound = 20000ull * 1000ull * 1000ull; // twenty seconds + +std::string narrow(const wchar_t* w, DWORD n) { + std::string s; + for (DWORD i = 0; i < n; ++i) s.push_back(w[i] < 0x80 ? static_cast(w[i]) : '?'); + return s; +} + +std::string module_name() { + wchar_t w[1024]; + const DWORD n = GetModuleFileNameW(nullptr, w, 1024); + return n && n < 1024 ? narrow(w, n) : std::string{}; +} + +std::string current_directory() { + wchar_t w[1024]; + const DWORD n = GetCurrentDirectoryW(1024, w); + return n && n < 1024 ? narrow(w, n) : std::string{}; +} + +bool begins_with(const std::string& s, const std::string& prefix) { + if (s.size() < prefix.size()) return false; + for (std::size_t i = 0; i < prefix.size(); ++i) + if ((s[i] | 0x20) != (prefix[i] | 0x20)) return false; + return true; +} + +std::map lines_of(const std::string& text) { + std::map out; + std::size_t at = 0; + while (at < text.size()) { + std::size_t end = text.find('\n', at); + if (end == std::string::npos) end = text.size(); + std::string line = text.substr(at, end - at); + if (!line.empty() && line.back() == '\r') line.pop_back(); + const std::size_t eq = line.find('='); + if (eq != std::string::npos) out[line.substr(0, eq)] = line.substr(eq + 1); + at = end + 1; + } + return out; +} + +// What the reporter writes, started from `base`'s `self' and running in `work'. +std::string report(kal_dir base, const std::string& self, kal_dir work) { + const std::vector command = child_command("report"); + std::vector argv; + std::vector lens; + for (const auto& a : command) { argv.push_back(a.c_str()); lens.push_back(a.size()); } + kal_stream mine{}, theirs{}; + if (kal_process_channel(&mine, &theirs) != kal_ok) return {}; + const kal_spawn_streams streams{ kal_stream{0}, theirs, kal_stream{0} }; + const kal_spawn how{ base, work, nullptr, nullptr, 0, 0 }; + kal_process child{}; + const int spawned = kal_process_spawn(&how, self.data(), self.size(), argv.data(), lens.data(), argv.size(), + nullptr, nullptr, 0, &streams, &child); + kal_process_channel_close(theirs); + std::string out; + if (spawned == kal_ok) { + char buf[512]; + for (;;) { + const kal_intptr got = kal_timeout_read(mine, buf, sizeof buf, kBound); + if (got <= 0) break; + out.append(buf, static_cast(got)); + } + int status = -1, terminated = -1; + if (kal_timeout_wait_process(child, kBound, &status, &terminated) != kal_ok) kal_process_terminate(child); + kal_process_close(child); + } + kal_process_channel_close(mine); + return out; +} + +} // namespace + +child reporter{"report", [](std::vector) { + std::printf("module=%s\ncwd=%s\n", module_name().c_str(), current_directory().c_str()); + std::fflush(stdout); + return 0; +}}; + +// Started under the alias, in the directory its file is in: its working +// directory is its first preopen, named as the alias. args[0] is the alias's +// drive ("Q:"), args[1] the program's file name. +child relay{"relay", [](std::vector args) { + if (args.size() != 2 || args[0].size() != 2) return 2; + kal_dir work{}; + char wname[1024]; + kal_uintptr wlen = 0; + if (kal_fs_preopen(0, &work, wname, sizeof wname, &wlen) != kal_ok || wlen == 0 || wlen >= sizeof wname) return 3; + const std::string here(wname, wlen); + const std::string self = args[1]; + std::printf("work=%s\nrelay.module=%s\nrelay.cwd=%s\n", here.c_str(), module_name().c_str(), + current_directory().c_str()); + for (const auto& [k, v] : lines_of(report(work, self, work))) std::printf("inside.%s=%s\n", k.c_str(), v.c_str()); + for (kal_uintptr i = 1; i < kal_fs_preopen_count(); ++i) { + kal_dir d{}; + char name[16]; + kal_uintptr len = 0; + if (kal_fs_preopen(i, &d, name, sizeof name, &len) != kal_ok || len != 2 || name[1] != ':') continue; + if ((name[0] | 0x20) == (args[0][0] | 0x20)) continue; + std::printf("outside.volume=%c:\n", name[0]); + for (const auto& [k, v] : lines_of(report(work, self, d))) std::printf("outside.%s=%s\n", k.c_str(), v.c_str()); + break; + } + std::fflush(stdout); + return 0; +}}; + +UTest named_as_spelled{"a_started_program_is_named_as_its_starter_spelled_it", [] { + wchar_t module[1024]; + const DWORD n = GetModuleFileNameW(nullptr, module, 1024); + if (n == 0 || n >= 1024) skip("this program's own name could not be read"); + DWORD slash = n; + while (slash > 0 && module[slash - 1] != L'\\') --slash; + if (slash < 2) skip("this program's name has no directory"); + std::wstring directory(module, slash - 1), base(module + slash, n - slash); + + const DWORD drives = GetLogicalDrives(); + wchar_t letter = 0; + for (wchar_t c = L'Q'; c <= L'Y' && !letter; ++c) + if (!(drives & (1ul << (c - L'A')))) letter = c; + if (!letter) skip("no drive letter is free to substitute"); + const wchar_t drive[3] = { letter, L':', 0 }; + if (!DefineDosDeviceW(0, drive, directory.c_str())) skip("a drive letter could not be substituted"); + struct undo { + const wchar_t* drive; const wchar_t* target; + ~undo() { DefineDosDeviceW(kRemoveDefinition, drive, target); } + } guard{ drive, directory.c_str() }; + + const std::string alias{ static_cast(letter), ':' }; + std::string base_name; + for (wchar_t c : base) base_name.push_back(c < 0x80 ? static_cast(c) : '?'); + const std::vector command = child_command("relay", std::vector{ alias, base_name }); + std::wstring image = std::wstring(drive) + L"\\" + base; + std::wstring line = L"\"" + image + L"\""; + for (std::size_t i = 1; i < command.size(); ++i) { + line += L" \""; + for (char c : command[i]) line.push_back(static_cast(static_cast(c))); + line += L"\""; + } + const std::wstring cwd = std::wstring(drive) + L"\\"; + + SECURITY_ATTRIBUTES sa{ sizeof sa, nullptr, TRUE }; + HANDLE read_end = nullptr, write_end = nullptr; + if (!CreatePipe(&read_end, &write_end, &sa, 0)) skip("a pipe could not be made"); + SetHandleInformation(read_end, HANDLE_FLAG_INHERIT, 0); + STARTUPINFOW si{}; + si.cb = sizeof si; + si.dwFlags = STARTF_USESTDHANDLES; + si.hStdOutput = write_end; + si.hStdError = write_end; + PROCESS_INFORMATION pi{}; + std::vector mutable_line(line.begin(), line.end()); + mutable_line.push_back(0); + const BOOL started = CreateProcessW(image.c_str(), mutable_line.data(), nullptr, nullptr, TRUE, 0, nullptr, + cwd.c_str(), &si, &pi); + CloseHandle(write_end); + if (!started) { CloseHandle(read_end); skip("this program could not be started under the substituted drive"); } + std::string out; + char buf[512]; + DWORD got = 0; + while (ReadFile(read_end, buf, sizeof buf, &got, nullptr) && got > 0) out.append(buf, got); + WaitForSingleObject(pi.hProcess, 30000); + DWORD status = 1; + GetExitCodeProcess(pi.hProcess, &status); + CloseHandle(pi.hThread); + CloseHandle(pi.hProcess); + CloseHandle(read_end); + std::printf("%s", out.c_str()); + + const auto seen = lines_of(out); + expect(status == 0) << "the relay ran (status " << status << ")"; + const std::string prefix = alias + "\\"; + expect(begins_with(seen.count("work") ? seen.at("work") : "", alias)) + << "the relay's working directory is named as it was started in"; + expect(begins_with(seen.count("inside.module") ? seen.at("inside.module") : "", prefix)) + << "a program started from a preopen is named by the preopen's name"; + expect(begins_with(seen.count("inside.cwd") ? seen.at("inside.cwd") : "", prefix)) + << "a program running in the working directory runs in it as its starter named it"; + if (seen.count("outside.volume")) { + expect(begins_with(seen.count("outside.module") ? seen.at("outside.module") : "", prefix)) + << "a program running elsewhere is still named from its starter's preopen"; + expect(begins_with(seen.count("outside.cwd") ? seen.at("outside.cwd") : "", seen.at("outside.volume"))) + << "a directory outside the working directory is named by its own preopen's name"; + } +}};