8221852: SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE should be selected at runtime, not build time
Alan Bateman
Alan.Bateman at oracle.com
Fri Apr 5 14:22:41 UTC 2019
On 05/04/2019 01:46, Brian Burkhalter wrote:
> 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.
I met Robert Scholte (Maven) at FOSDEM and one of the things be brought
up is that Maven are looking for additional OS version info to put into
the mvn -version output [1]. Your #1 solution adds a os.buildNumber
property and maybe an alternative to look at is existing os.version to
add another element. It's hard to know how robust existing code that
parses the value is so there may be compatibility impact to extending it
beyond two elements.
In any case, the original intention for WindowsNativeDispatcher was that
the native methods map as close as possible to one win32 call so that
the native code is as minimal as possible. Once Panama is further along
then it should make it straight forward to migrate that code.
As regards the approach then WindowsFileSystem is the place where OS
versions/features are probed. If you dust off a jdk8 clone then you'll
see where it enables sym links and enumeration of data streams based on
the OS version. That code was removed when support for running on
ancient releases of Windows was dropped but it should give you ideas on
where the OS version check should be.
I have no objection to your #4, at least temporarily until you've found
a good approach. As it stands then it's problematic to have it set in
the native method as it fail on some versions of Windows
-Alan
[1] https://issues.apache.org/jira/browse/MNG-6587
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190405/8059e6e4/attachment.html>
More information about the nio-dev
mailing list