Debian Codegraph @

src/OVAL/probes/SEAP/seap-command.c

raw symbols SCIP
1 /*
2 * Copyright 2009 Red Hat Inc., Durham, North Carolina.
3 * All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Authors:
20 * "Daniel Kopecek" <[email protected]>
21 */
22
23 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
24 #include <config.h>cxx . . $ `<file>/build/config.h`/
25 #endif
26
27 #include <stdarg.h>
28 #include <string.h>
29 #include <errno.h>
30 #if defined(SEAP_THREAD_SAFE)
31 # include <pthread.h>
32 #endif
33
34 #include "generic/common.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/generic/common.h`/
35 #include "_seap-types.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap-types.h`/
36 #include "_sexp-types.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_sexp-types.h`/
37 #include "generic/redblack.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/generic/redblack.h`/
38 #include "_seap-command.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap-command.h`/
39 #include "_seap-packet.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap-packet.h`/
40 #include "_seap.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap.h`/
41 #include "debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/
42
43 int SEAP_cmd_registercxx . . $ SEAP_cmd_register(8e6e8c3c92801ad2). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, SEAP_cmdcode_tcxx . . $ SEAP_cmdcode_t# code, uint32_tcxx . . $ uint32_t# flags, SEAP_cmdfn_tcxx . . $ SEAP_cmdfn_t# func, ...) /* sd, arg */
44 {
45 va_listcxx . . $ va_list# ap;
46 int sd;
47 void *arg;
48
49 SEAP_desc_tcxx . . $ SEAP_desc_t# *dsc;
50 SEAP_cmdtbl_tcxx . . $ SEAP_cmdtbl_t# *tbl;
51 SEAP_cmdrec_tcxx . . $ SEAP_cmdrec_t# *rec;
52
53 _Acxx . . $ `src/common/debug_priv.h:43:9`!(ctx != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
54 _Acxx . . $ `src/common/debug_priv.h:43:9`!(func != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
55
56 sd = -1;
57 arg = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
58
59 va_startcxx . . $ `<external>/8105065126723003039/stdarg.h:50:9`! (ap, func);
60
61 if (flags & SEAP_CMDREG_LOCALcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:47:9`!) {
62 sd = va_argcxx . . $ `<external>/8105065126723003039/stdarg.h:53:9`! (ap, int);
63 dsc = SEAP_desc_getcxx . . $ SEAP_desc_get(b324436d5ff0f8fe). (ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., sd);
64
65 if (dsc == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
66 va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`!(ap);
67 return (-1);
68 }
69
70 tbl = dsc->cmd_c_tablecxx . . $ $anonymous_type_5b6d52305350878e_0#cmd_c_table.;
71 } else {
72 tbl = ctx->cmd_c_tablecxx . . $ SEAP_CTX#cmd_c_table.;
73 }
74
75 _Acxx . . $ `src/common/debug_priv.h:43:9`!(tbl != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
76
77 if (flags & SEAP_CMDREG_USEARGcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:48:9`!) {
78 arg = va_argcxx . . $ `<external>/8105065126723003039/stdarg.h:53:9`! (ap, void *);
79 _Acxx . . $ `src/common/debug_priv.h:43:9`!(arg != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
80 }
81
82 va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`!(ap);
83
84 rec = SEAP_cmdrec_newcxx . . $ SEAP_cmdrec_new(6a77a790710a8e8e). ();
85 rec->codecxx . . $ $anonymous_type_a585f4dc5f186eef_0#code. = code;
86 rec->funccxx . . $ $anonymous_type_a585f4dc5f186eef_0#func. = func;
87 rec->argcxx . . $ $anonymous_type_a585f4dc5f186eef_0#arg. = arg;
88
89 switch (SEAP_cmdtbl_addcxx . . $ SEAP_cmdtbl_add(91a94bcfad148675). (tbl, rec)) {
90 case 0:
91 /* rec is freed by SEAP_cmdtbl_add */
92 break;
93 case SEAP_CMDTBL_ECOLLcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:99:9`!:
94 dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't register command: code=%u, tbl=%p: already registered.",
95 code, (void *)tbl);
96 SEAP_cmdrec_freecxx . . $ SEAP_cmdrec_free(5f039f4040bea21b). (rec);
97 return (-1);
98 case -1:
99 dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't register command: code=%u, func=%p, tbl=%p, arg=%p: errno=%u, %s.",
100 code, (void *)func, (void *)tbl, arg, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
101 SEAP_cmdrec_freecxx . . $ SEAP_cmdrec_free(5f039f4040bea21b). (rec);
102 return (-1);
103 default:
104 SEAP_cmdrec_freecxx . . $ SEAP_cmdrec_free(5f039f4040bea21b). (rec);
105 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EDOOFUScxx . . $ `src/OVAL/probes/SEAP/generic/common.h:44:10`!;
106 return (-1);
107 }
108
109 return (0);
110 }
111
112 /*
113 * SEAP_cmd_register (ctx, SEAP_CMDREG_USEARG, 1, cmdfn, sd, NULL);
114 * SEAP_cmd_register (ctx, SEAP_CMDREG_GLOBAL, 1, cmdfn);
115 * SEAP_cmd_register (ctx, 0, 1, cmdfn, sd);
116 * SEAP_cmd_register (ctx, SEAP_CMDREG_USEARG | SEAP_CMDREG_GLOBAL, 1, cmdfn, NULL);
117 */
118 SEAP_cmdrec_tcxx . . $ SEAP_cmdrec_t# *SEAP_cmdrec_newcxx . . $ SEAP_cmdrec_new(6a77a790710a8e8e). (void)
119 {
120 SEAP_cmdrec_tcxx . . $ SEAP_cmdrec_t# *r = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(SEAP_cmdrec_tcxx . . $ SEAP_cmdrec_t#));
121 r->codecxx . . $ $anonymous_type_a585f4dc5f186eef_0#code. = 0;
122 r->funccxx . . $ $anonymous_type_a585f4dc5f186eef_0#func. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
123 r->argcxx . . $ $anonymous_type_a585f4dc5f186eef_0#arg. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
124
125 return (r);
126 }
127
128 void SEAP_cmdrec_freecxx . . $ SEAP_cmdrec_free(5f039f4040bea21b). (SEAP_cmdrec_tcxx . . $ SEAP_cmdrec_t# *r)
129 {
130 freecxx . . $ free(5d22bdacc48458e8).(r);
131 }
132
133 SEAP_cmdtbl_tcxx . . $ SEAP_cmdtbl_t# *SEAP_cmdtbl_newcxx . . $ SEAP_cmdtbl_new(d478133e2e207a3d). (void)
134 {
135 SEAP_cmdtbl_tcxx . . $ SEAP_cmdtbl_t# *t = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(SEAP_cmdtbl_tcxx . . $ SEAP_cmdtbl_t#));
136
137 t->tablecxx . . $ $anonymous_type_5317b32fcdb93fc7_1#table. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
138 t->maxcntcxx . . $ $anonymous_type_5317b32fcdb93fc7_1#maxcnt. = 0;
139
140 #if defined(SEAP_THREAD_SAFE)
141 if (pthread_rwlock_init (&t->lock, NULL) != 0) {
142 dD("Can't initialize rwlock: %u, %s.",
143 errno, strerror (errno));
144 free(t);
145 return (NULL);
146 }
147 #endif
148 return (t);
149 }
150
151 void SEAP_cmdtbl_freecxx . . $ SEAP_cmdtbl_free(52f2919cbb21a2a). (SEAP_cmdtbl_tcxx . . $ SEAP_cmdtbl_t# *t)
152 {
153 if (t != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
154 SEAP_cmdtbl_backendT_freecxx . . $ SEAP_cmdtbl_backendT_free(52f2919cbb21a2a). (t);
155 freecxx . . $ free(5d22bdacc48458e8).(t);
156 }
157
158 int SEAP_cmdtbl_setsizecxx . . $ SEAP_cmdtbl_setsize(9a74fad16344486a). (SEAP_cmdtbl_tcxx . . $ SEAP_cmdtbl_t# *t, size_t maxsz)
159 {
160 t->maxcntcxx . . $ $anonymous_type_5317b32fcdb93fc7_1#maxcnt. = maxsz;
161 return (0);
162 }
163
164 int SEAP_cmdtbl_setflcxx . . $ SEAP_cmdtbl_setfl(da4bbfea9cf010c). (SEAP_cmdtbl_tcxx . . $ SEAP_cmdtbl_t# *t, uint8_tcxx . . $ uint8_t# f)
165 {
166 t->flagscxx . . $ $anonymous_type_5317b32fcdb93fc7_1#flags. |= f;
167 return (0);
168 }
169
170 int SEAP_cmdtbl_unsetflcxx . . $ SEAP_cmdtbl_unsetfl(da4bbfea9cf010c). (SEAP_cmdtbl_tcxx . . $ SEAP_cmdtbl_t# *t, uint8_tcxx . . $ uint8_t# f)
171 {
172 t->flagscxx . . $ $anonymous_type_5317b32fcdb93fc7_1#flags. &= ~(f);
173 return (0);
174 }
175
176 int SEAP_cmdtbl_addcxx . . $ SEAP_cmdtbl_add(91a94bcfad148675). (SEAP_cmdtbl_tcxx . . $ SEAP_cmdtbl_t# *t, SEAP_cmdrec_tcxx . . $ SEAP_cmdrec_t# *r)
177 {
178 return SEAP_cmdtbl_backendT_addcxx . . $ SEAP_cmdtbl_backendT_add(91a94bcfad148675). (t, r);
179 }
180
181 int SEAP_cmdtbl_inscxx . . $ SEAP_cmdtbl_ins(91a94bcfad148675). (SEAP_cmdtbl_tcxx . . $ SEAP_cmdtbl_t# *t, SEAP_cmdrec_tcxx . . $ SEAP_cmdrec_t# *r)
182 {
183 return SEAP_cmdtbl_backendT_inscxx . . $ SEAP_cmdtbl_backendT_ins(91a94bcfad148675). (t, r);
184 }
185
186 int SEAP_cmdtbl_delcxx . . $ SEAP_cmdtbl_del(91a94bcfad148675). (SEAP_cmdtbl_tcxx . . $ SEAP_cmdtbl_t# *t, SEAP_cmdrec_tcxx . . $ SEAP_cmdrec_t# *r)
187 {
188 return SEAP_cmdtbl_backendT_delcxx . . $ SEAP_cmdtbl_backendT_del(c318b9daec7b3026). (t, r->codecxx . . $ $anonymous_type_a585f4dc5f186eef_0#code.);
189 }
190
191 SEAP_cmdrec_tcxx . . $ SEAP_cmdrec_t# *SEAP_cmdtbl_getcxx . . $ SEAP_cmdtbl_get(e4b5e91c7ff4ee30). (SEAP_cmdtbl_tcxx . . $ SEAP_cmdtbl_t# *t, SEAP_cmdcode_tcxx . . $ SEAP_cmdcode_t# c)
192 {
193 return SEAP_cmdtbl_backendT_getcxx . . $ SEAP_cmdtbl_backendT_get(e4b5e91c7ff4ee30). (t, c);
194 }
195
196 int SEAP_cmdtbl_cmpcxx . . $ SEAP_cmdtbl_cmp(8997b9623a79863c). (SEAP_cmdrec_tcxx . . $ SEAP_cmdrec_t# *a, SEAP_cmdrec_tcxx . . $ SEAP_cmdrec_t# *b)
197 {
198 return (int)(a->codecxx . . $ $anonymous_type_a585f4dc5f186eef_0#code. - b->codecxx . . $ $anonymous_type_a585f4dc5f186eef_0#code.);
199 }
200
201 static SEXP_tcxx . . $ SEXP_t# *__SEAP_cmd_sync_handlercxx . . $ __SEAP_cmd_sync_handler(313521213da5ee5). (SEXP_tcxx . . $ SEXP_t# *res, void *arg)
202 {
203 struct SEAP_synchelpercxx . . $ SEAP_synchelper# *h = (struct SEAP_synchelpercxx . . $ SEAP_synchelper# *)arg;
204
205 h->argscxx . . $ SEAP_synchelper#args. = res;
206 (void) pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9). (&h->mtxcxx . . $ SEAP_synchelper#mtx.);
207 h->signaledcxx . . $ SEAP_synchelper#signaled. = 1;
208 (void) pthread_cond_broadcastcxx . . $ pthread_cond_broadcast(98095c34a2b0149d). (&h->condcxx . . $ SEAP_synchelper#cond.);
209 (void) pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9). (&h->mtxcxx . . $ SEAP_synchelper#mtx.);
210
211 return (NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
212 }
213
214 SEXP_tcxx . . $ SEXP_t# *SEAP_cmd_execcxx . . $ SEAP_cmd_exec(68703026cc6e447d). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx,
215 int sd,
216 uint32_tcxx . . $ uint32_t# flags,
217 SEAP_cmdcode_tcxx . . $ SEAP_cmdcode_t# code,
218 SEXP_tcxx . . $ SEXP_t# *args,
219 SEAP_cmdtype_tcxx . . $ SEAP_cmdtype_t# type,
220 SEAP_cmdfn_tcxx . . $ SEAP_cmdfn_t# func,
221 void *funcarg)
222 {
223 SEAP_desc_tcxx . . $ SEAP_desc_t# *dsc = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
224 SEAP_cmdrec_tcxx . . $ SEAP_cmdrec_t# *rec = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
225 SEAP_cmdtbl_tcxx . . $ SEAP_cmdtbl_t# *tbl[2];
226 SEXP_tcxx . . $ SEXP_t# *res = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
227 int8_tcxx . . $ int8_t# i;
228
229 _Acxx . . $ `src/common/debug_priv.h:43:9`!(ctx != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
230
231 #if !defined(NDEBUGcxx . . $ `<built-in>:425:9`!) || defined(VALIDATE_SEXP)
232 if (args != NULL) {
233 SEXP_VALIDATE(args);
234 }
235 #endif
236
237 dDcxx . . $ `src/common/debug_priv.h:64:9`!("code=%u, args=%p", code, args);
238
239 dsc = SEAP_desc_getcxx . . $ SEAP_desc_get(b324436d5ff0f8fe). (ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., sd);
240
241 if (dsc == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
242 return (NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
243
244 if (flags & (SEAP_EXEC_LOCALcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:51:9`! | SEAP_EXEC_WQUEUEcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:55:9`!)) {
245 dDcxx . . $ `src/common/debug_priv.h:64:9`!("EXEC_LOCAL");
246
247 /* get table pointers */
248 if (flags & SEAP_EXEC_WQUEUEcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:55:9`!) {
249 i = 0;
250 tbl[0] = dsc->cmd_w_tablecxx . . $ $anonymous_type_5b6d52305350878e_0#cmd_w_table.;
251 } else if (flags & SEAP_EXEC_LONLYcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:52:9`!) {
252 i = 0;
253 tbl[0] = dsc->cmd_c_tablecxx . . $ $anonymous_type_5b6d52305350878e_0#cmd_c_table.;
254 } else {
255 i = 1;
256
257 if (flags & SEAP_EXEC_GFIRSTcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:53:9`!) {
258 tbl[1] = ctx->cmd_c_tablecxx . . $ SEAP_CTX#cmd_c_table.;
259 tbl[0] = dsc->cmd_c_tablecxx . . $ $anonymous_type_5b6d52305350878e_0#cmd_c_table.;
260 } else {
261 tbl[1] = dsc->cmd_c_tablecxx . . $ $anonymous_type_5b6d52305350878e_0#cmd_c_table.;
262 tbl[0] = ctx->cmd_c_tablecxx . . $ SEAP_CTX#cmd_c_table.;
263 }
264 }
265
266 /* lookup command */
267 rec = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
268
269 for (; i >= 0; --i)
270 if ((rec = SEAP_cmdtbl_getcxx . . $ SEAP_cmdtbl_get(e4b5e91c7ff4ee30). (tbl[i], code)) != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
271 break;
272
273 dDcxx . . $ `src/common/debug_priv.h:64:9`!("rec=%p, w=%u", rec, (flags & SEAP_EXEC_WQUEUEcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:55:9`!) ? 1 : 0);
274
275 if (rec == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
276
277 return (NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
278 }
279 /* execute command */
280 res = rec->funccxx . . $ $anonymous_type_a585f4dc5f186eef_0#func. (args, rec->argcxx . . $ $anonymous_type_a585f4dc5f186eef_0#arg.);
281
282 dDcxx . . $ `src/common/debug_priv.h:64:9`!("res=%p", res);
283
284 /* filter result */
285 if (func != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
286 res = func (res, funcarg);
287
288 dDcxx . . $ `src/common/debug_priv.h:64:9`!("func@%p(res)=%p", func, res);
289
290 /* delete command from the wait queue */
291 if (flags & SEAP_EXEC_WQUEUEcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:55:9`!) {
292 SEAP_cmdtbl_delcxx . . $ SEAP_cmdtbl_del(91a94bcfad148675).(tbl[i], rec);
293 }
294
295 return (res);
296 } else {
297 SEAP_cmd_tcxx . . $ SEAP_cmd_t# *cmdptr;
298 SEAP_packet_tcxx . . $ SEAP_packet_t# *packet;
299
300 dDcxx . . $ `src/common/debug_priv.h:64:9`!("EXEC_REMOTE");
301
302 packet = SEAP_packet_newcxx . . $ SEAP_packet_new(384bfbf0d7214bc9). ();
303 cmdptr = SEAP_packet_settypecxx . . $ SEAP_packet_settype(332ceac18a0c9d9b). (packet, SEAP_PACKET_CMDcxx . . $ `src/OVAL/probes/SEAP/_seap-packet.h:42:9`!);
304
305 cmdptr->idcxx . . $ SEAP_cmd#id. = SEAP_desc_gencmdidcxx . . $ SEAP_desc_gencmdid(bbbb35498d66006b). (ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., sd);
306 cmdptr->ridcxx . . $ SEAP_cmd#rid. = 0;
307 cmdptr->classcxx . . $ SEAP_cmd#class. = SEAP_CMDCLASS_USRcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:37:9`!;
308 cmdptr->codecxx . . $ SEAP_cmd#code. = code;
309 cmdptr->argscxx . . $ SEAP_cmd#args. = args;
310 cmdptr->flagscxx . . $ SEAP_cmd#flags. = 0;
311
312 switch (type) {
313 case SEAP_CMDTYPE_SYNCcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:44:9`!: {
314 struct SEAP_synchelpercxx . . $ SEAP_synchelper# h;
315
316 cmdptr->flagscxx . . $ SEAP_cmd#flags. |= SEAP_CMDFLAG_SYNCcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:39:9`!;
317
318 if (pthread_cond_initcxx . . $ pthread_cond_init(fc876bc1ec1249fc). (&h.condcxx . . $ SEAP_synchelper#cond., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) != 0 ||
319 pthread_mutex_initcxx . . $ pthread_mutex_init(db9d29dab44ea1aa). (&h.mtxcxx . . $ SEAP_synchelper#mtx., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) != 0)
320 abortcxx . . $ abort(8df32a62017fbbf6). ();
321
322 h.argscxx . . $ SEAP_synchelper#args. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
323 h.signaledcxx . . $ SEAP_synchelper#signaled. = 0;
324
325 rec = SEAP_cmdrec_newcxx . . $ SEAP_cmdrec_new(6a77a790710a8e8e). ();
326 rec->codecxx . . $ $anonymous_type_a585f4dc5f186eef_0#code. = cmdptr->idcxx . . $ SEAP_cmd#id.;
327 rec->funccxx . . $ $anonymous_type_a585f4dc5f186eef_0#func. = &__SEAP_cmd_sync_handlercxx . . $ __SEAP_cmd_sync_handler(313521213da5ee5).;
328 rec->argcxx . . $ $anonymous_type_a585f4dc5f186eef_0#arg. = &h;
329
330 switch (SEAP_cmdtbl_addcxx . . $ SEAP_cmdtbl_add(91a94bcfad148675). (dsc->cmd_w_tablecxx . . $ $anonymous_type_5b6d52305350878e_0#cmd_w_table., rec)) {
331 case 0:
332 break;
333 case SEAP_CMDTBL_ECOLLcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:99:9`!:
334 dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't register async command handler: id=%u, tbl=%p, sd=%u: already registered.",
335 rec->code, (void *)dsc->cmd_w_table, sd);
336 SEAP_cmdrec_freecxx . . $ SEAP_cmdrec_free(5f039f4040bea21b). (rec);
337 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f).(packet);
338 return (NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
339 case -1:
340 dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't register async command handler: id=%u, tbl=%p, sd=%u: errno=%u, %s.",
341 rec->code, (void *)dsc->cmd_w_table, sd, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
342 SEAP_cmdrec_freecxx . . $ SEAP_cmdrec_free(5f039f4040bea21b). (rec);
343 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f).(packet);
344 return (NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
345 default:
346 SEAP_cmdrec_freecxx . . $ SEAP_cmdrec_free(5f039f4040bea21b). (rec);
347 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f).(packet);
348 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EDOOFUScxx . . $ `src/OVAL/probes/SEAP/generic/common.h:44:10`!;
349 return (NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
350 }
351
352 if (SEAP_packet_sendcxx . . $ SEAP_packet_send(ef224cc9abb3a138). (ctx, sd, packet) != 0) {
353 protect_errnocxx . . $ `src/common/util.h:446:9`! {
354 dDcxx . . $ `src/common/debug_priv.h:64:9`!("FAIL: errno=%u, %s.", errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
355 SEAP_cmdtbl_delcxx . . $ SEAP_cmdtbl_del(91a94bcfad148675).(dsc->cmd_w_tablecxx . . $ $anonymous_type_5b6d52305350878e_0#cmd_w_table., rec);
356 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f).(packet);
357 }
358 return (NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
359 }
360
361 if (flags & SEAP_EXEC_RECVcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:56:9`!) {
362 /* struct timespec timeout; */
363 SEAP_packet_tcxx . . $ SEAP_packet_t# *packet_rcv;
364 /*
365 * We have to do own receiving of events. We'll queue
366 * all events (errors, messages) that we are not interested
367 * in. After a command (reply) is received, we'll try to
368 * check whether the condition we are waiting for was signaled.
369 */
370
371 packet_rcv = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
372 /*
373 timeout.tv_sec = 0;
374 timeout.tv_nsec = 0;
375 */
376 for (;;) {
377 if (SEAP_packet_recvcxx . . $ SEAP_packet_recv(a0f51301b886eec1).(ctx, sd, &packet_rcv) != 0) {
378 dDcxx . . $ `src/common/debug_priv.h:64:9`!("FAIL: ctx=%p, sd=%d, errno=%u, %s.", ctx, sd, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
379 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f).(packet);
380 return(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
381 }
382
383 switch(SEAP_packet_gettypecxx . . $ SEAP_packet_gettype(22e705be93eb9565).(packet_rcv)) {
384 case SEAP_PACKET_CMDcxx . . $ `src/OVAL/probes/SEAP/_seap-packet.h:42:9`!:
385 switch (__SEAP_recvmsg_process_cmdcxx . . $ __SEAP_recvmsg_process_cmd(6df9f23f786c4d17). (ctx, sd, SEAP_packet_cmdcxx . . $ SEAP_packet_cmd(9f46e6fb5acf697d).(packet_rcv))) {
386 case 0:
387 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f).(packet_rcv);
388 break;
389 default:
390 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f).(packet);
391 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EDOOFUScxx . . $ `src/OVAL/probes/SEAP/generic/common.h:44:10`!;
392 return(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
393 }
394 case SEAP_PACKET_MSGcxx . . $ `src/OVAL/probes/SEAP/_seap-packet.h:40:9`!:
395 /* FIXME */
396 break;
397 case SEAP_PACKET_ERRcxx . . $ `src/OVAL/probes/SEAP/_seap-packet.h:41:9`!:
398 /* FIXME */
399 break;
400 default:
401 abortcxx . . $ abort(8df32a62017fbbf6).();
402 }
403
404 /* Morbo: THIS IS NOT HOW SYCHNRONIZATION WORKS! */
405 if (h.signaledcxx . . $ SEAP_synchelper#signaled.) {
406 h.signaledcxx . . $ SEAP_synchelper#signaled. = 0;
407 break;
408 }
409 }
410 } else {
411 /*
412 * Someone else does receiving of events for us.
413 * Just wait for the condition to be signaled.
414 */
415 pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&h.mtxcxx . . $ SEAP_synchelper#mtx.);
416 while (!h.signaledcxx . . $ SEAP_synchelper#signaled.) {
417 pthread_cond_waitcxx . . $ pthread_cond_wait(6145be15a5d9db5d).(&h.condcxx . . $ SEAP_synchelper#cond., &h.mtxcxx . . $ SEAP_synchelper#mtx.);
418 }
419 // This might not be needed, but still
420 h.signaledcxx . . $ SEAP_synchelper#signaled. = 0;
421 pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&h.mtxcxx . . $ SEAP_synchelper#mtx.);
422 }
423
424 dDcxx . . $ `src/common/debug_priv.h:64:9`!("cond return: h.args=%p", h.args);
425
426 if (h.argscxx . . $ SEAP_synchelper#args. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
427 res = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
428 else if (func != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
429 res = func (h.argscxx . . $ SEAP_synchelper#args., funcarg);
430 else
431 res = h.argscxx . . $ SEAP_synchelper#args.;
432
433 /*
434 * SEAP_cmdtbl_del(dsc->cmd_w_table, rec);
435 */
436 pthread_cond_destroycxx . . $ pthread_cond_destroy(98095c34a2b0149d). (&(h.condcxx . . $ SEAP_synchelper#cond.));
437 pthread_mutex_destroycxx . . $ pthread_mutex_destroy(d89ae235521888f9). (&(h.mtxcxx . . $ SEAP_synchelper#mtx.));
438 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f).(packet);
439
440 return (res);
441 }
442 case SEAP_CMDTYPE_ASYNCcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:45:9`!:
443 cmdptr->flagscxx . . $ SEAP_cmd#flags. |= SEAP_CMDFLAG_ASYNCcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:40:9`!;
444
445 /* Register handler */
446 rec = SEAP_cmdrec_newcxx . . $ SEAP_cmdrec_new(6a77a790710a8e8e). ();
447 rec->codecxx . . $ $anonymous_type_a585f4dc5f186eef_0#code. = cmdptr->idcxx . . $ SEAP_cmd#id.;
448 rec->funccxx . . $ $anonymous_type_a585f4dc5f186eef_0#func. = func;
449 rec->argcxx . . $ $anonymous_type_a585f4dc5f186eef_0#arg. = funcarg;
450
451 switch (SEAP_cmdtbl_addcxx . . $ SEAP_cmdtbl_add(91a94bcfad148675). (dsc->cmd_w_tablecxx . . $ $anonymous_type_5b6d52305350878e_0#cmd_w_table., rec)) {
452 case 0:
453 break;
454 case SEAP_CMDTBL_ECOLLcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:99:9`!:
455 dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't register async command handler: id=%u, tbl=%p, sd=%u: already registered.",
456 rec->code, (void *)dsc->cmd_w_table, sd);
457 SEAP_cmdrec_freecxx . . $ SEAP_cmdrec_free(5f039f4040bea21b). (rec);
458 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f).(packet);
459 return (NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
460 case -1:
461 dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't register async command handler: id=%u, tbl=%p, sd=%u: errno=%u, %s.",
462 rec->code, (void *)dsc->cmd_w_table, sd, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
463 SEAP_cmdrec_freecxx . . $ SEAP_cmdrec_free(5f039f4040bea21b).(rec);
464 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f).(packet);
465 return (NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
466 default:
467 SEAP_cmdrec_freecxx . . $ SEAP_cmdrec_free(5f039f4040bea21b).(rec);
468 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f).(packet);
469 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EDOOFUScxx . . $ `src/OVAL/probes/SEAP/generic/common.h:44:10`!;
470 return (NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
471 }
472
473 if (SEAP_packet_sendcxx . . $ SEAP_packet_send(ef224cc9abb3a138). (ctx, sd, packet) != 0) {
474 protect_errnocxx . . $ `src/common/util.h:446:9`! {
475 dDcxx . . $ `src/common/debug_priv.h:64:9`!("FAIL: errno=%u, %s.", errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
476 SEAP_cmdtbl_delcxx . . $ SEAP_cmdtbl_del(91a94bcfad148675).(dsc->cmd_w_tablecxx . . $ $anonymous_type_5b6d52305350878e_0#cmd_w_table., rec);
477 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f).(packet);
478 }
479 return (NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
480 }
481
482 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f).(packet);
483
484 return (args);
485 default:
486 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!;
487 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f).(packet);
488 return (NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
489 }
490 }
491
492 /* NOTREACHED */
493 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EDOOFUScxx . . $ `src/OVAL/probes/SEAP/generic/common.h:44:10`!;
494 return (NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
495 }
496
497 SEAP_cmdjob_tcxx . . $ SEAP_cmdjob_t# *SEAP_cmdjob_newcxx . . $ SEAP_cmdjob_new(20f750e0dec7af40). (void)
498 {
499 SEAP_cmdjob_tcxx . . $ SEAP_cmdjob_t# *j = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(SEAP_cmdjob_tcxx . . $ SEAP_cmdjob_t#));
500 j->ctxcxx . . $ $anonymous_type_a585f4dc5f186eef_1#ctx. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
501 j->sdcxx . . $ $anonymous_type_a585f4dc5f186eef_1#sd. = -1;
502
503 return (j);
504 }
505
506 void SEAP_cmdjob_freecxx . . $ SEAP_cmdjob_free(c3ce16d0b4ef215). (SEAP_cmdjob_tcxx . . $ SEAP_cmdjob_t# *j)
507 {
508 freecxx . . $ free(5d22bdacc48458e8).(j);
509 }