# HG changeset patch # User bpb # Date 1554159585 25200 # Node ID 66185e52b979e5f5932b6bd41cd3d7799d87205c # Parent f15b5d110fbca1b52683ae58b1ce07dc75047384 8218418: (fs) Files.createSymbolicLink should use SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE (win) Reviewed-by: alanb diff -r f15b5d110fbc -r 66185e52b979 src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c --- a/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c Mon Apr 01 14:54:48 2019 -0700 +++ b/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c Mon Apr 01 15:59:45 2019 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1063,8 +1063,14 @@ LPCWSTR link = jlong_to_ptr(linkAddress); LPCWSTR target = jlong_to_ptr(targetAddress); - /* On Windows 64-bit this appears to succeed even when there is insufficient privileges */ - if (CreateSymbolicLinkW(link, target, (DWORD)flags) == 0) + // Allow creation of symbolic links when the process is not elevated. + // Developer Mode must be enabled for this option to function, otherwise + // it will be ignored. + DWORD dwFlags = (DWORD)flags | SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE; + + // On Windows 64-bit this appears to succeed even when there are + // insufficient privileges + if (CreateSymbolicLinkW(link, target, dwFlags) == 0) throwWindowsException(env, GetLastError()); }