Expose callingUser in HelperSupport if available

Review Request #126724 - Created Jan. 12, 2016 and updated

Information
Martin Flöser
kauth
master
126723
Reviewers
kdeframeworks
dafre, davidedmundson
The Polkit backend is able to retrieve the calling user. As this is
a useful information for a helper the information can be exposed in
the AuthBackend and be retrieved through the HelperSupport.

a helper with:
ActionReply KScreenLockerAuthHelper::save(const QVariantMap &args)
{
auto user = KAuth::HelperSupport::callingUser();

QFile file(QStringLiteral("/tmp/authtest"));
file.open(QIODevice::WriteOnly);
file.write(user->homeDir().toUtf8());
file.write("\n");
file.write(user->loginName().toUtf8());
file.write("\n");
file.write(QByteArray::number(user->userId().nativeId()));
file.write("\n");

return ActionReply::SuccessReply();
}

created the file /tmp/authtest with the following content:

/home/martin
martin
1000

Which matches my user.

David Edmundson

looks good, thanks for this patch.

note given my comment in the other patch you'll need to change 1 line here.

  1. I have adjusted to the new code locally. As it's only a minor change I'm not going to upload again to RB.

Dario Freddi

As long as the additional dependency does not cause any issue (I strongly doubt it), it definitely makes sense to me.

Albert Astals Cid

Martin any reason this was not commmited? Should I?

  1. If I remember correctly it depends on a newer polkit-qt functionality and polkit-qt hasn't seen a release yet. Unfortunately I cannot really check as the diff now only shows whitespace changes (yay for reviewboard to break the diffs)

Loading...