Skip to content

Commit c78bb9b

Browse files
committed
Update validation to support dynamic musl
1 parent f156f44 commit c78bb9b

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/validation.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ const ELF_ALLOWED_LIBRARIES: &[&str] = &[
7171
"libpthread.so.0",
7272
"librt.so.1",
7373
"libutil.so.1",
74+
// musl libc
75+
"libc.so",
7476
];
7577

7678
const PE_ALLOWED_LIBRARIES: &[&str] = &[
@@ -919,7 +921,7 @@ fn validate_elf<Elf: FileHeader<Endian = Endianness>>(
919921
}
920922

921923
allowed_libraries.push(format!(
922-
"$ORIGIN/../lib/libpython{}.so.1.0",
924+
"libpython{}.so.1.0",
923925
python_major_minor
924926
));
925927
allowed_libraries.push(format!(
@@ -935,6 +937,26 @@ fn validate_elf<Elf: FileHeader<Endian = Endianness>>(
935937
python_major_minor
936938
));
937939

940+
// On musl, we don't use `$ORIGIN`
941+
if target_triple.contains("-musl") {
942+
allowed_libraries.push(format!(
943+
"libpython{}.so.1.0",
944+
python_major_minor
945+
));
946+
allowed_libraries.push(format!(
947+
"libpython{}d.so.1.0",
948+
python_major_minor
949+
));
950+
allowed_libraries.push(format!(
951+
"libpython{}t.so.1.0",
952+
python_major_minor
953+
));
954+
allowed_libraries.push(format!(
955+
"libpython{}td.so.1.0",
956+
python_major_minor
957+
));
958+
}
959+
938960
// Allow the _crypt extension module - and only it - to link against libcrypt,
939961
// which is no longer universally present in Linux distros.
940962
if let Some(filename) = path.file_name() {
@@ -1720,7 +1742,8 @@ fn validate_distribution(
17201742

17211743
let is_debug = dist_filename.contains("-debug-");
17221744

1723-
let is_static = triple.contains("unknown-linux-musl");
1745+
// For now, there are now static builds — this is historic
1746+
let is_static = false;
17241747

17251748
let mut tf = crate::open_distribution_archive(dist_path)?;
17261749

0 commit comments

Comments
 (0)