diff options
author | kh1 <karsten.heimrich@digia.com> | 2014-06-13 12:03:49 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2014-06-19 17:30:37 +0200 |
commit | b8c0d6d49b2eb65524e393baf0e15b70e447dcc3 (patch) | |
tree | 83f13f51dac79bd6ee8980271405bfc0ab25e974 /src/libs/installer/adminauthorization_x11.cpp | |
parent | 246e13d6920f1fd869267537d6ccde4149192898 (diff) |
Fix AdminAuthorization implementation.
- execute() does the magic of getting privileges and starting
the process
- hasAdminRights() simply returns if we started privileged..
Change-Id: I0940a02556fe240af0ee7dfb068f7f8009eb683e
Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
Diffstat (limited to 'src/libs/installer/adminauthorization_x11.cpp')
-rw-r--r-- | src/libs/installer/adminauthorization_x11.cpp | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/src/libs/installer/adminauthorization_x11.cpp b/src/libs/installer/adminauthorization_x11.cpp index 6af037e91..cd3a4ecbf 100644 --- a/src/libs/installer/adminauthorization_x11.cpp +++ b/src/libs/installer/adminauthorization_x11.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2012-2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Installer Framework. @@ -69,31 +69,20 @@ #define SU_COMMAND "/usr/bin/sudo" //#define SU_COMMAND "/bin/echo" -AdminAuthorization::AdminAuthorization() -{ -} +namespace QInstaller { -bool AdminAuthorization::authorize() +static QString getPassword(QWidget *parent) { - return true; -} - -static QString getPassword(QWidget *) -{ -#if QT_VERSION < 0x050000 - if (QApplication::type() == QApplication::GuiClient) -#else - if (qobject_cast<QApplication*> (qApp) != 0) -#endif - { + if (qobject_cast<QApplication*> (qApp) != 0) { bool ok = false; - const QString result = QInputDialog::getText(0, QObject::tr("Authorization required"), + const QString result = QInputDialog::getText(parent, QObject::tr("Authorization required"), QObject::tr("Enter your password to authorize for sudo:"), QLineEdit::Password, QString(), &ok); return ok ? result : QString(); } else { std::cout << QObject::tr("Authorization required").toStdString() << std::endl; - std::cout << QObject::tr("Enter your password to authorize for sudo:").toStdString() << std::endl; + std::cout << QObject::tr("Enter your password to authorize for sudo:").toStdString() + << std::endl; std::string password; std::cin >> password; return QString::fromStdString(password); @@ -102,12 +91,7 @@ static QString getPassword(QWidget *) static void printError(QWidget *parent, const QString &value) { -#if QT_VERSION < 0x050000 - if (QApplication::type() == QApplication::GuiClient) -#else - if (qobject_cast<QApplication*> (qApp) != 0) -#endif - { + if (qobject_cast<QApplication*> (qApp) != 0) { QMessageBox::critical(parent, QObject::tr( "Error acquiring admin rights" ), value, QMessageBox::Ok, QMessageBox::Ok); } else { @@ -280,3 +264,5 @@ bool AdminAuthorization::hasAdminRights() { return getuid() == 0; } + +} // namespace QInstaller |