Commit f455c2f6 authored by David Zeuthen's avatar David Zeuthen
Browse files

add C++ include guards and a new method to get pfe's by annotation

parent 0d7cdd74
......@@ -30,6 +30,8 @@
#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);
......@@ -54,6 +56,7 @@ PolKitCaller *polkit_tracker_get_caller_from_dbus_name (PolKitTracker *pk_trac
PolKitCaller *polkit_tracker_get_caller_from_pid (PolKitTracker *pk_tracker, pid_t pid, DBusError *error);
POLKIT_END_DECLS
#endif /* POLKIT_DBUS_H */
......
......@@ -28,6 +28,8 @@
#include <polkit/polkit.h>
POLKIT_BEGIN_DECLS
struct _PolKitGrant;
typedef struct _PolKitGrant PolKitGrant;
......@@ -360,6 +362,7 @@ void polkit_grant_cancel_auth (PolKitGrant *polkit_grant);
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 */
......
......@@ -32,6 +32,8 @@
#include <polkit/polkit-types.h>
POLKIT_BEGIN_DECLS
struct _PolKitAction;
typedef struct _PolKitAction PolKitAction;
......@@ -46,6 +48,8 @@ polkit_bool_t polkit_action_validate (PolKitAction *action);
polkit_bool_t polkit_action_validate_id (const char *action_id);
POLKIT_END_DECLS
#endif /* POLKIT_ACTION_H */
......@@ -34,6 +34,8 @@
#include <polkit/polkit-session.h>
#include <sys/types.h>
POLKIT_BEGIN_DECLS
struct _PolKitCaller;
typedef struct _PolKitCaller PolKitCaller;
......@@ -54,4 +56,6 @@ polkit_bool_t polkit_caller_get_ck_session (PolKitCaller *caller, Pol
void polkit_caller_debug (PolKitCaller *caller);
polkit_bool_t polkit_caller_validate (PolKitCaller *caller);
POLKIT_END_DECLS
#endif /* POLKIT_H */
......@@ -32,6 +32,7 @@
#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>
......@@ -39,6 +40,8 @@
#include <polkit/polkit-session.h>
#include <polkit/polkit-caller.h>
POLKIT_BEGIN_DECLS
struct _PolKitConfig;
typedef struct _PolKitConfig PolKitConfig;
......@@ -78,6 +81,8 @@ polkit_bool_t polkit_config_determine_admin_auth_type (PolKitConfig
PolKitConfigAdminAuthType *out_admin_auth_type,
const char **out_data);
POLKIT_END_DECLS
#endif /* POLKIT_CONFIG_H */
......@@ -41,6 +41,8 @@
#include <polkit/polkit-policy-cache.h>
#include <polkit/polkit-config.h>
POLKIT_BEGIN_DECLS
struct _PolKitContext;
typedef struct _PolKitContext PolKitContext;
......@@ -165,6 +167,8 @@ PolKitResult polkit_context_can_caller_do_action (PolKitContext *pk_contex
PolKitConfig *polkit_context_get_config (PolKitContext *pk_context, PolKitError **error);
POLKIT_END_DECLS
#endif /* POLKIT_CONTEXT_H */
......@@ -30,6 +30,10 @@
#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
......@@ -51,4 +55,6 @@ const char *polkit_error_get_error_message (PolKitError *error);
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 */
......@@ -28,6 +28,8 @@
#include <polkit/polkit.h>
POLKIT_BEGIN_DECLS
PolKitResult _polkit_grantdb_check_can_caller_do_action (PolKitContext *pk_context,
PolKitAction *action,
PolKitCaller *caller);
......@@ -78,4 +80,6 @@ void _polkit_grantdb_foreach (PolKitGrantDbForeachFunc callback, void *user_data
polkit_bool_t _polkit_grantdb_delete_for_user (uid_t uid);
POLKIT_END_DECLS
#endif /* POLKIT_GRANT_DATABASE_H */
......@@ -301,3 +301,45 @@ polkit_policy_cache_foreach (PolKitPolicyCache *policy_cache,
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;
}
......@@ -30,10 +30,13 @@
#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;
......@@ -56,10 +59,17 @@ PolKitPolicyFileEntry* polkit_policy_cache_get_entry (PolKitPolicyCache *policy_
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 */
......@@ -30,12 +30,15 @@
#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;
......@@ -57,6 +60,8 @@ PolKitResult polkit_policy_default_get_allow_active (PolKitPolicyDefault *policy
/* TODO: export knobs for "default policy" */
POLKIT_END_DECLS
#endif /* POLKIT_POLICY_DEFAULT_H */
......@@ -30,9 +30,12 @@
#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;
......@@ -66,6 +69,7 @@ void polkit_policy_file_entry_annotations_foreach (PolKitPolic
const char *polkit_policy_file_entry_get_annotation (PolKitPolicyFileEntry *policy_file_entry,
const char *key);
POLKIT_END_DECLS
#endif /* POLKIT_POLICY_FILE_ENTRY_H */
......
......@@ -30,9 +30,12 @@
#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;
......@@ -57,6 +60,8 @@ void polkit_policy_file_entry_foreach (PolKitPolicyFile
PolKitPolicyFileEntryForeachFunc cb,
void *user_data);
POLKIT_END_DECLS
#endif /* POLKIT_POLICY_FILE_H */
......@@ -32,6 +32,8 @@
#include <polkit/polkit-types.h>
POLKIT_BEGIN_DECLS
/**
* PolKitResult:
* @POLKIT_RESULT_UNKNOWN: The result is unknown / cannot be
......@@ -88,4 +90,6 @@ polkit_result_to_string_representation (PolKitResult result);
polkit_bool_t
polkit_result_from_string_representation (const char *string, PolKitResult *out_result);
POLKIT_END_DECLS
#endif /* POLKIT_RESULT_H */
......@@ -32,6 +32,8 @@
#include <polkit/polkit-types.h>
POLKIT_BEGIN_DECLS
struct _PolKitSeat;
typedef struct _PolKitSeat PolKitSeat;
......@@ -44,6 +46,8 @@ polkit_bool_t polkit_seat_get_ck_objref (PolKitSeat *seat, char **out_ck_o
void polkit_seat_debug (PolKitSeat *seat);
polkit_bool_t polkit_seat_validate (PolKitSeat *seat);
POLKIT_END_DECLS
#endif /* POLKIT_SEAT_H */
......@@ -35,6 +35,8 @@
#include <sys/types.h>
POLKIT_BEGIN_DECLS
struct _PolKitSession;
typedef struct _PolKitSession PolKitSession;
......@@ -57,4 +59,6 @@ polkit_bool_t polkit_session_get_ck_remote_host (PolKitSession *session, char
void polkit_session_debug (PolKitSession *session);
polkit_bool_t polkit_session_validate (PolKitSession *session);
POLKIT_END_DECLS
#endif /* POLKIT_SESSION_H */
......@@ -30,6 +30,16 @@
#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
......@@ -59,6 +69,8 @@ typedef unsigned long long polkit_uint64_t;
# define FALSE 0
#endif
POLKIT_END_DECLS
#endif /* POLKIT_TYPES_H */
......@@ -28,10 +28,14 @@
#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 */
......@@ -39,6 +39,7 @@
#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 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment