restoration_unlock(lock_fd);
}
+static void remount_image_sessions(int uid) try
+{
+ const auto subsessions = get_user_list(uid);
+
+ std::string_view prev = SUBSESSION_INITIAL_SID;
+ for (const auto &subsession : subsessions) {
+
+ /* A bit of a hack. This doesn't actually perform
+ * a switch (no D-Bus events etc) but happens to do
+ * all the needed work (detect backend, remount). */
+ switch_user_subsession(uid, prev, subsession);
+
+ prev = subsession;
+ }
+ switch_user_subsession(uid, prev, SUBSESSION_INITIAL_SID);
+} catch (const std::exception& ex) {
+ LOGE("Could not remount image-based subsessions uid %d: %s", uid, ex.what());
+ throw;
+}
+
void restore_all_user_sessions()
{
/* In theory this should live among OS or FS helpers, but
continue;
}
+ /* We rely on all image-based subsessions being mounted to
+ * make sure that external updates (e.g. when packages are
+ * installed) are correctly reflected in existing subsessions. */
+ LOGI("Remounting image-based subsessions for user %s (uid %d)", username.c_str(), uid);
+ remount_image_sessions(uid);
+
LOGI("Restoring last session for user %s (uid %d)", username.c_str(), uid);
restore_user_session(username, uid);
}