Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Open each game's Windows profile to FTP with a capable kit

Leonardo Lobatoc43688cc106a
diff --git a/README.md b/README.md
index 3d4dfff..a4a2a98 100644
--- a/README.md
+++ b/README.md
@@ -169,6 +169,21 @@ The kit is built on a **Linux x86-64 machine or VM** from prospero-win, Wine, Me
see [Build the kit](CONTRIBUTING.md#build-the-kit). The scripts are a record of how we built it, not a turnkey build
yet, so most people should use the release download.
+### Saves and game configs over FTP
+
+Each game's Windows user folder holds its saves and most of its `.ini` configs:
+
+```text
+/data/playden/games/steam-<Steam app ID>/library/prefixes/game/drive_c/users/prospero/
+```
+
+For Half-Life 2 that is `steam-220`. Look in `AppData/Roaming`, `AppData/Local`, `Documents` and `Saved Games`.
+
+This needs the next runtime kit (it has the `bottle-profile-shared` capability); kit 0.10 keeps the whole folder
+private. With it, you can read and write everything in `prospero`. The folders above it can be entered but not
+listed, so type the full path in your FTP client instead of browsing to it. New saves a game writes are private
+at first. Playden opens them to FTP when it starts, when a game it started ends, and before it starts a game.
+
## Build from source
### What you need
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cpp
index c69f231..a55b632 100644
--- a/src/homebrew/runtime_host.cpp
+++ b/src/homebrew/runtime_host.cpp
@@ -63,6 +63,9 @@ constexpr std::int64_t kPreflightFreshMs = 5000;
constexpr char kActivityUnknown[] =
"The PS5 could not tell Playden whether the game is running. Restart the PS5, then try again.";
+// A moved game whose publication can't be redone: Recreate bottle (confirmed) prepares it again.
+constexpr char kRecreateHint[] = " Use Maintenance > Recreate bottle on the game page to prepare it again.";
+
std::string InstallId(std::uint32_t app_id) { return "steam-" + std::to_string(app_id); }
// Why the kit cannot run a recipe Playden ships (its requirements), for the player; empty when it
@@ -966,21 +969,39 @@ void RuntimeHost::OpenGameFolders(const Composition& c, const rt::RuntimeInstall
return;
const auto working = WorkingFolder(record.launch_working_directory, record.launch_path, record.launch_in_install_root);
auto folder = HostPath(record.install_path);
- const auto open_up = [this](const std::filesystem::path& path) {
+ // Each folder through its descriptor, never through a link (the walk stops at one).
+ const auto open_up = [this](int fd, const std::filesystem::path& path) {
struct stat info{};
- if (lstat(path.c_str(), &info) != 0 || !S_ISDIR(info.st_mode) || info.st_uid != geteuid() ||
- (info.st_mode & 07777) != 0755)
+ if (fstat(fd, &info) != 0 || !S_ISDIR(info.st_mode) || info.st_uid != geteuid() || (info.st_mode & 07777) != 0755)
return;
- const bool opened = chmod(path.c_str(), 0777) == 0;
+ const bool opened = fchmod(fd, 0777) == 0;
Log("game folder mode 0755 -> 0777 path=" + path.string() + (opened ? "" : " failed errno=" + std::to_string(errno)));
};
- open_up(folder);
- if (working.empty() || working == ".") return;
- for (const auto& part : std::filesystem::path(working)) {
- if (part.empty() || part == "." || part == ".." || part.is_absolute()) return;
- folder /= part;
- open_up(folder);
- }
+ const auto refused = [this](const std::filesystem::path& path) {
+ Log("game folder open stops path=" + path.string() + " errno=" + std::to_string(errno) +
+ (errno == ELOOP ? " (a link)" : ""));
+ };
+ int fd = rt::OpenFolderNoFollow(folder);
+ if (fd < 0) return refused(folder);
+ open_up(fd, folder);
+ if (!working.empty() && working != ".")
+ for (const auto& part : std::filesystem::path(working)) {
+ if (part.empty() || part == "." || part == ".." || part.is_absolute()) break;
+ const int child = rt::OpenChildFolderNoFollow(fd, folder, part.string());
+ close(fd);
+ fd = child;
+ folder /= part;
+ if (fd < 0) return refused(folder);
+ open_up(fd, folder);
+ }
+ close(fd);
+}
+
+void RuntimeHost::SettleBottle(Composition& c, const rt::RuntimeInstall& record, const char* when) {
+ const auto settled = c.installer->SettleBottleModes(record);
+ if (settled.state != rt::PackageActionState::kComplete)
+ Log(std::string("bottle modes ") + when + " install=" + record.install_id + " code=" + settled.code + " " +
+ settled.message);
}
std::string RuntimeHost::UnlinkDxvkConfig(const rt::RuntimeInstall& record) {
@@ -1042,9 +1063,37 @@ std::string RuntimeHost::UnlinkDxvkConfig(const rt::RuntimeInstall& record) {
}
std::string RuntimeHost::RepublishSettings(Composition& c, const rt::RuntimeInstall& record, bool* published,
- bool steam_account_known, bool* prepare_again) {
+ bool steam_account_known, bool* prepare_again,
+ std::string* upgrade_deferred) {
if (published) *published = false;
if (prepare_again) *prepare_again = false;
+ if (upgrade_deferred) upgrade_deferred->clear();
+ // A recipe this kit cannot run is refused before the game's files or bottle change.
+ if (c.kit)
+ for (const auto& candidate : c.recipes)
+ if (candidate.app_id == record.app_id && candidate.id == record.recipe_id)
+ if (const auto lacks = KitLacksForRecipe(candidate, c.kit->view); !lacks.empty()) return lacks;
+ // Only the unowned upgrade of a game that did not move, with no newer settings: the game
+ // played under its owned publication, which stays when the upgrade fails.
+ const auto saved_revision = config_.settings_record
+ ? config_.settings_record(record.app_id).value_or(rt::GameSettingsRecord{}).revision : 0;
+ const bool upgrade_only = record.moved_from.empty() && saved_revision <= record.settings_revision &&
+ NeedsUnownedPublication(c, record);
+ auto refused = PublishSavedSettings(c, record, published, steam_account_known, prepare_again);
+ if (refused.empty() || !upgrade_only) return refused;
+ Log("settings update app=" + std::to_string(record.app_id) + " unowned upgrade deferred, owned publication kept: " +
+ refused);
+ if (prepare_again) *prepare_again = false;
+ if (upgrade_deferred) *upgrade_deferred = refused;
+ // One that left a journal waits for recovery like any other update (Play refuses it).
+ const auto current = c.records.Find(record.install_id);
+ if (!current || current->journal) return refused;
+ // As before the upgrade existed: Play brings the Steam files in line; startup leaves them.
+ return steam_account_known ? ApplySteamworks(c, *current, true) : std::string{};
+}
+
+std::string RuntimeHost::PublishSavedSettings(Composition& c, const rt::RuntimeInstall& record, bool* published,
+ bool steam_account_known, bool* prepare_again) {
// Refusals only a new preparation gets past (the title's recipe or settings can't be published again).
const auto again = [prepare_again](std::string message) {
if (prepare_again) *prepare_again = true;
@@ -1052,11 +1101,6 @@ std::string RuntimeHost::RepublishSettings(Composition& c, const rt::RuntimeInst
};
const auto saved = config_.settings_record ? config_.settings_record(record.app_id).value_or(rt::GameSettingsRecord{})
: rt::GameSettingsRecord{};
- // A recipe this kit cannot run is refused before the game's files or bottle change.
- if (c.kit)
- for (const auto& candidate : c.recipes)
- if (candidate.app_id == record.app_id && candidate.id == record.recipe_id)
- if (const auto lacks = KitLacksForRecipe(candidate, c.kit->view); !lacks.empty()) return lacks;
// A game whose folder moved (RuntimeInstall::moved_from) is published again at its revision, so
// its descriptor, profile and dxvk.conf name the new folder.
const bool moved = !record.moved_from.empty();
@@ -1372,16 +1416,16 @@ void RuntimeHost::RunPlay(Composition& c, std::uint32_t app_id) {
settings = RepublishSettings(c, *record, nullptr, true, &again);
Publish([&](RuntimeSnapshot& s) { s.play_progress.erase(app_id); });
if (!settings.empty())
- settings = "This game could not be updated for Playden 0.5: " + settings +
- (again ? " Press Update on the game page to prepare it again." : "");
+ settings = "This game could not be updated for Playden 0.5: " + settings + (again ? kRecreateHint : "");
Log("play moved app=" + std::to_string(app_id) + " " + (settings.empty() ? "republished" : settings));
}
} else if (idle) {
- bool again = false;
- settings = RepublishSettings(c, *record, nullptr, true, &again);
- if (again && NeedsUnownedPublication(c, *record))
- settings += " Press Update on the game page to prepare it again.";
+ settings = RepublishSettings(c, *record);
}
+ // Saves the game wrote and FTP edits made since, once nothing of the bottle is held and
+ // only when Play goes ahead: a refused Play changes no modes.
+ if (idle && settings.empty())
+ if (const auto current = c.records.Find(record->install_id)) SettleBottle(c, *current, "play");
result = settings.empty() ? c.launch->Request(record->install_id)
: rt::LaunchResult::Failure(rt::LaunchError::kPreflight, settings);
}
@@ -1425,6 +1469,11 @@ bool RuntimeHost::PollLaunch(Composition& c) {
}
if (pending && (snapshot.state == rt::LaunchState::kExited || snapshot.state == rt::LaunchState::kFailed)) {
const auto finished = c.launch->Finish();
+ // The saves the game just wrote are Wine's (0600): opened to FTP again.
+ if (finished.accepted && c.kit && rt::KitCapabilitiesFromManifest(c.kit->capabilities, true).bottle_profile_shared)
+ if (const auto record = c.records.Find(snapshot.install_id);
+ record && c.coordinator->Activity(record->title_id) == rt::NativeActivity::kStopped)
+ SettleBottle(c, *record, "session");
Log("play finished install=" + snapshot.install_id + " session=" + snapshot.session_id + " state=" +
std::to_string(static_cast<int>(snapshot.state)) + " code=" + snapshot.code + " exit=" +
(snapshot.exit_code ? std::to_string(*snapshot.exit_code) : std::string("unknown")) +
@@ -1849,29 +1898,21 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&
changed = true;
}
// A game whose folder moved in 0.5 is published again for the new folder first, and an
- // owned publication again as unowned.
+ // owned publication again as unowned. A moved game whose publication can't be redone
+ // (settings older than its title, a recipe Playden no longer has) stays as it is: the way
+ // out is the player's confirmed choice.
if (!existing->moved_from.empty() || NeedsUnownedPublication(c, *existing)) {
bool again = false;
- if (const auto refused = RepublishSettings(c, *existing, nullptr, true, &again); !refused.empty()) {
- if (!again) return refused;
- // Its publication can't be redone (settings older than its title, a recipe Playden no
- // longer has): it is prepared again, as Recreate bottle does. The title goes, the bottle
- // is kept for its saves, and a new title is made from the game's folder.
- Log("prepare again app=" + std::to_string(request.app_id) + " because: " + refused);
- if (const auto removed = RunRemove(c, request.app_id, false); !removed.empty())
- return "The game could not be prepared again: " + removed;
- PublishKeptBottles(c);
- const auto left = c.repository.Snapshot();
- if (std::any_of(left.begin(), left.end(),
- [&](const rt::RuntimeInstall& record) { return record.app_id == request.app_id; }))
- return "The game's old PS5 title is still being removed. Press Update again.";
- return RunPrepare(c, request, awaiting);
- }
+ std::string deferred;
+ if (const auto refused = RepublishSettings(c, *existing, nullptr, true, &again, &deferred); !refused.empty())
+ return again ? refused + kRecreateHint : refused;
const auto install_id = existing->install_id;
existing = c.records.Find(install_id);
if (!existing) return "The game's install record is missing.";
- changed = true;
+ if (deferred.empty()) changed = true;
}
+ // A refreshed title may now admit the kit's modes for its bottle.
+ SettleBottle(c, *existing, "update");
if (const auto unlinked = UnlinkDxvkConfig(*existing); !unlinked.empty()) return unlinked;
auto admission = c.installer->AdmissionDiagnostic(*existing);
if (admission != "ok") {
@@ -2183,7 +2224,10 @@ std::optional<KeptBottleView> ReadKeptMarker(const std::filesystem::path& kept,
// Copies a saves tree into a private bottle: directories 0700, files keep their
// owner bits, links are skipped (Wine links point outside the bottle).
-bool CopySavesTree(const std::filesystem::path& from, const std::filesystem::path& to, std::string* error) {
+// Files with another link are skipped (logged): their content may be another file's (a private
+// one linked into the profile), which the copy would make the profile's own.
+bool CopySavesTree(const std::filesystem::path& from, const std::filesystem::path& to, std::string* error,
+ const std::function<void(const std::string&)>& log) {
struct stat info{};
if (lstat(to.c_str(), &info) != 0) {
if (mkdir(to.c_str(), 0700) != 0) { *error = "cannot create " + to.filename().string(); return false; }
@@ -2197,13 +2241,24 @@ bool CopySavesTree(const std::filesystem::path& from, const std::filesystem::pat
if (lstat(source.c_str(), &info) != 0) continue;
if (S_ISLNK(info.st_mode)) continue;
if (S_ISDIR(info.st_mode)) {
- if (!CopySavesTree(source, target, error)) return false;
+ if (!CopySavesTree(source, target, error, log)) return false;
continue;
}
if (!S_ISREG(info.st_mode)) continue;
+ if (info.st_nlink != 1) {
+ log("saves copy skips " + source.string() + ": it has " + std::to_string(info.st_nlink) + " links");
+ continue;
+ }
+ const int input = open(source.c_str(), O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
+ struct stat opened{};
+ if (input >= 0 && (fstat(input, &opened) != 0 || opened.st_ino != info.st_ino || opened.st_dev != info.st_dev ||
+ opened.st_nlink != 1)) {
+ close(input);
+ log("saves copy skips " + source.string() + ": it changed while being copied");
+ continue;
+ }
const auto temporary = target.parent_path() / ("." + target.filename().string() + ".restore");
unlink(temporary.c_str());
- const int input = open(source.c_str(), O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
const int output = open(temporary.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW | O_CLOEXEC,
(info.st_mode & 0700) | 0600);
bool ok = input >= 0 && output >= 0;
@@ -2296,13 +2351,17 @@ std::string RuntimeHost::RunMaintenance(Composition& c, std::uint32_t app, Runti
// A game whose folder moved fails the check until it is published again, just below.
if (admission != "ok" && record->moved_from.empty() && !unowned_upgrade)
return "The PS5 title still fails its start check: " + admission;
- if (auto refused = RepublishSettings(c, *record); !refused.empty()) return refused;
+ std::string deferred;
+ if (auto refused = RepublishSettings(c, *record, nullptr, true, nullptr, &deferred); !refused.empty())
+ return refused;
if (!record->moved_from.empty() || unowned_upgrade)
if (const auto current = c.records.Find(record->install_id))
if (const auto checked = c.installer->AdmissionDiagnostic(*current); checked != "ok")
- return "The PS5 title still fails its start check: " + checked;
+ return (deferred.empty() ? std::string() : "The game folder could not be published for mods: " + deferred + " ") +
+ "The PS5 title still fails its start check: " + checked;
*ok = true;
if (const auto current = c.records.Find(record->install_id)) OpenGameFolders(c, *current);
+ if (!deferred.empty()) return "Repaired, but the game folder could not be published for mods: " + deferred;
if (!c.installer->TitleCurrent(*record) || !c.installer->TitleMetadataCurrent(*record))
return "Repaired. The PS5 title also has an update: press Update on the game page.";
return "Repaired. The game's start files and settings are in place.";
@@ -2320,7 +2379,8 @@ std::string RuntimeHost::RunMaintenance(Composition& c, std::uint32_t app, Runti
RemoveTreeNoFollow(staging, error);
if (mkdir(staging.c_str(), 0700) != 0) return "The backup folder could not be made.";
std::string reason;
- if (!CopySavesTree(users, staging / "users", &reason) || rename(staging.c_str(), target.c_str()) != 0) {
+ if (!CopySavesTree(users, staging / "users", &reason, [this](const std::string& line) { Log(line); }) ||
+ rename(staging.c_str(), target.c_str()) != 0) {
RemoveTreeNoFollow(staging, error);
Log("maintenance backup failed app=" + std::to_string(app) + " " + reason);
return "The saves could not be backed up" + (reason.empty() ? std::string(".") : ": " + reason + ".");
@@ -2627,10 +2687,13 @@ std::string RuntimeHost::RestoreKeptSaves(Composition& c, std::uint32_t app) {
if (lstat(from.c_str(), &info) == 0 && S_ISDIR(info.st_mode)) {
if (lstat(to.parent_path().c_str(), &info) != 0 || !S_ISDIR(info.st_mode))
return "The game's new bottle has no drive C for its kept saves.";
- if (!CopySavesTree(from, to, &reason)) {
+ if (!CopySavesTree(from, to, &reason, [this](const std::string& line) { Log(line); })) {
Log("restore kept saves failed app=" + std::to_string(app) + " " + reason);
return "The saves kept from the previous install could not be brought back: " + reason;
}
+ // The restored profile is opened to FTP like the rest (bottle-profile-shared); the copy is private.
+ if (c.kit && rt::KitCapabilitiesFromManifest(c.kit->capabilities, true).bottle_profile_shared)
+ SettleBottle(c, *record, "restore");
}
{
const int fd = open((bottle / kRestoredMarker).c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW | O_CLOEXEC, 0600);
@@ -2697,6 +2760,7 @@ void RuntimeHost::Run() {
else Log("recipe " + recipe.id + " refused kit=" + c.kit->view.kit_id + " " + lacks);
}
installer->AcceptShippedRecipes(std::move(shipped));
+ installer->ShareBottleProfiles(rt::KitCapabilitiesFromManifest(c.kit->capabilities, true).bottle_profile_shared);
c.installer = std::move(installer);
} else {
if (kit_reason.empty()) kit_reason = "No verified compatibility kit is installed.";
@@ -2708,7 +2772,8 @@ void RuntimeHost::Run() {
c.records, *c.installer, c.registry, config_.homebrew_root, std::move(native));
c.owner = std::make_unique<rt::SettingsPublicationOwner>(
c.records, *c.installer, *c.coordinator,
- c.kit && rt::KitCapabilitiesFromManifest(c.kit->capabilities, true).game_root_unowned);
+ c.kit && rt::KitCapabilitiesFromManifest(c.kit->capabilities, true).game_root_unowned,
+ config_.host_namespace_prefix);
c.service = std::make_unique<rt::RuntimeInstallService>(
c.records, *c.installer, *c.coordinator,
[&c](const rt::RuntimeInstall& record) {
@@ -2801,6 +2866,16 @@ void RuntimeHost::Run() {
std::lock_guard<std::mutex> lock(mutex_);
launch_poll_ = true;
}
+ // Games started from Home (and Playden's, which close Playden) left Wine's 0600 saves: with
+ // bottle-profile-shared they are opened to FTP again once their title is stopped.
+ if (c.kit && rt::KitCapabilitiesFromManifest(c.kit->capabilities, true).bottle_profile_shared) {
+ const auto began = std::chrono::steady_clock::now();
+ std::size_t settled = 0;
+ for (const auto& record : c.repository.Snapshot())
+ if (MaintenanceRefusal(c, record).empty()) { SettleBottle(c, record, "startup"); ++settled; }
+ Log("startup bottle profiles settled=" + std::to_string(settled) + " ms=" +
+ std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - began).count()));
+ }
// Games whose folder moved with the games root (0.5) start from Home only once their
// publication names the new folder: republished now, busy titles wait for Play.
// So are games published owned while the kit admits unowned folders (folders opened for
@@ -2811,9 +2886,12 @@ void RuntimeHost::Run() {
if (!moved && !NeedsUnownedPublication(c, record)) continue;
const auto busy = c.kit ? MaintenanceRefusal(c, record) : std::string("no verified kit");
bool published = false;
- const auto refused = busy.empty() ? RepublishSettings(c, record, &published, false) : busy;
+ std::string deferred;
+ const auto refused = busy.empty() ? RepublishSettings(c, record, &published, false, nullptr, &deferred) : busy;
Log(std::string(moved ? "startup moved app=" : "startup unowned app=") + std::to_string(record.app_id) + " " +
- (published ? std::string("republished") : (busy.empty() ? "failed: " : "waits: ") + refused));
+ (published ? std::string("republished")
+ : !deferred.empty() ? "deferred: " + deferred
+ : (busy.empty() ? "failed: " : "waits: ") + refused));
}
FinishGamesMove(c);
// Settings saved while Playden was closed, or before a title was stopped, are published
diff --git a/src/homebrew/runtime_host.hpp b/src/homebrew/runtime_host.hpp
index cbb59ff..e3bc643 100644
--- a/src/homebrew/runtime_host.hpp
+++ b/src/homebrew/runtime_host.hpp
@@ -355,9 +355,14 @@ class RuntimeHost {
// (NeedsUnownedPublication), is published again at its revision.
// steam_account_known false (at startup): the Steam emulator's files wait for Play.
// *prepare_again: refused for a reason only a new preparation gets past (recipe or settings).
+ // The unowned upgrade alone (not moved, no newer settings) never refuses: its failure is in
+ // *upgrade_deferred and the owned publication stays, as it played before.
std::string RepublishSettings(Composition& composition, const runtime::RuntimeInstall& record,
bool* published = nullptr, bool steam_account_known = true,
- bool* prepare_again = nullptr);
+ bool* prepare_again = nullptr, std::string* upgrade_deferred = nullptr);
+ // RepublishSettings without the upgrade's fallback.
+ std::string PublishSavedSettings(Composition& composition, const runtime::RuntimeInstall& record,
+ bool* published, bool steam_account_known, bool* prepare_again);
// A Ready game published owned (schema 2, before 0.5 or by a kit before 0.10) while the kit
// admits unowned game folders: published again as unowned, so folders the player opened pass.
bool NeedsUnownedPublication(const Composition& composition, const runtime::RuntimeInstall& record);
@@ -390,6 +395,10 @@ class RuntimeHost {
void OpenGameFolders(const Composition& composition, const runtime::RuntimeInstall& record);
// A dxvk.conf with more than one link fails the title's start check; it becomes a copy of its own.
std::string UnlinkDxvkConfig(const runtime::RuntimeInstall& record);
+ // The bottle's way to its user profile takes the kit's mode, and with bottle-profile-shared its
+ // profile is opened to FTP again (files Wine made since are 0600). Only for a stopped title,
+ // while no ManagedDirectory of the bottle is open. Failures are logged; the start check decides.
+ void SettleBottle(Composition& composition, const runtime::RuntimeInstall& record, const char* when);
runtime::LaunchPreflight Preflight(Composition& composition, const runtime::RuntimeInstall& record);
runtime::LaunchEvidence Evidence(Composition& composition, const runtime::RuntimeInstall& record,
const std::string& session_id);
diff --git a/src/platform/durable_storage.cpp b/src/platform/durable_storage.cpp
index 57a4758..de513d8 100644
--- a/src/platform/durable_storage.cpp
+++ b/src/platform/durable_storage.cpp
@@ -13,8 +13,9 @@ using platform::DirectoryPolicy;
using platform::ManagedDirectory;
std::optional<ManagedDirectory> Parent(const std::string& root,
- const std::string& relative_path) {
- auto directory = ManagedDirectory::Open(root, DirectoryPolicy::kPrivate);
+ const std::string& relative_path, bool traversable_root) {
+ auto directory = ManagedDirectory::Open(
+ root, traversable_root ? DirectoryPolicy::kPrivateTraversable : DirectoryPolicy::kPrivate);
if (!directory) return std::nullopt;
for (const auto& part : std::filesystem::path(relative_path).parent_path()) {
auto child = directory->OpenChild(part.string(), DirectoryPolicy::kPrivate);
@@ -34,7 +35,7 @@ Result<Bytes> Storage::ReadDurable(const std::string& relative_path,
if (!resolved.ok()) return Result<Bytes>::Failure(resolved.error(), resolved.message());
if (!max_bytes || max_bytes > 32 * 1024 * 1024)
return Result<Bytes>::Failure(StorageError::kReadFailed, "Invalid bounded journal read.");
- auto parent = Parent(root_, relative_path);
+ auto parent = Parent(root_, relative_path, traversable_root_);
if (!parent) return Result<Bytes>::Failure(StorageError::kOpenFailed, "Private journal directory is unavailable.");
const auto name = std::filesystem::path(relative_path).filename().string();
const int fd = parent->OpenRegularFile(name, true);
@@ -85,7 +86,7 @@ Result<void> Storage::WriteDurableImpl(const std::string& relative_path,
bool replace_existing) const {
const auto resolved = Resolve(relative_path);
if (!resolved.ok()) return Failure(resolved.error(), "Invalid journal path.");
- auto parent = Parent(root_, relative_path);
+ auto parent = Parent(root_, relative_path, traversable_root_);
if (!parent) return Failure(StorageError::kOpenFailed, "Private journal directory is unavailable.");
const auto name = std::filesystem::path(relative_path).filename().string();
if (!replace_existing) {
@@ -126,7 +127,7 @@ Result<void> Storage::WriteDurableImpl(const std::string& relative_path,
Result<void> Storage::RemoveDurable(const std::string& relative_path) const {
const auto resolved = Resolve(relative_path);
if (!resolved.ok()) return Failure(resolved.error(), "Invalid journal removal path.");
- auto parent = Parent(root_, relative_path);
+ auto parent = Parent(root_, relative_path, traversable_root_);
if (!parent) return Failure(StorageError::kOpenFailed, "Private journal directory is unavailable.");
const auto name = std::filesystem::path(relative_path).filename().string();
struct stat existing{};
diff --git a/src/platform/managed_directory.cpp b/src/platform/managed_directory.cpp
index abab784..6ca6976 100644
--- a/src/platform/managed_directory.cpp
+++ b/src/platform/managed_directory.cpp
@@ -26,9 +26,15 @@ bool SameIdentity(const struct stat& a, const struct stat& b) {
(a.st_mode & (S_IFMT | 07777)) == (b.st_mode & (S_IFMT | 07777));
}
-bool Private(const struct stat& info, uid_t uid) {
+bool PrivateFamily(DirectoryPolicy policy) {
+ return policy == DirectoryPolicy::kPrivate || policy == DirectoryPolicy::kPrivateTraversable;
+}
+
+// kPrivateTraversable also admits 0711: others may enter, but not list or write.
+bool Private(const struct stat& info, uid_t uid, DirectoryPolicy policy = DirectoryPolicy::kPrivate) {
+ const auto mode = info.st_mode & 07777;
return S_ISDIR(info.st_mode) && info.st_uid == uid &&
- (info.st_mode & 07777) == 0700;
+ (mode == 0700 || (policy == DirectoryPolicy::kPrivateTraversable && mode == 0711));
}
bool Ordinary(const struct stat& info) {
@@ -117,14 +123,14 @@ std::optional<ManagedDirectory> ManagedDirectory::Open(
#endif
next = ::open(absolute.c_str(), kDirectoryFlags);
if (next < 0) return false;
- const bool is_private = policy == DirectoryPolicy::kPrivate && absolute == path;
+ const auto check = PrivateFamily(policy) && absolute == path ? policy : DirectoryPolicy::kApprovedTree;
bool valid = ::fstat(next, &after) == 0;
if (valid && !SameIdentity(before, after)) valid = Refuse(ESTALE);
- if (valid && is_private && !Private(after, result.uid_)) valid = Refuse(EACCES);
+ if (valid && PrivateFamily(check) && !Private(after, result.uid_, check)) valid = Refuse(EACCES);
if (!valid) { ClosePreservingError(next); return false; }
ClosePreservingError(result.fd_);
result.fd_ = next;
- result.observations_.push_back({absolute, after, is_private});
+ result.observations_.push_back({absolute, after, check});
return true;
};
if (!observe(current, current)) return std::nullopt;
@@ -147,7 +153,7 @@ bool ManagedDirectory::Validate() const {
if (::lstat(observation.path.c_str(), &current) != 0) return false;
if (!SameIdentity(observation.identity, current)) return Refuse(ESTALE);
if (!S_ISDIR(current.st_mode)) return Refuse(ENOTDIR);
- if (observation.private_directory && !Private(current, uid_)) return Refuse(EACCES);
+ if (PrivateFamily(observation.check) && !Private(current, uid_, observation.check)) return Refuse(EACCES);
}
return true;
}
@@ -187,7 +193,9 @@ std::optional<ManagedDirectory> ManagedDirectory::OpenChild(
const std::string& name, DirectoryPolicy policy, bool create, mode_t created_mode) const {
if (!ValidName(name) || !Validate()) return std::nullopt;
if ((created_mode & ~0777) != 0 || (policy == DirectoryPolicy::kPrivate && created_mode != 0700) ||
- (policy_ == DirectoryPolicy::kPrivate && policy != DirectoryPolicy::kPrivate)) {
+ (policy == DirectoryPolicy::kPrivateTraversable && created_mode != 0700 && created_mode != 0711) ||
+ (policy_ == DirectoryPolicy::kPrivate && policy != DirectoryPolicy::kPrivate) ||
+ (policy_ == DirectoryPolicy::kPrivateTraversable && !PrivateFamily(policy))) {
errno = EINVAL;
return std::nullopt;
}
@@ -228,7 +236,7 @@ std::optional<ManagedDirectory> ManagedDirectory::OpenChild(
errno = S_ISLNK(before.st_mode) ? ELOOP : ENOTDIR;
return std::nullopt;
}
- if (policy == DirectoryPolicy::kPrivate && !Private(before, uid_)) {
+ if (PrivateFamily(policy) && !Private(before, uid_, policy)) {
errno = EACCES;
return std::nullopt;
}
@@ -237,12 +245,12 @@ std::optional<ManagedDirectory> ManagedDirectory::OpenChild(
if (child.fd_ < 0 || ::fstat(child.fd_, &after) != 0) return std::nullopt;
if (!SameIdentity(before, after)) { errno = ESTALE; return std::nullopt; }
child.path_ = path_ / name;
- child.root_ = policy == DirectoryPolicy::kPrivate && policy_ != policy ? child.path_ : root_;
+ child.root_ = PrivateFamily(policy) && !PrivateFamily(policy_) ? child.path_ : root_;
child.policy_ = policy;
child.backend_ = backend_;
child.uid_ = uid_;
child.observations_ = observations_;
- child.observations_.push_back({child.path_, after, policy == DirectoryPolicy::kPrivate});
+ child.observations_.push_back({child.path_, after, PrivateFamily(policy) ? policy : DirectoryPolicy::kApprovedTree});
if (!child.Validate()) return std::nullopt;
return child;
}
@@ -292,7 +300,7 @@ bool ManagedDirectory::RenameChild(const std::string& from,
destination.policy_ == DirectoryPolicy::kUnownedTree;
if (!InspectChild(from, &source)) return false;
if (!unowned && source.st_uid != uid_) return Refuse(EACCES);
- if (S_ISDIR(source.st_mode) && destination.policy_ == DirectoryPolicy::kPrivate && !Private(source, uid_))
+ if (S_ISDIR(source.st_mode) && PrivateFamily(destination.policy_) && !Private(source, uid_, destination.policy_))
return Refuse(EACCES);
if (destination.InspectChild(to, &target)) {
if (!replace_existing || S_ISDIR(target.st_mode)) return Refuse(EEXIST);
diff --git a/src/platform/managed_directory.h b/src/platform/managed_directory.h
index 153ac4e..1ed927a 100644
--- a/src/platform/managed_directory.h
+++ b/src/platform/managed_directory.h
@@ -9,7 +9,7 @@
namespace playden::platform {
enum class DirectoryBackend { kDescriptorRelative, kAbsolutePath };
-enum class DirectoryPolicy { kApprovedTree, kPrivate, kUnownedTree };
+enum class DirectoryPolicy { kApprovedTree, kPrivate, kPrivateTraversable, kUnownedTree };
// Operations assume a stable managed namespace and coordinated writers. The
// absolute-path backend checks components and observed identities, but is NOT a
@@ -18,7 +18,11 @@ enum class DirectoryPolicy { kApprovedTree, kPrivate, kUnownedTree };
// that context without reconciling its identity. No process CWD is changed.
//
// kPrivate requires current-EUID ownership and mode 0700 from the selected root
-// downward; ancestors above that root may be public. kApprovedTree accepts
+// downward; ancestors above that root may be public. kPrivateTraversable is
+// kPrivate that also admits 0711 (others may pass through, never list), for the
+// bottle's way to its user profile. A kPrivate folder only opens kPrivate
+// children; a kPrivateTraversable one opens kPrivate or kPrivateTraversable
+// children; neither opens other policies. kApprovedTree accepts
// existing directory ownership/modes, then refuses identity/owner/mode drift.
// kUnownedTree is kApprovedTree for a filesystem that records no owner or
// permissions (exFAT: every entry shows the mount owner and 0777): file
@@ -47,7 +51,8 @@ class ManagedDirectory {
ManagedDirectory& operator=(const ManagedDirectory&) = delete;
// A folder it creates gets created_mode exactly (umask ignored); an existing
- // folder is never chmodded. kPrivate children are always created 0700.
+ // folder is never chmodded. kPrivate children are always created 0700,
+ // kPrivateTraversable ones 0700 or 0711.
std::optional<ManagedDirectory> OpenChild(const std::string& name,
DirectoryPolicy policy,
bool create = false,
@@ -85,7 +90,7 @@ class ManagedDirectory {
struct Observation {
std::filesystem::path path;
struct stat identity;
- bool private_directory = false;
+ DirectoryPolicy check = DirectoryPolicy::kApprovedTree; // kPrivate*: mode rechecked
};
ManagedDirectory() = default;
bool ValidName(const std::string& name) const;
diff --git a/src/platform/storage.h b/src/platform/storage.h
index 42be3ce..2b034fe 100644
--- a/src/platform/storage.h
+++ b/src/platform/storage.h
@@ -123,6 +123,10 @@ class Storage {
// Missing files are already removed and therefore succeed.
Result<void> Remove(const std::string& relative_path) const;
+ // Journal operations also admit a 0711 root (others may pass through, never
+ // list): a bottle whose way to its user profile is open. Parents stay 0700.
+ Storage& AllowTraversableRoot() { traversable_root_ = true; return *this; }
+
private:
Result<std::string> Resolve(const std::string& relative_path) const;
Result<void> WriteAtomicImpl(const std::string& relative_path,
@@ -132,6 +136,7 @@ class Storage {
const Bytes& bytes, bool replace_existing) const;
std::string root_;
+ bool traversable_root_ = false;
};
} // namespace playden
diff --git a/src/runtime/game_settings.cpp b/src/runtime/game_settings.cpp
index 729a203..3d02ada 100644
--- a/src/runtime/game_settings.cpp
+++ b/src/runtime/game_settings.cpp
@@ -2296,7 +2296,8 @@ static bool ApplyRegistryFileValues(const std::vector<RegistryValue>& values, co
return false;
};
if (values.empty()) return true;
- auto directory = ManagedDirectory::Open(prefix_dir, DirectoryPolicy::kPrivate);
+ // The bottle may be 0711 (bottle-profile-shared).
+ auto directory = ManagedDirectory::Open(prefix_dir, DirectoryPolicy::kPrivateTraversable);
if (!directory) return fail("cannot read the bottle's " + hive);
std::string original;
constexpr std::size_t kMaxRegistryBytes = 32u * 1024u * 1024u;
@@ -2516,7 +2517,7 @@ Ue3EulaResult AcceptUe3Eula(const std::string& game_root, const std::vector<std:
{"Software\\Wow6432Node\\" + key, "EULAAccepted", "dword:00000001"}};
std::string before, reason;
{
- auto directory = ManagedDirectory::Open(prefix_dir, DirectoryPolicy::kPrivate);
+ auto directory = ManagedDirectory::Open(prefix_dir, DirectoryPolicy::kPrivateTraversable);
if (directory) ReadRegularAt(*directory, "system.reg", 32u * 1024u * 1024u, &before, nullptr, true);
}
auto intended = before;
@@ -2554,6 +2555,7 @@ KitCapabilities KitCapabilitiesFromManifest(const std::vector<std::string>& capa
kit.shared_sections = has(kKitSharedSections);
kit.title_any_id = has(kKitTitleAnyId);
kit.game_root_unowned = has(kKitGameRootUnowned);
+ kit.bottle_profile_shared = has(kKitBottleProfileShared);
kit.opengl_zink = has(kKitOpenGLZink);
kit.wine_mono = has(kKitWineMono);
kit.vkd3d_proton = has(kKitVkd3dProton);
diff --git a/src/runtime/game_settings.h b/src/runtime/game_settings.h
index b6ff344..a647a0e 100644
--- a/src/runtime/game_settings.h
+++ b/src/runtime/game_settings.h
@@ -42,6 +42,7 @@ struct KitCapabilities {
bool shared_sections = false; // Wine maps unaligned shared PE sections as private copies (patch 0602)
bool title_any_id = false; // one title shell for every game; no fixed set of titles
bool game_root_unowned = false; // games start from drives that record no file owners (exFAT)
+ bool bottle_profile_shared = false; // the bottle's 4 folders to its user profile may be 0711
bool opengl_zink = false; // OpenGL games draw through Mesa's Zink, not the PS5 OpenGL SDK
bool wine_mono = false; // .NET programs start on the kit's Wine Mono
bool vkd3d_proton = false; // the kit's runtime carries vkd3d-proton's Direct3D 12 DLLs
@@ -410,6 +411,9 @@ inline constexpr const char* kKitTitleAnyId = "title-any-id";
// Runtime ability: launch admission accepts a game folder on a drive that records no file
// owners or permissions, such as an exFAT USB disk (publication metadata schema 3).
inline constexpr const char* kKitGameRootUnowned = "game-root-unowned";
+// Runtime ability: launch admission accepts 0711 as well as 0700 for the bottle's way to its user
+// profile (games/<id>, library, library/prefixes, library/prefixes/game), so FTP can reach the saves.
+inline constexpr const char* kKitBottleProfileShared = "bottle-profile-shared";
// Runtime ability: OpenGL games draw through Mesa's WGL/Zink on Vulkan (prospero-win upstream #463-#465)
// instead of the PS5 OpenGL SDK, which had the 120 Hz output and the OpenGL worker thread.
inline constexpr const char* kKitOpenGLZink = "opengl-zink";
diff --git a/src/runtime/install_service.h b/src/runtime/install_service.h
index 30ac10f..9ed8ea7 100644
--- a/src/runtime/install_service.h
+++ b/src/runtime/install_service.h
@@ -83,6 +83,13 @@ public:
virtual PackageActionResult RepairBottle(const RuntimeInstall &) {
return {PackageActionState::kFailed, "repair-unsupported", "this package layer cannot repair bottles"};
}
+ // Sets the bottle's way to its user profile (data root, library, library/prefixes, the bottle,
+ // drive_c, drive_c/users) to the kit's mode: 0711 when the kit has bottle-profile-shared, which
+ // then also opens the profile (drive_c/users/prospero) to FTP, else 0700. The title must be
+ // stopped, and no directory of the bottle held open across it (a mode change reads as ESTALE).
+ virtual PackageActionResult SettleBottleModes(const RuntimeInstall &) {
+ return {PackageActionState::kComplete, {}, {}};
+ }
// Whether a staged title was made from the admitted kit (cheap marker check).
virtual bool TitleCurrent(const RuntimeInstall &) { return true; }
virtual PackageActionResult WriteTitleMetadata(const RuntimeInstall &, const std::string &,
diff --git a/src/runtime/kit_trust.cpp b/src/runtime/kit_trust.cpp
index 24b5781..e8fdb29 100644
--- a/src/runtime/kit_trust.cpp
+++ b/src/runtime/kit_trust.cpp
@@ -11,7 +11,7 @@ KitAdmissionConfig DevelopmentKitAdmission() {
config.expected_manifest_sha256 = kExpectedKitManifestSha256;
// The publication guard capability stays unused until native qualification.
config.known_capabilities = {"dxvk", "offline_bottle", "per_game_title", "wow64_i386", kKitSharedSections,
- kKitTitleAnyId, kKitGameRootUnowned, kKitOpenGLZink,
+ kKitTitleAnyId, kKitGameRootUnowned, kKitBottleProfileShared, kKitOpenGLZink,
kKitAudioVolume, kKitDxvkConfig, kKitDxvkPresent, kKitInputTuning,
kKitInputWheel, kKitEnvironment, kKitWineMono, kKitVkd3dProton};
std::sort(config.known_capabilities.begin(), config.known_capabilities.end());
diff --git a/src/runtime/package_installer.cpp b/src/runtime/package_installer.cpp
index 1408633..b0b11d7 100644
--- a/src/runtime/package_installer.cpp
+++ b/src/runtime/package_installer.cpp
@@ -687,7 +687,8 @@ PackageActionResult FilesystemPackageInstaller::WriteTitleMetadata(const Runtime
return Failed("title-metadata", "the title parameters do not name this title");
const auto root = TitleMetadataPath(record, {});
std::string detail;
- if (!EnsurePrivateDirectories(paths_.host_data_root, paths->game, root / "sce_sys", &detail))
+ if (!EnsurePrivateDirectories(paths_.host_data_root, paths->game, root / "sce_sys", &detail,
+ BottleTraversal(*paths, ProfileShared(record, *paths))))
return Failed("private-directory", detail);
// Each file is written beside its final name, synced, then moved over it.
const auto replace = [&](const fs::path& path, const std::string& bytes) {
@@ -785,9 +786,18 @@ bool FilesystemPackageInstaller::TitleFilesMatch(
return true;
}
+bool FilesystemPackageInstaller::ProfileShared(const RuntimeInstall& record, const ResolvedPaths& paths) const {
+ // A title keeps the shell it was made with after a kit swap; an older shell admits only 0700.
+ return profile_shared_ && MarkerEquals(paths.title / kTitleOwner, OwnerMarker(record, kit_, "title"));
+}
+
+PrivateTraversal FilesystemPackageInstaller::BottleTraversal(const ResolvedPaths& paths, bool shared) const {
+ return {{paths.game, paths.library, paths.library / "prefixes", paths.bottle}, static_cast<mode_t>(shared ? 0711 : 0700)};
+}
+
bool FilesystemPackageInstaller::BottleOwned(
const RuntimeInstall& record, const ResolvedPaths& paths) const {
- return IsPrivateDirectoryTree(paths.game, paths.bottle) &&
+ return IsPrivateDirectoryTree(paths.game, paths.bottle, BottleTraversal(paths)) &&
MarkerIdentifies(paths.bottle / kTemplateOwner, record, "template") &&
operations_.validate_bottle(paths.bottle);
}
@@ -861,7 +871,7 @@ std::string FilesystemPackageInstaller::QuickAdmission(const RuntimeInstall& rec
PackageActionResult FilesystemPackageInstaller::RepairBottle(const RuntimeInstall& record) {
const auto paths = Resolve(record);
if (!paths) return Failed("kit-invalid", "record or verified kit view is invalid");
- if (!IsPrivateDirectoryTree(paths->game, paths->bottle))
+ if (!IsPrivateDirectoryTree(paths->game, paths->bottle, BottleTraversal(*paths)))
return Failed("repair-ownership", "the bottle is not this install's private directory");
// Wine saves registry hives with the process umask; earlier per-game titles
// ran with umask 0 and left them 0666. Only app-owned regular files change.
@@ -875,6 +885,34 @@ PackageActionResult FilesystemPackageInstaller::RepairBottle(const RuntimeInstal
if (mode != 0600 && (::chmod(path.c_str(), 0600) != 0 || !SyncPath(path, false)))
return Failed("repair-mode", std::string(name) + " permissions could not be restored");
}
+ return SettleBottleModes(record);
+}
+
+PackageActionResult FilesystemPackageInstaller::SettleBottleModes(const RuntimeInstall& record) {
+ const auto paths = Resolve(record);
+ if (!paths) return Failed("kit-invalid", "record or verified kit view is invalid");
+ const bool shared = ProfileShared(record, *paths);
+ const auto traversal = BottleTraversal(*paths, shared);
+ if (!IsPrivateDirectoryTree(paths->game, paths->bottle, traversal))
+ return Failed("repair-ownership", "the bottle is not this install's private directory");
+ // A kit without bottle-profile-shared admits only 0700 there (after a kit downgrade too), and
+ // so does a title made by an older kit until Update refreshes it. The profile itself is left
+ // as it is: no kit checks below the bottle.
+ auto folders = traversal.folders;
+ folders.push_back(paths->bottle / "drive_c");
+ folders.push_back(paths->bottle / "drive_c/users");
+ for (const auto& folder : folders)
+ if (!SetTraversableMode(folder, traversal.created_mode))
+ return Failed("repair-mode", "the permissions of " + folder.string() + " could not be set: " + strerror(errno));
+ // The profile only matters to FTP: what can't be opened is logged, never a failure of the game.
+ SharedTreeResult opened;
+ if (shared) opened = OpenTreeToEveryone(paths->bottle / "drive_c/users/prospero");
+ if (operations_.log)
+ operations_.log("bottle modes install=" + record.install_id + " way=" + (shared ? "0711" : "0700") +
+ (shared ? " profile_opened=" + std::to_string(opened.changed) + " skipped=" +
+ std::to_string(opened.skipped) + " linked=" + std::to_string(opened.linked) +
+ " walked=" + std::to_string(opened.ok) + " truncated=" + std::to_string(opened.truncated)
+ : std::string(profile_shared_ ? " title-not-current" : "") + " profile=unchanged"));
return Complete();
}
@@ -1136,7 +1174,7 @@ PackageActionResult FilesystemPackageInstaller::CopyMappings(
return CopyMappings(record, mappings, staging, final, stage_kind, final_marker);
}
if (staging_exists) {
- if (stage_kind == "template" && !IsPrivateDirectory(staging))
+ if (stage_kind == "template" && !IsPrivateDirectory(staging, true))
return Failed("staging-collision", "existing bottle staging has wrong owner or permissions");
// An earlier install of this game (another kit, title or recipe) can leave its
// incomplete staging behind; it is ours and holds nothing published.
@@ -1152,10 +1190,18 @@ PackageActionResult FilesystemPackageInstaller::CopyMappings(
}
// Staging trees are private to the app user. A published title's directories
// become 0755 afterwards so ShadowMount can read them; title files keep their
- // kit modes.
+ // kit modes. A bottle's way to its user profile is 0711 with bottle-profile-shared.
+ const bool template_stage = stage_kind == "template";
+ const auto resolved = template_stage ? Resolve(record) : std::nullopt;
+ const bool shared_profile = resolved && ProfileShared(record, *resolved);
+ PrivateTraversal staging_traversal;
+ if (template_stage)
+ staging_traversal = {{staging, staging / "drive_c", staging / "drive_c/users"},
+ static_cast<mode_t>(shared_profile ? 0711 : 0700)};
+ const fs::path profile_relative = "drive_c/users/prospero";
{
std::string detail;
- if (!EnsurePrivateDirectories(paths_.host_data_root, staging, staging, &detail))
+ if (!EnsurePrivateDirectories(paths_.host_data_root, staging, staging, &detail, staging_traversal))
return Failed("private-directory", detail);
}
struct stat created_stage{};
@@ -1182,7 +1228,8 @@ PackageActionResult FilesystemPackageInstaller::CopyMappings(
if (!PathComponentsHaveNoSymlink(staging, mapping.destination_relative, false))
return Failed("destination-invalid", "staging destination contains a symbolic link");
std::string detail;
- if (!EnsurePrivateDirectories(paths_.host_data_root, staging, destination.parent_path(), &detail))
+ if (!EnsurePrivateDirectories(paths_.host_data_root, staging, destination.parent_path(), &detail,
+ staging_traversal))
return Failed("private-directory", detail);
checked_directories.insert(destination.parent_path());
}
@@ -1190,7 +1237,13 @@ PackageActionResult FilesystemPackageInstaller::CopyMappings(
times.Add("dirs", since);
since = PartTimes::Clock::now();
const int input = ::open(source.c_str(), O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
- const unsigned mode = stage_kind == "template" ? (0600 | (mapping.file->mode & 0100)) : mapping.file->mode;
+ // The user profile is open to FTP with bottle-profile-shared (the walk below opens its folders).
+ const fs::path relative(mapping.destination_relative);
+ const bool profile_file = shared_profile &&
+ std::mismatch(profile_relative.begin(), profile_relative.end(), relative.begin(), relative.end()).first ==
+ profile_relative.end();
+ const unsigned mode = profile_file ? (0666 | (mapping.file->mode & 0111))
+ : template_stage ? (0600 | (mapping.file->mode & 0100)) : mapping.file->mode;
const int output = ::open(destination.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW, mode);
if (input < 0 || output < 0) {
if (input >= 0) ::close(input);
@@ -1248,13 +1301,39 @@ PackageActionResult FilesystemPackageInstaller::CopyMappings(
// console. Without AppData/LocalLow, SHGetKnownFolderPath fails and Unity has no persistent
// data path: Caves of Qud stops at startup and other Unity games save beside their program,
// where Cloud saves cannot see them.
- if (stage_kind == "template") {
- const fs::path user = staging / "drive_c/users/prospero";
- for (const char* folder : {"AppData/LocalLow", "AppData/Local", "AppData/Roaming", "Documents", "Saved Games",
- "Desktop", "Downloads", "Music", "Pictures", "Videos"}) {
+ // With bottle-profile-shared the profile's folders are 0777 (FTP runs as root, which has no
+ // permission bypass) and anything the kit put there is opened up too.
+ static constexpr const char* kProfileFolders[] = {"AppData/LocalLow", "AppData/Local", "AppData/Roaming",
+ "Documents", "Saved Games", "Desktop", "Downloads",
+ "Music", "Pictures", "Videos"};
+ if (template_stage) {
+ const fs::path user = staging / profile_relative;
+ if (shared_profile) {
std::string detail;
- if (!EnsurePrivateDirectories(paths_.host_data_root, staging, user / folder, &detail))
+ if (!EnsurePrivateDirectories(paths_.host_data_root, staging, user.parent_path(), &detail, staging_traversal))
return Failed("private-directory", detail);
+ CreateDirectoriesWithMode(user, 0777, error);
+ if (error) return Failed("private-directory", "cannot create the bottle's user profile: " + user.string());
+ for (const char* folder : kProfileFolders) {
+ auto current = platform::ManagedDirectory::Open(user, platform::DirectoryPolicy::kApprovedTree);
+ for (const auto& part : fs::path(folder)) {
+ auto next = current ? current->OpenChild(part.string(), platform::DirectoryPolicy::kApprovedTree, true, 0777)
+ : std::nullopt;
+ if (!next || !next->Sync() || !current->Sync())
+ return Failed("private-directory", "cannot create profile folder " + (user / folder).string() + ": " +
+ strerror(errno));
+ current = std::move(next);
+ }
+ }
+ if (!OpenTreeToEveryone(user).ok)
+ return Failed("private-directory", "cannot open the bottle's user profile: " + user.string());
+ }
+ for (const char* folder : kProfileFolders) {
+ if (!shared_profile) {
+ std::string detail;
+ if (!EnsurePrivateDirectories(paths_.host_data_root, staging, user / folder, &detail))
+ return Failed("private-directory", detail);
+ }
for (auto directory = user / folder; directory != staging; directory = directory.parent_path())
copied_directories.insert(directory);
}
@@ -1283,7 +1362,9 @@ PackageActionResult FilesystemPackageInstaller::CopyMappings(
if (stage_kind == "template") {
std::string detail;
const auto game = paths_.host_data_root / "playden/games" / record.install_id;
- if (!EnsurePrivateDirectories(paths_.host_data_root, game, final.parent_path(), &detail))
+ const PrivateTraversal parents{{game, game / "library", game / "library/prefixes"},
+ static_cast<mode_t>(shared_profile ? 0711 : 0700)};
+ if (!EnsurePrivateDirectories(paths_.host_data_root, game, final.parent_path(), &detail, parents))
return Failed("private-directory", detail);
} else {
CreateDirectoriesWithMode(final.parent_path(), 0755, error);
@@ -1480,7 +1561,7 @@ PackageActionResult FilesystemPackageInstaller::RefreshTitle(const RuntimeInstal
return marker->substr(start, marker->find('\n', start) - start);
};
const auto title_digest = old_digest(title_marker);
- if (!IsDirectoryNoSymlink(paths->title) || !IsPrivateDirectoryTree(paths->game, paths->bottle) ||
+ if (!IsDirectoryNoSymlink(paths->title) || !IsPrivateDirectoryTree(paths->game, paths->bottle, BottleTraversal(*paths)) ||
!title_marker || !bottle_marker || !IsHexDigest(title_digest) || old_digest(bottle_marker) != title_digest ||
!WithFilesDigest(new_title, title_digest) || !WithFilesDigest(new_bottle, title_digest) ||
RespinIdentity(new_title) != RespinIdentity(*title_marker) ||
@@ -1573,13 +1654,12 @@ PackageActionResult FilesystemPackageInstaller::CopyTemplate(
bool bottle_known = false;
const bool bottle_exists = ExistsNoThrow(paths->bottle, &bottle_known);
if (!bottle_known) return Failed("bottle-unavailable", "mutable bottle state is unavailable");
- if (bottle_exists)
- return !BottleOwned(record, *paths)
- ? Failed("bottle-collision", "mutable bottle exists without matching ownership")
- : (SyncTree(paths->bottle) && SyncAncestors(paths->bottle.parent_path())
- ? Complete()
- : Failed("sync-failed",
- "owned mutable bottle durability could not be established"));
+ if (bottle_exists) {
+ if (!BottleOwned(record, *paths)) return Failed("bottle-collision", "mutable bottle exists without matching ownership");
+ if (!SyncTree(paths->bottle) || !SyncAncestors(paths->bottle.parent_path()))
+ return Failed("sync-failed", "owned mutable bottle durability could not be established");
+ return profile_shared_ ? SettleBottleModes(record) : Complete();
+ }
auto result = CopyMappings(record, TemplateMappings(), paths->bottle_staging,
paths->bottle, "template", kTemplateOwner);
if (result.state != PackageActionState::kComplete) return result;
@@ -1587,7 +1667,8 @@ PackageActionResult FilesystemPackageInstaller::CopyTemplate(
const bool owned = BottleOwned(record, *paths);
if (operations_.log) operations_.log("template check " + PartTimes{}.Summary(started));
if (!owned) return Failed("template-validation", "published bottle failed semantic validation");
- return result;
+ // Folders made before this bottle (its data root for the title metadata) get the kit's mode too.
+ return profile_shared_ ? SettleBottleModes(record) : result;
}
PackageActionResult FilesystemPackageInstaller::ValidateArtifacts(
diff --git a/src/runtime/package_installer.h b/src/runtime/package_installer.h
index 10c31ff..569f7d4 100644
--- a/src/runtime/package_installer.h
+++ b/src/runtime/package_installer.h
@@ -1,6 +1,7 @@
#pragma once
#include "runtime/install_service.h"
+#include "runtime/private_directories.h"
#include <cstdint>
#include <filesystem>
@@ -164,6 +165,10 @@ class FilesystemPackageInstaller final : public PackageInstaller {
// The recipes Playden ships (runtime/recipes) besides the kit's own. A record
// prepared with one of them resolves whatever recipe the kit carries.
void AcceptShippedRecipes(std::vector<std::string> recipe_ids);
+ // The kit has bottle-profile-shared: bottles of titles made from it are made and repaired with
+ // their way to the user profile 0711 and the profile open to FTP (0777/0666); titles of older
+ // kits keep 0700 until Update. Reads always admit 0711.
+ void ShareBottleProfiles(bool shared) { profile_shared_ = shared; }
PackageStatus Inspect(const RuntimeInstall& record) override;
// The title's owner marker instead of its files and folder modes; the bottle,
@@ -183,7 +188,9 @@ class FilesystemPackageInstaller final : public PackageInstaller {
bool TitleCurrent(const RuntimeInstall& record) override;
std::string AdmissionDiagnostic(const RuntimeInstall& record) override;
std::string QuickAdmission(const RuntimeInstall& record) override;
+ // Also settles the bottle's modes (SettleBottleModes).
PackageActionResult RepairBottle(const RuntimeInstall& record) override;
+ PackageActionResult SettleBottleModes(const RuntimeInstall& record) override;
// Replaces changed title files (temp, fsync, rename) and rewrites the title
// and bottle owner markers. Refuses unless each existing marker equals the
// new one except for the kit's files_sha256, and the record's artifacts are
@@ -207,6 +214,12 @@ class FilesystemPackageInstaller final : public PackageInstaller {
// Exact file contents and modes only, whatever the marker and folder modes say.
bool TitleFilesMatch(const RuntimeInstall& record, const ResolvedPaths& paths) const;
bool BottleOwned(const RuntimeInstall& record, const ResolvedPaths& paths) const;
+ // The bottle chain's traversal folders (data root, library, library/prefixes, the bottle), with
+ // the mode new ones get (0711 when shared). Checks admit 0700 and 0711 either way.
+ PrivateTraversal BottleTraversal(const ResolvedPaths& paths, bool shared = false) const;
+ // The bottle's way to its profile is 0711 and the profile open: the kit has
+ // bottle-profile-shared and the record's title was made from it (an older shell demands 0700).
+ bool ProfileShared(const RuntimeInstall& record, const ResolvedPaths& paths) const;
bool ArtifactsMatch(const RuntimeInstall& record, const ResolvedPaths& paths) const;
bool PublicationMatches(const RuntimeInstall& record, const ResolvedPaths& paths,
std::uint64_t* revision) const;
@@ -230,6 +243,7 @@ class FilesystemPackageInstaller final : public PackageInstaller {
PackageInstallPaths paths_;
PackageInstallerOperations operations_;
std::vector<std::string> shipped_recipe_ids_;
+ bool profile_shared_ = false;
};
} // namespace playden::runtime
diff --git a/src/runtime/private_directories.cpp b/src/runtime/private_directories.cpp
index 5381bf6..b67b1e5 100644
--- a/src/runtime/private_directories.cpp
+++ b/src/runtime/private_directories.cpp
@@ -2,6 +2,10 @@
#include "platform/managed_directory.h"
#include <cerrno>
#include <cstring>
+#include <dirent.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <unistd.h>
namespace playden::runtime {
namespace fs = std::filesystem;
namespace {
@@ -13,18 +17,30 @@ bool SafeRelative(const fs::path& path) {
if (part.empty() || part == "." || part == "..") return false;
return true;
}
+bool Traversable(const PrivateTraversal& traversal, const fs::path& path) {
+ for (const auto& folder : traversal.folders)
+ if (folder == path) return true;
+ return false;
}
-bool IsPrivateDirectory(const fs::path& directory) {
- return ManagedDirectory::Open(directory, DirectoryPolicy::kPrivate).has_value();
+DirectoryPolicy PolicyFor(const PrivateTraversal& traversal, const fs::path& path) {
+ return Traversable(traversal, path) ? DirectoryPolicy::kPrivateTraversable : DirectoryPolicy::kPrivate;
}
-bool IsPrivateDirectoryTree(const fs::path& private_root, const fs::path& directory) {
+}
+bool IsPrivateDirectory(const fs::path& directory, bool traversable) {
+ return ManagedDirectory::Open(directory, traversable ? DirectoryPolicy::kPrivateTraversable
+ : DirectoryPolicy::kPrivate).has_value();
+}
+bool IsPrivateDirectoryTree(const fs::path& private_root, const fs::path& directory,
+ const PrivateTraversal& traversal) {
const auto relative = directory.lexically_relative(private_root);
if (directory != private_root && !SafeRelative(relative)) return false;
- auto current = ManagedDirectory::Open(private_root, DirectoryPolicy::kPrivate);
+ auto current = ManagedDirectory::Open(private_root, PolicyFor(traversal, private_root));
if (!current) return false;
if (directory != private_root) {
+ fs::path path = private_root;
for (const auto& part : relative) {
- auto next = current->OpenChild(part.string(), DirectoryPolicy::kPrivate);
+ path /= part;
+ auto next = current->OpenChild(part.string(), PolicyFor(traversal, path));
if (!next) return false;
current = std::move(next);
}
@@ -32,7 +48,8 @@ bool IsPrivateDirectoryTree(const fs::path& private_root, const fs::path& direct
return current->Validate();
}
bool EnsurePrivateDirectories(const fs::path& boundary, const fs::path& private_root,
- const fs::path& directory, std::string* error) {
+ const fs::path& directory, std::string* error,
+ const PrivateTraversal& traversal) {
if (error) error->clear();
const auto fail = [&](const std::string& message) {
if (error) *error = message;
@@ -41,6 +58,8 @@ bool EnsurePrivateDirectories(const fs::path& boundary, const fs::path& private_
const auto relative = directory.lexically_relative(boundary);
const auto private_relative = private_root.lexically_relative(boundary);
const auto within = directory.lexically_relative(private_root);
+ if (traversal.created_mode != 0700 && traversal.created_mode != 0711)
+ return fail("traversal folders must be created 0700 or 0711");
if (!SafeRelative(relative) || !SafeRelative(private_relative) ||
(directory != private_root && !SafeRelative(within)))
return fail("private directory is outside its trusted boundary");
@@ -53,8 +72,11 @@ bool EnsurePrivateDirectories(const fs::path& boundary, const fs::path& private_
if (path == private_root) in_private = true;
// Shared parents it creates above the private root are 0777, so FTP and other
// apps can write beside them; existing ones keep their mode.
- auto next = in_private ? current->OpenChild(part.string(), DirectoryPolicy::kPrivate, true)
- : current->OpenChild(part.string(), DirectoryPolicy::kApprovedTree, true, 0777);
+ const auto policy = PolicyFor(traversal, path);
+ auto next = !in_private ? current->OpenChild(part.string(), DirectoryPolicy::kApprovedTree, true, 0777)
+ : policy == DirectoryPolicy::kPrivateTraversable
+ ? current->OpenChild(part.string(), policy, true, traversal.created_mode)
+ : current->OpenChild(part.string(), policy, true);
if (!next)
return fail("cannot open/create private directory (wrong owner or permissions): " + path.string() + ": " + strerror(errno));
// Flush the directory and its parent entry before journaled preparation.
@@ -65,4 +87,173 @@ bool EnsurePrivateDirectories(const fs::path& boundary, const fs::path& private_
}
return current->Validate();
}
+namespace {
+#if defined(__PROSPERO__) || (defined(PLAYDEN_PLATFORM_PS5) && PLAYDEN_PLATFORM_PS5)
+constexpr bool kDescriptorRelative = false; // as ManagedDirectory: no *at calls on the console
+#else
+constexpr bool kDescriptorRelative = true;
+#endif
+bool SameEntry(const struct stat& a, const struct stat& b) {
+ return a.st_dev == b.st_dev && a.st_ino == b.st_ino && (a.st_mode & S_IFMT) == (b.st_mode & S_IFMT);
+}
+// A child opened without following a link: relative to its folder where *at calls exist, else
+// by path, checked to be the entry lstat saw, in a folder its path still names. -1 with
+// *stop: the folder's path names another folder now, so nothing more is opened through it.
+int OpenEntry(int folder, const struct stat& folder_info, const fs::path& folder_path, const char* name, bool by_path,
+ int extra_flags, bool* stop) {
+ const int flags = O_RDONLY | O_NOFOLLOW | O_NONBLOCK | O_CLOEXEC | extra_flags;
+ *stop = false;
+ if (!by_path) return ::openat(folder, name, flags);
+ struct stat parent{}, before{}, opened{};
+ if (::lstat(folder_path.c_str(), &parent) != 0 || !SameEntry(parent, folder_info)) {
+ *stop = true;
+ errno = ESTALE;
+ return -1;
+ }
+ const auto path = folder_path / name;
+ if (::lstat(path.c_str(), &before) != 0) return -1;
+ if (S_ISLNK(before.st_mode)) { errno = ELOOP; return -1; }
+ const int fd = ::open(path.c_str(), flags);
+ if (fd >= 0 && (::fstat(fd, &opened) != 0 || !SameEntry(opened, before))) {
+ ::close(fd);
+ errno = ESTALE;
+ return -1;
+ }
+ return fd;
+}
+constexpr int kSharedTreeDepth = 64;
+constexpr std::size_t kSharedTreeEntries = 200000;
+struct Walk {
+ bool by_path;
+ const SharedTreeOptions& options;
+ std::size_t entries = 0;
+ SharedTreeResult* result;
+};
+// Takes fd. Folders of other owners are not entered. False: a folder could not be listed, or
+// the walk found a folder's path changed under it.
+bool ShareFolder(int fd, const fs::path& path, int depth, Walk& walk) {
+ auto* result = walk.result;
+ struct stat info{};
+ if (::fstat(fd, &info) != 0 || !S_ISDIR(info.st_mode)) { ::close(fd); return false; }
+ if (info.st_uid != ::geteuid()) { ::close(fd); ++result->skipped; return true; }
+ if ((info.st_mode & 07777) != 0777) {
+ if (::fchmod(fd, 0777) != 0) { ::close(fd); ++result->skipped; return true; }
+ ++result->changed;
+ }
+ const int listing_fd = ::dup(fd);
+ DIR* listing = listing_fd >= 0 ? ::fdopendir(listing_fd) : nullptr;
+ if (!listing) {
+ if (listing_fd >= 0) ::close(listing_fd);
+ ::close(fd);
+ return false;
+ }
+ bool ok = true;
+ for (;;) {
+ errno = 0;
+ const auto* entry = ::readdir(listing);
+ if (!entry) { ok = errno == 0; break; }
+ const std::string name = entry->d_name;
+ if (name == "." || name == "..") continue;
+ if (++walk.entries > kSharedTreeEntries) { result->truncated = true; break; }
+ if (entry->d_type == DT_LNK) continue;
+ if (walk.options.before_open) walk.options.before_open(path / name);
+ // O_NOFOLLOW: a link swapped in is refused, never followed.
+ bool stop = false;
+ const int child = OpenEntry(fd, info, path, name.c_str(), walk.by_path, 0, &stop);
+ if (stop) { result->changed_under = true; ok = false; break; }
+ if (child < 0) {
+ if (errno != ELOOP && errno != EMLINK) ++result->skipped;
+ continue;
+ }
+ struct stat opened{};
+ if (::fstat(child, &opened) != 0) { ::close(child); ++result->skipped; continue; }
+ if (S_ISDIR(opened.st_mode)) {
+ if (depth + 1 > kSharedTreeDepth) { ::close(child); result->truncated = true; break; }
+ if (!ShareFolder(child, path / name, depth + 1, walk)) { ok = false; break; }
+ if (result->truncated) break;
+ continue;
+ }
+ // A file with another link is someone else's too (a private file linked in): left alone.
+ if (S_ISREG(opened.st_mode) && opened.st_nlink != 1) {
+ ++result->linked;
+ } else if (S_ISREG(opened.st_mode) && opened.st_uid == ::geteuid()) {
+ const mode_t wanted = 0666 | (opened.st_mode & 0111);
+ if ((opened.st_mode & 07777) != wanted) {
+ if (::fchmod(child, wanted) == 0) ++result->changed;
+ else ++result->skipped;
+ }
+ }
+ ::close(child);
+ }
+ ::closedir(listing);
+ ::close(fd);
+ return ok;
+}
+} // namespace
+bool DescriptorRelativeOpens() { return kDescriptorRelative; }
+int OpenFolderNoFollow(const fs::path& path) {
+ struct stat before{}, opened{};
+ if (::lstat(path.c_str(), &before) != 0) return -1;
+ if (S_ISLNK(before.st_mode)) { errno = ELOOP; return -1; }
+ if (!S_ISDIR(before.st_mode)) { errno = ENOTDIR; return -1; }
+ const int fd = ::open(path.c_str(), O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
+ if (fd >= 0 && (::fstat(fd, &opened) != 0 || !SameEntry(opened, before))) {
+ ::close(fd);
+ errno = ESTALE;
+ return -1;
+ }
+ return fd;
+}
+int OpenChildFolderNoFollow(int parent_fd, const fs::path& parent_path, const std::string& name, bool by_path) {
+ struct stat parent{};
+ if (name.empty() || name == "." || name == ".." || name.find('/') != std::string::npos) { errno = EINVAL; return -1; }
+ if (::fstat(parent_fd, &parent) != 0) return -1;
+ bool stop = false;
+ const int fd = OpenEntry(parent_fd, parent, parent_path, name.c_str(), by_path, O_DIRECTORY, &stop);
+ struct stat opened{};
+ // O_DIRECTORY|O_NOFOLLOW on a link may say ENOTDIR (macOS): it is still a link.
+ if (fd < 0 && errno == ENOTDIR && !by_path && ::fstatat(parent_fd, name.c_str(), &opened, AT_SYMLINK_NOFOLLOW) == 0 &&
+ S_ISLNK(opened.st_mode))
+ errno = ELOOP;
+ if (fd >= 0 && (::fstat(fd, &opened) != 0 || !S_ISDIR(opened.st_mode))) {
+ ::close(fd);
+ errno = ENOTDIR;
+ return -1;
+ }
+ return fd;
+}
+bool SetTraversableMode(const fs::path& folder, mode_t mode) {
+ if (mode != 0700 && mode != 0711) { errno = EINVAL; return false; }
+ struct stat before{};
+ if (::lstat(folder.c_str(), &before) != 0) return errno == ENOENT;
+ const auto current = before.st_mode & 07777;
+ if (!S_ISDIR(before.st_mode) || before.st_uid != ::geteuid() || (current != 0700 && current != 0711) ||
+ current == mode)
+ return true;
+ const int fd = ::open(folder.c_str(), O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
+ if (fd < 0) return false;
+ struct stat opened{};
+ const bool same = ::fstat(fd, &opened) == 0 && opened.st_dev == before.st_dev && opened.st_ino == before.st_ino &&
+ opened.st_uid == ::geteuid();
+ const bool changed = same && ::fchmod(fd, mode) == 0 && ::fsync(fd) == 0;
+ const int error = errno;
+ ::close(fd);
+ errno = error;
+ return changed;
+}
+SharedTreeResult OpenTreeToEveryone(const fs::path& root, const SharedTreeOptions& options) {
+ SharedTreeResult result;
+ struct stat before{};
+ if (::lstat(root.c_str(), &before) != 0) { result.ok = errno == ENOENT; return result; }
+ if (!S_ISDIR(before.st_mode) || before.st_uid != ::geteuid()) return result;
+ const int fd = ::open(root.c_str(), O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
+ struct stat opened{};
+ if (fd < 0 || ::fstat(fd, &opened) != 0 || opened.st_dev != before.st_dev || opened.st_ino != before.st_ino) {
+ if (fd >= 0) ::close(fd);
+ return result;
+ }
+ Walk walk{options.by_path || !kDescriptorRelative, options, 0, &result};
+ result.ok = ShareFolder(fd, root, 0, walk);
+ return result;
+}
}
diff --git a/src/runtime/private_directories.h b/src/runtime/private_directories.h
index a0402f8..8c57ab4 100644
--- a/src/runtime/private_directories.h
+++ b/src/runtime/private_directories.h
@@ -1,17 +1,69 @@
#pragma once
+#include <cstddef>
#include <filesystem>
+#include <functional>
#include <string>
+#include <vector>
+#include <sys/types.h>
namespace playden::runtime {
+// Folders of a private tree that may also be 0711 (kPrivateTraversable): others can
+// pass through them, never list them. Absolute paths at or under private_root; the
+// ones EnsurePrivateDirectories creates get created_mode (0700 or 0711). Empty:
+// the whole tree is 0700.
+struct PrivateTraversal {
+ std::vector<std::filesystem::path> folders;
+ mode_t created_mode = 0700;
+};
// Creates directories as the current effective user, without credential changes.
// boundary is an existing trusted directory; private_root and descendants must
-// belong to that user and have mode 0700. Existing foreign/public directories
-// in the private tree are rejected, never chmodded or taken over. Missing
-// folders between boundary and private_root are created 0777.
+// belong to that user and have mode 0700 (or 0711 for traversal folders).
+// Existing foreign/public directories in the private tree are rejected, never
+// chmodded or taken over. Missing folders between boundary and private_root are
+// created 0777.
bool EnsurePrivateDirectories(const std::filesystem::path& boundary,
const std::filesystem::path& private_root,
const std::filesystem::path& directory,
- std::string* error);
+ std::string* error,
+ const PrivateTraversal& traversal = {});
bool IsPrivateDirectoryTree(const std::filesystem::path& private_root,
- const std::filesystem::path& directory);
-bool IsPrivateDirectory(const std::filesystem::path& directory);
+ const std::filesystem::path& directory,
+ const PrivateTraversal& traversal = {});
+// traversable: also admits 0711.
+bool IsPrivateDirectory(const std::filesystem::path& directory, bool traversable = false);
+// Sets an app-owned private folder (0700 or 0711) to mode, 0700 or 0711, through a descriptor
+// that is not a link. Missing, and folders of other modes or owners, are left: true. False only
+// when the change itself failed.
+bool SetTraversableMode(const std::filesystem::path& folder, mode_t mode);
+// Opens a tree to everyone (FTP runs as root, which the console gives no permission bypass):
+// app-owned folders become 0777, app-owned regular files 0666 with their execute bits kept.
+// Links are never followed, entries of other owners are neither changed nor entered, files
+// with more than one link are left alone, and the walk is bounded. On the console (by path)
+// each folder must still be the entry listed, in a folder its path still names; the walk ends
+// where one changed. ok: the root is missing, or an owned folder that could be listed and
+// nothing changed under the walk; truncated: the walk stopped at its bound; skipped counts
+// entries that could not be opened or changed, linked the files with other links.
+struct SharedTreeResult {
+ bool ok = false;
+ bool truncated = false;
+ bool changed_under = false;
+ std::size_t changed = 0;
+ std::size_t skipped = 0;
+ std::size_t linked = 0;
+};
+// Test seams: by_path walks the console's way on the host; before_open runs before each entry opens.
+struct SharedTreeOptions {
+ bool by_path = false;
+ std::function<void(const std::filesystem::path&)> before_open;
+};
+SharedTreeResult OpenTreeToEveryone(const std::filesystem::path& root, const SharedTreeOptions& options = {});
+// Whether folders are opened relative to a descriptor (*at calls): not on the console.
+bool DescriptorRelativeOpens();
+// A folder opened O_DIRECTORY|O_NOFOLLOW and checked to be the entry lstat saw. -1: errno ELOOP
+// for a link, ENOTDIR, ESTALE when it changed in between.
+int OpenFolderNoFollow(const std::filesystem::path& path);
+// parent_path/name, a folder, opened without following a link: by openat(parent_fd) unless
+// by_path, else by path once the parent's path still names parent_fd, checked to be the entry
+// lstat saw. -1: errno ELOOP for a link, ENOTDIR, ESTALE when the parent or the entry changed.
+int OpenChildFolderNoFollow(int parent_fd, const std::filesystem::path& parent_path, const std::string& name,
+ bool by_path = !DescriptorRelativeOpens());
}
diff --git a/src/runtime/session_storage.cpp b/src/runtime/session_storage.cpp
index db04cb9..af2b57a 100644
--- a/src/runtime/session_storage.cpp
+++ b/src/runtime/session_storage.cpp
@@ -249,9 +249,10 @@ bool BoundToRecord(const WrapperSession &session, const RuntimeInstall &record)
}
std::optional<ManagedDirectory> Child(ManagedDirectory directory,
- std::initializer_list<const char *> parts) {
+ std::initializer_list<const char *> parts,
+ DirectoryPolicy policy = DirectoryPolicy::kPrivate) {
for (const auto *part : parts) {
- auto child = directory.OpenChild(part, DirectoryPolicy::kPrivate);
+ auto child = directory.OpenChild(part, policy);
if (!child) return std::nullopt;
directory = std::move(*child);
}
@@ -502,14 +503,15 @@ std::optional<ManagedDirectory> FilesystemReconcileSessionSource::OpenSessions(
return std::nullopt;
}
const auto mapped = host_data_root_ / "playden/games" / record.install_id;
- auto game = ManagedDirectory::Open(mapped, DirectoryPolicy::kPrivate);
+ // The data root, library, prefixes and the bottle may be 0711 (bottle-profile-shared).
+ auto game = ManagedDirectory::Open(mapped, DirectoryPolicy::kPrivateTraversable);
if (!game)
{
*failure = SourceFailure("session-root-unavailable",
"managed game root is unavailable or unsafe");
return std::nullopt;
}
- auto marker_root = ManagedDirectory::Open(mapped, DirectoryPolicy::kPrivate);
+ auto marker_root = ManagedDirectory::Open(mapped, DirectoryPolicy::kPrivateTraversable);
if (!marker_root)
{
*failure = SourceFailure("session-root-unavailable",
@@ -517,7 +519,7 @@ std::optional<ManagedDirectory> FilesystemReconcileSessionSource::OpenSessions(
return std::nullopt;
}
auto bottle = Child(std::move(*marker_root),
- {"library", "prefixes", "game"});
+ {"library", "prefixes", "game"}, DirectoryPolicy::kPrivateTraversable);
if (!bottle || !MarkerMatches(*bottle, record))
{
*failure = SourceFailure("session-owner-invalid",
diff --git a/src/runtime/settings_publication.cpp b/src/runtime/settings_publication.cpp
index 8c252ca..954bbb7 100644
--- a/src/runtime/settings_publication.cpp
+++ b/src/runtime/settings_publication.cpp
@@ -391,9 +391,10 @@ PackageActionResult ApplyPendingPublicationRegistry(const SettingsPublicationOpe
intended.size() > kMaxPublicationRegistryBackupBytes)
return Failure("publication-registry-render", "Frozen registry edits cannot be safely rendered.");
const auto prefix_path = Map(prefix, o.install.data_root + "/library/prefixes/game");
- auto bottle = ManagedDirectory::Open(prefix_path, DirectoryPolicy::kPrivate);
+ auto bottle = ManagedDirectory::Open(prefix_path, DirectoryPolicy::kPrivateTraversable);
if (!bottle) return Failure("publication-registry-directory", "Private bottle directory is unavailable.");
Storage storage(prefix_path.string());
+ storage.AllowTraversableRoot();
auto read = [&](std::string* bytes, unsigned* mode) {
struct stat before{}, after{};
if (!bottle->InspectChild("user.reg", &before) || !S_ISREG(before.st_mode) || before.st_size < 0 ||
@@ -517,7 +518,7 @@ PackageActionResult ApplyPendingPublicationFiles(const SettingsPublicationOperat
o.previous_metadata_bytes.size(), &previous) != PW_OK))
return Failure("publication-invalid", "Frozen publication metadata is invalid.");
if (!checkpoint(Map(prefix, current.dxvk_path))) return Failure("publication-interrupted", "DXVK effect requires fresh recovery.");
- auto library = ManagedDirectory::Open(Map(prefix, o.install.data_root + "/library"), DirectoryPolicy::kPrivate);
+ auto library = ManagedDirectory::Open(Map(prefix, o.install.data_root + "/library"), DirectoryPolicy::kPrivateTraversable);
if (!library) return Failure("publication-directory", "Owned private library is unavailable.");
auto profiles = library->OpenChild("profiles", DirectoryPolicy::kPrivate, true);
if (!profiles || !profiles->Sync() || !library->Sync() || !checkpoint(paths.profile.parent_path()))
@@ -579,7 +580,7 @@ PackageActionResult PreflightSettingsPublication(const SettingsPublicationOperat
std::string reason;
if (!EncodeSettingsPublicationOperation(o, &reason) || !PathsMatch(o, paths, prefix))
return Failure("publication-invalid", "Frozen preflight operation or canonical paths are invalid.");
- auto data = ManagedDirectory::Open(Map(prefix, o.install.data_root), DirectoryPolicy::kPrivate);
+ auto data = ManagedDirectory::Open(Map(prefix, o.install.data_root), DirectoryPolicy::kPrivateTraversable);
auto control = data ? data->OpenChild(".playden-control", DirectoryPolicy::kPrivate) : std::nullopt;
auto held = [&] { return control && LeaseHeld(borrowed, control->path()); };
if (!held()) return Failure("publication-lock", "Preflight publisher descriptor is unavailable or changed.");
@@ -587,7 +588,7 @@ PackageActionResult PreflightSettingsPublication(const SettingsPublicationOperat
const bool initial = o.previous_receipt_bytes.empty();
if (!receipt.ok || (initial ? !receipt.absent : receipt.absent || receipt.bytes != o.previous_receipt_bytes))
return Failure("publication-preflight-receipt", "Preflight requires the exact previous receipt or initial absence.");
- auto library = data->OpenChild("library", DirectoryPolicy::kPrivate);
+ auto library = data->OpenChild("library", DirectoryPolicy::kPrivateTraversable);
auto title = ManagedDirectory::Open(paths.descriptor.parent_path(), DirectoryPolicy::kApprovedTree);
struct stat title_info{};
if (!library || !title || lstat(title->path().c_str(), &title_info) || title_info.st_uid != geteuid() ||
@@ -636,8 +637,8 @@ PackageActionResult PreflightSettingsPublication(const SettingsPublicationOperat
return Failure("publication-preflight-snapshot", "Live DXVK disagrees with the frozen before snapshot.");
// A dxvk.conf Playden did not write (one the game ships) is kept in the frozen
// before-snapshot, then written over or removed as the title's contract requires.
- auto prefixes = library->OpenChild("prefixes", DirectoryPolicy::kPrivate);
- auto bottle = prefixes ? prefixes->OpenChild("game", DirectoryPolicy::kPrivate) : std::nullopt;
+ auto prefixes = library->OpenChild("prefixes", DirectoryPolicy::kPrivateTraversable);
+ auto bottle = prefixes ? prefixes->OpenChild("game", DirectoryPolicy::kPrivateTraversable) : std::nullopt;
auto registry = bottle ? ReadPublicationFile(*bottle, "user.reg", kMaxPublicationRegistryBackupBytes) : std::nullopt;
if (!registry || !registry->present)
return Failure("publication-preflight-registry", "Owned bottle registry is unavailable.");
@@ -754,13 +755,13 @@ Result<SettingsPublicationOperation> CaptureSettingsPublicationOperation(const R
}
auto metadata = SerializePublicationMetadata(m);
if (!metadata) return fail("Completion metadata is invalid."); o.metadata_bytes = *metadata;
- auto data = ManagedDirectory::Open(Map(prefix, r.data_root), DirectoryPolicy::kPrivate);
+ auto data = ManagedDirectory::Open(Map(prefix, r.data_root), DirectoryPolicy::kPrivateTraversable);
auto control = data ? data->OpenChild(".playden-control", DirectoryPolicy::kPrivate) : std::nullopt;
auto held = [&] { return control && LeaseHeld(borrowed, control->path()); };
if (!held()) return fail("Qualified publisher descriptor/private tree is unavailable.");
auto receipt = ReadReceipt(control->path(), *control);
if (!receipt.ok) return fail("Before receipt is corrupt or unavailable.");
- auto library = data->OpenChild("library", DirectoryPolicy::kPrivate);
+ auto library = data->OpenChild("library", DirectoryPolicy::kPrivateTraversable);
if (!library) return fail("Private library is unavailable.");
if (!receipt.absent) {
PwTitlePublication parsed{}; PwTitlePublicationDescriptor descriptor{}; PwTitlePublicationContents contents{};
@@ -795,8 +796,8 @@ Result<SettingsPublicationOperation> CaptureSettingsPublicationOperation(const R
if (dxvk->present) {
auto digest = HashArtifactBytes(dxvk->bytes); if (!digest) return fail("Before DXVK hashing failed."); o.dxvk_before.sha256 = *digest;
}
- auto prefixes = library->OpenChild("prefixes", DirectoryPolicy::kPrivate);
- auto bottle = prefixes ? prefixes->OpenChild("game", DirectoryPolicy::kPrivate) : std::nullopt;
+ auto prefixes = library->OpenChild("prefixes", DirectoryPolicy::kPrivateTraversable);
+ auto bottle = prefixes ? prefixes->OpenChild("game", DirectoryPolicy::kPrivateTraversable) : std::nullopt;
auto registry = bottle ? ReadPublicationFile(*bottle, "user.reg", kMaxPublicationRegistryBackupBytes) : std::nullopt;
if (!registry || !registry->present) return fail("Before registry cannot be verified.");
auto intended_registry = registry->bytes; std::string reason;
diff --git a/src/runtime/settings_publication_owner.cpp b/src/runtime/settings_publication_owner.cpp
index 808b7c3..c47ff8e 100644
--- a/src/runtime/settings_publication_owner.cpp
+++ b/src/runtime/settings_publication_owner.cpp
@@ -41,18 +41,23 @@ PublicationPaths OperationPaths(const SettingsPublicationOperation& operation, c
}
// A Ready update publishes a newer revision, or the same one again when the game folder
// moved (RuntimeInstall::moved_from): its publication must then name the new folder. With a
-// kit that admits unowned folders, an owned publication is also published again as unowned.
-bool UpdateRevisionAllowed(const RuntimeInstall& current, std::uint64_t requested, bool unowned_game_roots) {
- return requested > current.settings_revision ||
- (requested == current.settings_revision && (!current.moved_from.empty() || unowned_game_roots));
+// kit that admits unowned folders, a committed owned publication (schema 2) is also published
+// again as unowned; one already unowned, or unreadable, is not.
+bool UpdateRevisionAllowed(const RuntimeInstall& current, std::uint64_t requested, bool unowned_game_roots,
+ const std::filesystem::path& prefix) {
+ if (requested > current.settings_revision) return true;
+ if (requested != current.settings_revision) return false;
+ if (!current.moved_from.empty()) return true;
+ return unowned_game_roots && PublishedGameRootUnowned(current, prefix) == std::optional<bool>(false);
}
bool MatchingJournal(const RuntimeInstall& r, const SettingsPublicationOperation& o) {
return r.journal && r.journal->operation == "settings-publication" && r.journal->operation_id == o.transaction_id;
}
}
SettingsPublicationOwner::SettingsPublicationOwner(InstallRecordStore& records, PackageInstaller& package,
- NativeCoordinator& native, bool unowned_game_roots)
- : records_(records), package_(package), native_(native), unowned_game_roots_(unowned_game_roots) {}
+ NativeCoordinator& native, bool unowned_game_roots, std::filesystem::path host_namespace_prefix)
+ : records_(records), package_(package), native_(native), unowned_game_roots_(unowned_game_roots),
+ host_namespace_prefix_(std::move(host_namespace_prefix)) {}
PackageActionResult SettingsPublicationOwner::Request(const SettingsPublicationRequest& request,
const std::filesystem::path& directory) {
std::string reason; auto expected = EncodeSettingsPublicationRequest(request, &reason);
@@ -60,7 +65,7 @@ PackageActionResult SettingsPublicationOwner::Request(const SettingsPublicationR
const bool update = current && current->state == PreparationState::kReady;
const bool armed = current && current->journal && current->journal->operation == "settings-request";
if (!expected || !current || !SameRuntimeInstallIdentity(*current, request.install) ||
- (update ? !UpdateRevisionAllowed(*current, request.plan.settings_revision, unowned_game_roots_) :
+ (update ? !UpdateRevisionAllowed(*current, request.plan.settings_revision, unowned_game_roots_, host_namespace_prefix_) :
request.plan.settings_revision != current->settings_revision) ||
(update ? !ReadyCaptureAllowed(*current, request.transaction_id) :
current->state != PreparationState::kPreparing || !current->journal ||
@@ -110,7 +115,7 @@ PackageActionResult SettingsPublicationOwner::ResumeRequested(const RuntimeInsta
auto loaded = LoadSettingsPublicationRequest(directory, current->journal->operation_id);
if (loaded.state != PublicationRecoveryState::kValid || !loaded.request ||
!SameRuntimeInstallIdentity(loaded.request->install, *current) ||
- (current->state == PreparationState::kReady ? !UpdateRevisionAllowed(*current, loaded.request->plan.settings_revision, unowned_game_roots_) :
+ (current->state == PreparationState::kReady ? !UpdateRevisionAllowed(*current, loaded.request->plan.settings_revision, unowned_game_roots_, prefix) :
loaded.request->plan.settings_revision != current->settings_revision))
return Failure("publication-request-unavailable", "Requested plan is missing, altered or does not match OWNER; preserve all evidence.");
const auto& request = *loaded.request;
@@ -142,7 +147,7 @@ PackageActionResult SettingsPublicationOwner::InitializeControl(const RuntimeIns
return Failure("publication-control-conflict", "An existing OWNER operation cannot be replaced by control initialization.");
const auto canonical = std::filesystem::path(record.data_root);
const auto data_path = prefix.empty() ? canonical : prefix / canonical.relative_path();
- auto data = platform::ManagedDirectory::Open(data_path, platform::DirectoryPolicy::kPrivate);
+ auto data = platform::ManagedDirectory::Open(data_path, platform::DirectoryPolicy::kPrivateTraversable);
if (!data) return Failure("publication-control-data", "Existing owned private bottle data root is unavailable.");
struct stat info{};
const bool exists = data->InspectChild(".playden-control", &info);
diff --git a/src/runtime/settings_publication_owner.h b/src/runtime/settings_publication_owner.h
index c7370f6..7552b3b 100644
--- a/src/runtime/settings_publication_owner.h
+++ b/src/runtime/settings_publication_owner.h
@@ -9,9 +9,10 @@ enum class PublicationControlStep { kOwnerArmed, kDirectorySynced, kLockSynced,
class SettingsPublicationOwner {
public:
// unowned_game_roots: the admitted kit has game-root-unowned; captures publish every game
- // folder unowned (CaptureSettingsPublicationOperation).
+ // folder unowned (CaptureSettingsPublicationOperation). host_namespace_prefix: where Request
+ // reads the committed publication (a same-revision update only replaces an owned one).
SettingsPublicationOwner(InstallRecordStore& records, PackageInstaller& package, NativeCoordinator& native,
- bool unowned_game_roots = false);
+ bool unowned_game_roots = false, std::filesystem::path host_namespace_prefix = {});
// Persist the exact requested plan in the existing
// private OWNER request directory, then arm OWNER before control/capture.
// Pre-arm orphans never resume implicitly. Ready updates retain their current
@@ -49,5 +50,6 @@ class SettingsPublicationOwner {
PackageInstaller& package_;
NativeCoordinator& native_;
bool unowned_game_roots_ = false;
+ std::filesystem::path host_namespace_prefix_;
};
} // namespace playden::runtime
diff --git a/tests/game_settings_test.cpp b/tests/game_settings_test.cpp
index 84d64ed..adb2994 100644
--- a/tests/game_settings_test.cpp
+++ b/tests/game_settings_test.cpp
@@ -1343,6 +1343,9 @@ int main(int argc, char** argv) {
}
CHECK(KitCapabilitiesFromManifest({kKitVkd3dProton}, false).vkd3d_proton &&
!KitCapabilitiesFromManifest({kKitDxvk}, false).vkd3d_proton);
+ CHECK(KitCapabilitiesFromManifest({kKitBottleProfileShared}, false).bottle_profile_shared &&
+ !KitCapabilitiesFromManifest({kKitGameRootUnowned}, false).bottle_profile_shared &&
+ !KitCapabilitiesFromManifest({kKitBottleProfileShared}, false).game_root_unowned);
// A locked row keeps the recipe's value until the player changes it anyway.
CHECK(BuildEffectiveSettings(hl2, nullptr, {{"graphics", "opengl"}}, KitCapabilities{}, &settings, &error));
CHECK(settings.graphics == "dxvk" && settings.values.at("graphics").locked && !settings.values.at("graphics").unlocked);
diff --git a/tests/homebrew_runtime_host_test.cpp b/tests/homebrew_runtime_host_test.cpp
index 067b490..c02b544 100644
--- a/tests/homebrew_runtime_host_test.cpp
+++ b/tests/homebrew_runtime_host_test.cpp
@@ -1442,10 +1442,15 @@ void MaintainsReadyTitle() {
CHECK(!fs::exists(game / "hl2.dxvk-cache") && Read(game / "hl2.exe") == "existing-game");
// Backups copy the Windows user folders; the newest three are kept.
+ // A file with another link (here the bottle's registry linked into the profile) is not copied.
Write(data / "library/prefixes/game/drive_c/users/prospero/Documents/save.dat", "progress", 0600);
+ const auto linked = data / "library/prefixes/game/drive_c/users/prospero/Documents/linked.reg";
+ CHECK(link((data / "library/prefixes/game/user.reg").c_str(), linked.c_str()) == 0);
for (int index = 0; index < 4; ++index, ++now) CHECK(maintain(RuntimeMaintenance::kBackupSaves).maintenance.at(220).ok);
const auto backups = fixture.root / "data/playden/games/steam-220.saves";
CHECK(Read(backups / "1760000003/users/prospero/Documents/save.dat") == "progress");
+ CHECK(!fs::exists(backups / "1760000003/users/prospero/Documents/linked.reg"));
+ CHECK(unlink(linked.c_str()) == 0);
CHECK(!fs::exists(backups / "1760000000") && fs::exists(backups / "1760000001"));
result = host.Snapshot();
CHECK(result.installs[0].save_backups == 3 && result.installs[0].latest_save_backup == 1760000003);
@@ -1455,6 +1460,12 @@ void MaintainsReadyTitle() {
CHECK(result.maintenance.at(220).ok);
struct stat info{};
CHECK(stat((data / "library/prefixes/game/user.reg").c_str(), &info) == 0 && (info.st_mode & 0777) == 0600);
+ // A kit without bottle-profile-shared keeps the bottle private: its way and its saves.
+ for (const auto* folder : {"", "library", "library/prefixes", "library/prefixes/game", "library/prefixes/game/drive_c/users"})
+ CHECK(lstat((data / folder).c_str(), &info) == 0 && (info.st_mode & 07777) == 0700);
+ CHECK(lstat((data / "library/prefixes/game/drive_c/users/prospero/Documents/save.dat").c_str(), &info) == 0 &&
+ (info.st_mode & 07777) == 0600);
+ CHECK(lstat(backups.c_str(), &info) == 0 && (info.st_mode & 07777) == 0700);
// An update interrupted after its arm keeps its journal: Play waits, and Resume (Prepare)
// finishes the saved request instead of making a new one.
@@ -1603,7 +1614,8 @@ void ModdedGameFolderStillPlays() {
// mod. With a kit that admits unowned folders, each way back republishes it unowned: the
// startup pass (route 0), or with the title busy at startup, Repair (1), a settings update (2),
// Update (3) or Play (4). Owned 0755 folders that were tightened open up again (route 0), but
-// never while the publication stays owned (5: the republication is refused).
+// never while the publication stays owned (5: the republication is refused). Such a game
+// played before, so it still plays, Repairs and Updates under its owned publication (5).
void OwnedPublicationOpenedUpRecovers(int route) {
Fixture fixture;
auto config = fixture.Config();
@@ -1665,8 +1677,26 @@ void OwnedPublicationOpenedUpRecovers(int route) {
RuntimeHost host(config);
CHECK(host.Start());
WaitFor(host, Started);
- CHECK(logged("startup unowned app=220 failed: "));
+ CHECK(logged("startup unowned app=220 deferred: "));
CHECK(Read(metadata).find("schema=2\n") != std::string::npos && mode(game) == 0755);
+ const auto maintain = [&host](RuntimeMaintenance action) {
+ const auto before = host.Snapshot().maintenance_handled;
+ host.Maintain(220, action);
+ return WaitFor(host, [before](const RuntimeSnapshot& s) { return s.maintenance_handled > before; }, 60).maintenance.at(220);
+ };
+ const auto repaired = maintain(RuntimeMaintenance::kRepair);
+ if (!repaired.ok) std::fprintf(stderr, "route 5 Repair refused: %s\n", repaired.message.c_str());
+ CHECK(repaired.ok && repaired.message.find("could not be published for mods") != std::string::npos);
+ const auto before = host.Snapshot().prepares_handled;
+ host.Prepare(Hl2());
+ const auto updated = WaitFor(host, [before](const RuntimeSnapshot& s) { return s.prepares_handled > before; }, 60);
+ CHECK(updated.refusals.count(220) && updated.refusals.at(220) == "This game is already prepared.");
+ host.Play(220);
+ const auto done = WaitFor(host, [](const RuntimeSnapshot& s) { return s.handoff_ready || s.play_refusals.count(220); }, 30);
+ if (done.play_refusals.count(220)) std::fprintf(stderr, "route 5 Play refused: %s\n", done.play_refusals.at(220).c_str());
+ CHECK(done.handoff_ready && host.Handoff());
+ CHECK(Read(metadata).find("schema=2\n") != std::string::npos && mode(game) == 0755);
+ CHECK(Read(game / "GInput.asi") == "mod-plugin");
host.Shutdown();
return;
}
@@ -2743,10 +2773,10 @@ void MovedGameStartupKeepsSteamAccount() {
host.Shutdown();
}
-// A moved game whose publication can't be redone (here its saved settings went back to an older
-// revision than the title's) would be stuck: Play says to press Update, and Update prepares it
-// again from its new folder, as Recreate bottle does, keeping its saves.
-void StuckMovedGamePreparesAgainOnUpdate() {
+// A moved game whose publication can't be redone (here its saved settings are older than its
+// title's) is not prepared again behind the player's back: Play and Update refuse, name the
+// confirmed way out (Recreate bottle), and change nothing.
+void StuckMovedGameOffersRecreateBottle() {
Fixture fixture;
GamesMove move;
const auto kit = SyntheticKit(fixture.root / "kit");
@@ -2757,9 +2787,9 @@ void StuckMovedGamePreparesAgainOnUpdate() {
GameSettingsRecord saved; saved.revision = revision->load(); saved.overrides = {{"resolution", "1280x720"}};
return saved;
};
- config.removal_poll_interval = std::chrono::milliseconds(1);
- config.unregister_title = [&fixture](const std::string&, const std::string&) {
- fixture.registered = false; fixture.submitted = false;
+ bool unregistered = false;
+ config.unregister_title = [&unregistered](const std::string&, const std::string&) {
+ unregistered = true;
return TitleRemoverResult{true, 0, "answered"};
};
PrepareThenMoveGames(fixture, config, move);
@@ -2771,23 +2801,22 @@ void StuckMovedGamePreparesAgainOnUpdate() {
CHECK(host.Start());
WaitFor(host, Started);
CHECK(move.Logged("startup moved app=220 failed: ") && move.Done() == 0);
+ const auto records_before = Read(fixture.root / "data/runtime-state/installs.json");
+ CHECK(records_before.find("moved_from") != std::string::npos);
+ const auto title = host.Snapshot().installs.at(0).title_id;
host.Play(220);
const auto played = WaitFor(host, [](const RuntimeSnapshot& s) { return s.handoff_ready || s.play_refusals.count(220); }, 30);
CHECK(played.play_refusals.count(220) &&
- played.play_refusals.at(220).find("Press Update on the game page") != std::string::npos);
+ played.play_refusals.at(220).find("Use Maintenance > Recreate bottle on the game page") != std::string::npos);
const auto before = host.Snapshot().prepares_handled;
host.Prepare({220, std::string(kNewGames) + "/220", "internal", "Half-Life \"2\""});
const auto done = WaitFor(host, [before](const RuntimeSnapshot& s) { return s.prepares_handled > before; }, 60);
- if (done.refusals.count(220)) std::fprintf(stderr, "Update refused: %s\n", done.refusals.at(220).c_str());
- CHECK(!done.refusals.count(220));
- CHECK(done.installs.size() == 1 && done.installs[0].state == PreparationState::kReady);
- CHECK(move.Logged("prepare again app=220 because: ") && move.Done() == 1);
- const auto records = Read(fixture.root / "data/runtime-state/installs.json");
- CHECK(records.find(R"("install_path":"/data/playden-games/220")") != std::string::npos &&
- records.find("moved_from") == std::string::npos);
+ CHECK(done.refusals.count(220) &&
+ done.refusals.at(220).find("Use Maintenance > Recreate bottle on the game page") != std::string::npos);
+ CHECK(done.installs.size() == 1 && done.installs[0].state == PreparationState::kReady && done.installs[0].title_id == title);
+ CHECK(!move.Logged("prepare again app=220") && move.Done() == 0 && !unregistered);
+ CHECK(Read(fixture.root / "data/runtime-state/installs.json") == records_before);
CHECK(Read(save) == "player-save" && !fs::exists(fixture.root / "data/playden/games/steam-220.kept"));
- const auto descriptor = Read(fixture.root / "data/homebrew" / done.installs[0].title_id / "game-launch.json");
- CHECK(descriptor.find(R"("game_root":"/data/playden-games/220")") != std::string::npos);
host.Shutdown();
}
@@ -2974,6 +3003,256 @@ void MovedGameMissingAtNewRootKeepsTheMove() {
host.Shutdown();
}
+// bottle-profile-shared: the bottle's way to its user profile is 0711 and the profile is open to FTP.
+RuntimeKit SharedProfileKit(const fs::path& kit) {
+ auto admitted = SyntheticKit(kit);
+ admitted.capabilities.push_back(kKitBottleProfileShared);
+ std::sort(admitted.capabilities.begin(), admitted.capabilities.end());
+ return admitted;
+}
+unsigned ModeOf(const fs::path& path) {
+ struct stat info{};
+ CHECK(lstat(path.c_str(), &info) == 0);
+ return static_cast<unsigned>(info.st_mode & 07777);
+}
+// The six folders on the way from the data root to the profile.
+std::vector<fs::path> ProfileWay(const fs::path& data) {
+ const auto bottle = data / "library/prefixes/game";
+ return {data, data / "library", data / "library/prefixes", bottle, bottle / "drive_c", bottle / "drive_c/users"};
+}
+
+// A prepared HL2 title with a kit that the test can swap, Play from Playden and a working remover.
+struct ProfileRun {
+ Fixture fixture;
+ RuntimeKit kit;
+ unsigned uuids = 0;
+ std::vector<std::vector<std::string>> launches;
+ RuntimeHostConfig config;
+ const fs::path data = fixture.root / "data/playden/games/steam-220";
+ const fs::path profile = data / "library/prefixes/game/drive_c/users/prospero";
+ explicit ProfileRun(bool shared) {
+ kit = shared ? SharedProfileKit(fixture.root / "kit") : SyntheticKit(fixture.root / "kit");
+ config = fixture.Config();
+ config.host_namespace_prefix = fixture.root;
+ config.session_data_root = fixture.root / "data";
+ config.package_paths.console_data_root = "/data";
+ config.package_paths.host_data_root = fixture.root / "data";
+ config.package_operations.hash_file = HashArtifactFile;
+ config.package_operations.hash_bytes = HashArtifactBytes;
+ config.package_operations.free_space_unverifiable = true;
+ config.package_operations.validate_bottle = [](const fs::path& bottle) {
+ return fs::is_regular_file(bottle / "system.reg") && fs::is_regular_file(bottle / "user.reg");
+ };
+ config.admit_kit = [this](std::string*) { return std::optional<RuntimeKit>(kit); };
+ config.uuid = [this]() -> std::optional<std::string> {
+ ++uuids;
+ char id[37];
+ std::snprintf(id, sizeof(id), "00000000-0000-4000-8000-%012u", uuids);
+ return std::string(id);
+ };
+ config.unix_time = [] { return std::int64_t{1760000000}; };
+ config.launch_title = [this](const std::string&, const std::vector<std::string>& arguments) {
+ launches.push_back(arguments);
+ return TitleResult{true, 0, "launch"};
+ };
+ config.removal_confirm_polls = 3;
+ config.removal_poll_interval = std::chrono::milliseconds(1);
+ config.unregister_title = [this](const std::string&, const std::string&) {
+ fixture.registered = false; fixture.submitted = false;
+ return TitleRemoverResult{true, 0, "answered"};
+ };
+ Write(fixture.root / "data/homebrew/FAKE77031/games/220/hl2.exe", "existing-game", 0644);
+ }
+ RuntimeSnapshot Prepare(RuntimeHost& host) {
+ host.Prepare(Hl2());
+ const auto done = WaitFor(host, [](const RuntimeSnapshot& s) {
+ return !s.preparing_app && (s.refusals.count(220) ||
+ (!s.installs.empty() && s.installs[0].state == PreparationState::kReady));
+ }, 60);
+ if (done.refusals.count(220)) std::fprintf(stderr, "Prepare refused: %s\n", done.refusals.at(220).c_str());
+ CHECK(!done.refusals.count(220) && done.installs.size() == 1);
+ return done;
+ }
+ RuntimeSnapshot Maintain(RuntimeHost& host, RuntimeMaintenance action) {
+ const auto before = host.Snapshot().maintenance_handled;
+ host.Maintain(220, action);
+ return WaitFor(host, [before](const RuntimeSnapshot& s) { return s.maintenance_handled > before; }, 60);
+ }
+ // Play from Playden up to the handoff; returns the session it starts.
+ std::string Play(RuntimeHost& host) {
+ const auto handled = host.Snapshot().plays_handled;
+ host.Play(220);
+ const auto played = WaitFor(host, [handled](const RuntimeSnapshot& s) {
+ return s.handoff_ready || s.plays_handled > handled;
+ }, 30);
+ if (!played.handoff_ready && played.play_refusals.count(220))
+ std::fprintf(stderr, "Play refused: %s\n", played.play_refusals.at(220).c_str());
+ WaitFor(host, [](const RuntimeSnapshot& s) { return s.handoff_ready; }, 30);
+ CHECK(host.Handoff());
+ return launches.back().at(0).substr(std::string("session=").size());
+ }
+ // The title's wrapper records the session in the private data root.
+ void Session(const std::string& id, const std::string& phase) {
+ const auto sessions = data / "logs/sessions";
+ fs::create_directories(sessions);
+ CHECK(chmod((data / "logs").c_str(), 0700) == 0 && chmod(sessions.c_str(), 0700) == 0);
+ Write(sessions / (id + ".json"),
+ R"({"schema_version":1,"session_id":")" + id +
+ R"(","install_id":"steam-220","title_id":"FAKE78001","origin":"playden","settings_revision":0,)"
+ R"("runtime_bundle_id":"wine-wow64","phase":")" + phase + "\"}\n", 0600);
+ }
+};
+
+// Whether the linked publication verifier (the pinned kit's) admits a 0711 data root. One from
+// before bottle-profile-shared refuses it, and with it every start check of a shared bottle:
+// those checks wait for the pin that brings the capability.
+bool VerifierAdmitsSharedBottle() {
+ static const bool admits = [] {
+ ProfileRun run(false);
+ {
+ RuntimeHost host(run.config);
+ CHECK(host.Start());
+ run.Prepare(host);
+ host.Shutdown();
+ }
+ CHECK(chmod(run.data.c_str(), 0711) == 0);
+ FilesystemPackageInstaller installer(run.kit.view, run.config.package_paths, run.config.package_operations);
+ auto record = Record();
+ record.title_id = "FAKE78001";
+ record.data_root = "/data/playden/games/steam-220";
+ const bool ok = installer.AdmissionDiagnostic(record) == "ok";
+ if (!ok)
+ std::fprintf(stderr, "note: the linked publication verifier refuses 0711 bottles; "
+ "bottle-profile-shared start checks are skipped until the kit pin admits them\n");
+ return ok;
+ }();
+ return admits;
+}
+
+// A kit with bottle-profile-shared makes the bottle's way 0711 and its profile 0777/0666. Saves
+// Wine makes (0600, umask 077) are opened again at Play and when the session ends; Repair keeps
+// the modes, backups stay private, and saves kept across an uninstall come back open.
+void SharedProfileKitOpensSaves() {
+ if (!VerifierAdmitsSharedBottle()) return;
+ ProfileRun run(true);
+ RuntimeHost host(run.config);
+ CHECK(host.Start());
+ CHECK(WaitFor(host, Started).kit_available);
+ auto ready = run.Prepare(host);
+ CHECK(ready.installs[0].admission == "ok");
+ for (const auto& folder : ProfileWay(run.data)) CHECK(ModeOf(folder) == 0711);
+ for (const auto* folder : {".playden-control", "library/profiles", "library/input"}) CHECK(ModeOf(run.data / folder) == 0700);
+ CHECK(ModeOf(run.data / "library/prefixes/game/user.reg") == 0600);
+ for (const auto* folder : {"", "AppData", "AppData/Roaming", "Documents", "Saved Games"})
+ CHECK(ModeOf(run.profile / folder) == 0777);
+
+ // Between sessions (from Home, or over FTP) Wine left a private save: Play opens it first.
+ const auto game = run.profile / "AppData/Roaming/Game";
+ Write(game / "save.dat", "first", 0600);
+ CHECK(chmod(game.c_str(), 0700) == 0);
+ const auto session = run.Play(host);
+ CHECK(ModeOf(game) == 0777 && ModeOf(game / "save.dat") == 0666);
+ // The game saves while it runs; once its session ends the new save is opened too.
+ run.Session(session, "running");
+ WaitFor(host, [](const RuntimeSnapshot& s) { return s.launch && s.launch->state == LaunchState::kRunning; }, 30);
+ Write(game / "later.dat", "second", 0600);
+ run.Session(session, "exited");
+ WaitFor(host, [](const RuntimeSnapshot& s) { return s.launch && s.launch->state == LaunchState::kExited; }, 30);
+ CHECK(ModeOf(game / "later.dat") == 0666);
+ CHECK(ModeOf(run.data / "logs/sessions") == 0700 && ModeOf(run.data / "library/prefixes/game/user.reg") == 0600);
+
+ // Repair keeps the modes and the start check passes.
+ auto result = run.Maintain(host, RuntimeMaintenance::kRepair);
+ CHECK(result.maintenance.at(220).ok);
+ for (const auto& folder : ProfileWay(run.data)) CHECK(ModeOf(folder) == 0711);
+ // Backups live in Playden's private backup folder.
+ result = run.Maintain(host, RuntimeMaintenance::kBackupSaves);
+ CHECK(result.maintenance.at(220).ok);
+ const auto backups = run.fixture.root / "data/playden/games/steam-220.saves";
+ CHECK(ModeOf(backups) == 0700 && ModeOf(backups / "1760000000/users/prospero/AppData/Roaming/Game/save.dat") == 0600);
+
+ // Uninstalled keeping saves, prepared again: the saves come back open.
+ const auto removals = host.Snapshot().removals_handled;
+ host.Remove(220, false);
+ auto removed = WaitFor(host, [removals](const RuntimeSnapshot& s) { return s.removals_handled > removals; }, 30);
+ CHECK(removed.installs.empty() && removed.kept_bottles.size() == 1);
+ const auto kept = run.fixture.root / "data/playden/games/steam-220.kept";
+ CHECK(ModeOf(kept / "library/prefixes/game/drive_c/users/prospero/AppData/Roaming/Game/save.dat") == 0666);
+ ready = run.Prepare(host);
+ CHECK(ready.kept_bottles.empty() && Read(game / "save.dat") == "first");
+ CHECK(ModeOf(game) == 0777 && ModeOf(game / "save.dat") == 0666 && ModeOf(game / "later.dat") == 0666);
+ for (const auto& folder : ProfileWay(run.data)) CHECK(ModeOf(folder) == 0711);
+ host.Shutdown();
+}
+
+// A bottle made before the kit had bottle-profile-shared (all 0700) is opened when Playden starts
+// with the new kit, and again by Repair and by the first Play if it was tightened since.
+void ExistingBottleOpensWithSharedKit() {
+ if (!VerifierAdmitsSharedBottle()) return;
+ ProfileRun run(false);
+ {
+ RuntimeHost host(run.config);
+ CHECK(host.Start());
+ run.Prepare(host);
+ host.Shutdown();
+ }
+ for (const auto& folder : ProfileWay(run.data)) CHECK(ModeOf(folder) == 0700);
+ Write(run.profile / "Documents/My Games/settings.ini", "[video]\n", 0600);
+ run.kit = SharedProfileKit(run.fixture.root / "kit");
+ const auto tighten = [&run] {
+ for (const auto& folder : ProfileWay(run.data)) CHECK(chmod(folder.c_str(), 0700) == 0);
+ CHECK(chmod((run.profile / "Documents/My Games/settings.ini").c_str(), 0600) == 0);
+ };
+ RuntimeHost host(run.config);
+ CHECK(host.Start());
+ CHECK(WaitFor(host, Started).kit_available);
+ for (const auto& folder : ProfileWay(run.data)) CHECK(ModeOf(folder) == 0711);
+ CHECK(ModeOf(run.profile / "Documents/My Games") == 0777 && ModeOf(run.profile / "Documents/My Games/settings.ini") == 0666);
+ tighten();
+ CHECK(run.Maintain(host, RuntimeMaintenance::kRepair).maintenance.at(220).ok);
+ for (const auto& folder : ProfileWay(run.data)) CHECK(ModeOf(folder) == 0711);
+ CHECK(ModeOf(run.profile / "Documents/My Games/settings.ini") == 0666);
+ tighten();
+ run.Play(host);
+ for (const auto& folder : ProfileWay(run.data)) CHECK(ModeOf(folder) == 0711);
+ CHECK(ModeOf(run.profile / "Documents/My Games/settings.ini") == 0666);
+ host.Shutdown();
+}
+
+// Without the capability nothing opens: Wine's saves stay as they are after Play and after a
+// session. A bottle a capable kit opened (then a kit downgrade) fails the strict start check
+// until Repair, or the next Play, puts its way back to 0700; the profile keeps its modes.
+void KitWithoutSharedProfileKeepsBottlePrivate() {
+ ProfileRun run(false);
+ RuntimeHost host(run.config);
+ CHECK(host.Start());
+ run.Prepare(host);
+ const auto save = run.profile / "Saved Games/Game/save.dat";
+ Write(save, "save", 0600);
+ CHECK(chmod(save.parent_path().c_str(), 0700) == 0);
+ const auto session = run.Play(host);
+ run.Session(session, "exited");
+ WaitFor(host, [](const RuntimeSnapshot& s) { return s.launch && s.launch->state == LaunchState::kExited; }, 30);
+ CHECK(ModeOf(save) == 0600 && ModeOf(save.parent_path()) == 0700 && ModeOf(run.profile) == 0700);
+ for (const auto& folder : ProfileWay(run.data)) CHECK(ModeOf(folder) == 0700);
+
+ const auto open_up = [&run, &save] {
+ for (const auto& folder : ProfileWay(run.data)) CHECK(chmod(folder.c_str(), 0711) == 0);
+ CHECK(chmod(run.profile.c_str(), 0777) == 0 && chmod(save.c_str(), 0666) == 0);
+ };
+ open_up();
+ auto result = run.Maintain(host, RuntimeMaintenance::kRepair);
+ if (!result.maintenance.at(220).ok) std::fprintf(stderr, "Repair: %s\n", result.maintenance.at(220).message.c_str());
+ CHECK(result.maintenance.at(220).ok && result.installs[0].admission == "ok");
+ for (const auto& folder : ProfileWay(run.data)) CHECK(ModeOf(folder) == 0700);
+ CHECK(ModeOf(run.profile) == 0777 && ModeOf(save) == 0666);
+ open_up();
+ run.Play(host);
+ for (const auto& folder : ProfileWay(run.data)) CHECK(ModeOf(folder) == 0700);
+ CHECK(ModeOf(save) == 0666);
+ host.Shutdown();
+}
+
int main(int argc, char** argv) {
CHECK(argc == 2);
g_runtime_dir = argv[1];
@@ -3007,13 +3286,16 @@ int main(int argc, char** argv) {
KitRespinKeepsWaitingSettingsUpdate();
RemovesTitleKeepingSaves();
PreparesGameInstalledAgainElsewhere();
+ SharedProfileKitOpensSaves();
+ ExistingBottleOpensWithSharedKit();
+ KitWithoutSharedProfileKeepsBottlePrivate();
ShippedRecipePreparesWithAnotherKitsRecipe();
ShippedRecipeRequirementsFollowTheKit(false);
ShippedRecipeRequirementsFollowTheKit(true);
MigrationRewritesInstallPathsAndRepublishes();
MovedModdedGameRepublishesUnowned();
MovedGameStartupKeepsSteamAccount();
- StuckMovedGamePreparesAgainOnUpdate();
+ StuckMovedGameOffersRecreateBottle();
PlayBeforeRepublishRepublishesFirst();
MigrationSkipsRecordsOutsideOldPrefix();
RestartDuringRepublishResumes();
diff --git a/tests/managed_directory_test.cpp b/tests/managed_directory_test.cpp
index b1ff999..7275724 100644
--- a/tests/managed_directory_test.cpp
+++ b/tests/managed_directory_test.cpp
@@ -170,6 +170,87 @@ void ForeignOwnershipWhenPrivileged(DirectoryBackend backend) {
CHECK(::chown((f.root / "foreign-dir").c_str(), 0, static_cast<gid_t>(-1)) == 0);
CHECK(!approved->Validate());
}
+
+// kPrivateTraversable admits 0700 and 0711 only, owned by the user; it opens
+// private children, and a kPrivate parent never opens it.
+void PrivateTraversableAccepts0711Only(DirectoryBackend backend) {
+ Fixture f;
+ const auto mode = [](const fs::path& path) {
+ struct stat info{};
+ CHECK(::lstat(path.c_str(), &info) == 0);
+ return info.st_mode & 07777;
+ };
+ const auto chain = f.root / "chain";
+ fs::create_directory(chain);
+ for (mode_t admitted : {0700, 0711}) {
+ CHECK(::chmod(chain.c_str(), admitted) == 0);
+ auto opened = ManagedDirectory::Open(chain, DirectoryPolicy::kPrivateTraversable, backend);
+ CHECK(opened && opened->policy() == DirectoryPolicy::kPrivateTraversable && opened->root() == chain);
+ }
+ for (mode_t refused : {0755, 0751, 0701, 0710, 0733, 0777, 0500}) {
+ CHECK(::chmod(chain.c_str(), refused) == 0);
+ CHECK(!ManagedDirectory::Open(chain, DirectoryPolicy::kPrivateTraversable, backend) && errno == EACCES);
+ }
+ CHECK(::chmod(chain.c_str(), 0711) == 0);
+ CHECK(!ManagedDirectory::Open(chain, DirectoryPolicy::kPrivate, backend));
+ auto root = ManagedDirectory::Open(f.root, DirectoryPolicy::kApprovedTree, backend);
+ CHECK(root);
+ auto traversable = root->OpenChild("chain", DirectoryPolicy::kPrivateTraversable);
+ CHECK(traversable && traversable->root() == chain);
+ CHECK(!root->OpenChild("chain", DirectoryPolicy::kPrivate) && errno == EACCES);
+
+ // Created 0711 or 0700 whatever the umask; other modes are refused before mkdir.
+ const auto previous = ::umask(077);
+ auto library = traversable->OpenChild("library", DirectoryPolicy::kPrivateTraversable, true, 0711);
+ CHECK(library && mode(chain / "library") == 0711 && library->root() == chain);
+ auto closed = traversable->OpenChild("closed", DirectoryPolicy::kPrivateTraversable, true, 0700);
+ CHECK(closed && mode(chain / "closed") == 0700);
+ CHECK(!traversable->OpenChild("wide", DirectoryPolicy::kPrivateTraversable, true, 0755) && errno == EINVAL);
+ CHECK(!traversable->OpenChild("wide", DirectoryPolicy::kPrivate, true, 0711) && errno == EINVAL);
+ CHECK(!fs::exists(chain / "wide"));
+ ::umask(previous);
+
+ // A traversable folder opens kPrivate children (exactly 0700) but no other policy.
+ auto profiles = library->OpenChild("profiles", DirectoryPolicy::kPrivate, true);
+ CHECK(profiles && mode(chain / "library/profiles") == 0700 && profiles->root() == chain);
+ CHECK(!library->OpenChild("public", DirectoryPolicy::kApprovedTree, true) && errno == EINVAL);
+ CHECK(!library->OpenChild("public", DirectoryPolicy::kUnownedTree, true) && errno == EINVAL);
+ CHECK(!fs::exists(chain / "library/public"));
+ // A kPrivate folder stays strict: no traversable child, even an existing 0711 one.
+ fs::create_directory(chain / "library/profiles/open");
+ CHECK(::chmod((chain / "library/profiles/open").c_str(), 0711) == 0);
+ CHECK(!profiles->OpenChild("open", DirectoryPolicy::kPrivateTraversable) && errno == EINVAL);
+ CHECK(!profiles->OpenChild("open", DirectoryPolicy::kPrivate) && errno == EACCES);
+ CHECK(!profiles->OpenChild("made", DirectoryPolicy::kPrivateTraversable, true, 0711));
+ CHECK(!fs::exists(chain / "library/profiles/made"));
+
+ // Mode drift is caught by Validate, also between the two admitted modes (identity).
+ CHECK(::chmod((chain / "library").c_str(), 0755) == 0);
+ CHECK(!library->Validate() && !profiles->Validate());
+ CHECK(!traversable->OpenChild("library", DirectoryPolicy::kPrivateTraversable) && errno == EACCES);
+ CHECK(::chmod((chain / "library").c_str(), 0700) == 0);
+ CHECK(!library->Validate());
+ auto reopened = traversable->OpenChild("library", DirectoryPolicy::kPrivateTraversable);
+ CHECK(reopened && reopened->Validate());
+
+ // Renames into a traversable folder admit 0700 or 0711 folders; into kPrivate, 0700 only.
+ CHECK(::chmod((chain / "closed").c_str(), 0711) == 0);
+ CHECK(::chmod((chain / "library").c_str(), 0711) == 0);
+ reopened = traversable->OpenChild("library", DirectoryPolicy::kPrivateTraversable);
+ auto private_profiles = reopened ? reopened->OpenChild("profiles", DirectoryPolicy::kPrivate) : std::nullopt;
+ CHECK(private_profiles);
+ CHECK(!traversable->RenameChild("closed", *private_profiles, "moved") && errno == EACCES);
+ CHECK(traversable->RenameChild("closed", *reopened, "game"));
+ CHECK(mode(chain / "library/game") == 0711);
+
+ if (::geteuid() == 0) { // Wrong owner, in privileged CI only.
+ fs::create_directory(f.root / "foreign");
+ CHECK(::chmod((f.root / "foreign").c_str(), 0711) == 0);
+ CHECK(::chown((f.root / "foreign").c_str(), 1, static_cast<gid_t>(-1)) == 0);
+ CHECK(!ManagedDirectory::Open(f.root / "foreign", DirectoryPolicy::kPrivateTraversable, backend));
+ CHECK(!root->OpenChild("foreign", DirectoryPolicy::kPrivateTraversable));
+ }
+}
}
// kUnownedTree is used for game folders on drives without owners or permissions.
@@ -211,6 +292,7 @@ int main() {
RejectPolicyAndIdentityDrift(backend, true);
RenameAdmission(backend);
ForeignOwnershipWhenPrivileged(backend);
+ PrivateTraversableAccepts0711Only(backend);
UnownedTreeOperations(backend);
}
std::printf("managed directory: %zu backends, identity, policy and file operations pass\n", backends.size());
diff --git a/tests/runtime_package_installer_test.cpp b/tests/runtime_package_installer_test.cpp
index f04bfcb..e4b5027 100644
--- a/tests/runtime_package_installer_test.cpp
+++ b/tests/runtime_package_installer_test.cpp
@@ -559,7 +559,9 @@ void CompletePublicationAndFreshInspection() {
"playden/games/install-hl2/library/prefixes/game";
CHECK(Read(bottle / "dosdevices/.pw-symlinks") == "c:\t../drive_c\nz:\t/\n");
CHECK(!std::filesystem::is_symlink(bottle / "dosdevices/c:"));
- for (const auto& path : {bottle, bottle / "drive_c", bottle / "drive_c/windows", bottle / "dosdevices"}) {
+ for (const auto& path : {bottle, bottle / "drive_c", bottle / "drive_c/windows", bottle / "dosdevices",
+ bottle / "drive_c/users", bottle.parent_path(), bottle.parent_path().parent_path(),
+ bottle.parent_path().parent_path().parent_path()}) {
struct stat info{};
CHECK(::lstat(path.c_str(), &info) == 0);
CHECK(info.st_uid == ::geteuid());
@@ -607,6 +609,217 @@ void CompletePublicationAndFreshInspection() {
CHECK(!installer.InspectOwnership(record).manifest_matches);
}
+unsigned ModeOf(const std::filesystem::path& path) {
+ struct stat info{};
+ CHECK(::lstat(path.c_str(), &info) == 0);
+ return static_cast<unsigned>(info.st_mode & 07777);
+}
+
+// With bottle-profile-shared the bottle's way to its user profile is 0711 (others pass through,
+// never list) and the profile itself is open to FTP (0777/0666). Playden's own checks admit
+// 0711 there whatever the kit; the other private folders stay 0700.
+void SharedProfileBottleModes() {
+ Fixture fixture;
+ Write(fixture.kit / "template/bottle/drive_c/users/prospero/Documents/kit.ini", "kit", 0644);
+ fixture.view.files.push_back({"template/bottle/drive_c/users/prospero/Documents/kit.ini", 3,
+ *TestHash(fixture.kit / "template/bottle/drive_c/users/prospero/Documents/kit.ini"), 0644});
+ auto record = Record();
+ record.artifacts = {{"runtime", "rev", fixture.view.artifacts[0].sha256},
+ {"recipe", "steam-220-hl2-v1-1", fixture.view.artifacts[1].sha256}};
+ auto installer = fixture.Installer();
+ installer.ShareBottleProfiles(true);
+ const auto game = fixture.host_data / "playden/games/install-hl2";
+ const auto bottle = game / "library/prefixes/game";
+ const auto profile = bottle / "drive_c/users/prospero";
+ // The title metadata makes the data root first, before there is a title: 0700, until the
+ // bottle (made after the title) settles it.
+ std::filesystem::create_directories(fixture.host_data);
+ const auto metadata = installer.WriteTitleMetadata(record, R"({"titleId":"FAKE78001"})", std::nullopt);
+ if (metadata.state != PackageActionState::kComplete) std::fprintf(stderr, "%s\n", metadata.message.c_str());
+ CHECK(metadata.state == PackageActionState::kComplete);
+ CHECK(ModeOf(game) == 0700 && ModeOf(game / "title-metadata") == 0700);
+ CHECK(installer.StageTitle(record).state == PackageActionState::kComplete);
+ CHECK(installer.CopyTemplate(record).state == PackageActionState::kComplete);
+ for (const auto& path : {game, game / "library", game / "library/prefixes", bottle, bottle / "drive_c",
+ bottle / "drive_c/users"})
+ CHECK(ModeOf(path) == 0711);
+ for (const auto& path : {bottle / "drive_c/windows", bottle / "dosdevices"}) CHECK(ModeOf(path) == 0700);
+ CHECK(ModeOf(bottle / "drive_c/windows/system.reg") == 0600);
+ for (const char* folder : {"", "AppData", "AppData/LocalLow", "AppData/Roaming", "Documents", "Saved Games"})
+ CHECK(ModeOf(profile / folder) == 0777);
+ CHECK(ModeOf(profile / "Documents/kit.ini") == 0666 && Read(profile / "Documents/kit.ini") == "kit");
+ CHECK(installer.ValidateArtifacts(record).state == PackageActionState::kComplete);
+ CHECK(installer.Inspect(record).mutable_bottle_owned);
+ // The linked verifier is the pinned kit's: one before bottle-profile-shared refuses a 0711 data
+ // root, so the publication is checked only where it admits one.
+ const auto published = installer.PublishProfile(record);
+ if (published.state == PackageActionState::kComplete) {
+ CHECK(installer.Inspect(record).profile_published);
+ } else {
+ CHECK(published.code == "publication-verification");
+ std::fprintf(stderr, "note: the linked publication verifier refuses 0711 bottles; publication not checked\n");
+ }
+ for (const auto& path : {game / ".playden-control", game / "library/profiles", game / "library/input"})
+ if (std::filesystem::exists(path)) CHECK(ModeOf(path) == 0700);
+
+ // Wine (umask 077) saves 0600 in 0700 folders; settling opens them again. Links are never
+ // followed, a file with another link (a private one linked in) is left alone, and the
+ // registry stays private.
+ Write(profile / "AppData/Roaming/Game/save.dat", "save", 0600);
+ CHECK(::chmod((profile / "AppData/Roaming/Game").c_str(), 0700) == 0);
+ Write(profile / "AppData/Roaming/Game/tool.exe", "tool", 0700);
+ Write(fixture.temporary.path / "outside/secret", "secret", 0600);
+ CHECK(::chmod((fixture.temporary.path / "outside").c_str(), 0700) == 0);
+ std::filesystem::create_directory_symlink(fixture.temporary.path / "outside", profile / "Desktop/outside");
+ std::filesystem::create_symlink(fixture.temporary.path / "outside/secret", profile / "Desktop/secret");
+ CHECK(::chmod((bottle / "user.reg").c_str(), 0600) == 0);
+ CHECK(::link((bottle / "user.reg").c_str(), (profile / "Documents/user.reg").c_str()) == 0);
+ fixture.logs.clear();
+ CHECK(installer.SettleBottleModes(record).state == PackageActionState::kComplete);
+ CHECK(ModeOf(profile / "Documents/user.reg") == 0600);
+ CHECK(std::any_of(fixture.logs.begin(), fixture.logs.end(),
+ [](const std::string& line) { return line.find(" linked=1 ") != std::string::npos; }));
+ CHECK(::unlink((profile / "Documents/user.reg").c_str()) == 0);
+ CHECK(ModeOf(profile / "AppData/Roaming/Game") == 0777);
+ CHECK(ModeOf(profile / "AppData/Roaming/Game/save.dat") == 0666);
+ CHECK(ModeOf(profile / "AppData/Roaming/Game/tool.exe") == 0766); // execute bits kept
+ CHECK(ModeOf(fixture.temporary.path / "outside") == 0700 && ModeOf(fixture.temporary.path / "outside/secret") == 0600);
+ CHECK(ModeOf(bottle / "user.reg") == 0600 && ModeOf(game / "title-metadata") == 0700);
+
+ // A kit without the capability admits only 0700: Repair puts the way back, and leaves the
+ // profile (no kit checks below the bottle) as the player had it.
+ auto strict = fixture.Installer();
+ CHECK(strict.Inspect(record).mutable_bottle_owned);
+ CHECK(strict.RepairBottle(record).state == PackageActionState::kComplete);
+ for (const auto& path : {game, game / "library", game / "library/prefixes", bottle, bottle / "drive_c",
+ bottle / "drive_c/users"})
+ CHECK(ModeOf(path) == 0700);
+ CHECK(ModeOf(profile) == 0777 && ModeOf(profile / "AppData/Roaming/Game/save.dat") == 0666);
+ // A 0700 bottle (made before the capability) opens on Repair with the capable kit.
+ CHECK(installer.RepairBottle(record).state == PackageActionState::kComplete);
+ CHECK(ModeOf(game) == 0711 && ModeOf(bottle / "drive_c/users") == 0711);
+ // Other modes on the way are not private: refused, never chmodded.
+ CHECK(::chmod((game / "library").c_str(), 0755) == 0);
+ CHECK(installer.SettleBottleModes(record).code == "repair-ownership");
+ CHECK(ModeOf(game / "library") == 0755);
+}
+
+// The console walks by path: the same profile opens, a hard link stays private, and a folder
+// swapped for another mid-walk (its path names something else) ends the walk there.
+void SharedTreeWalksByPath() {
+ TemporaryDirectory temporary;
+ const auto root = temporary.path / "profile";
+ Write(root / "AppData/Roaming/Game/save.dat", "save", 0600);
+ Write(root / "Documents/notes.txt", "notes", 0600);
+ Write(temporary.path / "private/secret", "secret", 0600);
+ CHECK(::link((temporary.path / "private/secret").c_str(), (root / "Documents/secret").c_str()) == 0);
+ SharedTreeOptions options;
+ options.by_path = true;
+ auto opened = OpenTreeToEveryone(root, options);
+ CHECK(opened.ok && !opened.changed_under && opened.linked == 1);
+ CHECK(ModeOf(root / "AppData/Roaming/Game") == 0777 && ModeOf(root / "AppData/Roaming/Game/save.dat") == 0666);
+ CHECK(ModeOf(root / "Documents/notes.txt") == 0666 && ModeOf(temporary.path / "private/secret") == 0600);
+
+ // Documents is moved away (and an outside folder put in its place) while the walk is in it.
+ Write(root / "Documents/later.txt", "later", 0600);
+ Write(temporary.path / "outside/inside.txt", "outside", 0600);
+ for (const auto& folder : {root / "Documents", temporary.path / "outside"}) CHECK(::chmod(folder.c_str(), 0700) == 0);
+ bool swapped = false;
+ options.before_open = [&](const std::filesystem::path& entry) {
+ if (swapped || entry.parent_path() != root / "Documents") return;
+ swapped = true;
+ std::filesystem::rename(root / "Documents", temporary.path / "moved-documents");
+ std::filesystem::rename(temporary.path / "outside", root / "Documents");
+ };
+ opened = OpenTreeToEveryone(root, options);
+ CHECK(swapped && !opened.ok && opened.changed_under);
+ CHECK(ModeOf(root / "Documents") == 0700 && ModeOf(root / "Documents/inside.txt") == 0600);
+
+ // Folder by folder (OpenGameFolders): a link component is refused, whatever it points at.
+ std::filesystem::create_directories(temporary.path / "game/bin");
+ std::filesystem::create_directory_symlink(temporary.path / "game/bin", temporary.path / "game/link");
+ const int game = OpenFolderNoFollow(temporary.path / "game");
+ CHECK(game >= 0);
+ for (const bool by_path : {true, false}) {
+ if (!by_path && !DescriptorRelativeOpens()) continue; // the console's build has no *at calls
+ errno = 0;
+ CHECK(OpenChildFolderNoFollow(game, temporary.path / "game", "link", by_path) < 0 && errno == ELOOP);
+ const int bin = OpenChildFolderNoFollow(game, temporary.path / "game", "bin", by_path);
+ CHECK(bin >= 0);
+ if (bin >= 0) ::close(bin);
+ }
+ if (game >= 0) ::close(game);
+ errno = 0;
+ CHECK(OpenFolderNoFollow(temporary.path / "game/link") < 0 && errno == ELOOP);
+}
+
+// Titles keep the shell they were made with after a kit swap: an older shell admits only a
+// 0700 way to the profile, so a capable kit settles a title it did not make to 0700, and to
+// 0711 once Update made the title its own.
+void SharedProfileWaitsForCurrentTitle() {
+ Fixture fixture;
+ std::filesystem::create_directories(fixture.host_data);
+ auto record = Record();
+ for (const auto& artifact : fixture.view.artifacts)
+ record.artifacts.push_back({artifact.artifact_id, artifact.identity, artifact.sha256});
+ const auto game = fixture.host_data / "playden/games/install-hl2";
+ const auto bottle = game / "library/prefixes/game";
+ const auto way = {game, game / "library", game / "library/prefixes", bottle, bottle / "drive_c", bottle / "drive_c/users"};
+ {
+ auto installer = fixture.Installer();
+ CHECK(installer.WriteTitleMetadata(record, R"({"titleId":"FAKE78001"})", std::nullopt).state ==
+ PackageActionState::kComplete);
+ CHECK(installer.StageTitle(record).state == PackageActionState::kComplete);
+ CHECK(installer.CopyTemplate(record).state == PackageActionState::kComplete);
+ }
+ for (const auto& path : way) CHECK(ModeOf(path) == 0700);
+ Write(bottle / "drive_c/users/prospero/Documents/save.dat", "save", 0600);
+ // The respun kit has bottle-profile-shared; the title is the old kit's.
+ Write(fixture.kit / "titles/variant/eboot.bin", "shared-profile-shell", 0755);
+ for (auto& file : fixture.view.files)
+ if (file.path == "titles/variant/eboot.bin") {
+ file.size = std::string("shared-profile-shell").size();
+ file.sha256 = *TestHash(fixture.kit / file.path);
+ }
+ fixture.view.files_sha256 = std::string(64, 'b');
+ auto capable = fixture.Installer();
+ capable.ShareBottleProfiles(true);
+ CHECK(!capable.TitleCurrent(record));
+ CHECK(capable.SettleBottleModes(record).state == PackageActionState::kComplete);
+ CHECK(capable.RepairBottle(record).state == PackageActionState::kComplete);
+ CHECK(capable.CopyTemplate(record).state == PackageActionState::kComplete);
+ for (const auto& path : way) CHECK(ModeOf(path) == 0700);
+ CHECK(ModeOf(bottle / "drive_c/users/prospero/Documents/save.dat") == 0600);
+ // A 0711 way left by the capable kit before a downgrade goes back to 0700 for the old shell.
+ CHECK(::chmod(game.c_str(), 0711) == 0);
+ CHECK(capable.SettleBottleModes(record).state == PackageActionState::kComplete && ModeOf(game) == 0700);
+ // Update refreshes the title from this kit; the next settle opens the way and the profile.
+ const auto refreshed = capable.RefreshTitle(record);
+ if (refreshed.state != PackageActionState::kComplete) std::fprintf(stderr, "refresh: %s\n", refreshed.message.c_str());
+ CHECK(refreshed.state == PackageActionState::kComplete && capable.TitleCurrent(record));
+ CHECK(capable.SettleBottleModes(record).state == PackageActionState::kComplete);
+ for (const auto& path : way) CHECK(ModeOf(path) == 0711);
+ CHECK(ModeOf(bottle / "drive_c/users/prospero/Documents/save.dat") == 0666);
+}
+
+// Without the capability every folder Playden makes in the bottle is 0700, as before.
+void UnsharedBottleStaysPrivate() {
+ Fixture fixture;
+ auto installer = fixture.Installer();
+ const auto record = Record();
+ CHECK(installer.CopyTemplate(record).state == PackageActionState::kComplete);
+ const auto game = fixture.host_data / "playden/games/install-hl2";
+ const auto bottle = game / "library/prefixes/game";
+ for (const auto& path : {game, game / "library", game / "library/prefixes", bottle, bottle / "drive_c",
+ bottle / "drive_c/users", bottle / "drive_c/users/prospero",
+ bottle / "drive_c/users/prospero/AppData/Roaming"})
+ CHECK(ModeOf(path) == 0700);
+ Write(bottle / "drive_c/users/prospero/Documents/save.dat", "save", 0600);
+ CHECK(installer.SettleBottleModes(record).state == PackageActionState::kComplete);
+ CHECK(installer.RepairBottle(record).state == PackageActionState::kComplete);
+ CHECK(ModeOf(bottle / "drive_c/users/prospero/Documents/save.dat") == 0600 && ModeOf(game) == 0700);
+}
+
void CancelAndSpaceFailuresAreBounded() {
Fixture fixture;
auto record = Record();
@@ -1226,6 +1439,10 @@ int main() {
CommittedReceiptIsRequired();
LegacyDescriptorOnlyBindsHistoricalRoot();
CompletePublicationAndFreshInspection();
+ SharedProfileBottleModes();
+ UnsharedBottleStaysPrivate();
+ SharedTreeWalksByPath();
+ SharedProfileWaitsForCurrentTitle();
CancelAndSpaceFailuresAreBounded();
UnreadableFreeSpaceRequiresExplicitMode();
SyncFailureNeverPublishesWatchedTitle();
diff --git a/tests/runtime_private_directories_native_policy_test.cpp b/tests/runtime_private_directories_native_policy_test.cpp
index 4a3f525..0ef307b 100644
--- a/tests/runtime_private_directories_native_policy_test.cpp
+++ b/tests/runtime_private_directories_native_policy_test.cpp
@@ -36,6 +36,60 @@ void CreatedPublicAncestorsAreShared(const fs::path& boundary) {
umask(previous);
}
+// The bottle's way to its user profile (games/<id>, library, prefixes, game) may
+// be 0711; the rest of the tree, and anything not asked for, stays 0700.
+void TraversalChainAdmits0711(const fs::path& boundary) {
+ using playden::runtime::EnsurePrivateDirectories;
+ using playden::runtime::IsPrivateDirectoryTree;
+ using playden::runtime::PrivateTraversal;
+ const auto mode = [](const fs::path& path) {
+ struct stat info{};
+ assert(stat(path.c_str(), &info) == 0);
+ return info.st_mode & 07777;
+ };
+ const auto previous = umask(077);
+ const auto game = boundary / "playden/games/install-a";
+ const auto bottle = game / "library/prefixes/game";
+ PrivateTraversal traversal{{game, game / "library", game / "library/prefixes", bottle}, 0711};
+ std::string error;
+ assert(EnsurePrivateDirectories(boundary, game, bottle / "drive_c/users", &error, traversal));
+ assert(EnsurePrivateDirectories(boundary, game, game / "library/profiles", &error, traversal));
+ assert(EnsurePrivateDirectories(boundary, game, game / ".playden-control", &error, traversal));
+ assert(mode(boundary / "playden") == 0777 && mode(boundary / "playden/games") == 0777);
+ for (const auto& folder : traversal.folders) assert(mode(folder) == 0711);
+ assert(mode(bottle / "drive_c") == 0700 && mode(bottle / "drive_c/users") == 0700);
+ assert(mode(game / "library/profiles") == 0700 && mode(game / ".playden-control") == 0700);
+ assert(IsPrivateDirectoryTree(game, bottle / "drive_c/users", traversal));
+ assert(IsPrivateDirectoryTree(game, game / ".playden-control", traversal));
+ assert(playden::runtime::IsPrivateDirectory(bottle, true) && !playden::runtime::IsPrivateDirectory(bottle));
+ // Without the traversal, the 0711 chain is refused as before.
+ assert(!IsPrivateDirectoryTree(game, bottle));
+ assert(!EnsurePrivateDirectories(boundary, game, bottle, &error));
+ // 0700 still passes for a traversal folder (a bottle from an older kit).
+ assert(chmod((game / "library/prefixes").c_str(), 0700) == 0);
+ assert(IsPrivateDirectoryTree(game, bottle, traversal));
+ // 0755 is refused on the chain; 0711 is refused off it.
+ assert(chmod((game / "library").c_str(), 0755) == 0);
+ assert(!IsPrivateDirectoryTree(game, bottle, traversal));
+ assert(!EnsurePrivateDirectories(boundary, game, bottle, &error, traversal));
+ assert(chmod((game / "library").c_str(), 0711) == 0);
+ assert(chmod((game / "library/profiles").c_str(), 0711) == 0);
+ assert(!IsPrivateDirectoryTree(game, game / "library/profiles", traversal));
+ assert(chmod((game / "library/profiles").c_str(), 0700) == 0);
+ assert(chmod((bottle / "drive_c").c_str(), 0711) == 0);
+ assert(!IsPrivateDirectoryTree(game, bottle / "drive_c/users", traversal));
+ // With created_mode 0700 (kit without the capability), new traversal folders are 0700.
+ const auto other = boundary / "playden/games/install-b";
+ const auto other_bottle = other / "library/prefixes/game";
+ PrivateTraversal closed{{other, other / "library", other / "library/prefixes", other_bottle}};
+ assert(EnsurePrivateDirectories(boundary, other, other_bottle, &error, closed));
+ assert(mode(other) == 0700 && mode(other_bottle) == 0700);
+ assert(IsPrivateDirectoryTree(other, other_bottle) && IsPrivateDirectoryTree(other, other_bottle, closed));
+ closed.created_mode = 0755;
+ assert(!EnsurePrivateDirectories(boundary, other, other_bottle, &error, closed));
+ umask(previous);
+}
+
int main() {
char scratch[] = "/tmp/playden-private-policy-XXXXXX";
const char* made = mkdtemp(scratch);
@@ -56,6 +110,7 @@ int main() {
assert(!fs::exists(boundary / "child"));
assert(!playden::runtime::EnsurePrivateDirectories(boundary, root, root / "../outside", &error));
CreatedPublicAncestorsAreShared(boundary);
+ TraversalChainAdmits0711(boundary);
fs::remove_all(boundary);
std::cout << "private directory callers pass with native relative operations unavailable\n";
}
diff --git a/tests/runtime_settings_publication_test.cpp b/tests/runtime_settings_publication_test.cpp
index fb99b68..510763c 100644
--- a/tests/runtime_settings_publication_test.cpp
+++ b/tests/runtime_settings_publication_test.cpp
@@ -1127,5 +1127,49 @@ int main() {
if (!remove) CHECK(stat(t.DxvkPath().c_str(), &info) == 0 && (info.st_mode & 07777) == 0644);
CHECK(LoadSettingsPublicationOperation(t.control).operation->dxvk_before.bytes == shipped);
}
+ // A Ready update at the same revision only replaces an owned publication (schema 2) when the
+ // kit admits unowned game folders: one already unowned (or a game that did not move, with a
+ // kit that doesn't) is refused before anything is written.
+ {
+ Test t; const auto owner_root = t.root / "owner"; fs::create_directory(owner_root); CHECK(chmod(owner_root.c_str(), 0700) == 0);
+ const auto requests = t.root / "requests"; fs::create_directory(requests); CHECK(chmod(requests.c_str(), 0700) == 0);
+ playden::Storage storage(owner_root.string());
+ auto availability = [](const std::string&) { return NativeTitleAvailability{TitleAvailability::kFree, TitleAvailability::kFree}; };
+ RuntimeInstallRepository repository(storage, "installs.json", availability); SeedOwner(repository, t.operation.install, false);
+ auto ready = *repository.Find(t.operation.install.install_id);
+ ready.state = PreparationState::kReady; ready.journal.reset(); ready.last_failure.reset();
+ CHECK(repository.Update(ready).ok());
+ RepositoryInstallRecordStore records(repository); OwnerPackage package; OwnerNative native; native.records = &records;
+ const auto profiles = t.paths.metadata.parent_path();
+ fs::create_directories(profiles); CHECK(chmod(profiles.c_str(), 0700) == 0);
+ const auto publish = [&](const std::string& bytes) {
+ { std::ofstream(t.paths.metadata, std::ios::trunc) << bytes; }
+ CHECK(chmod(t.paths.metadata.c_str(), 0600) == 0);
+ };
+ PwTitlePublicationMetadata unowned_metadata{};
+ CHECK(pw_title_publication_metadata_parse(reinterpret_cast<const uint8_t*>(t.operation.metadata_bytes.data()),
+ t.operation.metadata_bytes.size(), &unowned_metadata) == PW_OK);
+ CHECK(unowned_metadata.game_root_unowned == 0);
+ unowned_metadata.schema_version = 3; unowned_metadata.game_root_unowned = 1;
+ const auto unowned_bytes = SerializePublicationMetadata(unowned_metadata); CHECK(unowned_bytes);
+ SettingsPublicationRequest request;
+ request.transaction_id = "00000000-0000-7000-8000-000000000009"; request.kit_id = t.operation.kit_id;
+ request.install = ready; request.plan = t.operation.plan; request.registry_unix_time = 1760000000;
+ CHECK(request.plan.settings_revision == ready.settings_revision);
+ SettingsPublicationOwner capable(records, package, native, true, t.root);
+ publish(*unowned_bytes);
+ CHECK(PublishedGameRootUnowned(ready, t.root) == std::optional<bool>(true));
+ CHECK(capable.Request(request, requests).code == "publication-request-owner");
+ publish(t.operation.metadata_bytes);
+ CHECK(PublishedGameRootUnowned(ready, t.root) == std::optional<bool>(false));
+ SettingsPublicationOwner strict(records, package, native, false, t.root);
+ CHECK(strict.Request(request, requests).code == "publication-request-owner");
+ CHECK(!repository.Find(ready.install_id)->journal && fs::is_empty(requests));
+ // The owned one is published again as unowned: the request is armed.
+ const auto armed = capable.Request(request, requests);
+ if (armed.state != PackageActionState::kComplete) std::fprintf(stderr, "same-revision request: %s %s\n", armed.code.c_str(), armed.message.c_str());
+ CHECK(armed.state == PackageActionState::kComplete);
+ CHECK(repository.Find(ready.install_id)->journal->operation == "settings-request");
+ }
std::puts("settings publication coordinator tests passed");
}