about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2018-01-06 02:13:32 +0100
committerGitHub <noreply@github.com>2018-01-06 02:13:32 +0100
commit67e3a2bb2c71c2a59fa5c4bc08e71fe07f25c5c2 (patch)
treec7d414dd6274cd8e59c782f4f6b263b28f5f22fd /src/libstd
parentb98fd524eca6dca5c4788f0d20becb10e099b876 (diff)
parent17380f2ac6d0d259ab6fd3685f9f107e368c01d3 (diff)
downloadrust-67e3a2bb2c71c2a59fa5c4bc08e71fe07f25c5c2.tar.gz
rust-67e3a2bb2c71c2a59fa5c4bc08e71fe07f25c5c2.zip
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.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/env.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/libstd/env.rs b/src/libstd/env.rs
index 457c6e1409d..ed34c1204b3 100644
--- a/src/libstd/env.rs
+++ b/src/libstd/env.rs
@@ -571,8 +571,11 @@ pub fn temp_dir() -> PathBuf {
 
 /// Returns the full filesystem path of the current running executable.
 ///
-/// The path returned is not necessarily a "real path" of the executable as
-/// there may be intermediate symlinks.
+/// # Platform-specific behavior
+///
+/// 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
 ///
@@ -599,14 +602,14 @@ pub fn temp_dir() -> PathBuf {
 /// Ok("/home/alex/foo")
 /// ```
 ///
-/// And you make a symbolic link of the program:
+/// And you make a hard link of the program:
 ///
 /// ```bash
 /// $ ln foo bar
 /// ```
 ///
-/// When you run it, you won't get the original executable, you'll get the
-/// symlink:
+/// When you run it, you won’t get the path of the original executable, you’ll
+/// get the path of the hard link:
 ///
 /// ```bash
 /// $ ./bar
@@ -614,9 +617,9 @@ pub fn temp_dir() -> PathBuf {
 /// ```
 ///
 /// 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
 ///
@@ -625,7 +628,7 @@ pub fn temp_dir() -> PathBuf {
 ///
 /// match env::current_exe() {
 ///     Ok(exe_path) => println!("Path of this executable is: {}",
-///                               exe_path.display()),
+///                              exe_path.display()),
 ///     Err(e) => println!("failed to get current exe path: {}", e),
 /// };
 /// ```