提交 67e3a2bb 编写于 作者: G Guillaume Gomez 提交者: GitHub

Rollup merge of #46987 - frewsxcv:frewsxcv-current-exe, r=QuietMisdreavus

Minor rewrite of env::current_exe docs; clarify symlinks.

- Update example in ‘security’ section to use hard links, like the
  linked securityvulns.com example.
- Weaken language on symbolic links – indicate behavior is
  platform-specific

Fixes https://github.com/rust-lang/rust/issues/43617.
...@@ -571,8 +571,11 @@ pub fn temp_dir() -> PathBuf { ...@@ -571,8 +571,11 @@ pub fn temp_dir() -> PathBuf {
/// Returns the full filesystem path of the current running executable. /// Returns the full filesystem path of the current running executable.
/// ///
/// The path returned is not necessarily a "real path" of the executable as /// # Platform-specific behavior
/// there may be intermediate symlinks. ///
/// If the executable was invoked through a symbolic link, some platforms will
/// return the path of the symbolic link and other platforms will return the
/// path of the symbolic link’s target.
/// ///
/// # Errors /// # Errors
/// ///
...@@ -599,14 +602,14 @@ pub fn temp_dir() -> PathBuf { ...@@ -599,14 +602,14 @@ pub fn temp_dir() -> PathBuf {
/// Ok("/home/alex/foo") /// Ok("/home/alex/foo")
/// ``` /// ```
/// ///
/// And you make a symbolic link of the program: /// And you make a hard link of the program:
/// ///
/// ```bash /// ```bash
/// $ ln foo bar /// $ ln foo bar
/// ``` /// ```
/// ///
/// When you run it, you won't get the original executable, you'll get the /// When you run it, you won’t get the path of the original executable, you’ll
/// symlink: /// get the path of the hard link:
/// ///
/// ```bash /// ```bash
/// $ ./bar /// $ ./bar
...@@ -614,9 +617,9 @@ pub fn temp_dir() -> PathBuf { ...@@ -614,9 +617,9 @@ pub fn temp_dir() -> PathBuf {
/// ``` /// ```
/// ///
/// This sort of behavior has been known to [lead to privilege escalation] when /// This sort of behavior has been known to [lead to privilege escalation] when
/// used incorrectly, for example. /// used incorrectly.
/// ///
/// [lead to privilege escalation]: http://securityvulns.com/Wdocument183.html /// [lead to privilege escalation]: https://securityvulns.com/Wdocument183.html
/// ///
/// # Examples /// # Examples
/// ///
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册