diff --git a/steam-runtime-tools/steam.c b/steam-runtime-tools/steam.c index 819fa0f671907cdd8e62c4e30c1bfe05a1e6fac0..603c14fa11b476e4e3ad002a555e2d0ae6f1470b 100644 --- a/steam-runtime-tools/steam.c +++ b/steam-runtime-tools/steam.c @@ -391,6 +391,7 @@ _srt_steam_check (const GStrv my_environ, const char *commandline = NULL; const char *executable = NULL; const char *app_id = NULL; + const char *steam_compat_client_install_path = NULL; gboolean in_flatpak = FALSE; GStrv env = NULL; GError *error = NULL; @@ -693,6 +694,24 @@ _srt_steam_check (const GStrv my_environ, } } + steam_compat_client_install_path = g_environ_getenv (env, "STEAM_COMPAT_CLIENT_INSTALL_PATH"); + /* Is not an issue if STEAM_COMPAT_CLIENT_INSTALL_PATH is missing */ + if (steam_compat_client_install_path != NULL) + { + /* We expect STEAM_COMPAT_CLIENT_INSTALL_PATH to be equivalent to + * "~/.steam/root" */ + g_autofree gchar *steam_compat_resolved = realpath (steam_compat_client_install_path, NULL); + g_autofree gchar *dot_steam_root_resolved = realpath (dot_steam_root, NULL); + if (g_strcmp0 (steam_compat_resolved, dot_steam_root_resolved) != 0) + { + g_debug ("\"STEAM_COMPAT_CLIENT_INSTALL_PATH\" points to \"%s\", " + "that is different from the expected \"%s\" pointed by " + "\"~/.steam/root\"", steam_compat_resolved, + dot_steam_root_resolved); + issues |= SRT_STEAM_ISSUES_UNEXPECTED_STEAM_COMPAT_CLIENT_INSTALL_PATH; + } + } + steam_script_version = g_environ_getenv (env, "STEAMSCRIPT_VERSION"); if (more_details_out != NULL) diff --git a/steam-runtime-tools/steam.h b/steam-runtime-tools/steam.h index 68fa5ad509e7cba8aa1b6d82c45e246cba409108..4b42bfbb3d247182dfee9243ac74783d79bdec6d 100644 --- a/steam-runtime-tools/steam.h +++ b/steam-runtime-tools/steam.h @@ -88,6 +88,9 @@ GType srt_steam_get_type (void); * one `STEAMSCRIPT` points to. * @SRT_STEAM_ISSUES_UNEXPECTED_STEAM_DESKTOP_ID: The default Steam desktop * application ID is not what we expected. + * @SRT_STEAM_ISSUES_UNEXPECTED_STEAM_COMPAT_CLIENT_INSTALL_PATH: If the + * environment `STEAM_COMPAT_CLIENT_INSTALL_PATH` is set, its realpath() is + * not the equivalent of `~/.steam/root`. * @SRT_STEAM_ISSUES_UNKNOWN: The Steam problems are not known * * A bitfield with flags representing problems with the Steam @@ -109,6 +112,7 @@ typedef enum SRT_STEAM_ISSUES_MISSING_STEAM_URI_HANDLER = (1 << 8), SRT_STEAM_ISSUES_UNEXPECTED_STEAM_URI_HANDLER = (1 << 9), SRT_STEAM_ISSUES_UNEXPECTED_STEAM_DESKTOP_ID = (1 << 10), + SRT_STEAM_ISSUES_UNEXPECTED_STEAM_COMPAT_CLIENT_INSTALL_PATH = (1 << 11), SRT_STEAM_ISSUES_NONE = 0 } SrtSteamIssues; diff --git a/tests/system-info.c b/tests/system-info.c index 8a9facc03093cbf8a49a8e275403c02f45d9bef0..aaab1794cb63e6472c344e84d0c3912fd582d15b 100644 --- a/tests/system-info.c +++ b/tests/system-info.c @@ -1214,6 +1214,57 @@ steam_symlink (Fixture *f, g_free (ubuntu12_32); } +static void +steam_compat_environment_variable (Fixture *f, + gconstpointer context) +{ + g_autoptr(SrtSystemInfo) info = NULL; + SrtSteamIssues issues; + g_autofree gchar *dot_steam_root = NULL; + g_autofree gchar *dot_steam_root_resolved = NULL; + g_autofree gchar *dot_steam_bin32 = NULL; + FakeHome *fake_home; + + fake_home = fake_home_new (fake_home_path); + fake_home_create_structure (fake_home); + + info = srt_system_info_new (NULL); + dot_steam_root = g_build_filename (fake_home->home, ".steam", "root", NULL); + dot_steam_bin32 = g_build_filename (fake_home->home, ".steam", "bin32", NULL); + + fake_home->env = g_environ_unsetenv (fake_home->env, + "STEAM_COMPAT_CLIENT_INSTALL_PATH"); + fake_home_apply_to_system_info (fake_home, info); + issues = srt_system_info_get_steam_issues (info); + g_assert_cmpint (issues, ==, SRT_STEAM_ISSUES_NONE); + + fake_home->env = g_environ_setenv (fake_home->env, + "STEAM_COMPAT_CLIENT_INSTALL_PATH", + dot_steam_root, TRUE); + fake_home_apply_to_system_info (fake_home, info); + issues = srt_system_info_get_steam_issues (info); + g_assert_cmpint (issues, ==, SRT_STEAM_ISSUES_NONE); + + dot_steam_root_resolved = realpath (dot_steam_root, NULL); + fake_home->env = g_environ_setenv (fake_home->env, + "STEAM_COMPAT_CLIENT_INSTALL_PATH", + dot_steam_root_resolved, TRUE); + fake_home_apply_to_system_info (fake_home, info); + issues = srt_system_info_get_steam_issues (info); + g_assert_cmpint (issues, ==, SRT_STEAM_ISSUES_NONE); + + /* Set STEAM_COMPAT_CLIENT_INSTALL_PATH to an unexpected value */ + fake_home->env = g_environ_setenv (fake_home->env, + "STEAM_COMPAT_CLIENT_INSTALL_PATH", + dot_steam_bin32, TRUE); + fake_home_apply_to_system_info (fake_home, info); + issues = srt_system_info_get_steam_issues (info); + g_assert_cmpint (issues, ==, + SRT_STEAM_ISSUES_UNEXPECTED_STEAM_COMPAT_CLIENT_INSTALL_PATH); + + fake_home_clean_up (fake_home); +} + /* Recreate the conditions that triggered the Debian bug 916303. * Steam was installed into "~/.steam", which meant that the "steam/" * directory inside the Steam installation collided with the "~/.steam/steam" @@ -3707,6 +3758,8 @@ main (int argc, setup, runtime_unexpected_location, teardown); g_test_add ("/system-info/steam_symlink", Fixture, NULL, setup, steam_symlink, teardown); + g_test_add ("/system-info/steam_compat_environment_variable", Fixture, NULL, + setup, steam_compat_environment_variable, teardown); g_test_add ("/system-info/debian_bug_916303", Fixture, NULL, setup, debian_bug_916303, teardown); g_test_add ("/system-info/testing_beta_client", Fixture, NULL,