mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-19 11:13:02 +08:00
[vcpkg-test] Fix the check for ability to make symlinks (#10543)
The old check checked to see if the computer was in developer mode _OR_ allowed sideloading apps, but we want _only_ developer mode.
This commit is contained in:
parent
47a4913834
commit
1448db9d6f
@ -65,8 +65,6 @@ namespace
|
|||||||
Width width = Width{5},
|
Width width = Width{5},
|
||||||
CurrentDepth current_depth = CurrentDepth{0})
|
CurrentDepth current_depth = CurrentDepth{0})
|
||||||
{
|
{
|
||||||
std::random_device rd;
|
|
||||||
|
|
||||||
// we want ~70% of our "files" to be directories, and then a third
|
// we want ~70% of our "files" to be directories, and then a third
|
||||||
// each of the remaining ~30% to be regular files, directory symlinks,
|
// each of the remaining ~30% to be regular files, directory symlinks,
|
||||||
// and regular symlinks
|
// and regular symlinks
|
||||||
@ -132,7 +130,7 @@ namespace
|
|||||||
CHECK_EC_ON_FILE(base_link, ec);
|
CHECK_EC_ON_FILE(base_link, ec);
|
||||||
vcpkg::Test::create_symlink(base_link, base, ec);
|
vcpkg::Test::create_symlink(base_link, base, ec);
|
||||||
}
|
}
|
||||||
else // type == directory_symlink_tag
|
else // file_type == directory_symlink_tag
|
||||||
{
|
{
|
||||||
// directory symlink
|
// directory symlink
|
||||||
auto parent = base;
|
auto parent = base;
|
||||||
|
@ -114,21 +114,21 @@ namespace vcpkg::Test
|
|||||||
#elif !defined(_WIN32) // FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_STD
|
#elif !defined(_WIN32) // FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_STD
|
||||||
return AllowSymlinks::Yes;
|
return AllowSymlinks::Yes;
|
||||||
#else
|
#else
|
||||||
HKEY key;
|
constexpr static const wchar_t regkey[] =
|
||||||
bool allow_symlinks = true;
|
LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock)";
|
||||||
|
constexpr static const wchar_t regkey_member[] = LR"(AllowDevelopmentWithoutDevLicense)";
|
||||||
|
|
||||||
const auto status = RegOpenKeyExW(
|
DWORD data;
|
||||||
HKEY_LOCAL_MACHINE, LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock)", 0, 0, &key);
|
DWORD dataSize = sizeof(data);
|
||||||
|
const auto status = RegGetValueW(
|
||||||
|
HKEY_LOCAL_MACHINE, regkey, regkey_member, RRF_RT_DWORD, nullptr, &data, &dataSize);
|
||||||
|
|
||||||
if (status == ERROR_FILE_NOT_FOUND)
|
if (status == ERROR_SUCCESS && data == 1) {
|
||||||
{
|
return AllowSymlinks::Yes;
|
||||||
allow_symlinks = false;
|
} else {
|
||||||
std::clog << "Symlinks are not allowed on this system\n";
|
std::clog << "Symlinks are not allowed on this system\n";
|
||||||
|
return AllowSymlinks::No;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == ERROR_SUCCESS) RegCloseKey(key);
|
|
||||||
|
|
||||||
return allow_symlinks ? AllowSymlinks::Yes : AllowSymlinks::No;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
const static AllowSymlinks CAN_CREATE_SYMLINKS = internal_can_create_symlinks();
|
const static AllowSymlinks CAN_CREATE_SYMLINKS = internal_can_create_symlinks();
|
||||||
|
Loading…
Reference in New Issue
Block a user