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