| 328 | } |
| 329 | |
| 330 | QSet<QString> additionalAppImagesLocations(const bool includeAllMountPoints) { |
| 331 | QSet<QString> additionalLocations; |
| 332 | |
| 333 | additionalLocations << "/Applications"; |
| 334 | |
| 335 | // integrate AppImages from mounted filesystems, if requested |
| 336 | // we don't want to read files from any FUSE mounted filesystems nor from any virtual filesystems |
| 337 | // to |
| 338 | static const auto validFilesystems = {"ext2", "ext3", "ext4", "ntfs", "vfat"}; |
| 339 | |
| 340 | static const auto blacklistedMountPointPrefixes = { |
| 341 | "/var/lib/schroot", |
| 342 | "/run/docker", |
| 343 | "/boot", |
| 344 | "/sys", |
| 345 | "/proc", |
| 346 | "/snap", |
| 347 | }; |
| 348 | |
| 349 | if (includeAllMountPoints) { |
| 350 | for (const auto& mount : listMounts()) { |
| 351 | const auto& device = mount.getDevice(); |
| 352 | const auto& mountPoint = mount.getMountPoint(); |
| 353 | const auto& fsType = mount.getFsType(); |
| 354 | |
| 355 | // we have to filter out virtual filesystems, i.e., ones which have a "nonsense" device path |
| 356 | // any device that doesn't start with / is likely virtual, this is the first indicator |
| 357 | if (device.size() < 1 || device[0] != '/') { |
| 358 | continue; |
| 359 | } |
| 360 | |
| 361 | // the device should exist for obvious reasons |
| 362 | if (!QFileInfo(QFileInfo(device).absoluteFilePath()).exists()) { |
| 363 | continue; |
| 364 | } |
| 365 | |
| 366 | // we don't want to mount any loop-mounted or bind-mounted or other devices, only... "native" ones |
| 367 | // therefore we permit only "real" devices listed within /dev |
| 368 | if (!device.startsWith("/dev/")) { |
| 369 | continue; |
| 370 | } |
| 371 | |
| 372 | // there's a few locations which we know we don't want to search for AppImages in |
| 373 | // either it's a waste of time or otherwise a bad idea, but it will surely save time *not* to search them |
| 374 | if (std::find_if(blacklistedMountPointPrefixes.begin(), blacklistedMountPointPrefixes.end(), |
| 375 | [&mountPoint](const QString& prefix) { |
| 376 | return mountPoint == prefix || mountPoint.startsWith(prefix + "/"); |
| 377 | }) != blacklistedMountPointPrefixes.end()) { |
| 378 | continue; |
| 379 | } |
| 380 | |
| 381 | // we can skip the root mount point, as we handled it above |
| 382 | if (mountPoint == "/") { |
| 383 | continue; |
| 384 | } |
| 385 | |
| 386 | // we only support a limited set of filesystems |
| 387 | if (std::find(validFilesystems.begin(), validFilesystems.end(), fsType) == validFilesystems.end()) { |
no test coverage detected