1/***************************************************************************
2 *
3 * libpolkit.h : Wraps a subset of methods on the PolicyKit daemon
4 *
5 * Copyright (C) 2006 David Zeuthen, <david@fubar.dk>
6 *
7 * Licensed under the Academic Free License version 2.1
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 *
23 **************************************************************************/
24
25#ifndef LIBPOLKIT_H
26#define LIBPOLKIT_H
27
28#include <stdio.h>
29#include <unistd.h>
30#include <sys/types.h>
31#include <glib.h>
32#include <dbus/dbus.h>
33
34typedef enum {
35	LIBPOLKIT_RESULT_OK,
36	LIBPOLKIT_RESULT_ERROR,
37	LIBPOLKIT_RESULT_INVALID_CONTEXT,
38	LIBPOLKIT_RESULT_NOT_PRIVILEGED,
39	LIBPOLKIT_RESULT_NO_SUCH_PRIVILEGE,
40	LIBPOLKIT_RESULT_NO_SUCH_USER
41} LibPolKitResult;
42
43struct LibPolKitContext_s;
44typedef struct LibPolKitContext_s LibPolKitContext;
45
46LibPolKitContext  *libpolkit_new_context                              (DBusConnection        *connection);
47
48gboolean           libpolkit_free_context                             (LibPolKitContext      *ctx);
49
50LibPolKitResult    libpolkit_get_privilege_list                       (LibPolKitContext      *ctx,
51								       GList                **result);
52
53LibPolKitResult    libpolkit_is_uid_allowed_for_privilege             (LibPolKitContext      *ctx,
54								       const char            *system_bus_unique_name,
55								       const char            *user,
56								       const char            *privilege,
57								       const char            *resource,
58								       gboolean              *out_is_allowed,
59								       gboolean              *out_is_temporary,
60								       char                 **out_is_privileged_but_restricted_to_system_bus_unique_name);
61
62LibPolKitResult    libpolkit_revoke_temporary_privilege               (LibPolKitContext      *ctx,
63								       const char            *user,
64								       const char            *privilege,
65								       const char            *resource,
66								       gboolean              *result);
67
68LibPolKitResult    libpolkit_get_allowed_resources_for_privilege_for_uid (LibPolKitContext      *ctx,
69									  const char            *user,
70									  const char            *privilege,
71									  GList                **resources,
72									  GList                **restrictions,
73									  int                   *num_non_temporary);
74
75#endif /* LIBPOLKIT_H */
76
77
78