mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-15 08:34:30 +02:00
8218418: (fs) Files.createSymbolicLink should use SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE (win)
Reviewed-by: alanb
This commit is contained in:
parent
4494be3b5f
commit
07991d3f2d
1 changed files with 9 additions and 3 deletions
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -1063,8 +1063,14 @@ Java_sun_nio_fs_WindowsNativeDispatcher_CreateSymbolicLink0(JNIEnv* env,
|
||||||
LPCWSTR link = jlong_to_ptr(linkAddress);
|
LPCWSTR link = jlong_to_ptr(linkAddress);
|
||||||
LPCWSTR target = jlong_to_ptr(targetAddress);
|
LPCWSTR target = jlong_to_ptr(targetAddress);
|
||||||
|
|
||||||
/* On Windows 64-bit this appears to succeed even when there is insufficient privileges */
|
// Allow creation of symbolic links when the process is not elevated.
|
||||||
if (CreateSymbolicLinkW(link, target, (DWORD)flags) == 0)
|
// 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());
|
throwWindowsException(env, GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue