8221852: SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE should be selected at runtime, not build time
Brian Burkhalter
brian.burkhalter at oracle.com
Fri Apr 5 00:46:11 UTC 2019
Whether SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE can be selected at runtime is not necessarily feasible using only the major and minor version numbers of Windows. If the major version is 10 and the minor version is 0 then the build number is also needed. The necessary logic is
if (majorVersion > 10
|| (majorVersion == 10 && (minorVersion > 0 || buildNumber >= 14972))) {
flags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
}
Unfortunately the build number is not stored at either the Java or native level. There appear to be at least four approaches to solve the problem.
1. Propagate the build number to the Java level and put the logic there [1].
2. Handle the availability of the flag via exceptions in native code [2].
3. Obtain the build number in the native level and put the logic there [patch not developed].
4. Revert the modified code to the revision level just before the patch for JDK-8218418 was applied.
The patch for option 3 would likely require a new getVersionAndBuild() native method derived from the property initialization Windows native code which could itself be refactored to use it.
The patches for options 1 and 2 have been tested on Windows 7, Windows Server 2016 (build 14393), and Windows 10 with, on the latter two platforms, Developer Mode both off and on. In all cases both patches exhibited the same desired and expected behavior.
In patch [1], I am aware that SystemProps.java line 235 is out of order, and that lines 930-941 in WindowsNativeDispatcher.java could be more efficient.
Despite the foregoing investigation, however, the relative value of the SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE flag compared to the quantity of changes required in options 1-3, option 4 might be the best choice.
Thanks,
Brian
[1] http://cr.openjdk.java.net/~bpb/8221852/webrev-option-1.00/
[2] http://cr.openjdk.java.net/~bpb/8221852/webrev-option-2.00/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190404/44cde9cf/attachment.html>
More information about the nio-dev
mailing list