![]() |
![]() |
![]() |
PolicyKit Library Reference Manual | ![]() |
---|---|---|---|---|
Authorization ConstraintsAuthorization Constraints — Conditions that must be satisfied in order for an authorization to apply |
enum PolKitAuthorizationConstraintType; PolKitAuthorizationConstraint; PolKitAuthorizationConstraint* polkit_authorization_constraint_get_require_local (void); PolKitAuthorizationConstraint* polkit_authorization_constraint_get_require_active (void); PolKitAuthorizationConstraint* polkit_authorization_constraint_ref (PolKitAuthorizationConstraint *authc); void polkit_authorization_constraint_unref (PolKitAuthorizationConstraint *authc); void polkit_authorization_constraint_debug (PolKitAuthorizationConstraint *authc); polkit_bool_t polkit_authorization_constraint_validate (PolKitAuthorizationConstraint *authc); PolKitAuthorizationConstraintType polkit_authorization_constraint_type (PolKitAuthorizationConstraint *authc); polkit_bool_t polkit_authorization_constraint_check_session (PolKitAuthorizationConstraint *authc, PolKitSession *session); polkit_bool_t polkit_authorization_constraint_check_caller (PolKitAuthorizationConstraint *authc, PolKitCaller *caller); size_t polkit_authorization_constraint_to_string (PolKitAuthorizationConstraint *authc, char *out_buf, size_t buf_size); PolKitAuthorizationConstraint* polkit_authorization_constraint_from_string (const char *str); size_t polkit_authorization_constraint_get_from_caller (PolKitCaller *caller, PolKitAuthorizationConstraint **out_array, size_t array_size); polkit_bool_t polkit_authorization_constraint_equal (PolKitAuthorizationConstraint *a, PolKitAuthorizationConstraint *b);
This class is used to represent conditions that must be satisfied in order for an authorization to apply
typedef enum { POLKIT_AUTHORIZATION_CONSTRAINT_TYPE_REQUIRE_LOCAL, POLKIT_AUTHORIZATION_CONSTRAINT_TYPE_REQUIRE_ACTIVE } PolKitAuthorizationConstraintType;
This enumeration describes the type of the authorization constraint.
typedef struct _PolKitAuthorizationConstraint PolKitAuthorizationConstraint;
Instances of this class are used to represent conditions that must be satisfied in order for an authorization to apply.
Since 0.7
PolKitAuthorizationConstraint* polkit_authorization_constraint_get_require_local (void);
Get a PolKitAuthorizationConstraint object that represents the constraint that the session or caller must be local.
Returns : |
the constraint; the caller shall not unref this object |
Since 0.7
PolKitAuthorizationConstraint* polkit_authorization_constraint_get_require_active (void);
Get a PolKitAuthorizationConstraint object that represents the constraint that the session or caller must be active.
Returns : |
the constraint; the caller shall not unref this object |
Since 0.7
PolKitAuthorizationConstraint* polkit_authorization_constraint_ref (PolKitAuthorizationConstraint *authc);
Increase reference count.
|
the object |
Returns : |
the object |
Since 0.7
void polkit_authorization_constraint_unref (PolKitAuthorizationConstraint *authc);
Decreases the reference count of the object. If it becomes zero, the object is freed. Before freeing, reference counts on embedded objects are decresed by one.
|
the authorization_constraint object |
Since 0.7
void polkit_authorization_constraint_debug (PolKitAuthorizationConstraint *authc);
Print debug details
|
the object |
Since 0.7
polkit_bool_t polkit_authorization_constraint_validate (PolKitAuthorizationConstraint *authc);
Validate the object
|
the object |
Returns : |
TRUE iff the object is valid. |
Since 0.7
PolKitAuthorizationConstraintType polkit_authorization_constraint_type (PolKitAuthorizationConstraint *authc);
Describe the constraint; this is only useful when inspecting an authorization to present information to the user (e.g. as polkit-auth(1) does).
|
the object |
Returns : |
type from PolKitAuthorizationConstraintFlags |
Since 0.7
polkit_bool_t polkit_authorization_constraint_check_session (PolKitAuthorizationConstraint *authc, PolKitSession *session);
Determine if the given session satisfies the conditions imposed by the given constraint.
|
the object |
|
the session |
Returns : |
TRUE if, and only if, the given session satisfies the conditions imposed by the given constraint. |
Since 0.7
polkit_bool_t polkit_authorization_constraint_check_caller (PolKitAuthorizationConstraint *authc, PolKitCaller *caller);
Determine if the given caller satisfies the conditions imposed by the given constraint
|
the object |
|
the caller |
Returns : |
TRUE if, and only if, the given caller satisfies the conditions imposed by the given constraint. |
Since 0.7
size_t polkit_authorization_constraint_to_string (PolKitAuthorizationConstraint *authc, char *out_buf, size_t buf_size);
Get a textual representation of the constraint; this is only useful for serializing; it's a machine, not human, readable string.
|
the object |
|
buffer to store the string representation in |
|
size of buffer |
Returns : |
Number of characters written (not including trailing '\0'). If the output was truncated due to the buffer being too small, buf_size will be returned. Thus, a return value of buf_size or more indicates that the output was truncated (see snprintf(3)) or an error occured. |
Since 0.7
PolKitAuthorizationConstraint* polkit_authorization_constraint_from_string (const char *str);
Construct a constraint from a textual representation as returned by
polkit_authorization_constraint_to_string()
.
|
textual representation of constraint |
Returns : |
the constraint or NULL if the string coulnd't be parsed. |
size_t polkit_authorization_constraint_get_from_caller (PolKitCaller *caller, PolKitAuthorizationConstraint **out_array, size_t array_size);
Given a caller, return the set of most restrictive constraints possible. For example, if the caller is local and active, a set constraints requiring this will be returned.
This function is typically used when the caller obtains an authorization through authentication; the goal is to put constraints on the authorization such that it's only valid when the caller is in the context as where she obtained it.
The caller must unref all the created objects using
polkit_authorization_constraint_unref()
.
|
caller |
|
return location for constraints |
|
size of the passed array |
Returns : |
This function do not create more than array_size constraints
(including the trailing NULL ). If the output was truncated due to
this limit then the return value is the number of objects (not
including the trailing NULL ) which would have been written to the
final array if enough space had been available. Thus, a return
value of array_size or more means that the output was truncated.
|
polkit_bool_t polkit_authorization_constraint_equal (PolKitAuthorizationConstraint *a, PolKitAuthorizationConstraint *b);
Determines if two constraints are equal
|
first constraint |
|
first constraint |
Returns : |
TRUE only if the given constraints are equal |
Since 0.7