Skip to content

Commit c989b79

Browse files
committed
auto merge of #7132 : thestinger/rust/rpath, r=brson
This is a bad default, because the binaries will point at an absolute path regardless of where they are moved. This opens up a security issue for packages, because they will attempt to load libraries from a path that's often owned by a regular user. Every Rust binary is currently flagged by Debian, Fedora and Arch lint checkers as having dangerous rpaths. They don't meet the requirements to be placed in the repositories without manually stripping this from each binary. The relative rpath is still enough to keep the binaries working until they are moved relative to the crates they're linked against. http://wiki.debian.org/RpathIssue https://fedoraproject.org/wiki/Packaging:Guidelines#Beware_of_Rpath
2 parents 579c614 + 708395d commit c989b79

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

src/librustc/back/rpath.rs

+1-25
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ fn get_rpaths(os: session::os,
7777
// crates they depend on.
7878
let rel_rpaths = get_rpaths_relative_to_output(os, output, libs);
7979

80-
// Make backup absolute paths to the libraries. Binaries can
81-
// be moved as long as the crates they link against don't move.
82-
let abs_rpaths = get_absolute_rpaths(libs);
83-
8480
// And a final backup rpath to the global library location.
8581
let fallback_rpaths = ~[get_install_prefix_rpath(target_triple)];
8682

@@ -92,11 +88,9 @@ fn get_rpaths(os: session::os,
9288
}
9389

9490
log_rpaths("relative", rel_rpaths);
95-
log_rpaths("absolute", abs_rpaths);
9691
log_rpaths("fallback", fallback_rpaths);
9792

9893
let mut rpaths = rel_rpaths;
99-
rpaths.push_all(abs_rpaths);
10094
rpaths.push_all(fallback_rpaths);
10195

10296
// Remove duplicates
@@ -166,14 +160,6 @@ pub fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
166160
}
167161
}
168162

169-
fn get_absolute_rpaths(libs: &[Path]) -> ~[Path] {
170-
vec::map(libs, |a| get_absolute_rpath(a) )
171-
}
172-
173-
pub fn get_absolute_rpath(lib: &Path) -> Path {
174-
os::make_absolute(lib).dir_path()
175-
}
176-
177163
#[cfg(stage0)]
178164
pub fn get_install_prefix_rpath(target_triple: &str) -> Path {
179165
let install_prefix = env!("CFG_PREFIX");
@@ -220,7 +206,7 @@ mod test {
220206
// these redundant #[cfg(test)] blocks can be removed
221207
#[cfg(test)]
222208
#[cfg(test)]
223-
use back::rpath::{get_absolute_rpath, get_install_prefix_rpath};
209+
use back::rpath::{get_install_prefix_rpath};
224210
use back::rpath::{get_relative_to, get_rpath_relative_to_output};
225211
use back::rpath::{minimize_rpaths, rpaths_to_flags};
226212
use driver::session;
@@ -364,14 +350,4 @@ mod test {
364350
&Path("lib/libstd.so"));
365351
assert_eq!(res.to_str(), ~"@executable_path/../lib");
366352
}
367-
368-
#[test]
369-
fn test_get_absolute_rpath() {
370-
let res = get_absolute_rpath(&Path("lib/libstd.so"));
371-
debug!("test_get_absolute_rpath: %s vs. %s",
372-
res.to_str(),
373-
os::make_absolute(&Path("lib")).to_str());
374-
375-
assert_eq!(res, os::make_absolute(&Path("lib")));
376-
}
377353
}

0 commit comments

Comments
 (0)