This source file includes following definitions.
- pcmk__ipc_sys_name
1
2
3
4
5
6
7
8
9
10 #ifndef PCMK__IPC_INTERNAL_H
11 #define PCMK__IPC_INTERNAL_H
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 #include <stdbool.h>
18 #include <stdint.h>
19 #include <sys/uio.h>
20 #include <sys/types.h>
21
22 #ifdef HAVE_GNUTLS_GNUTLS_H
23 # include <gnutls/gnutls.h>
24 #endif
25
26 #include <glib.h>
27 #include <libxml/tree.h>
28 #include <qb/qbipcs.h>
29
30 #include <crm_config.h>
31 #include <crm/common/ipc.h>
32 #include <crm/common/mainloop.h>
33
34
35
36
37
38
39
40
41 #define PCMK__SPECIAL_PID 1
42
43
44 #define PCMK__IPC_TIMEOUT 120
45
46 #if defined(US_AUTH_GETPEEREID)
47
48
49
50
51 #define PCMK__SPECIAL_PID_AS_0(p) (((p) == PCMK__SPECIAL_PID) ? 0 : (p))
52 #else
53 #define PCMK__SPECIAL_PID_AS_0(p) (p)
54 #endif
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 int pcmk__ipc_is_authentic_process_active(const char *name, uid_t refuid,
89 gid_t refgid, pid_t *gotpid);
90
91
92
93
94
95
96 typedef struct pcmk__client_s pcmk__client_t;
97
98 struct pcmk__remote_s {
99
100 char *buffer;
101 size_t buffer_size;
102 size_t buffer_offset;
103 int auth_timeout;
104 int tcp_socket;
105 mainloop_io_t *source;
106
107
108 bool authenticated;
109 char *token;
110
111
112 # ifdef HAVE_GNUTLS_GNUTLS_H
113 gnutls_session_t *tls_session;
114 bool tls_handshake_complete;
115 # endif
116 };
117
118 enum pcmk__client_flags {
119
120
121
122 pcmk__client_ipc = (UINT64_C(1) << 32),
123 pcmk__client_tcp = (UINT64_C(1) << 33),
124 # ifdef HAVE_GNUTLS_GNUTLS_H
125 pcmk__client_tls = (UINT64_C(1) << 34),
126 # endif
127
128
129 pcmk__client_proxied = (UINT64_C(1) << 40),
130 pcmk__client_privileged = (UINT64_C(1) << 41),
131 pcmk__client_to_proxy = (UINT64_C(1) << 42),
132 };
133
134 #define PCMK__CLIENT_TYPE(client) ((client)->flags & UINT64_C(0xff00000000))
135
136 struct pcmk__client_s {
137 unsigned int pid;
138
139 char *id;
140 char *name;
141 char *user;
142 uint64_t flags;
143
144 int request_id;
145 void *userdata;
146
147 int event_timer;
148 GQueue *event_queue;
149
150
151
152
153
154 qb_ipcs_connection_t *ipcs;
155
156 struct pcmk__remote_s *remote;
157
158 unsigned int queue_backlog;
159 unsigned int queue_max;
160 };
161
162 #define pcmk__set_client_flags(client, flags_to_set) do { \
163 (client)->flags = pcmk__set_flags_as(__func__, __LINE__, \
164 LOG_TRACE, \
165 "Client", pcmk__client_name(client), \
166 (client)->flags, (flags_to_set), #flags_to_set); \
167 } while (0)
168
169 #define pcmk__clear_client_flags(client, flags_to_clear) do { \
170 (client)->flags = pcmk__clear_flags_as(__func__, __LINE__, \
171 LOG_TRACE, \
172 "Client", pcmk__client_name(client), \
173 (client)->flags, (flags_to_clear), #flags_to_clear); \
174 } while (0)
175
176 #define pcmk__set_ipc_flags(ipc_flags, ipc_name, flags_to_set) do { \
177 ipc_flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE, \
178 "IPC", (ipc_name), \
179 (ipc_flags), (flags_to_set), \
180 #flags_to_set); \
181 } while (0)
182
183 #define pcmk__clear_ipc_flags(ipc_flags, ipc_name, flags_to_clear) do { \
184 ipc_flags = pcmk__clear_flags_as(__func__, __LINE__, LOG_TRACE, \
185 "IPC", (ipc_name), \
186 (ipc_flags), (flags_to_clear), \
187 #flags_to_clear); \
188 } while (0)
189
190 guint pcmk__ipc_client_count(void);
191 void pcmk__foreach_ipc_client(GHFunc func, gpointer user_data);
192
193 void pcmk__client_cleanup(void);
194
195 pcmk__client_t *pcmk__find_client(qb_ipcs_connection_t *c);
196 pcmk__client_t *pcmk__find_client_by_id(const char *id);
197 const char *pcmk__client_name(pcmk__client_t *c);
198 const char *pcmk__client_type_str(uint64_t client_type);
199
200 pcmk__client_t *pcmk__new_unauth_client(void *key);
201 pcmk__client_t *pcmk__new_client(qb_ipcs_connection_t *c, uid_t uid, gid_t gid);
202 void pcmk__free_client(pcmk__client_t *c);
203 void pcmk__drop_all_clients(qb_ipcs_service_t *s);
204 bool pcmk__set_client_queue_max(pcmk__client_t *client, const char *qmax);
205
206 xmlNode *pcmk__ipc_create_ack_as(const char *function, int line, uint32_t flags,
207 const char *tag, crm_exit_t status);
208 #define pcmk__ipc_create_ack(flags, tag, st) \
209 pcmk__ipc_create_ack_as(__func__, __LINE__, (flags), (tag), (st))
210
211 int pcmk__ipc_send_ack_as(const char *function, int line, pcmk__client_t *c,
212 uint32_t request, uint32_t flags, const char *tag,
213 crm_exit_t status);
214 #define pcmk__ipc_send_ack(c, req, flags, tag, st) \
215 pcmk__ipc_send_ack_as(__func__, __LINE__, (c), (req), (flags), (tag), (st))
216
217 int pcmk__ipc_prepare_iov(uint32_t request, xmlNode *message,
218 uint32_t max_send_size,
219 struct iovec **result, ssize_t *bytes);
220 int pcmk__ipc_send_xml(pcmk__client_t *c, uint32_t request, xmlNode *message,
221 uint32_t flags);
222 int pcmk__ipc_send_iov(pcmk__client_t *c, struct iovec *iov, uint32_t flags);
223 xmlNode *pcmk__client_data2xml(pcmk__client_t *c, void *data,
224 uint32_t *id, uint32_t *flags);
225
226 int pcmk__client_pid(qb_ipcs_connection_t *c);
227
228 void pcmk__serve_attrd_ipc(qb_ipcs_service_t **ipcs,
229 struct qb_ipcs_service_handlers *cb);
230 void pcmk__serve_fenced_ipc(qb_ipcs_service_t **ipcs,
231 struct qb_ipcs_service_handlers *cb);
232 void pcmk__serve_pacemakerd_ipc(qb_ipcs_service_t **ipcs,
233 struct qb_ipcs_service_handlers *cb);
234 qb_ipcs_service_t *pcmk__serve_schedulerd_ipc(struct qb_ipcs_service_handlers *cb);
235 qb_ipcs_service_t *pcmk__serve_controld_ipc(struct qb_ipcs_service_handlers *cb);
236
237 void pcmk__serve_based_ipc(qb_ipcs_service_t **ipcs_ro,
238 qb_ipcs_service_t **ipcs_rw,
239 qb_ipcs_service_t **ipcs_shm,
240 struct qb_ipcs_service_handlers *ro_cb,
241 struct qb_ipcs_service_handlers *rw_cb);
242
243 void pcmk__stop_based_ipc(qb_ipcs_service_t *ipcs_ro,
244 qb_ipcs_service_t *ipcs_rw,
245 qb_ipcs_service_t *ipcs_shm);
246
247 static inline const char *
248 pcmk__ipc_sys_name(const char *ipc_name, const char *fallback)
249 {
250 return ipc_name ? ipc_name : ((crm_system_name ? crm_system_name : fallback));
251 }
252
253 #ifdef __cplusplus
254 }
255 #endif
256
257 #endif