diff --git a/src/basic/virt.c b/src/basic/virt.c index 07831634da..f567696265 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -462,13 +462,14 @@ int detect_container(void) { goto finish; } - /* "Official" way of detecting WSL https://github.com/Microsoft/WSL/issues/423#issuecomment-221627364 */ + /* "Official" way of detecting WSL https://github.com/Microsoft/WSL/issues/423#issuecomment-221627364, + * ... and a working one, since the official one doesn't actually work ;( + */ r = read_one_line_file("/proc/sys/kernel/osrelease", &o); - if (r >= 0) { - if (strstr(o, "Microsoft") || strstr(o, "WSL")) { - r = VIRTUALIZATION_WSL; - goto finish; - } + if (r >= 0 && + (strstr(o, "Microsoft") || strstr(o, "microsoft") || strstr(o, "WSL"))) { + r = VIRTUALIZATION_WSL; + goto finish; } if (getpid_cached() == 1) {