#include <polkit/polkit.h>
#include <dbus/dbus.h>
+POLKIT_BEGIN_DECLS
+
PolKitSession *polkit_session_new_from_objpath (DBusConnection *con, const char *objpath, uid_t uid, DBusError *error);
PolKitSession *polkit_session_new_from_cookie (DBusConnection *con, const char *cookie, DBusError *error);
PolKitCaller *polkit_tracker_get_caller_from_pid (PolKitTracker *pk_tracker, pid_t pid, DBusError *error);
+POLKIT_END_DECLS
#endif /* POLKIT_DBUS_H */
#include <polkit/polkit.h>
+POLKIT_BEGIN_DECLS
+
struct _PolKitGrant;
typedef struct _PolKitGrant PolKitGrant;
void polkit_grant_io_func (PolKitGrant *polkit_grant, int fd);
void polkit_grant_child_func (PolKitGrant *polkit_grant, pid_t pid, int exit_code);
+POLKIT_END_DECLS
#endif /* POLKIT_GRANT_H */
#include <polkit/polkit-types.h>
+POLKIT_BEGIN_DECLS
+
struct _PolKitAction;
typedef struct _PolKitAction PolKitAction;
polkit_bool_t polkit_action_validate_id (const char *action_id);
+POLKIT_END_DECLS
+
#endif /* POLKIT_ACTION_H */
#include <polkit/polkit-session.h>
#include <sys/types.h>
+POLKIT_BEGIN_DECLS
+
struct _PolKitCaller;
typedef struct _PolKitCaller PolKitCaller;
void polkit_caller_debug (PolKitCaller *caller);
polkit_bool_t polkit_caller_validate (PolKitCaller *caller);
+POLKIT_END_DECLS
+
#endif /* POLKIT_H */
#include <sys/types.h>
#include <regex.h>
+#include <polkit/polkit-types.h>
#include <polkit/polkit-error.h>
#include <polkit/polkit-types.h>
#include <polkit/polkit-result.h>
#include <polkit/polkit-session.h>
#include <polkit/polkit-caller.h>
+POLKIT_BEGIN_DECLS
+
struct _PolKitConfig;
typedef struct _PolKitConfig PolKitConfig;
PolKitConfigAdminAuthType *out_admin_auth_type,
const char **out_data);
+POLKIT_END_DECLS
+
#endif /* POLKIT_CONFIG_H */
#include <polkit/polkit-policy-cache.h>
#include <polkit/polkit-config.h>
+POLKIT_BEGIN_DECLS
+
struct _PolKitContext;
typedef struct _PolKitContext PolKitContext;
PolKitConfig *polkit_context_get_config (PolKitContext *pk_context, PolKitError **error);
+POLKIT_END_DECLS
+
#endif /* POLKIT_CONTEXT_H */
#ifndef POLKIT_ERROR_H
#define POLKIT_ERROR_H
+#include <polkit/polkit-types.h>
+
+POLKIT_BEGIN_DECLS
+
/**
* PolKitErrorCode:
* @POLKIT_ERROR_OUT_OF_MEMORY: Out of memory
void polkit_error_free (PolKitError *error);
void polkit_error_set_error (PolKitError **error, PolKitErrorCode error_code, const char *format, ...) __attribute__((__format__ (__printf__, 3, 4)));
+POLKIT_END_DECLS
+
#endif /* POLKIT_ERROR_H */
#include <polkit/polkit.h>
+POLKIT_BEGIN_DECLS
+
PolKitResult _polkit_grantdb_check_can_caller_do_action (PolKitContext *pk_context,
PolKitAction *action,
PolKitCaller *caller);
polkit_bool_t _polkit_grantdb_delete_for_user (uid_t uid);
+POLKIT_END_DECLS
+
#endif /* POLKIT_GRANT_DATABASE_H */
callback (policy_cache, pfe, user_data);
}
}
+
+/**
+ * polkit_policy_cache_get_entry_by_annotation:
+ * @policy_cache: the policy cache
+ * @annotation_key: the key to check for
+ * @annotation_value: the value to check for
+ *
+ * Find the first policy file entry where a given annotation matches a
+ * given value. Note that there is nothing preventing the existence of
+ * multiple policy file entries matching this criteria; it would
+ * however be a packaging bug if this situation occured.
+ *
+ * Returns: The first #PolKitPolicyFileEntry matching the search
+ * criteria. The caller shall not unref this object. Returns #NULL if
+ * there are no policy file entries matching the search criteria.
+ */
+PolKitPolicyFileEntry*
+polkit_policy_cache_get_entry_by_annotation (PolKitPolicyCache *policy_cache,
+ const char *annotation_key,
+ const char *annotation_value)
+{
+ GSList *i;
+
+ g_return_val_if_fail (policy_cache != NULL, NULL);
+ g_return_val_if_fail (annotation_key != NULL, NULL);
+ g_return_val_if_fail (annotation_value != NULL, NULL);
+
+ for (i = policy_cache->priv_entries; i != NULL; i = g_slist_next (i)) {
+ const char *value;
+ PolKitPolicyFileEntry *pfe = i->data;
+
+ value = polkit_policy_file_entry_get_annotation (pfe, annotation_key);
+ if (value == NULL)
+ continue;
+
+ if (strcmp (annotation_value, value) == 0) {
+ return pfe;
+ }
+ }
+
+ return NULL;
+}
#ifndef POLKIT_POLICY_CACHE_H
#define POLKIT_POLICY_CACHE_H
+#include <polkit/polkit-types.h>
#include <polkit/polkit-error.h>
#include <polkit/polkit-action.h>
#include <polkit/polkit-policy-file-entry.h>
+POLKIT_BEGIN_DECLS
+
struct _PolKitPolicyCache;
typedef struct _PolKitPolicyCache PolKitPolicyCache;
PolKitAction *action);
PolKitPolicyFileEntry* polkit_policy_cache_get_entry_by_id (PolKitPolicyCache *policy_cache,
const char *action_id);
+
+PolKitPolicyFileEntry* polkit_policy_cache_get_entry_by_annotation (PolKitPolicyCache *policy_cache,
+ const char *annotation_key,
+ const char *annotation_value);
+
void polkit_policy_cache_foreach (PolKitPolicyCache *policy_cache,
PolKitPolicyCacheForeachFunc callback,
void *user_data);
+POLKIT_END_DECLS
+
#endif /* POLKIT_POLICY_CACHE_H */
#ifndef POLKIT_POLICY_DEFAULT_H
#define POLKIT_POLICY_DEFAULT_H
+#include <polkit/polkit-types.h>
#include <polkit/polkit-result.h>
#include <polkit/polkit-action.h>
#include <polkit/polkit-session.h>
#include <polkit/polkit-caller.h>
#include <polkit/polkit-error.h>
+POLKIT_BEGIN_DECLS
+
struct _PolKitPolicyDefault;
typedef struct _PolKitPolicyDefault PolKitPolicyDefault;
/* TODO: export knobs for "default policy" */
+POLKIT_END_DECLS
+
#endif /* POLKIT_POLICY_DEFAULT_H */
#ifndef POLKIT_POLICY_FILE_ENTRY_H
#define POLKIT_POLICY_FILE_ENTRY_H
+#include <polkit/polkit-types.h>
#include <polkit/polkit-result.h>
#include <polkit/polkit-policy-default.h>
+POLKIT_BEGIN_DECLS
+
struct _PolKitPolicyFileEntry;
typedef struct _PolKitPolicyFileEntry PolKitPolicyFileEntry;
const char *polkit_policy_file_entry_get_annotation (PolKitPolicyFileEntry *policy_file_entry,
const char *key);
+POLKIT_END_DECLS
#endif /* POLKIT_POLICY_FILE_ENTRY_H */
#ifndef POLKIT_POLICY_FILE_H
#define POLKIT_POLICY_FILE_H
+#include <polkit/polkit-types.h>
#include <polkit/polkit-error.h>
#include <polkit/polkit-policy-file-entry.h>
+POLKIT_BEGIN_DECLS
+
struct _PolKitPolicyFile;
typedef struct _PolKitPolicyFile PolKitPolicyFile;
PolKitPolicyFileEntryForeachFunc cb,
void *user_data);
+POLKIT_END_DECLS
+
#endif /* POLKIT_POLICY_FILE_H */
#include <polkit/polkit-types.h>
+POLKIT_BEGIN_DECLS
+
/**
* PolKitResult:
* @POLKIT_RESULT_UNKNOWN: The result is unknown / cannot be
polkit_bool_t
polkit_result_from_string_representation (const char *string, PolKitResult *out_result);
+POLKIT_END_DECLS
+
#endif /* POLKIT_RESULT_H */
#include <polkit/polkit-types.h>
+POLKIT_BEGIN_DECLS
+
struct _PolKitSeat;
typedef struct _PolKitSeat PolKitSeat;
void polkit_seat_debug (PolKitSeat *seat);
polkit_bool_t polkit_seat_validate (PolKitSeat *seat);
+POLKIT_END_DECLS
+
#endif /* POLKIT_SEAT_H */
#include <sys/types.h>
+POLKIT_BEGIN_DECLS
+
struct _PolKitSession;
typedef struct _PolKitSession PolKitSession;
void polkit_session_debug (PolKitSession *session);
polkit_bool_t polkit_session_validate (PolKitSession *session);
+POLKIT_END_DECLS
+
#endif /* POLKIT_SESSION_H */
#ifndef POLKIT_TYPES_H
#define POLKIT_TYPES_H
+#ifdef __cplusplus
+# define POLKIT_BEGIN_DECLS extern "C" {
+# define POLKIT_END_DECLS }
+#else
+# define POLKIT_BEGIN_DECLS
+# define POLKIT_END_DECLS
+#endif
+
+POLKIT_BEGIN_DECLS
+
/**
* SECTION:polkit-types
* @title: Basic types
# define FALSE 0
#endif
+POLKIT_END_DECLS
+
#endif /* POLKIT_TYPES_H */
#include <polkit/polkit-types.h>
+POLKIT_BEGIN_DECLS
+
polkit_bool_t _pk_validate_identifier (const char *identifier);
polkit_bool_t _pk_validate_unique_bus_name (const char *unique_bus_name);
+POLKIT_END_DECLS
+
#endif /* POLKIT_UTILS_H */
#include <polkit/polkit-policy-file.h>
#include <polkit/polkit-policy-cache.h>
#include <polkit/polkit-policy-default.h>
+#include <polkit/polkit-config.h>
#undef _POLKIT_INSIDE_POLKIT_H
#endif /* POLKIT_H */