PolkitQt.Auth Namespace Reference
from PyKDE4.polkitqt.PolkitQt.Auth import *
Detailed Description
Functions used to obtain authorizations
This namespace contains class is a simple wrapper around the DBus interface org.freedesktop.PolicyKit.AuthenticationAgent to make usage of policykit easier in Qt/KDE worlds
Enumerations | |
Result | { Unknown, Yes, AdminAuthOneShot, AdminAuth, AdminAuthKeepSession, AdminAuthKeepAlways, SelfAuthOneShot, SelfAuth, SelfAuthKeepSession, SelfAuthKeepAlways, No } |
Functions | |
bool | computeAndObtainAuth (QString actionId, WId winId=0, long pid=QCoreApplication.applicationPid()) |
PolkitQt.Auth.Result | isCallerAuthorized (PolKitAction action, long pid, bool revokeIfOneShot) |
PolkitQt.Auth.Result | isCallerAuthorized (QString actionId, long pid, bool revokeIfOneShot) |
PolkitQt.Auth.Result | isCallerAuthorized (QString actionId, QString dbusName, bool revokeIfOneShot) |
PolkitQt.Auth.Result | isCallerAuthorized (PolKitAction action, QString dbusName, bool revokeIfOneShot) |
bool | obtainAuth (QString actionId, WId winId=0, long pid=QCoreApplication.applicationPid()) |
Enumeration Documentation
Result |
Result unknown
- Enumerator:
-
Unknown = 0x00 Result unknown < p>
Yes = 0x01 AdminAuthOneShot = 0x02 AdminAuth = 0x03 AdminAuthKeepSession = 0x04 AdminAuthKeepAlways = 0x5 SelfAuthOneShot = 0x6 SelfAuth = 0x7 SelfAuthKeepSession = 0x8 SelfAuthKeepAlways = 0x9 No = 0x10
Function Documentation
bool computeAndObtainAuth | ( | QString | actionId, | |
WId | winId=0, | |||
long | pid=QCoreApplication.applicationPid() | |||
) |
Obtains authorization for the given action regardless of the Action Result. This method is meant to be used if you don't want to have an Action class that can handle all states. It will simply compute the Polkit Result and prompt for password if needed.
- See also:
- Action
- Parameters:
-
actionId id of the action in question (i.e. org.freedesktop.policykit.read)
- Parameters:
-
winId the X window id for the request (use 0 if there's no window)
- Parameters:
-
pid Process id of the application in question
- Returns:
- true if the user is authorized
PolkitQt.Auth.Result isCallerAuthorized | ( | PolKitAction | action, | |
long | pid, | |||
bool | revokeIfOneShot | |||
) |
This function should be used by mechanisms (e.g.: helper applications). It returns the action should be carried out, so if the caller was actually authorized to perform it. The result is in form of a PolKitResult, so that you can have more control over the whole process, and detect an eventual error. Most of the times you simply want to check if the result is == to Result.Yes, if you don't have specific needs.
It is CRITICAL that you call this function and check what it returns before doing anything in your helper, since otherwise you could be actually performing an action from an unknown or unauthorized caller.
The revokeIfOneShot parameter is very important: if it is set to true, if the authorization was a OneShot authorization, it will be revoked right after calling this function. To the bottom line, you should set this parameter to true if you're the mechanism (so you're actually carrying out the action), to false if you're not (for example, if you only want to check if the caller is authorized but not perform the action).
DEPRECATION WARNING: This function uses a type that will be removed in PolicyKit 1.0. Please don't use this function in your application unless strictly needed, or you will have to update it when polkit-qt 1.0 will come out. Please use the equivalent without PolKit* types.
- Note:
- The pid parameter refers to the caller. You can retrieve this through DBus.
- Parameters:
-
action the PolKitAction in question
- Parameters:
-
pid the pid of the caller we want to check authorization for
- Parameters:
-
revokeIfOneShot true if we're carrying out the action, so we want the auth to be revoked right after
false if we're not carrying out the action, so we don't want the auth to be revoked right after
- Returns:
- Result.Yes if the caller is authorized and the action should be performed
PolkitQt.Auth.Result isCallerAuthorized | ( | QString | actionId, | |
long | pid, | |||
bool | revokeIfOneShot | |||
) |
Convenience overload. Lets you use isCallerAuthorized with a QString instead of a PolKitAction.
- Parameters:
-
actionId the Id of the action in question
- Parameters:
-
pid the pid of the caller we want to check authorization for
- Parameters:
-
revokeIfOneShot true if we're carrying out the action, so we want the auth to be revoked right after
false if we're not carrying out the action, so we don't want the auth to be revoked right after
- Returns:
- Result.Yes if the caller is authorized and the action should be performed
PolkitQt.Auth.Result isCallerAuthorized | ( | QString | actionId, | |
QString | dbusName, | |||
bool | revokeIfOneShot | |||
) |
Same as above. Lets you use isCallerAuthorized with a QString DBus name instead of the PID.
- Parameters:
-
actionId the Id of the action in question
- Parameters:
-
dbusName unique name on the system message bus
- Parameters:
-
revokeIfOneShot true if we're carrying out the action, so we want the auth to be revoked right after
false if we're not carrying out the action, so we don't want the auth to be revoked right after
- Returns:
- Result.Yes if the caller is authorized and the action should be performed
PolkitQt.Auth.Result isCallerAuthorized | ( | PolKitAction | action, | |
QString | dbusName, | |||
bool | revokeIfOneShot | |||
) |
Same as above. Lets you use isCallerAuthorized with a QString DBus name instead of the PID.
DEPRECATION WARNING: This function uses a type that will be removed in PolicyKit 1.0. Please don't use this function in your application unless strictly needed, or you will have to update it when polkit-qt 1.0 will come out. Please use the equivalent without PolKit* types.
- Parameters:
-
action the PolKitAction in question
- Parameters:
-
dbusName unique name on the system message bus
- Parameters:
-
revokeIfOneShot true if we're carrying out the action, so we want the auth to be revoked right after
false if we're not carrying out the action, so we don't want the auth to be revoked right after
- Returns:
- Result.Yes if the caller is authorized and the action should be performed
bool obtainAuth | ( | QString | actionId, | |
WId | winId=0, | |||
long | pid=QCoreApplication.applicationPid() | |||
) |
Obtain authorization for the given action regardless of the Action Result. This method was meant to be used only by Action, use it only if you know what you're doing (ie. computing the Polkit Result for the given action first). If you are unsure, use computeAndObtainAuth instead
- See also:
- computeAndObtainAuth
- Parameters:
-
actionId id of the action in question (i.e. org.freedesktop.policykit.read)
- Parameters:
-
winId the X window id for the request (use 0 if there's no window)
- Parameters:
-
pid Process id of the application in question
- Returns:
- true if the user is authorized