Adding upstream version 0.11.0.

upstream/0.11.0
Alf Gaida 8 years ago
parent b590848671
commit 68e7af3f55

2
.gitignore vendored

@ -0,0 +1,2 @@
build
translations/lxqt-policykit

@ -0,0 +1,80 @@
lxqt-policykit-0.11.0 / 2016-09-24
==================================
* agentGui: Use default icon
* agentGui: Choose current user in identities combo
* agentGui: Handle setting the prompt correctly
* agent: Handle multiple identities correctly
* Update README.md
* Fixed typo prefered -> preferred
* Add README.md
* build: Use external translations
* ts-files removal (#21)
* Bump year in AUTHORS
* Italian translation update
* Updated Russian translation Removed ru_RU file
* update: lxqt-policykit-agent_hu.ts
0.10.0 / 2015-10-31
===================
* Update translations
* Fix license file
* GPL2 not used - removed in AUTHORS Fixed link to Github LXQt issues Fix wording in manpage - 'can be used by others' was nuts for a file under LGPL root license
* Add Greek (el) translation
* Rename LxQt to LXQt everywhere
* Added german translation.
* Added missing tr() call.
* Handles CMake policy CMP0063
* Use the LXQtCompilerSettings CMake module
* Adds Runtime install COMPONENT
* Use GNUInstallDirs
* Removes unneede entries from include_directories()
* Uses CMAKE_AUTOUIC
* Updates the build system to use the Targets infrastructure
* Remove trailing whitespaces
* Fix naming and links
* Hungarian translation
* - Add a choice option for install binary. Some distributions use libexec instead os default usr/bin installs. It defauls to bin
0.9.0 / 2015-01-19
==================
* File name was ok but language name wasn´t. My mistake.
* Makes filename match translation language
* Portuguese update
* - Unify naming for a unique lxqt. No more suffixes
* CMakeLists.txt maintenance.
* Uses the new translations cmake modules
* Add Russian translation
* CMakeLists.txt cleanups
0.8.0 / 2014-06-28
==================
* Use portable Polkit headers
* Deal with a bug in polkit-qt1 cmake file
* Choose Qt5 version of PolkitQt when build with Qt5.
* Add initial Qt5 support.
* Use new LXQt header files.
0.7.0 / 2014-05-01
==================
* Update AUTHORS and COPYING files
* Add CPack rules for creating tarball
* Removed CMAKE_SOURCE_DIR usage from CMakeLists.txt
* Fix renaming bugs, replacing lxqt-qt with lxde-qt
* Finish the crazy razor=>lxqt renaming tasks.
* Rename binary to lxqt-policykit-agent and migrate to the latest liblxqt.
* Add COPYING and AUTHORS
* Fix authentization->authentication misspelling
* Trtanslations
* Translation support for policykit agent
* preliminary manpages primary for razorqt and usefully in venenux
* Add build option to make policykit optional, even if installed.
* RazorApplication class implemented; all modules ported to this class
* Relicense
* initial but finally working policykit integration (agent)
* initial revision of the policykit integration (non-functional)

@ -4,23 +4,13 @@
lxqt-policykit is the polkit authentification agent of LXQt.
[polkit](https://www.freedesktop.org/wiki/Software/polkit/) is a software framework to handle privileges of processes.
In LXQt it is e. g. used to extend the privileges of the GUI tools of [lxqt-admin](https://github.com/lxde/lxqt-admin/).
These are launched by a regular user. But in order to apply the settings that can be adjusted root privileges are needed
and acquired via polkit.
[polkit](https://www.freedesktop.org/wiki/Software/polkit/) is a software framework to handle privileges of processes.
In LXQt it is e. g. used to extend the privileges of the GUI tools of [lxqt-admin](https://github.com/lxde/lxqt-admin/). These are launched by a regular user. But in order to apply the settings they deal with root privileges are needed and acquired via polkit.
Among the various components of polkit the authentication agent is the one to query the user for credentials by dialogue windows like this one of lxqt-policykit.
![lxqt-policykit: GUI](lxqt-policykit_gui.png)
While there's only a single implementation of all other polkit components various different authentication agents are provided by the various desktop environments. Basically these can be used interchangeably, that is lxqt-policykit can be used in an LXDE session or lxpolkit, the authentication agent of LXDE, can be used in an Xfce session. Most of the time it's better to use the implementation provided by a distinct desktop environment as it integrates better, though.
Among the various components of polkit the authentication agent is the one to query the user for credentials and hence
comes with its own GUI like this one of lxqt-policykit.
![lxqt-policykit: GUI](lxqt-policykit_gui.png)
While there's only a single implementation of all other polkit components there are various different authentication
agents provided by the various desktop environments. Normally these can be used interchangeably, that is lxqt-policykit
can be used in an LXDE session or lxpolkit, the authentication agent of LXDE, can be used in an Xfce session. Normally
it's better to use the implementation provided by a distinct desktop environment as it integrates better, though.
Technically, lxqt-policykit is just a single binary `lxqt-policykit-agent` which has to be running all over the LXQt
sessions and is therefor launched as so-called LXQt Module, see [Configuration](#configuration).
Technically, lxqt-policykit is just a single binary `lxqt-policykit-agent` which is running as [LXQt Module](https://github.com/lxde/lxqt-session#lxqt-modules) and launching the GUI on demand.
Note that the naming lxqt-policykit is strictly speaking an anachronism. It refers to Policykit which was the predecessor
of polkit. The name wasn't changed when Policykit was replaced by polkit as both provide roughly the same features albeit
@ -30,14 +20,12 @@ they are technically different.
### Compiling sources
Runtime dependencies are [liblxqt](https://github.com/lxde/liblxqt) and its dependency
[libqtxdg](https://github.com/lxde/libqtxdg) as well as polkit-qt5, to build Git and CMake are needed in addition.
By default lxqt-policykit is pulling translations from repository [translations](https://github.com/lxde/translations/) at
compile time, see file README.md of the latter.
Runtime dependencies are polkit-qt5 and [liblxqt](https://github.com/lxde/liblxqt).
Additional build dependencies are CMake and optionally Git to pull latest VCS checkouts. The localization files were outsourced to repository [lxqt-l10n](https://github.com/lxde/lxqt-l10n) so the corresponding dependencies are needed, too. Please refer to this repository's `README.md` for further information.
To compile, run `cmake`, `make` and `make install`.
`cmake` can be invoked in an out of source build directory and will normally need variable `-DCMAKE_INSTALL_PREFIX=/usr`.
`make install` can be invoked with `DESTDIR=<some path>`.
Code configuration is handled by CMake. CMake variable `CMAKE_INSTALL_PREFIX` has to be set to `/usr` on most operating systems.
To build run `make`, to install `make install` which accepts variable `DESTDIR` as usual.
### Binary packages
@ -60,16 +48,8 @@ Package `lxqt-policykit` is available as of Fedora 22.
Package `lxqt-policykit` is providing the binary, `lxqt-policykit-lang` the translations. Both are available as of
openSUSE Leap 42.1.
## Configuration
As mentioned in section [Overview](#overview) binary `lxqt-policykit-agent` is started as LXQt Module, which is a particular
way of LXQt to launch binaries at the beginning of an LXQt session and keep them running all the time.
This is handled by desktop entry file `/etc/xdg/autostart/lxqt-policykit-agent.desktop`. It belongs to
[lxqt-common](https://github.com/lxde/lxqt-common/) and is featuring key `OnlyShowIn=LXQt;` restricting it to LXQt sessions.
So no further action has to be taken as far as LXQt is concerned. In order to use lxqt-policykit in other sessions the key has
to be modified accordingly and/or removed, optionally after copying the file to a user specific directory, normally
`~/.config/autostart/`.
## Configuration, Usage
## Usage
Like all LXQt Modules `lxqt-policykit-agent` can be adjusted from section "Basic Settings" in configuration dialogue [LXQt Session Settings](https://github.com/lxde/lxqt-session#lxqt-session-settings) of [lxqt-session](https://github.com/lxde/lxqt-session).
From a user's point of view the usage is limited to interacting with the GUI as seen above.

@ -32,7 +32,7 @@ The module detected on shares privilege escalation, and maintain a security dial
that ask for the user's key need for action.
.SH AUTOSTART
The module only are showed on \fBLXQt\fR desktop, but u can create an autostart action
for u prefered desktop environment.
for u preferred desktop environment.
.SH "REPORTING BUGS"
Report bugs to https://github.com/lxde/lxqt/issues
.SH "SEE ALSO"

@ -116,27 +116,36 @@ void PolicykitAgent::request(const QString &request, bool echo)
PolkitQt1::Identity identity = m_SessionIdentity[session];
m_gui->setPrompt(identity, request, echo);
if (m_gui->exec())
session->setResponse(m_gui->response());
else
session->setResponse("");
connect(m_gui, &QDialog::finished, [this, session] (int result)
{
if (result == QDialog::Accepted && m_gui->identity() == m_SessionIdentity[session].toString())
session->setResponse(m_gui->response());
else
session->cancel();
});
m_gui->show();
}
void PolicykitAgent::completed(bool gainedAuthorization)
{
PolkitQt1::Agent::Session * session = qobject_cast<PolkitQt1::Agent::Session *>(sender());
Q_ASSERT(session);
Q_ASSERT(m_gui);
if (!gainedAuthorization)
if (m_gui->identity() == m_SessionIdentity[session].toString())
{
QMessageBox::information(0, tr("Authorization Failed"), tr("Authorization failed for some reason"));
if (!gainedAuthorization)
{
QMessageBox::information(0, tr("Authorization Failed"), tr("Authorization failed for some reason"));
}
// Note: the setCompleted() must be called exacly once (as the
// AsyncResult is shared by all the sessions)
session->result()->setCompleted();
m_inProgress = false;
}
session->result()->setCompleted();
delete session;
m_inProgress = false;
}
void PolicykitAgent::showError(const QString &text)

@ -25,8 +25,9 @@
*
* END_COMMON_COPYRIGHT_HEADER */
#include <XdgIcon>
#include <QIcon>
#include "policykitagentgui.h"
#include <unistd.h>
namespace LXQtPolicykit
{
@ -44,30 +45,47 @@ PolicykitAgentGUI::PolicykitAgentGUI(const QString &actionId,
Q_UNUSED(details); // it seems too confusing for end user (=me)
messageLabel->setText(message);
iconLabel->setPixmap(XdgIcon::fromTheme(iconName).pixmap(64, 64));
QIcon icon = QIcon::fromTheme(iconName);
if (icon.isNull())
icon = QIcon::fromTheme(QLatin1String("dialog-question"));
iconLabel->setPixmap(icon.pixmap(64, 64));
const uid_t current_uid = getuid();
int current_user_index = -1;
foreach (PolkitQt1::Identity identity, identities)
{
m_identityMap[identity.toString()] = identity;
const int i = identityComboBox->count(); // index of the added item
identityComboBox->addItem(identity.toString());
PolkitQt1::UnixUserIdentity const * const u_id = static_cast<PolkitQt1::UnixUserIdentity *>(&identity);
if (u_id != nullptr && u_id->uid() == current_uid)
current_user_index = i;
}
if (current_user_index != -1)
identityComboBox->setCurrentIndex(current_user_index);
connect(identityComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &PolicykitAgentGUI::onIdentityChanged);
passwordEdit->setFocus(Qt::OtherFocusReason);
}
void PolicykitAgentGUI::setPrompt(const PolkitQt1::Identity &identity, const QString &text, bool echo)
{
int ix = identityComboBox->findText(identity.toString());
const int ix = identityComboBox->findText(identity.toString());
if (ix != -1)
{
identityComboBox->setCurrentIndex(ix);
passwordEdit->setFocus(Qt::OtherFocusReason);
identityComboBox->setItemData(ix, text, RolePromptText);
identityComboBox->setItemData(ix, echo, RolePromptEcho);
if (ix == identityComboBox->currentIndex())
{
promptLabel->setText(text);
passwordEdit->setEchoMode(echo ? QLineEdit::Normal : QLineEdit::Password);
}
}
promptLabel->setText(text);
passwordEdit->setEchoMode(echo ? QLineEdit::Normal : QLineEdit::Password);
}
PolkitQt1::Identity PolicykitAgentGUI::identity()
QString PolicykitAgentGUI::identity()
{
return m_identityMap[identityComboBox->currentText()];
Q_ASSERT(identityComboBox->currentIndex() != -1);
return identityComboBox->currentText();
}
QString PolicykitAgentGUI::response()
@ -75,4 +93,14 @@ QString PolicykitAgentGUI::response()
return passwordEdit->text();
}
void PolicykitAgentGUI::onIdentityChanged(int index)
{
QVariant text = identityComboBox->itemData(index, RolePromptText);
QVariant echo = identityComboBox->itemData(index, RolePromptEcho);
if (text != QVariant{})
promptLabel->setText(text.toString());
if (echo != QVariant{})
passwordEdit->setEchoMode(echo.toBool() ? QLineEdit::Normal : QLineEdit::Password);
}
} // namespace

@ -40,6 +40,13 @@ class PolicykitAgentGUI : public QDialog, public Ui::PolicykitAgentGUI
{
Q_OBJECT
private:
enum DataRoles
{
RolePromptText = Qt::UserRole
, RolePromptEcho
};
public:
PolicykitAgentGUI(const QString &actionId,
const QString &message,
@ -48,11 +55,14 @@ public:
const PolkitQt1::Identity::List &identities);
void setPrompt(const PolkitQt1::Identity &identity, const QString &text, bool echo);
PolkitQt1::Identity identity();
/*! \brief Returns currently selected identity (serialized by toString())
*/
QString identity();
QString response();
private:
QHash<QString,PolkitQt1::Identity> m_identityMap;
public slots:
void onIdentityChanged(int index);
};
} // namespace

Loading…
Cancel
Save