Skip to content

Commit 9c3b0d8

Browse files
committed
Add a caveat to std::os::windows::fs::symlink_file
This is similar to the note on [Python's `os.symlink()`](https://docs.python.org/3/library/os.html#os.symlink). Some additional notes in dimo414/bkt#3.
1 parent 18fa434 commit 9c3b0d8

File tree

1 file changed

+20
-0
lines changed
  • library/std/src/os/windows

1 file changed

+20
-0
lines changed

Diff for: library/std/src/os/windows/fs.rs

+20
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,16 @@ impl FileTypeExt for fs::FileType {
543543
/// Ok(())
544544
/// }
545545
/// ```
546+
///
547+
/// # Limitations
548+
///
549+
/// Windows treats symlink creation as a [privileged action][symlink-security],
550+
/// therefore this function is likely to fail unless the user makes changes to
551+
/// their system to permit symlink creation. Users can try enabling Developer
552+
/// Mode, granting the `SeCreateSymbolicLinkPrivilege` privilege, or running
553+
/// the process as an administrator.
554+
///
555+
/// [symlink-security]: https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links
546556
#[stable(feature = "symlink", since = "1.1.0")]
547557
pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io::Result<()> {
548558
sys::fs::symlink_inner(original.as_ref(), link.as_ref(), false)
@@ -572,6 +582,16 @@ pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io:
572582
/// Ok(())
573583
/// }
574584
/// ```
585+
///
586+
/// # Limitations
587+
///
588+
/// Windows treats symlink creation as a [privileged action][symlink-security],
589+
/// therefore this function is likely to fail unless the user makes changes to
590+
/// their system to permit symlink creation. Users can try enabling Developer
591+
/// Mode, granting the `SeCreateSymbolicLinkPrivilege` privilege, or running
592+
/// the process as an administrator.
593+
///
594+
/// [symlink-security]: https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links
575595
#[stable(feature = "symlink", since = "1.1.0")]
576596
pub fn symlink_dir<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io::Result<()> {
577597
sys::fs::symlink_inner(original.as_ref(), link.as_ref(), true)

0 commit comments

Comments
 (0)