Debian Codegraph @

src/polkitbackend/polkitbackendcommon.h

raw
1 /*
2 * Copyright (C) 2008 Red Hat, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General
15 * Public License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Zeuthen <[email protected]>
20 */
21
22 #if !defined (_POLKIT_BACKEND_COMPILATION) && !defined(_POLKIT_BACKEND_INSIDE_POLKIT_BACKEND_H)
23 #error "Only <polkitbackend/polkitbackend.h> can be included directly, this file may disappear or change contents."
24 #endif
25
26 #ifndef __POLKIT_BACKEND_COMMON_H
27 #define __POLKIT_BACKEND_COMMON_H
28
29 #include <sys/wait.h>
30 #include <errno.h>
31 #include <pwd.h>
32 #include <grp.h>
33 #ifdef HAVE_NETGROUP_H
34 #include <netgroup.h>
35 #else
36 #include <netdb.h>
37 #endif
38 #include <string.h>
39 #include <gio/gunixfdlist.h>
40 #include <glib/gstdio.h>
41 #include <locale.h>
42 #include <glib/gi18n-lib.h> //here, all things glib via glib.h (including -> gspawn.h)
43
44 #include <polkit/polkit.h>
45 #include "polkitbackendjsauthority.h"
46
47 #include <polkit/polkitprivate.h>
48
49 #ifdef HAVE_LIBSYSTEMD
50 #include <systemd/sd-login.h>
51 #endif /* HAVE_LIBSYSTEMD */
52
53 #define RUNAWAY_KILLER_TIMEOUT (15)
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 enum
60 {
61 PROP_0,
62 PROP_RULES_DIRS,
63 };
64
65 typedef struct
66 {
67 GSimpleAsyncResult *simple; /* borrowed reference */
68 GMainContext *main_context; /* may be NULL */
69
70 GCancellable *cancellable; /* may be NULL */
71 gulong cancellable_handler_id;
72
73 GPid child_pid;
74 gint child_stdout_fd;
75 gint child_stderr_fd;
76
77 GIOChannel *child_stdout_channel;
78 GIOChannel *child_stderr_channel;
79
80 GSource *child_watch_source;
81 GSource *child_stdout_source;
82 GSource *child_stderr_source;
83
84 guint timeout_seconds;
85 gboolean timed_out;
86 GSource *timeout_source;
87
88 GString *child_stdout;
89 GString *child_stderr;
90
91 gint exit_status;
92 } UtilsSpawnData;
93
94 typedef struct
95 {
96 GMainLoop *loop;
97 GAsyncResult *res;
98 } SpawnData;
99
100 void polkit_backend_common_spawn (const gchar *const *argv,
101 guint timeout_seconds,
102 GCancellable *cancellable,
103 GAsyncReadyCallback callback,
104 gpointer user_data);
105 void polkit_backend_common_spawn_cb (GObject *source_object,
106 GAsyncResult *res,
107 gpointer user_data);
108 gboolean polkit_backend_common_spawn_finish (GAsyncResult *res,
109 gint *out_exit_status,
110 gchar **out_standard_output,
111 gchar **out_standard_error,
112 GError **error);
113
114 void polkit_backend_common_on_dir_monitor_changed (GFileMonitor *monitor,
115 GFile *file,
116 GFile *other_file,
117 GFileMonitorEvent event_type,
118 gpointer user_data);
119
120 void polkit_backend_common_js_authority_class_init_common (PolkitBackendJsAuthorityClass *klass);
121
122 gint polkit_backend_common_rules_file_name_cmp (const gchar *a,
123 const gchar *b);
124
125 const gchar *polkit_backend_common_get_signal_name (gint signal_number);
126
127 /* To be provided by each JS backend, from here onwards ---------------------------------------------- */
128
129 void polkit_backend_common_reload_scripts (PolkitBackendJsAuthority *authority);
130 void polkit_backend_common_js_authority_finalize (GObject *object);
131 void polkit_backend_common_js_authority_constructed (GObject *object);
132 GList *polkit_backend_common_js_authority_get_admin_auth_identities (PolkitBackendInteractiveAuthority *_authority,
133 PolkitSubject *caller,
134 PolkitSubject *subject,
135 PolkitIdentity *user_for_subject,
136 gboolean subject_is_local,
137 gboolean subject_is_active,
138 const gchar *action_id,
139 PolkitDetails *details);
140 void polkit_backend_common_js_authority_set_property (GObject *object,
141 guint property_id,
142 const GValue *value,
143 GParamSpec *pspec);
144 PolkitImplicitAuthorization polkit_backend_common_js_authority_check_authorization_sync (PolkitBackendInteractiveAuthority *_authority,
145 PolkitSubject *caller,
146 PolkitSubject *subject,
147 PolkitIdentity *user_for_subject,
148 gboolean subject_is_local,
149 gboolean subject_is_active,
150 const gchar *action_id,
151 PolkitDetails *details,
152 PolkitImplicitAuthorization implicit);
153 void polkit_backend_common_pidfd_to_systemd_unit (gint pid,
154 gchar **ret_unit,
155 gboolean *ret_no_new_privs);
156 #ifdef __cplusplus
157 }
158 #endif
159
160 #endif /* __POLKIT_BACKEND_COMMON_H */
161