Debian Codegraph @

src/OVAL/probes/SEAP/seap.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 <stddef.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <ctype.h>
31 #include <pthread.h>
32 #include <errno.h>
33
34 #if defined(OS_FREEBSD)
35 #include <pthread_np.h>
36 #endif
37
38 #include "_seap.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap.h`/
39 #include "generic/common.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/generic/common.h`/
40 #include "_sexp-types.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_sexp-types.h`/
41 #include "_seap-types.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap-types.h`/
42 #include "_seap-message.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap-message.h`/
43 #include "_seap-command.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap-command.h`/
44 #include "_seap-error.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap-error.h`/
45 #include "_seap-packet.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap-packet.h`/
46 #include "_seap.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap.h`/
47 #include "seap-descriptor.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/seap-descriptor.h`/
48 #include "debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/
49
50 #define SCH_QUEUEcxx . . $ `src/OVAL/probes/SEAP/seap.c:50:9`! 4
51
52 static void SEAP_CTX_initdefaultcxx . . $ SEAP_CTX_initdefault(6b73584f16c77d33). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx)
53 {
54 _Acxx . . $ `src/common/debug_priv.h:43:9`!(ctx != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
55
56 ctx->fmt_incxx . . $ SEAP_CTX#fmt_in. = SEXP_FMT_CANONICALcxx . . $ `src/OVAL/probes/SEAP/public/sexp-types.h:71:9`!;
57 ctx->fmt_outcxx . . $ SEAP_CTX#fmt_out. = SEXP_FMT_CANONICALcxx . . $ `src/OVAL/probes/SEAP/public/sexp-types.h:71:9`!;
58
59 /* Initialize descriptor table */
60 ctx->sd_tablecxx . . $ SEAP_CTX#sd_table. = SEAP_desctable_newcxx . . $ SEAP_desctable_new(3edbe157c33b3149).();
61 ctx->cmd_c_tablecxx . . $ SEAP_CTX#cmd_c_table. = SEAP_cmdtbl_newcxx . . $ SEAP_cmdtbl_new(d478133e2e207a3d). ();
62
63 ctx->recv_timeoutcxx . . $ SEAP_CTX#recv_timeout. = 5;
64 ctx->send_timeoutcxx . . $ SEAP_CTX#send_timeout. = 5;
65 ctx->cflagscxx . . $ SEAP_CTX#cflags. = 0;
66
67 return;
68 }
69
70 SEAP_CTX_tcxx . . $ SEAP_CTX_t# *SEAP_CTX_newcxx . . $ SEAP_CTX_new(4c59508b5756fef7). (void)
71 {
72 SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(SEAP_CTX_tcxx . . $ SEAP_CTX_t#));
73 SEAP_CTX_initdefaultcxx . . $ SEAP_CTX_initdefault(6b73584f16c77d33). (ctx);
74
75 return (ctx);
76 }
77
78 void SEAP_CTX_initcxx . . $ SEAP_CTX_init(6b73584f16c77d33). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx)
79 {
80 _Acxx . . $ `src/common/debug_priv.h:43:9`!(ctx != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
81 SEAP_CTX_initdefaultcxx . . $ SEAP_CTX_initdefault(6b73584f16c77d33). (ctx);
82 return;
83 }
84
85 void SEAP_CTX_freecxx . . $ SEAP_CTX_free(6b73584f16c77d33). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx)
86 {
87 _Acxx . . $ `src/common/debug_priv.h:43:9`!(ctx != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
88 SEAP_desctable_freecxx . . $ SEAP_desctable_free(dcdcf0775e6a3e02).(ctx->sd_tablecxx . . $ SEAP_CTX#sd_table.);
89 SEAP_cmdtbl_freecxx . . $ SEAP_cmdtbl_free(52f2919cbb21a2a). (ctx->cmd_c_tablecxx . . $ SEAP_CTX#cmd_c_table.);
90 freecxx . . $ free(5d22bdacc48458e8).(ctx);
91
92 return;
93 }
94
95 int SEAP_connectcxx . . $ SEAP_connect(8239b944deed0079).(SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx)
96 {
97 SEAP_desc_tcxx . . $ SEAP_desc_t# *dsc;
98 int sd;
99
100
101 sd = SEAP_desc_addcxx . . $ SEAP_desc_add(4bfd83e388c9f71b).(ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., SCH_QUEUEcxx . . $ `src/OVAL/probes/SEAP/seap.c:50:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
102
103 if (sd < 0) {
104 dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't create/add new SEAP descriptor");
105 return (-1);
106 }
107
108 dsc = SEAP_desc_getcxx . . $ SEAP_desc_get(b324436d5ff0f8fe). (ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., sd);
109
110 if (dsc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
111 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = ESRCHcxx . . $ `<external>/8987895939074593727/errno-base.h:7:9`!;
112 return(-1);
113 }
114 dsc->subtypecxx . . $ $anonymous_type_5b6d52305350878e_0#subtype. = ctx->subtypecxx . . $ SEAP_CTX#subtype.;
115
116 if (sch_queue_connectcxx . . $ sch_queue_connect(697248ac26eea891).(dsc) != 0) {
117 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`!));
118 SEAP_desc_delcxx . . $ SEAP_desc_del(ad0fa72a6b5db2).(ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., sd);
119
120 return (-1);
121 }
122
123 return (sd);
124 }
125
126 int SEAP_opencxx . . $ SEAP_open(b74c1535fff19e6e). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, const char *path, uint32_tcxx . . $ uint32_t# flags)
127 {
128 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EOPNOTSUPPcxx . . $ `<external>/17922322188510340118/errno.h:79:9`!;
129 return (-1);
130 }
131
132 int SEAP_openfdcxx . . $ SEAP_openfd(9da57444f8379d64). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int fd, uint32_tcxx . . $ uint32_t# flags)
133 {
134 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EOPNOTSUPPcxx . . $ `<external>/17922322188510340118/errno.h:79:9`!;
135 return (-1);
136 }
137
138 int SEAP_openfd2cxx . . $ SEAP_openfd2(25c179136f4ebf9). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int ifd, int ofd, uint32_tcxx . . $ uint32_t# flags)
139 {
140 SEAP_desc_tcxx . . $ SEAP_desc_t# *dsc;
141 int sd;
142
143 sd = SEAP_desc_addcxx . . $ SEAP_desc_add(4bfd83e388c9f71b).(ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., SCH_QUEUEcxx . . $ `src/OVAL/probes/SEAP/seap.c:50:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
144
145 if (sd < 0) {
146 dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't create/add new SEAP descriptor");
147 return (-1);
148 }
149
150 dsc = SEAP_desc_getcxx . . $ SEAP_desc_get(b324436d5ff0f8fe). (ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., sd);
151
152 if (dsc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
153 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = ESRCHcxx . . $ `<external>/8987895939074593727/errno-base.h:7:9`!;
154 return(-1);
155 }
156
157 return (sd);
158 }
159
160 int SEAP_add_probecxx . . $ SEAP_add_probe(c415db66edacb127). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, sch_queuedata_tcxx . . $ sch_queuedata_t# *data)
161 {
162 int sd = SEAP_desc_addcxx . . $ SEAP_desc_add(4bfd83e388c9f71b).(ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., SCH_QUEUEcxx . . $ `src/OVAL/probes/SEAP/seap.c:50:9`!, data);
163 dDcxx . . $ `src/common/debug_priv.h:64:9`!("SEAP_add_probe");
164 if (sd < 0) {
165 dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't create/add new SEAP descriptor");
166 return (-1);
167 }
168 SEAP_desc_tcxx . . $ SEAP_desc_t# *dsc = SEAP_desc_getcxx . . $ SEAP_desc_get(b324436d5ff0f8fe). (ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., sd);
169
170 if (dsc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
171 dDcxx . . $ `src/common/debug_priv.h:64:9`!("dsc == NULL");
172 }
173 return sd;
174 }
175
176 int SEAP_recvsexpcxx . . $ SEAP_recvsexp(63d062d154236fae). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd, SEXP_tcxx . . $ SEXP_t# **sexp)
177 {
178 SEAP_msg_tcxx . . $ SEAP_msg_t# *msg = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
179
180 if (SEAP_recvmsgcxx . . $ SEAP_recvmsg(548af285d41333c4). (ctx, sd, &msg) == 0) {
181 *sexp = SEAP_msg_getcxx . . $ SEAP_msg_get(265ef69b98da50a9). (msg);
182 SEAP_msg_freecxx . . $ SEAP_msg_free(4995d55015d41e57). (msg);
183
184 return (0);
185 }
186
187 *sexp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
188 return (-1);
189 }
190
191 static int __SEAP_cmdexec_replycxx . . $ __SEAP_cmdexec_reply(6df9f23f786c4d17). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd, SEAP_cmd_tcxx . . $ SEAP_cmd_t# *cmd)
192 {
193 SEAP_desc_tcxx . . $ SEAP_desc_t# *dsc;
194 SEXP_tcxx . . $ SEXP_t# *res;
195 SEAP_packet_tcxx . . $ SEAP_packet_t# *packet;
196 SEAP_cmd_tcxx . . $ SEAP_cmd_t# *cmdrep;
197
198 dsc = SEAP_desc_getcxx . . $ SEAP_desc_get(b324436d5ff0f8fe). (ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., sd);
199
200 if (dsc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
201 return (-1);
202
203 res = SEAP_cmd_execcxx . . $ SEAP_cmd_exec(68703026cc6e447d). (ctx, sd, SEAP_EXEC_LOCALcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:51:9`!,
204 cmd->codecxx . . $ SEAP_cmd#code., cmd->argscxx . . $ SEAP_cmd#args.,
205 SEAP_CMDCLASS_USRcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:37:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
206
207 packet = SEAP_packet_newcxx . . $ SEAP_packet_new(384bfbf0d7214bc9). ();
208 cmdrep = SEAP_packet_settypecxx . . $ SEAP_packet_settype(332ceac18a0c9d9b). (packet, SEAP_PACKET_CMDcxx . . $ `src/OVAL/probes/SEAP/_seap-packet.h:42:9`!);
209
210 cmdrep->idcxx . . $ SEAP_cmd#id. = SEAP_desc_gencmdidcxx . . $ SEAP_desc_gencmdid(bbbb35498d66006b). (ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., sd);
211 cmdrep->ridcxx . . $ SEAP_cmd#rid. = cmd->idcxx . . $ SEAP_cmd#id.;
212 cmdrep->flagscxx . . $ SEAP_cmd#flags. |= SEAP_CMDFLAG_REPLYcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:41:9`!;
213 cmdrep->argscxx . . $ SEAP_cmd#args. = res;
214 cmdrep->classcxx . . $ SEAP_cmd#class. = cmd->classcxx . . $ SEAP_cmd#class.;
215 cmdrep->codecxx . . $ SEAP_cmd#code. = cmd->codecxx . . $ SEAP_cmd#code.;
216
217 if (SEAP_packet_sendcxx . . $ SEAP_packet_send(ef224cc9abb3a138). (ctx, sd, packet) != 0) {
218 protect_errnocxx . . $ `src/common/util.h:446:9`! {
219 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`!));
220 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f). (packet);
221 }
222 return (-1);
223 }
224
225 if (res != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && res != cmd->argscxx . . $ SEAP_cmd#args.)
226 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(res);
227
228 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f). (packet);
229
230 return (0);
231 }
232
233 static void *__SEAP_cmdexec_workercxx . . $ __SEAP_cmdexec_worker(9f162e79bfc6c74). (void *arg)
234 {
235 SEAP_cmdjob_tcxx . . $ SEAP_cmdjob_t# *job = (SEAP_cmdjob_tcxx . . $ SEAP_cmdjob_t# *)arg;
236
237 _Acxx . . $ `src/common/debug_priv.h:43:9`!(job != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
238 _Acxx . . $ `src/common/debug_priv.h:43:9`!(job->cmd != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
239 #if defined(HAVE_PTHREAD_SETNAME_NPcxx . . $ `build/config.h:53:9`!)
240 # if defined(OS_APPLE)
241 pthread_setname_np("command_worker");
242 # else
243 pthread_setname_npcxx . . $ pthread_setname_np(bee54c13bee684da).(pthread_selfcxx . . $ pthread_self(f708dce9a8856c70).(), "command_worker");
244 # endif
245 #endif
246
247 if (job->cmdcxx . . $ $anonymous_type_a585f4dc5f186eef_1#cmd.->flagscxx . . $ SEAP_cmd#flags. & SEAP_CMDFLAG_REPLYcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:41:9`!) {
248 (void) SEAP_cmd_execcxx . . $ SEAP_cmd_exec(68703026cc6e447d). (job->ctxcxx . . $ $anonymous_type_a585f4dc5f186eef_1#ctx., job->sdcxx . . $ $anonymous_type_a585f4dc5f186eef_1#sd., SEAP_EXEC_WQUEUEcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:55:9`!,
249 job->cmdcxx . . $ $anonymous_type_a585f4dc5f186eef_1#cmd.->ridcxx . . $ SEAP_cmd#rid., job->cmdcxx . . $ $anonymous_type_a585f4dc5f186eef_1#cmd.->argscxx . . $ SEAP_cmd#args.,
250 SEAP_CMDCLASS_USRcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:37:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
251 } else {
252 (void)__SEAP_cmdexec_replycxx . . $ __SEAP_cmdexec_reply(6df9f23f786c4d17). (job->ctxcxx . . $ $anonymous_type_a585f4dc5f186eef_1#ctx., job->sdcxx . . $ $anonymous_type_a585f4dc5f186eef_1#sd., job->cmdcxx . . $ $anonymous_type_a585f4dc5f186eef_1#cmd.);
253 }
254
255 return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
256 }
257
258 int __SEAP_recvmsg_process_cmdcxx . . $ __SEAP_recvmsg_process_cmd(6df9f23f786c4d17). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd, SEAP_cmd_tcxx . . $ SEAP_cmd_t# *cmd)
259 {
260 _Acxx . . $ `src/common/debug_priv.h:43:9`!(ctx != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
261 _Acxx . . $ `src/common/debug_priv.h:43:9`!(cmd != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
262
263 if (ctx->cflagscxx . . $ SEAP_CTX#cflags. & SEAP_CFLG_THREADcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:104:9`!) {
264 /*
265 * Create a new thread for processing this command
266 */
267 pthread_tcxx . . $ pthread_t# th;
268 pthread_attr_tcxx . . $ pthread_attr_t# th_attrs;
269
270 SEAP_cmdjob_tcxx . . $ SEAP_cmdjob_t# *job;
271
272 /* Initialize thread stuff */
273 pthread_attr_initcxx . . $ pthread_attr_init(26f1688c57ac69c9). (&th_attrs);
274 pthread_attr_setdetachstatecxx . . $ pthread_attr_setdetachstate(1c205214b8a99ab8). (&th_attrs, PTHREAD_CREATE_DETACHEDcxx . . $ `<external>/14712363683955484316/pthread.h:42:9`!);
275
276 /* Prepare the job */
277 job = SEAP_cmdjob_newcxx . . $ SEAP_cmdjob_new(20f750e0dec7af40). ();
278 job->ctxcxx . . $ $anonymous_type_a585f4dc5f186eef_1#ctx. = ctx;
279 job->sdcxx . . $ $anonymous_type_a585f4dc5f186eef_1#sd. = sd;
280 job->cmdcxx . . $ $anonymous_type_a585f4dc5f186eef_1#cmd. = cmd;
281
282 /* Create the worker */
283 if (pthread_createcxx . . $ pthread_create(2141a84bcac899e5). (&th, &th_attrs,
284 &__SEAP_cmdexec_workercxx . . $ __SEAP_cmdexec_worker(9f162e79bfc6c74)., (void *)job) != 0)
285 {
286 dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't create worker thread: %u, %s.", errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
287 SEAP_cmdjob_freecxx . . $ SEAP_cmdjob_free(c3ce16d0b4ef215). (job);
288 pthread_attr_destroycxx . . $ pthread_attr_destroy(26f1688c57ac69c9). (&th_attrs);
289
290 return (-1);
291 }
292
293 pthread_attr_destroycxx . . $ pthread_attr_destroy(26f1688c57ac69c9). (&th_attrs);
294 } else {
295 if (cmd->flagscxx . . $ SEAP_cmd#flags. & SEAP_CMDFLAG_REPLYcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:41:9`!) {
296 (void) SEAP_cmd_execcxx . . $ SEAP_cmd_exec(68703026cc6e447d). (ctx, sd, SEAP_EXEC_WQUEUEcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:55:9`!,
297 cmd->ridcxx . . $ SEAP_cmd#rid., cmd->argscxx . . $ SEAP_cmd#args.,
298 SEAP_CMDCLASS_USRcxx . . $ `src/OVAL/probes/SEAP/_seap-command.h:37:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
299 } else {
300 int ret;
301
302 ret = __SEAP_cmdexec_replycxx . . $ __SEAP_cmdexec_reply(6df9f23f786c4d17). (ctx, sd, cmd);
303
304 if (cmd->argscxx . . $ SEAP_cmd#args. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
305 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(cmd->argscxx . . $ SEAP_cmd#args.);
306
307 return (ret);
308 }
309 }
310
311 return (0);
312 }
313
314 static int __SEAP_recvmsg_process_errcxx . . $ __SEAP_recvmsg_process_err(aab4fc2f6bdac614). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd, SEAP_err_tcxx . . $ SEAP_err_t# *err)
315 {
316 SEAP_desc_tcxx . . $ SEAP_desc_t# *sd_desc;
317 SEAP_err_tcxx . . $ SEAP_err_t# *cloned_err;
318 void *prev_err;
319
320 sd_desc = SEAP_desc_getcxx . . $ SEAP_desc_get(b324436d5ff0f8fe).(ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., sd);
321
322 if (sd_desc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
323 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EBADFcxx . . $ `<external>/8987895939074593727/errno-base.h:13:9`!;
324 return (-1);
325 }
326
327 cloned_err = SEAP_error_clonecxx . . $ SEAP_error_clone(ad94040245d9f919).(err);
328 prev_err = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
329
330 /* XXX: handle 64bit message ids */
331 if (rbt_i32_addcxx . . $ rbt_i32_add(3215e2e734e57b31).(sd_desc->err_queuecxx . . $ $anonymous_type_5b6d52305350878e_0#err_queue.,
332 (uint32_tcxx . . $ uint32_t#)(err->idcxx . . $ SEAP_err#id.), cloned_err, (void **)&prev_err) != 0)
333 {
334 SEAP_error_freecxx . . $ SEAP_error_free(7b4adf922bbc6529).(cloned_err);
335 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!;
336 return (-1);
337 }
338
339 if (prev_err != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
340 /* XXX: log this */
341 SEAP_error_freecxx . . $ SEAP_error_free(7b4adf922bbc6529).((SEAP_err_tcxx . . $ SEAP_err_t#*)prev_err);
342 }
343
344 return (0);
345 }
346
347 int SEAP_recvmsgcxx . . $ SEAP_recvmsg(548af285d41333c4). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd, SEAP_msg_tcxx . . $ SEAP_msg_t# **seap_msg)
348 {
349 SEAP_packet_tcxx . . $ SEAP_packet_t# *packet;
350
351 _Acxx . . $ `src/common/debug_priv.h:43:9`!(ctx != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
352 _Acxx . . $ `src/common/debug_priv.h:43:9`!(seap_msg != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
353
354 (*seap_msg) = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
355
356 /*
357 * Packet loop
358 */
359 for (;;) {
360 if (SEAP_packet_recvcxx . . $ SEAP_packet_recv(a0f51301b886eec1). (ctx, sd, &packet) != 0) {
361 protect_errnocxx . . $ `src/common/util.h:446:9`! {
362 dDcxx . . $ `src/common/debug_priv.h:64:9`!("FAIL: ctx=%p, sd=%d, errno=%u, %s.",
363 ctx, sd, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
364 }
365 return (-1);
366 }
367
368 switch (SEAP_packet_gettypecxx . . $ SEAP_packet_gettype(22e705be93eb9565). (packet)) {
369 case SEAP_PACKET_MSGcxx . . $ `src/OVAL/probes/SEAP/_seap-packet.h:40:9`!:
370
371 (*seap_msg) = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(SEAP_msg_tcxx . . $ SEAP_msg_t#));
372 memcpycxx . . $ memcpy(cc817cb175f282d). ((*seap_msg), SEAP_packet_msgcxx . . $ SEAP_packet_msg(3b2c095c5026749b). (packet), sizeof (SEAP_msg_tcxx . . $ SEAP_msg_t#));
373
374 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f). (packet);
375 return (0);
376 case SEAP_PACKET_CMDcxx . . $ `src/OVAL/probes/SEAP/_seap-packet.h:42:9`!:
377 switch (__SEAP_recvmsg_process_cmdcxx . . $ __SEAP_recvmsg_process_cmd(6df9f23f786c4d17). (ctx, sd, SEAP_packet_cmdcxx . . $ SEAP_packet_cmd(9f46e6fb5acf697d). (packet))) {
378 case 0:
379 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f). (packet);
380 continue;
381 default:
382 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EDOOFUScxx . . $ `src/OVAL/probes/SEAP/generic/common.h:44:10`!;
383 return (-1);
384 }
385 case SEAP_PACKET_ERRcxx . . $ `src/OVAL/probes/SEAP/_seap-packet.h:41:9`!:
386 switch (__SEAP_recvmsg_process_errcxx . . $ __SEAP_recvmsg_process_err(aab4fc2f6bdac614). (ctx, sd, SEAP_packet_errcxx . . $ SEAP_packet_err(3bc7b797eb278dfe). (packet))) {
387 case 0:
388 break;
389 case -1:
390 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f). (packet);
391 return (-1);
392 default:
393 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EDOOFUScxx . . $ `src/OVAL/probes/SEAP/generic/common.h:44:10`!;
394 return (-1);
395 }
396
397 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f). (packet);
398 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = ECANCELEDcxx . . $ `<external>/17922322188510340118/errno.h:111:9`!;
399 return (-1);
400 default:
401 abortcxx . . $ abort(8df32a62017fbbf6). ();
402 }
403
404 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f). (packet);
405 }
406
407 /* NOTREACHED */
408 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EDOOFUScxx . . $ `src/OVAL/probes/SEAP/generic/common.h:44:10`!;
409 return (-1);
410 }
411
412 int SEAP_sendmsgcxx . . $ SEAP_sendmsg(44b2d65acd10f583). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd, SEAP_msg_tcxx . . $ SEAP_msg_t# *seap_msg)
413 {
414 int ret;
415 SEAP_packet_tcxx . . $ SEAP_packet_t# *packet;
416 SEAP_msg_tcxx . . $ SEAP_msg_t# *msg;
417
418 packet = SEAP_packet_newcxx . . $ SEAP_packet_new(384bfbf0d7214bc9). ();
419 msg = (SEAP_msg_tcxx . . $ SEAP_msg_t# *)SEAP_packet_settypecxx . . $ SEAP_packet_settype(332ceac18a0c9d9b). (packet, SEAP_PACKET_MSGcxx . . $ `src/OVAL/probes/SEAP/_seap-packet.h:40:9`!);
420
421 seap_msg->idcxx . . $ SEAP_msg#id. = SEAP_desc_genmsgidcxx . . $ SEAP_desc_genmsgid(c52f604638ef6a39). (ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., sd);
422 memcpycxx . . $ memcpy(cc817cb175f282d). (msg, seap_msg, sizeof (SEAP_msg_tcxx . . $ SEAP_msg_t#));
423
424 ret = SEAP_packet_sendcxx . . $ SEAP_packet_send(ef224cc9abb3a138). (ctx, sd, packet);
425
426 protect_errnocxx . . $ `src/common/util.h:446:9`! {
427 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f). (packet);
428 }
429 return (ret);
430 }
431
432 int SEAP_sendsexpcxx . . $ SEAP_sendsexp(b40b93abb4cdefd5). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd, SEXP_tcxx . . $ SEXP_t# *sexp)
433 {
434 SEAP_msg_tcxx . . $ SEAP_msg_t# *msg;
435 int ret;
436
437 msg = SEAP_msg_newcxx . . $ SEAP_msg_new(b76a66c6f733d68f). ();
438
439 if (SEAP_msg_setcxx . . $ SEAP_msg_set(780f103242f3120a). (msg, sexp) == 0)
440 ret = SEAP_sendmsgcxx . . $ SEAP_sendmsg(44b2d65acd10f583). (ctx, sd, msg);
441 else
442 ret = -1;
443
444 protect_errnocxx . . $ `src/common/util.h:446:9`! {
445 SEAP_msg_freecxx . . $ SEAP_msg_free(4995d55015d41e57). (msg);
446 }
447 return (ret);
448 }
449
450 int SEAP_replycxx . . $ SEAP_reply(86996c4f120c23bc). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd, SEAP_msg_tcxx . . $ SEAP_msg_t# *rep_msg, SEAP_msg_tcxx . . $ SEAP_msg_t# *req_msg)
451 {
452 SEXP_tcxx . . $ SEXP_t# *r0;
453
454 _Acxx . . $ `src/common/debug_priv.h:43:9`!(ctx != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
455 _Acxx . . $ `src/common/debug_priv.h:43:9`!(rep_msg != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
456 _Acxx . . $ `src/common/debug_priv.h:43:9`!(req_msg != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
457
458 if (SEAP_msgattr_setcxx . . $ SEAP_msgattr_set(be99563c35b05491). (rep_msg, "reply-id",
459 #if SEAP_MSGID_BITScxx . . $ `build/config.h:61:9`! == 64
460 r0 = SEXP_number_newu_64 (req_msg->id)
461 #else
462 r0 = SEXP_number_newu_32cxx . . $ SEXP_number_newu_32(8a1232211d6fd92a). (req_msg->idcxx . . $ SEAP_msg#id.)
463 #endif
464 ) == 0)
465 {
466 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4). (r0);
467
468 if (SEAP_msgattr_existscxx . . $ SEAP_msgattr_exists(2dc8898f2a6eccd3). (req_msg, "no-reply")) {
469 SEAP_msg_tcxx . . $ SEAP_msg_t# *nil_msg;
470 int ret;
471
472 dDcxx . . $ `src/common/debug_priv.h:64:9`!("no-reply set: sending empty reply");
473
474 nil_msg = SEAP_msg_clonecxx . . $ SEAP_msg_clone(5f7ab50696302eaa). (rep_msg);
475 SEAP_msg_unsetcxx . . $ SEAP_msg_unset(4995d55015d41e57). (nil_msg);
476 ret = SEAP_sendmsgcxx . . $ SEAP_sendmsg(44b2d65acd10f583). (ctx, sd, nil_msg);
477 SEAP_msg_freecxx . . $ SEAP_msg_free(4995d55015d41e57). (nil_msg);
478
479 return (ret);
480 } else {
481 dDcxx . . $ `src/common/debug_priv.h:64:9`!("no-reply not set: sending full reply");
482 return SEAP_sendmsgcxx . . $ SEAP_sendmsg(44b2d65acd10f583). (ctx, sd, rep_msg);
483 }
484 } else {
485 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4). (r0);
486 return (-1);
487 }
488 }
489
490 static int __SEAP_senderrcxx . . $ __SEAP_senderr(8386d985a8bd18fa). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd, SEAP_err_tcxx . . $ SEAP_err_t# *err, unsigned int type)
491 {
492 SEAP_packet_tcxx . . $ SEAP_packet_t# *packet;
493 SEAP_err_tcxx . . $ SEAP_err_t# *errptr;
494
495 _Acxx . . $ `src/common/debug_priv.h:43:9`!(ctx != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
496 _Acxx . . $ `src/common/debug_priv.h:43:9`!(err != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
497
498 packet = SEAP_packet_newcxx . . $ SEAP_packet_new(384bfbf0d7214bc9). ();
499 errptr = SEAP_packet_settypecxx . . $ SEAP_packet_settype(332ceac18a0c9d9b). (packet, SEAP_PACKET_ERRcxx . . $ `src/OVAL/probes/SEAP/_seap-packet.h:41:9`!);
500
501 memcpycxx . . $ memcpy(cc817cb175f282d). (errptr, err, sizeof (SEAP_err_tcxx . . $ SEAP_err_t#));
502 errptr->typecxx . . $ SEAP_err#type. = type;
503
504 if (SEAP_packet_sendcxx . . $ SEAP_packet_send(ef224cc9abb3a138). (ctx, sd, packet) != 0) {
505 protect_errnocxx . . $ `src/common/util.h:446:9`! {
506 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`!));
507 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f). (packet);
508 }
509
510 return (-1);
511 }
512
513 SEAP_packet_freecxx . . $ SEAP_packet_free(2cb4ed29150e9a0f). (packet);
514 return (0);
515 }
516
517 int SEAP_senderrcxx . . $ SEAP_senderr(aab4fc2f6bdac614). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd, SEAP_err_tcxx . . $ SEAP_err_t# *err)
518 {
519 return (__SEAP_senderrcxx . . $ __SEAP_senderr(8386d985a8bd18fa). (ctx, sd, err, SEAP_ETYPE_USERcxx . . $ `src/OVAL/probes/SEAP/_seap-types.h:74:9`!));
520 }
521
522 int SEAP_replyerrcxx . . $ SEAP_replyerr(9c3156c1fad5b304). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd, SEAP_msg_tcxx . . $ SEAP_msg_t# *rep_msg, uint32_tcxx . . $ uint32_t# e)
523 {
524 SEAP_err_tcxx . . $ SEAP_err_t# err;
525
526 _Acxx . . $ `src/common/debug_priv.h:43:9`!(ctx != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
527 _Acxx . . $ `src/common/debug_priv.h:43:9`!(rep_msg != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
528
529 err.typecxx . . $ SEAP_err#type. = 0;
530 err.codecxx . . $ SEAP_err#code. = e;
531 err.idcxx . . $ SEAP_err#id. = rep_msg->idcxx . . $ SEAP_msg#id.;
532 err.datacxx . . $ SEAP_err#data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; /* FIXME: Attach original message */
533
534 return (__SEAP_senderrcxx . . $ __SEAP_senderr(8386d985a8bd18fa). (ctx, sd, &err, SEAP_ETYPE_USERcxx . . $ `src/OVAL/probes/SEAP/_seap-types.h:74:9`!));
535 }
536
537 int SEAP_recverrcxx . . $ SEAP_recverr(1a1ba83450e44246). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd, SEAP_err_tcxx . . $ SEAP_err_t# **err)
538 {
539 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EOPNOTSUPPcxx . . $ `<external>/17922322188510340118/errno.h:79:9`!;
540 return (-1);
541 }
542
543 /**
544 * Receive the last error that happened on `sd' and was caused by a message
545 * with ID `id'.
546 * If an error is in the queue, it's saved at `*err' and zero is returned.
547 * The caller takes care of freeing the memory used by the returned SEAP_err_t
548 * structure. If there is not an error, 1 is returned. In case of an internal
549 * error, -1 is returned an errno is set.
550 */
551 int SEAP_recverr_byidcxx . . $ SEAP_recverr_byid(960dd4cce4b45919). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd, SEAP_err_tcxx . . $ SEAP_err_t# **err, SEAP_msgid_tcxx . . $ SEAP_msgid_t# id)
552 {
553 SEAP_desc_tcxx . . $ SEAP_desc_t# *sd_desc;
554 void *data;
555
556 if (err == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
557 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!;
558 return (-1);
559 }
560
561 sd_desc = SEAP_desc_getcxx . . $ SEAP_desc_get(b324436d5ff0f8fe).(ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., sd);
562
563 if (sd_desc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
564 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EBADFcxx . . $ `<external>/8987895939074593727/errno-base.h:13:9`!;
565 return (-1);
566 }
567
568 data = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
569
570 if (rbt_i32_delcxx . . $ rbt_i32_del(fbdfcf5a3c6c46ec).(sd_desc->err_queuecxx . . $ $anonymous_type_5b6d52305350878e_0#err_queue., (uint32_tcxx . . $ uint32_t#)id, &data) != 0)
571 return (1);
572 else {
573 if (data == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
574 return -1;
575 }
576 *err = (SEAP_err_tcxx . . $ SEAP_err_t# *)data;
577 }
578
579 return (0);
580 }
581
582 SEXP_tcxx . . $ SEXP_t# *SEAP_readcxx . . $ SEAP_read(89a0d7fa3fac4edd). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd)
583 {
584 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EOPNOTSUPPcxx . . $ `<external>/17922322188510340118/errno.h:79:9`!;
585 return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
586 }
587
588 int SEAP_writecxx . . $ SEAP_write(b40b93abb4cdefd5). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd, SEXP_tcxx . . $ SEXP_t# *sexp)
589 {
590 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EOPNOTSUPPcxx . . $ `<external>/17922322188510340118/errno.h:79:9`!;
591 return (-1);
592 }
593
594 int SEAP_closecxx . . $ SEAP_close(1db39790f33892d1). (SEAP_CTX_tcxx . . $ SEAP_CTX_t# *ctx, int sd)
595 {
596 SEAP_desc_tcxx . . $ SEAP_desc_t# *dsc;
597 int ret;
598
599 _Acxx . . $ `src/common/debug_priv.h:43:9`!(ctx != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
600
601 if (sd < 0) {
602 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EBADFcxx . . $ `<external>/8987895939074593727/errno-base.h:13:9`!;
603 return (-1);
604 }
605
606 dsc = SEAP_desc_getcxx . . $ SEAP_desc_get(b324436d5ff0f8fe). (ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., sd);
607
608 if (dsc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
609 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EBADFcxx . . $ `<external>/8987895939074593727/errno-base.h:13:9`!;
610 return (-1);
611 }
612
613 ret = sch_queue_closecxx . . $ sch_queue_close(912e80c1e1b86eec).(dsc, 0); /* TODO: Are flags usable here? */
614
615 protect_errnocxx . . $ `src/common/util.h:446:9`! {
616 if (SEAP_desc_delcxx . . $ SEAP_desc_del(ad0fa72a6b5db2). (ctx->sd_tablecxx . . $ SEAP_CTX#sd_table., sd) != 0) {
617 /* something very bad happened */
618 dDcxx . . $ `src/common/debug_priv.h:64:9`!("SEAP_desc_del failed");
619 return(-1);
620 }
621 }
622
623 return(ret);
624 }