Optimize permission for linux

This commit is contained in:
arm64v8a
2023-05-02 11:58:33 +09:00
parent 50387db15e
commit 3d2ce33a75
10 changed files with 73 additions and 11 deletions

View File

@@ -9,6 +9,12 @@
#include <QJsonArray>
#include <QJsonDocument>
#ifdef Q_OS_WIN
#include "sys/windows/guihelper.h"
#else
#include <unistd.h>
#endif
namespace NekoRay {
DataStore *dataStore = new DataStore();
@@ -371,4 +377,20 @@ namespace NekoRay {
return {};
}
short isAdminCache = -1;
bool isAdmin() {
if (isAdminCache >= 0) return isAdminCache;
auto admin = NekoRay::dataStore->flag_linux_run_core_as_admin;
#ifdef Q_OS_WIN
admin = Windows_IsInAdmin();
#else
admin |= geteuid() == 0;
#endif
isAdminCache = admin;
return admin;
};
} // namespace NekoRay