Check for root privileges.
This commit is contained in:
parent
b07fd97103
commit
02f4ab1501
@ -38,6 +38,8 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <unistd.h> //geteuid
|
||||||
|
|
||||||
RequirementsChecker::RequirementsChecker( QObject* parent )
|
RequirementsChecker::RequirementsChecker( QObject* parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
, m_widget( new QWidget() )
|
, m_widget( new QWidget() )
|
||||||
@ -62,6 +64,7 @@ RequirementsChecker::RequirementsChecker( QObject* parent )
|
|||||||
bool enoughRam = false;
|
bool enoughRam = false;
|
||||||
bool hasPower = false;
|
bool hasPower = false;
|
||||||
bool hasInternet = false;
|
bool hasInternet = false;
|
||||||
|
bool isRoot = false;
|
||||||
|
|
||||||
qint64 requiredStorageB = m_requiredStorageGB * 1073741824L; /*powers of 2*/
|
qint64 requiredStorageB = m_requiredStorageGB * 1073741824L; /*powers of 2*/
|
||||||
cDebug() << "Need at least storage bytes:" << requiredStorageB;
|
cDebug() << "Need at least storage bytes:" << requiredStorageB;
|
||||||
@ -79,8 +82,11 @@ RequirementsChecker::RequirementsChecker( QObject* parent )
|
|||||||
if ( m_entriesToCheck.contains( "internet" ) )
|
if ( m_entriesToCheck.contains( "internet" ) )
|
||||||
hasInternet = checkHasInternet();
|
hasInternet = checkHasInternet();
|
||||||
|
|
||||||
cDebug() << "enoughStorage, enoughRam, hasPower, hasInternet: "
|
if ( m_entriesToCheck.contains( "root" ) )
|
||||||
<< enoughStorage << enoughRam << hasPower << hasInternet;
|
isRoot = checkIsRoot();
|
||||||
|
|
||||||
|
cDebug() << "enoughStorage, enoughRam, hasPower, hasInternet, isRoot: "
|
||||||
|
<< enoughStorage << enoughRam << hasPower << hasInternet << isRoot;
|
||||||
|
|
||||||
QList< PrepareEntry > checkEntries;
|
QList< PrepareEntry > checkEntries;
|
||||||
foreach ( const QString& entry, m_entriesToCheck )
|
foreach ( const QString& entry, m_entriesToCheck )
|
||||||
@ -121,6 +127,15 @@ RequirementsChecker::RequirementsChecker( QObject* parent )
|
|||||||
hasInternet,
|
hasInternet,
|
||||||
m_entriesToRequire.contains( entry )
|
m_entriesToRequire.contains( entry )
|
||||||
} );
|
} );
|
||||||
|
else if ( entry == "root" )
|
||||||
|
checkEntries.append( {
|
||||||
|
entry,
|
||||||
|
[this]{ return QString(); }, //we hide it
|
||||||
|
[this]{ return tr( "The installer is not running with administrator rights." ); },
|
||||||
|
isRoot,
|
||||||
|
m_entriesToRequire.contains( entry )
|
||||||
|
} );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_actualWidget->init( checkEntries );
|
m_actualWidget->init( checkEntries );
|
||||||
@ -329,6 +344,13 @@ RequirementsChecker::checkHasInternet()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
RequirementsChecker::checkIsRoot()
|
||||||
|
{
|
||||||
|
return !geteuid();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
RequirementsChecker::detectFirmwareType()
|
RequirementsChecker::detectFirmwareType()
|
||||||
{
|
{
|
||||||
|
@ -63,6 +63,7 @@ private:
|
|||||||
bool checkBatteryExists();
|
bool checkBatteryExists();
|
||||||
bool checkHasPower();
|
bool checkHasPower();
|
||||||
bool checkHasInternet();
|
bool checkHasInternet();
|
||||||
|
bool checkIsRoot();
|
||||||
void detectFirmwareType();
|
void detectFirmwareType();
|
||||||
|
|
||||||
QWidget* m_widget;
|
QWidget* m_widget;
|
||||||
|
@ -11,6 +11,8 @@ requirements:
|
|||||||
- ram
|
- ram
|
||||||
- power
|
- power
|
||||||
- internet
|
- internet
|
||||||
|
- root
|
||||||
required:
|
required:
|
||||||
- storage
|
- storage
|
||||||
- ram
|
- ram
|
||||||
|
- root
|
||||||
|
Loading…
Reference in New Issue
Block a user