mirror of
https://github.com/audacity/linuxdeploy.git
synced 2025-12-11 19:56:54 -06:00
Make sure to compare canonical paths
Absolute paths do not have to be canonical. For instance, .../a/../AppDir may be equivalent to .../AppDir, however the current implementation would not match them.
This commit is contained in:
parent
a73dbf68f4
commit
d5c4124a0b
@ -830,27 +830,27 @@ namespace linuxdeploy {
|
||||
// TODO: quite similar to deployDependenciesForExistingFiles... maybe they should be merged or use each other
|
||||
bool AppDir::deployDependenciesOnlyForElfFile(const boost::filesystem::path& elfFilePath, bool failSilentForNonElfFile) {
|
||||
// preconditions: file must be an ELF one, and file must be contained in the AppDir
|
||||
const auto absoluteElfFilePath = bf::absolute(elfFilePath);
|
||||
const auto canonicalElfFilePath = bf::canonical(elfFilePath);
|
||||
|
||||
// can't bundle directories
|
||||
if (!bf::is_regular_file(absoluteElfFilePath)) {
|
||||
ldLog() << LD_DEBUG << "Skipping non-file directory entry:" << absoluteElfFilePath << std::endl;
|
||||
if (!bf::is_regular_file(canonicalElfFilePath)) {
|
||||
ldLog() << LD_DEBUG << "Skipping non-file directory entry:" << canonicalElfFilePath << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// to do a proper prefix check, we need a proper absolute path for the AppDir
|
||||
const auto absoluteAppDirPath = bf::absolute(this->path());
|
||||
ldLog() << LD_DEBUG << "absolute AppDir path:" << absoluteAppDirPath << std::endl;
|
||||
// to do a proper prefix check, we need a proper absolute canonical path for the AppDir
|
||||
const auto canonicalAppDirPath = bf::canonical(this->path());
|
||||
ldLog() << LD_DEBUG << "absolute canonical AppDir path:" << canonicalAppDirPath << std::endl;
|
||||
|
||||
// a fancy way to check STL strings for prefixes is to "ab"use rfind
|
||||
if (absoluteElfFilePath.string().rfind(absoluteAppDirPath.string()) != 0) {
|
||||
ldLog() << LD_ERROR << "File" << absoluteElfFilePath << "is not contained in AppDir, its dependencies cannot be deployed into the AppDir" << std::endl;
|
||||
if (canonicalElfFilePath.string().rfind(canonicalAppDirPath.string()) != 0) {
|
||||
ldLog() << LD_ERROR << "File" << canonicalElfFilePath << "is not contained in AppDir, its dependencies cannot be deployed into the AppDir" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// make sure we have an ELF file
|
||||
try {
|
||||
elf::ElfFile(absoluteElfFilePath.string());
|
||||
elf::ElfFile(canonicalElfFilePath.string());
|
||||
} catch (const elf::ElfFileParseError& e) {
|
||||
auto level = LD_ERROR;
|
||||
|
||||
@ -858,7 +858,7 @@ namespace linuxdeploy {
|
||||
level = LD_WARNING;
|
||||
}
|
||||
|
||||
ldLog() << level << "Not an ELF file:" << absoluteElfFilePath << std::endl;
|
||||
ldLog() << level << "Not an ELF file:" << canonicalElfFilePath << std::endl;
|
||||
|
||||
return failSilentForNonElfFile;
|
||||
}
|
||||
@ -867,7 +867,7 @@ namespace linuxdeploy {
|
||||
ldLog() << "Deploying dependencies for ELF file in AppDir:" << elfFilePath << std::endl;
|
||||
|
||||
// bundle dependencies
|
||||
if (!d->deployElfDependencies(absoluteElfFilePath))
|
||||
if (!d->deployElfDependencies(canonicalElfFilePath))
|
||||
return false;
|
||||
|
||||
// set rpath correctly
|
||||
@ -877,7 +877,7 @@ namespace linuxdeploy {
|
||||
const auto rpath = PrivateData::calculateRelativeRPath(elfFilePath.parent_path(), rpathDestination);
|
||||
ldLog() << LD_DEBUG << "Calculated rpath:" << rpath << std::endl;
|
||||
|
||||
d->setElfRPathOperations[absoluteElfFilePath] = rpath;
|
||||
d->setElfRPathOperations[canonicalElfFilePath] = rpath;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user