mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-05-30 05:40:18 +02:00
(#1693) Use a better approach to detect a noexec mount option
Signed-off-by: bit6tream <megapixel483@gmail.com>
This commit is contained in:
parent
681e76c551
commit
d414599974
@ -82,7 +82,6 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <string_view>
|
|
||||||
|
|
||||||
#include <QAccessible>
|
#include <QAccessible>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
@ -133,8 +132,13 @@
|
|||||||
#include "gamemode_client.h"
|
#include "gamemode_client.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
#if defined(Q_OS_LINUX)
|
||||||
#include <mntent.h>
|
#include <sys/statvfs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
@ -993,36 +997,37 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
|
||||||
|
|
||||||
// notify user if /tmp is mounted with `noexec` (#1693)
|
// notify user if /tmp is mounted with `noexec` (#1693)
|
||||||
{
|
{
|
||||||
FILE* description = setmntent(MOUNTED, "r");
|
bool is_tmp_noexec = false;
|
||||||
mntent* info = nullptr;
|
|
||||||
|
|
||||||
while ((info = getmntent(description)) != nullptr) {
|
#if defined(Q_OS_LINUX)
|
||||||
std::string_view directory = info->mnt_dir;
|
|
||||||
std::string_view options = info->mnt_opts;
|
|
||||||
|
|
||||||
if (directory == "/tmp" && options.rfind("noexec") != std::string_view::npos) {
|
struct statvfs tmp_stat;
|
||||||
auto infoMsg =
|
statvfs("/tmp", &tmp_stat);
|
||||||
tr("Your /tmp directory is currently mounted with the 'noexec' flag enabled.\n"
|
is_tmp_noexec = tmp_stat.f_flag & ST_NOEXEC;
|
||||||
"Some versions of Minecraft may not launch.\n");
|
|
||||||
auto msgBox = new QMessageBox(QMessageBox::Information, tr("Incompatible system configuration"), infoMsg, QMessageBox::Ok);
|
|
||||||
msgBox->setDefaultButton(QMessageBox::Ok);
|
|
||||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
msgBox->setMinimumWidth(460);
|
|
||||||
msgBox->adjustSize();
|
|
||||||
msgBox->open();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
endmntent(description);
|
#elif defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
||||||
}
|
|
||||||
|
struct statfs tmp_stat;
|
||||||
|
statfs("/tmp", &tmp_stat);
|
||||||
|
is_tmp_noexec = tmp_stat.f_flags & MNT_NOEXEC;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (is_tmp_noexec) {
|
||||||
|
auto infoMsg =
|
||||||
|
tr("Your /tmp directory is currently mounted with the 'noexec' flag enabled.\n"
|
||||||
|
"Some versions of Minecraft may not launch.\n");
|
||||||
|
auto msgBox = new QMessageBox(QMessageBox::Information, tr("Incompatible system configuration"), infoMsg, QMessageBox::Ok);
|
||||||
|
msgBox->setDefaultButton(QMessageBox::Ok);
|
||||||
|
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
msgBox->setMinimumWidth(460);
|
||||||
|
msgBox->adjustSize();
|
||||||
|
msgBox->open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (createSetupWizard()) {
|
if (createSetupWizard()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user