diff --git a/client/client_state.cpp b/client/client_state.cpp index aee937f6d5..6e2450fb1a 100644 --- a/client/client_state.cpp +++ b/client/client_state.cpp @@ -262,7 +262,7 @@ void CLIENT_STATE::show_host_info() { } } } else { - msg_printf(NULL, MSG_INFO, "No WSL found."); + msg_printf(NULL, MSG_INFO, "WSL is not found or not allowed to be used. For more details see https://github.com/BOINC/boinc/wiki/Client-configuration"); } #endif @@ -280,13 +280,35 @@ void CLIENT_STATE::show_host_info() { } #endif } +#ifndef _WIN64 + if (host_info.docker_available && strlen(host_info.docker_version)) { + msg_printf(NULL, MSG_INFO, "Docker %s is installed and available", host_info.docker_version); +#else if (host_info.docker_available) { - msg_printf(NULL, MSG_INFO, "Docker is installed and available"); + msg_printf(NULL, MSG_INFO, "Docker is installed and available on next WSLs:"); + for (size_t i = 0; i < host_info.wsls.wsls.size(); ++i) { + const WSL& wsl = host_info.wsls.wsls[i]; + if (wsl.is_docker_available) { + msg_printf(NULL, MSG_INFO, " [%s]: Docker version is: %s", wsl.distro_name.c_str(), wsl.docker_version.c_str()); + } + } +#endif } else { msg_printf(NULL, MSG_INFO, "Docker is not installed or is not available for running task"); } +#ifndef _WIN64 + if (host_info.docker_compose_available && strlen(host_info.docker_compose_version)) { + msg_printf(NULL, MSG_INFO, "Docker compose %s is installed and available", host_info.docker_compose_version); +#else if (host_info.docker_compose_available) { - msg_printf(NULL, MSG_INFO, "Docker compose is installed and available"); + msg_printf(NULL, MSG_INFO, "Docker compose is installed and available on next WSLs:"); + for (size_t i = 0; i < host_info.wsls.wsls.size(); ++i) { + const WSL& wsl = host_info.wsls.wsls[i]; + if (wsl.is_docker_compose_available) { + msg_printf(NULL, MSG_INFO, " [%s]: Docker compose version is: %s", wsl.distro_name.c_str(), wsl.docker_compose_version.c_str()); + } + } +#endif } else { msg_printf(NULL, MSG_INFO, "Docker compose is not installed or is not available for running task"); } diff --git a/client/hostinfo_win.cpp b/client/hostinfo_win.cpp index 95a83d424e..a38cb26b87 100644 --- a/client/hostinfo_win.cpp +++ b/client/hostinfo_win.cpp @@ -1669,7 +1669,7 @@ int HOST_INFO::get_host_info(bool init) { if (!cc_config.dont_use_wsl) { OSVERSIONINFOEX osvi; if (get_OSVERSIONINFO(osvi) && osvi.dwMajorVersion >= 10) { - get_wsl_information(wsl_available, wsls, !cc_config.dont_use_docker, docker_available, docker_compose_available); + get_wsl_information(cc_config.allowed_wsls, wsl_available, wsls, !cc_config.dont_use_docker, docker_available, docker_compose_available); } } #endif diff --git a/client/hostinfo_wsl.cpp b/client/hostinfo_wsl.cpp index 9c80b62f33..66f2afb63f 100644 --- a/client/hostinfo_wsl.cpp +++ b/client/hostinfo_wsl.cpp @@ -20,7 +20,7 @@ #include "boinc_win.h" #include "str_replace.h" - +#include "client_msgs.h" #include "hostinfo.h" bool get_available_wsls(std::vector>& wsls, std::string& default_wsl) { @@ -262,7 +262,7 @@ void parse_sysctl_output(const std::vector& lines, std::string& ost // Returns the OS name and version for WSL when enabled // -int get_wsl_information(bool& wsl_available, WSLS& wsls, bool detect_docker, bool& docker_available, bool& docker_compose_available) { +int get_wsl_information(std::vector allowed_wsls, bool& wsl_available, WSLS& wsls, bool detect_docker, bool& docker_available, bool& docker_compose_available) { std::vector> distros; std::string default_distro; @@ -292,6 +292,12 @@ int get_wsl_information(bool& wsl_available, WSLS& wsls, bool detect_docker, boo if (distro == "docker-desktop-data"){ continue; } + // skip distros that are not allowed except for 'docker-desktop' + if (distro != "docker-desktop" && std::find(allowed_wsls.begin(), allowed_wsls.end(), distro) == allowed_wsls.end()) { + msg_printf(0, MSG_INFO, "WSL distro '%s' detected but is not allowed", distro.c_str()); + continue; + } + WSL wsl; wsl.distro_name = distro; if (distro == default_distro) { diff --git a/client/log_flags.cpp b/client/log_flags.cpp index 634344340f..128cecddb4 100644 --- a/client/log_flags.cpp +++ b/client/log_flags.cpp @@ -198,6 +198,11 @@ void CC_CONFIG::show() { if (dont_use_wsl) { msg_printf(NULL, MSG_INFO, "Config: don't use the Windows Subsystem for Linux"); } + for (i=0; i%s\n", + allowed_wsls[i].c_str() + ); + } + for (i=0; i allowed_wsls; bool dont_use_docker; std::vector exclude_gpus; std::vector exclusive_apps; diff --git a/lib/hostinfo.cpp b/lib/hostinfo.cpp index c5ce57ff97..c48c3fa349 100644 --- a/lib/hostinfo.cpp +++ b/lib/hostinfo.cpp @@ -372,6 +372,9 @@ bool HOST_INFO::get_docker_version_string(std::string raw, std::string& parsed) return false; } parsed = raw.substr(pos1 + prefix.size() + 1, pos2 - pos1 - prefix.size() - 1); + if (!parsed.empty() && parsed[parsed.length() - 1] == '\n') { + parsed.erase(parsed.length() - 1); + } return true; } bool HOST_INFO::get_docker_compose_version_string(std::string raw, std::string& parsed) { @@ -381,6 +384,9 @@ bool HOST_INFO::get_docker_compose_version_string(std::string raw, std::string& return false; } parsed = raw.substr(pos1 + prefix.size(), raw.size() - pos1 - prefix.size()); + if (!parsed.empty() && parsed[parsed.length() - 1] == '\n') { + parsed.erase(parsed.length() - 1); + } return true; } diff --git a/lib/hostinfo.h b/lib/hostinfo.h index d3c90a8bf7..5f4b361619 100644 --- a/lib/hostinfo.h +++ b/lib/hostinfo.h @@ -172,7 +172,7 @@ public: extern void make_secure_random_string(char*); #ifdef _WIN64 -extern int get_wsl_information(bool& wsl_available, WSLS& wsls, bool detect_docker, bool& docker_available, bool& docker_compose_available); +extern int get_wsl_information(std::vector allowed_wsls, bool& wsl_available, WSLS& wsls, bool detect_docker, bool& docker_available, bool& docker_compose_available); extern int get_processor_group(HANDLE); #endif