Report if (i) we have the symlink creation privilege, and (ii) if developer mode is on, so unprivileged symlink creation is allowed. --- nio-ie5.cc | 12 +++++++++++- win32.cc | 18 ++++++++++++++++++ win32.h | 1 + 3 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/nio-ie5.cc b/nio-ie5.cc index e93d6d4..8fd7008 100644 --- a/nio-ie5.cc +++ b/nio-ie5.cc @@ -89,7 +89,17 @@ determine_default_useragent(void) langid << std::hex << std::setw(4) << std::setfill('0') << l; } - default_useragent = std::string("Cygwin-Setup/") + setup_version + " (" + os.str() + ";" + bitness + ";" + langid.str() + ")"; + std::string symlinks = ""; + if (nt_sec.hasSymlinkCreationRights()) + symlinks.append("SymLinkPriv"); + if (is_developer_mode()) + { + if (!symlinks.empty()) + symlinks.append("+"); + symlinks.append("UnprivilegedSymLink"); + } + + default_useragent = std::string("Cygwin-Setup/") + setup_version + " (" + os.str() + ";" + bitness + ";" + langid.str() + ";" + symlinks + ")"; Log (LOG_BABBLE) << "User-Agent: default is \"" << default_useragent << "\"" << endLog; return default_useragent; diff --git a/win32.cc b/win32.cc index 6455384..db79fd7 100644 --- a/win32.cc +++ b/win32.cc @@ -492,3 +492,21 @@ LoadStringW(unsigned int uID) return L""; } + +bool +is_developer_mode(void) +{ + HKEY hKey; + LSTATUS err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\AppModelUnlock", 0, KEY_READ, &hKey); + if (err != ERROR_SUCCESS) + return false; + + DWORD value; + DWORD size = sizeof(DWORD); + err = RegQueryValueExW(hKey, L"AllowDevelopmentWithoutDevLicense", NULL, NULL, reinterpret_cast<LPBYTE>(&value), &size); + RegCloseKey(hKey); + if (err != ERROR_SUCCESS) + return false; + + return value != 0; +} diff --git a/win32.h b/win32.h index e498077..5874d8b 100644 --- a/win32.h +++ b/win32.h @@ -196,5 +196,6 @@ SetDlgItemRect (HWND h, int item, LPRECT r) } const std::wstring LoadStringW(unsigned int uID); +bool is_developer_mode(void); #endif /* SETUP_WIN32_H */ -- 2.32.0