diff --git a/cmake/Targets.cmake b/cmake/Targets.cmake index 702ab7f..025ef7e 100644 --- a/cmake/Targets.cmake +++ b/cmake/Targets.cmake @@ -90,6 +90,7 @@ set(VOID_WINDOWS_MODULES Text Time Unicode + Update ) function(void_detect_target out_var) diff --git a/docs/targets.md b/docs/targets.md index 777e606..a73e97d 100644 --- a/docs/targets.md +++ b/docs/targets.md @@ -108,7 +108,7 @@ recognized and configured like Linux; musl-specific behaviour (subprocess | CMake / generator | CMake 4.5.0, Ninja 1.13.2 | | Language | C++26, reflection `yes` | | Runtime | Wine 11.0 (`wine64`), no native Windows runner available | -| Modules | `Algorithms Archive Async Binary Configuration ConfigurationAsync Containers Core Crypto CryptoAsync Data Discovery Fsm Functional FunctionalCoreFormatting IO IPC Log LogConfig LogState MCP Math Memory Messaging MessagingStorage Observability ObservabilityHooks Plugin Resilience ResilienceAsync Runtime Scheduler SchedulerStorage Script Service ServicePlugin ShortUrl Sqlite Storage System SystemAsync Testing TestingMock Text Time Unicode` | +| Modules | `Algorithms Archive Async Binary Configuration ConfigurationAsync Containers Core Crypto CryptoAsync Data Discovery Fsm Functional FunctionalCoreFormatting IO IPC Log LogConfig LogState MCP Math Memory Messaging MessagingStorage Observability ObservabilityHooks Plugin Resilience ResilienceAsync Runtime Scheduler SchedulerStorage Script Service ServicePlugin ShortUrl Sqlite Storage System SystemAsync Testing TestingMock Text Time Unicode Update` | | Observed | configure, compile, `cmake --install`, consume (`TargetProfile.exe` linked); each module's suite is verified under Wine before it is allowlisted. Full allowlisted set in one binary (Release) under Wine: **1851 tests, 1826 passed, 25 skipped, 0 failed** | Notes from the runtime run: @@ -135,8 +135,12 @@ Notes from the runtime run: user identity from the process token; the endpoint file is restricted to the current user. `adopt_pipe_pair` is not implemented on Windows yet, and the AF_UNIX/fork-based test and the session close-during-cancel test are skipped. +- `Update` uses the Windows CRT for the staging download file (binary mode, + `_commit` instead of `fsync`); its OpenSSL-signed feed fixtures are gated by + `// @requires-openssl`, and the compressed-package fixture skips when the + Archive backend has no LibArchive. - Still outside the Windows allowlist: - `Update` (POSIX file IO), `ShortUrlStorage` (needs `Security`), `Net`, + `ShortUrlStorage` (needs `Security`), `Net`, `RPC`, `DiscoveryRpc`, `MessagingRpc`, `Security`, `SecurityAsync`, `ShortUrlRemote`, `SqliteAsync`, `Stacktrace` (external dependencies not yet built for Windows in the qualification environment). diff --git a/src/Update/Install.cpp b/src/Update/Install.cpp index 098ddd2..fe5bec5 100644 --- a/src/Update/Install.cpp +++ b/src/Update/Install.cpp @@ -14,6 +14,9 @@ #include #include #include +#ifdef _WIN32 +#include +#endif namespace Void::Update { @@ -21,6 +24,32 @@ namespace Void::Update { std::atomic g_install_seq{0}; +#ifdef _WIN32 + // The staging file is created with O_EXCL, so a pre-existing entry + // (including a symlink) already fails the open; binary mode keeps the + // artifact bytes untouched. + constexpr int kStagingOpenFlags = + O_WRONLY | O_CREAT | O_EXCL | _O_NOINHERIT | _O_BINARY; + + [[nodiscard]] int sync_file(int fd) noexcept { return ::_commit(fd); } + + [[nodiscard]] int open_staging(const std::filesystem::path& path) noexcept + { + return ::_wopen(path.c_str(), kStagingOpenFlags, + _S_IREAD | _S_IWRITE); + } +#else + constexpr int kStagingOpenFlags = + O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC | O_NOFOLLOW; + + [[nodiscard]] int sync_file(int fd) noexcept { return ::fsync(fd); } + + [[nodiscard]] int open_staging(const std::filesystem::path& path) noexcept + { + return ::open(path.c_str(), kStagingOpenFlags, 0600); + } +#endif + [[nodiscard]] std::string sha256_hex(std::string_view data) { auto d = Crypto::sha256(data); @@ -825,9 +854,7 @@ namespace Void::Update return std::unexpected{std::move(hasher.error())}; } - int dl_fd = ::open(download_path.c_str(), - O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC | O_NOFOLLOW, - 0600); + int dl_fd = open_staging(download_path); if (dl_fd < 0) { remove_journal_best_effort(operation_journal_path()); return std::unexpected{make_update_error( @@ -891,7 +918,7 @@ namespace Void::Update return {}; }); - const bool sync_ok = (::fsync(dl_fd) == 0); + const bool sync_ok = (sync_file(dl_fd) == 0); (void)::close(dl_fd); if (!dl_res.has_value()) { remove_journal_best_effort(operation_journal_path()); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 64c351d..0ea8a1c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -37,6 +37,18 @@ function(_void_test_requires_satisfied src_file active_modules active_headers ou return() endif() endif() + # Whole-file OpenSSL gate: files that build signed fixtures with OpenSSL + # headers cannot be compiled where OpenSSL development files are absent + # (for example the Windows qualification environment). + if(NOT TARGET OpenSSL::Crypto) + string(FIND "${_src_content}" "// @requires-openssl" _needs_openssl) + if(NOT _needs_openssl EQUAL -1) + message(STATUS + "[VoidTests] Skipping ${src_file} (requires OpenSSL)") + set(${out_var} FALSE PARENT_SCOPE) + return() + endif() + endif() string(REGEX MATCHALL "#[ \t]*include[ \t]*[<\"](Void/[^/\">]+/[^>\"]+)[>\"]" _matches "${_src_content}") set(_ok TRUE) diff --git a/tests/standalone/Update/Update.cpp b/tests/standalone/Update/Update.cpp index f957d48..e3b07c1 100644 --- a/tests/standalone/Update/Update.cpp +++ b/tests/standalone/Update/Update.cpp @@ -1,3 +1,4 @@ +// @requires-openssl: signs feed fixtures with OpenSSL Ed25519. #include #include #include diff --git a/tests/standalone/Update/UpdateHardening.cpp b/tests/standalone/Update/UpdateHardening.cpp index 7e497c7..4964892 100644 --- a/tests/standalone/Update/UpdateHardening.cpp +++ b/tests/standalone/Update/UpdateHardening.cpp @@ -280,6 +280,13 @@ Void::Testing::Test update_replay_floor_and_trust_store_rotation_revocation() Void::Testing::Test update_coordinator_install_rollback_pins_cleanup_pending_and_reconcile() { +#ifndef VOID_ARCHIVE_HAS_LIBARCHIVE +#define VOID_ARCHIVE_HAS_LIBARCHIVE 0 +#endif +#if !VOID_ARCHIVE_HAS_LIBARCHIVE + Void::Testing::skip( + "needs the LibArchive backend to build a compressed .tar.zst fixture"); +#endif Void::FileSystem::TempDir tmp{"void_update_coord_"}; const auto pkg_dir = tmp / "packages"; const auto store_dir = tmp / "store";