mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4522 Ensure ResInsight does not run if the setuid bit is set on the executable.
* If you run a GUI-version this is likely to be checked anyway through Qt or GTK+ but not the console version.
This commit is contained in:
parent
3ba962aefb
commit
c1a89ec10e
@ -24,6 +24,11 @@
|
|||||||
#include "cvfProgramOptions.h"
|
#include "cvfProgramOptions.h"
|
||||||
#include "cvfqtUtils.h"
|
#include "cvfqtUtils.h"
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
RiaApplication* createApplication(int &argc, char *argv[])
|
RiaApplication* createApplication(int &argc, char *argv[])
|
||||||
{
|
{
|
||||||
for (int i = 1; i < argc; ++i)
|
for (int i = 1; i < argc; ++i)
|
||||||
@ -38,6 +43,15 @@ RiaApplication* createApplication(int &argc, char *argv[])
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
#ifndef WIN32
|
||||||
|
// From Qt 5.3 and onwards Qt has a mechanism for checking this automatically
|
||||||
|
// But it only checks user id not group id, so better to do it ourselves.
|
||||||
|
if (getuid() != geteuid() || getgid() != getegid())
|
||||||
|
{
|
||||||
|
std::cerr << "FATAL: The application binary appears to be running setuid or setgid, this is a security hole." << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
RiaLogging::loggerInstance()->setLevel(RI_LL_DEBUG);
|
RiaLogging::loggerInstance()->setLevel(RI_LL_DEBUG);
|
||||||
|
|
||||||
std::unique_ptr<RiaApplication> app (createApplication(argc, argv));
|
std::unique_ptr<RiaApplication> app (createApplication(argc, argv));
|
||||||
|
Loading…
Reference in New Issue
Block a user