diff options
author | Tony Cook <tony@develop-help.com> | 2020-10-15 11:21:31 +1100 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2020-12-01 15:29:33 +1100 |
commit | 17ab6b6399dbe07e478478e9eba9aeb345eab2ed (patch) | |
tree | 248844c1e9d630258c421afc9bc035e872883445 /win32 | |
parent | 690ab4ba4bc90fa2f43c03eb418c3dc163f57ea8 (diff) | |
download | perl-17ab6b6399dbe07e478478e9eba9aeb345eab2ed.tar.gz |
win32 symlink: only use the unprivileged flag if windows is new enough
Diffstat (limited to 'win32')
-rw-r--r-- | win32/win32.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/win32/win32.c b/win32/win32.c index 1046f6cfd5..8cbe4dad92 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -3432,7 +3432,15 @@ win32_symlink(const char *oldfile, const char *newfile) char szTargetName[MAX_PATH+1]; size_t oldfile_len = strlen(oldfile); DWORD dest_attr; - DWORD create_flags = SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE; + DWORD create_flags = 0; + + /* this flag can be used only on Windows 10 1703 or newer */ + if (g_osver.dwMajorVersion > 10 || + (g_osver.dwMajorVersion == 10 && + (g_osver.dwMinorVersion > 0 || g_osver.dwBuildNumber > 15063))) + { + create_flags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE; + } /* oldfile might be relative and we don't want to change that, so don't map that. |