| 1 |
/* |
| 2 |
* Open Vulnerability and Assessment Language |
| 3 |
* (http://oval.mitre.org/) |
| 4 |
*/ |
| 5 |
|
| 6 |
/* |
| 7 |
* Copyright 2009--2014 Red Hat Inc., Durham, North Carolina. |
| 8 |
* All Rights Reserved. |
| 9 |
* |
| 10 |
* This library is free software; you can redistribute it and/or |
| 11 |
* modify it under the terms of the GNU Lesser General Public |
| 12 |
* License as published by the Free Software Foundation; either |
| 13 |
* version 2.1 of the License, or (at your option) any later version. |
| 14 |
* |
| 15 |
* This library is distributed in the hope that it will be useful, |
| 16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 |
* Lesser General Public License for more details. |
| 19 |
* |
| 20 |
* You should have received a copy of the GNU Lesser General Public |
| 21 |
* License along with this library; if not, write to the Free Software |
| 22 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 23 |
* |
| 24 |
* Authors: |
| 25 |
* Maros Barabas <[email protected]> |
| 26 |
* |
| 27 |
*/ |
| 28 |
|
| 29 |
/* Define OSCAP_API as an empty string */ |
| 30 |
/* Prevents 'Syntax error in input(1).' message */ |
| 31 |
#define OSCAP_API |
| 32 |
|
| 33 |
/* Convert a tuple element to a C array */ |
| 34 |
/* SWIG can't understand __attribute__(x), so we make it go away */ |
| 35 |
#define __attribute__(x) |
| 36 |
|
| 37 |
#if defined(SWIGPYTHON) |
| 38 |
|
| 39 |
/* Definitions for PYTHON */ |
| 40 |
|
| 41 |
%exception xccdf_policy_evaluate { |
| 42 |
Py_BEGIN_ALLOW_THREADS |
| 43 |
$action |
| 44 |
Py_END_ALLOW_THREADS |
| 45 |
} |
| 46 |
|
| 47 |
%typemap(in) time_t |
| 48 |
{ |
| 49 |
if (PyLong_Check($input)) |
| 50 |
$1 = (time_t) PyLong_AsLong($input); |
| 51 |
else if (PyInt_Check($input)) |
| 52 |
$1 = (time_t) PyInt_AsLong($input); |
| 53 |
else if (PyFloat_Check($input)) |
| 54 |
$1 = (time_t) PyFloat_AsDouble($input); |
| 55 |
else { |
| 56 |
PyErr_SetString(PyExc_TypeError,"Expected a large number"); |
| 57 |
SWIG_fail; |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
%typemap(out) time_t |
| 62 |
{ |
| 63 |
$result = PyLong_FromLong((long)$1); |
| 64 |
} |
| 65 |
|
| 66 |
%typemap(in) void * { |
| 67 |
int ptrres = SWIG_ConvertPtr($input,%as_voidptrptr(&$1), 0, $disown); |
| 68 |
if (!SWIG_IsOK(ptrres)) { |
| 69 |
%argument_fail(ptrres, "$type", $symname, $argnum); |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
%module openscap |
| 75 |
|
| 76 |
%typemap(in) char ** { |
| 77 |
if (PyList_Check($input)) { |
| 78 |
int size = PyList_Size($input); |
| 79 |
int i = 0; |
| 80 |
$1 = (char **) malloc((size+1)*sizeof(char *)); |
| 81 |
for (i = 0; i < size; i++) { |
| 82 |
PyObject *o = PyList_GetItem($input,i); |
| 83 |
/*if (PyString_Check(o))*/ |
| 84 |
$1[i] = PyString_AsString(PyList_GetItem($input,i)); |
| 85 |
/*else { |
| 86 |
PyErr_SetString(PyExc_TypeError,"list must contain strings"); |
| 87 |
free($1); |
| 88 |
return NULL; |
| 89 |
}*/ |
| 90 |
} |
| 91 |
$1[i] = 0; |
| 92 |
} else { |
| 93 |
PyErr_SetString(PyExc_TypeError,"not a list"); |
| 94 |
SWIG_fail; |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
%typemap(freearg) char ** { |
| 99 |
free((char *) $1); |
| 100 |
} |
| 101 |
|
| 102 |
%typemap(in) struct cpe_name ** { |
| 103 |
|
| 104 |
int i; |
| 105 |
int a_size = 0; |
| 106 |
int res_o = 0; |
| 107 |
a_size = (int) PySequence_Length($input); |
| 108 |
|
| 109 |
if (!PySequence_Check($input)) { |
| 110 |
PyErr_SetString(PyExc_ValueError,"Expected a sequence"); |
| 111 |
SWIG_fail; |
| 112 |
} |
| 113 |
if (a_size <= 0) { |
| 114 |
PyErr_SetString(PyExc_ValueError,"Expected not empty sequence"); |
| 115 |
SWIG_fail; |
| 116 |
} |
| 117 |
|
| 118 |
$1 = (struct cpe_name **) malloc(a_size*sizeof(struct cpe_name *)); |
| 119 |
for (i = 0; i < a_size; i++) { |
| 120 |
void *arg = 0; |
| 121 |
PyObject *obj = PySequence_GetItem($input,i); |
| 122 |
if (obj == NULL) { |
| 123 |
SWIG_exception_fail(SWIG_ArgError(res_o), "in argument '" "cpe_name" "' substitution '" "', can't access sequence"); |
| 124 |
SWIG_fail; /*5956*/ |
| 125 |
} |
| 126 |
res_o = SWIG_ConvertPtr(obj, &arg, SWIGTYPE_p_cpe_name, 0 ); |
| 127 |
if (!SWIG_IsOK(res_o)) { |
| 128 |
SWIG_exception_fail(SWIG_ArgError(res_o), "in argument '" "cpe_name" "' substitution invalid types"); |
| 129 |
SWIG_fail; |
| 130 |
} |
| 131 |
$1[i] = (struct cpe_name *) arg; |
| 132 |
} |
| 133 |
} |
| 134 |
%typemap(in) struct oval_syschar_model ** { |
| 135 |
|
| 136 |
int i; |
| 137 |
int a_size = 0; |
| 138 |
int res_o = 0; |
| 139 |
a_size = (int) PySequence_Length($input); |
| 140 |
|
| 141 |
if (!PySequence_Check($input)) { |
| 142 |
PyErr_SetString(PyExc_ValueError,"Expected a sequence"); |
| 143 |
SWIG_fail; |
| 144 |
} |
| 145 |
if (a_size <= 0) { |
| 146 |
PyErr_SetString(PyExc_ValueError,"Expected not empty sequence"); |
| 147 |
SWIG_fail; |
| 148 |
} |
| 149 |
|
| 150 |
$1 = (struct oval_syschar_model **) malloc(a_size*sizeof(struct oval_syschar_model *)); |
| 151 |
for (i = 0; i < a_size; i++) { |
| 152 |
void *arg = 0; |
| 153 |
PyObject *obj = PySequence_GetItem($input,i); |
| 154 |
if (obj == NULL) { |
| 155 |
SWIG_exception_fail(SWIG_ArgError(res_o), "in argument '" "oval_syschar_model" "' substitution '" "', can't access sequence"); |
| 156 |
SWIG_fail; |
| 157 |
} |
| 158 |
res_o = SWIG_ConvertPtr(obj, &arg, SWIGTYPE_p_oval_syschar_model, 0 ); |
| 159 |
if (!SWIG_IsOK(res_o)) { |
| 160 |
SWIG_exception_fail(SWIG_ArgError(res_o), "in argument '" "oval_syschar_model" "' substitution invalid types"); |
| 161 |
SWIG_fail; |
| 162 |
} |
| 163 |
$1[i] = (struct oval_syschar_model *) arg; |
| 164 |
} |
| 165 |
} |
| 166 |
%typemap(freearg) struct oval_syschar_model ** { |
| 167 |
free($1); |
| 168 |
} |
| 169 |
#elif defined(SWIGPERL) |
| 170 |
/* Definitions for PERL */ |
| 171 |
#endif |
| 172 |
|
| 173 |
%module openscap |
| 174 |
%{ |
| 175 |
#include "../../src/common/public/oscap.h" |
| 176 |
#include "../../src/common/public/oscap_error.h" |
| 177 |
#include "../../src/common/public/oscap_text.h" |
| 178 |
|
| 179 |
#include "../../src/DS/public/scap_ds.h" |
| 180 |
%} |
| 181 |
|
| 182 |
%include "../../src/common/public/oscap.h" |
| 183 |
%include "../../src/common/public/oscap_error.h" |
| 184 |
%include "../../src/common/public/oscap_text.h" |
| 185 |
%include "../../src/common/public/oscap_reference.h" |
| 186 |
|
| 187 |
%include "../../src/DS/public/scap_ds.h" |
| 188 |
|
| 189 |
%module openscap |
| 190 |
%{ |
| 191 |
#include "../../src/CPE/public/cpe_name.h" |
| 192 |
#include "../../src/CPE/public/cpe_dict.h" |
| 193 |
#include "../../src/CPE/public/cpe_lang.h" |
| 194 |
%} |
| 195 |
%include "../../src/CPE/public/cpe_name.h" |
| 196 |
%include "../../src/CPE/public/cpe_dict.h" |
| 197 |
%include "../../src/CPE/public/cpe_lang.h" |
| 198 |
|
| 199 |
%module openscap |
| 200 |
%{ |
| 201 |
#include "../../src/DS/public/ds_rds_session.h" |
| 202 |
#include "../../src/DS/public/ds_sds_session.h" |
| 203 |
#include "../../src/DS/public/scap_ds.h" |
| 204 |
%} |
| 205 |
%include "../../src/DS/public/ds_rds_session.h" |
| 206 |
%include "../../src/DS/public/ds_sds_session.h" |
| 207 |
%include "../../src/DS/public/scap_ds.h" |
| 208 |
|
| 209 |
|
| 210 |
%module openscap |
| 211 |
%{ |
| 212 |
#include "../../src/XCCDF/public/xccdf_benchmark.h" |
| 213 |
#include "../../src/XCCDF/public/xccdf_session.h" |
| 214 |
#include "../../src/XCCDF_POLICY/public/xccdf_policy.h" |
| 215 |
%} |
| 216 |
%include "../../src/XCCDF/public/xccdf_benchmark.h" |
| 217 |
%include "../../src/XCCDF/public/xccdf_session.h" |
| 218 |
%include "../../src/XCCDF_POLICY/public/xccdf_policy.h" |
| 219 |
|
| 220 |
|
| 221 |
%module openscap |
| 222 |
%{ |
| 223 |
#include "../../src/OVAL/public/oval_adt.h" |
| 224 |
#include "../../src/OVAL/public/oval_agent_api.h" |
| 225 |
#include "../../src/OVAL/public/oval_definitions.h" |
| 226 |
#include "../../src/OVAL/public/oval_directives.h" |
| 227 |
#include "../../src/OVAL/public/oval_system_characteristics.h" |
| 228 |
#include "../../src/OVAL/public/oval_results.h" |
| 229 |
#include "../../src/OVAL/public/oval_schema_version.h" |
| 230 |
#include "../../src/OVAL/public/oval_session.h" |
| 231 |
#include "../../src/OVAL/public/oval_types.h" |
| 232 |
#include "../../src/OVAL/public/oval_variables.h" |
| 233 |
#include "../../src/OVAL/public/oval_probe.h" |
| 234 |
#include "../../src/OVAL/public/oval_probe_session.h" |
| 235 |
%} |
| 236 |
%include "../../src/OVAL/public/oval_adt.h" |
| 237 |
%include "../../src/OVAL/public/oval_agent_api.h" |
| 238 |
%include "../../src/OVAL/public/oval_definitions.h" |
| 239 |
%include "../../src/OVAL/public/oval_directives.h" |
| 240 |
%include "../../src/OVAL/public/oval_system_characteristics.h" |
| 241 |
%include "../../src/OVAL/public/oval_results.h" |
| 242 |
%include "../../src/OVAL/public/oval_schema_version.h" |
| 243 |
%include "../../src/OVAL/public/oval_session.h" |
| 244 |
%include "../../src/OVAL/public/oval_types.h" |
| 245 |
%include "../../src/OVAL/public/oval_variables.h" |
| 246 |
#if defined(ENABLE_PROBES) |
| 247 |
%include "../../src/OVAL/public/oval_probe.h" |
| 248 |
%include "../../src/OVAL/public/oval_probe_session.h" |
| 249 |
#endif |
| 250 |
|
| 251 |
%module openscap |
| 252 |
%{ |
| 253 |
#include "../../src/OVAL/public/oval_agent_xccdf_api.h" |
| 254 |
%} |
| 255 |
%include "../../src/OVAL/public/oval_agent_xccdf_api.h" |
| 256 |
|
| 257 |
%module openscap |
| 258 |
%{ |
| 259 |
#include "../../src/source/public/oscap_source.h" |
| 260 |
%} |
| 261 |
%include "../../src/source/public/oscap_source.h" |
| 262 |
|
| 263 |
/*%typemap(in) value[ANY] { |
| 264 |
|
| 265 |
int i; |
| 266 |
PyErr_SetString(PyExc_ValueError,"Expected a sequence"); |
| 267 |
return NULL; |
| 268 |
if (!PySequence_Check($input)) { |
| 269 |
PyErr_SetString(PyExc_ValueError,"Expected a sequence"); |
| 270 |
return NULL; |
| 271 |
} |
| 272 |
if (PySequence_Length($input) != $1_dim0) { |
| 273 |
PyErr_SetString(PyExc_ValueError,"Size mismatch. Expected $1_dim0 elements"); |
| 274 |
return NULL; |
| 275 |
} |
| 276 |
$1 = (void **) malloc($1_dim0*sizeof( Py_TYPE(PySequence_GetItem($input, 0)) )); |
| 277 |
|
| 278 |
for (i = 0; i < $1_dim0; i++) { |
| 279 |
PyObject *o = PySequence_GetItem($input,i); |
| 280 |
if (Py_TYPE(PySequence_GetItem($input,i)) != Py_TYPE(PySequence_GetItem($input,0)) { |
| 281 |
PyErr_SetString(PyExc_ValueError,"Type mismatch"); |
| 282 |
free($1); |
| 283 |
return NULL; |
| 284 |
} |
| 285 |
$1[i] = (PyTYPE(PySequence_GetItem($input, i))) o; |
| 286 |
} |
| 287 |
|
| 288 |
} |
| 289 |
|
| 290 |
*/ |
| 291 |
|
| 292 |
#if defined(SWIGPYTHON) |
| 293 |
|
| 294 |
|
| 295 |
%{ |
| 296 |
struct internal_usr { |
| 297 |
PyObject *func; |
| 298 |
PyObject *usr; |
| 299 |
}; |
| 300 |
|
| 301 |
int rule_result_output_callback_wrapper(struct xccdf_rule_result* rule_result, void *arg) |
| 302 |
{ |
| 303 |
PyGILState_STATE state; |
| 304 |
PyObject *py_rule_result; |
| 305 |
PyObject *arglist; |
| 306 |
PyObject *func, *usrdata; |
| 307 |
struct internal_usr *data; |
| 308 |
PyObject *result; |
| 309 |
double dres = 0; |
| 310 |
|
| 311 |
state = PyGILState_Ensure(); |
| 312 |
py_rule_result = SWIG_NewPointerObj(rule_result, SWIGTYPE_p_xccdf_rule_result, 1); |
| 313 |
data = (struct internal_usr *) arg; |
| 314 |
func = data->func; |
| 315 |
usrdata = data->usr; |
| 316 |
arglist = Py_BuildValue("OO", py_rule_result, usrdata); |
| 317 |
if (!PyCallable_Check(func)) { |
| 318 |
PyGILState_Release(state); |
| 319 |
return 1; |
| 320 |
} |
| 321 |
result = PyObject_CallObject(func,arglist); |
| 322 |
if (result == NULL) { |
| 323 |
if (PyErr_Occurred() != NULL) |
| 324 |
PyErr_PrintEx(0); |
| 325 |
PyErr_Print(); |
| 326 |
Py_DECREF(arglist); |
| 327 |
Py_XDECREF(result); |
| 328 |
PyGILState_Release(state); |
| 329 |
return -1; |
| 330 |
} |
| 331 |
Py_DECREF(arglist); |
| 332 |
dres = PyInt_AsLong(result); |
| 333 |
Py_XDECREF(result); |
| 334 |
PyGILState_Release(state); |
| 335 |
return dres; |
| 336 |
} |
| 337 |
|
| 338 |
int rule_start_callback_wrapper(struct xccdf_rule* rule, void *arg) |
| 339 |
{ |
| 340 |
PyGILState_STATE state; |
| 341 |
PyObject *py_rule; |
| 342 |
PyObject *arglist; |
| 343 |
PyObject *func, *usrdata; |
| 344 |
struct internal_usr *data; |
| 345 |
PyObject *result; |
| 346 |
double dres = 0; |
| 347 |
|
| 348 |
state = PyGILState_Ensure(); |
| 349 |
py_rule = SWIG_NewPointerObj(rule, SWIGTYPE_p_xccdf_rule, 1); |
| 350 |
data = (struct internal_usr *) arg; |
| 351 |
func = data->func; |
| 352 |
usrdata = data->usr; |
| 353 |
arglist = Py_BuildValue("OO", py_rule, usrdata); |
| 354 |
if (!PyCallable_Check(func)) { |
| 355 |
PyGILState_Release(state); |
| 356 |
return 1; |
| 357 |
} |
| 358 |
result = PyObject_CallObject(func,arglist); |
| 359 |
if (result == NULL) { |
| 360 |
if (PyErr_Occurred() != NULL) |
| 361 |
PyErr_PrintEx(0); |
| 362 |
PyErr_Print(); |
| 363 |
Py_DECREF(arglist); |
| 364 |
Py_XDECREF(result); |
| 365 |
PyGILState_Release(state); |
| 366 |
return -1; |
| 367 |
} |
| 368 |
Py_DECREF(arglist); |
| 369 |
dres = PyInt_AsLong(result); |
| 370 |
Py_XDECREF(result); |
| 371 |
PyGILState_Release(state); |
| 372 |
return dres; |
| 373 |
} |
| 374 |
|
| 375 |
int agent_reporter_callback_wrapper(const struct oval_result_definition* res_def, void *arg) |
| 376 |
{ |
| 377 |
PyGILState_STATE state; |
| 378 |
PyObject *py_res_def; |
| 379 |
PyObject *arglist; |
| 380 |
PyObject *func, *usrdata; |
| 381 |
struct internal_usr *data; |
| 382 |
PyObject *result; |
| 383 |
double dres = 0; |
| 384 |
|
| 385 |
state = PyGILState_Ensure(); |
| 386 |
py_res_def = SWIG_NewPointerObj(res_def, SWIGTYPE_p_oval_result_definition, 1); |
| 387 |
data = (struct internal_usr *) arg; |
| 388 |
func = data->func; |
| 389 |
usrdata = data->usr; |
| 390 |
arglist = Py_BuildValue("OO", py_res_def, usrdata); |
| 391 |
if (!PyCallable_Check(func)) { |
| 392 |
PyGILState_Release(state); |
| 393 |
return 1; |
| 394 |
} |
| 395 |
result = PyObject_CallObject(func,arglist); |
| 396 |
if (result == NULL) { |
| 397 |
if (PyErr_Occurred() != NULL) |
| 398 |
PyErr_PrintEx(0); |
| 399 |
PyErr_Print(); |
| 400 |
Py_DECREF(arglist); |
| 401 |
Py_XDECREF(result); |
| 402 |
PyGILState_Release(state); |
| 403 |
return -1; |
| 404 |
} |
| 405 |
Py_DECREF(arglist); |
| 406 |
dres = PyInt_AsLong(result); |
| 407 |
Py_XDECREF(result); |
| 408 |
PyGILState_Release(state); |
| 409 |
return dres; |
| 410 |
} |
| 411 |
|
| 412 |
int validate_callback_wrapper(const char* file, int line, const char* msg, void *arg) |
| 413 |
{ |
| 414 |
PyGILState_STATE state; |
| 415 |
PyObject *arglist; |
| 416 |
PyObject *func, *usrdata; |
| 417 |
struct internal_usr *data; |
| 418 |
PyObject *result; |
| 419 |
double dres = 0; |
| 420 |
|
| 421 |
state = PyGILState_Ensure(); |
| 422 |
data = (struct internal_usr *) arg; |
| 423 |
func = data->func; |
| 424 |
usrdata = data->usr; |
| 425 |
arglist = Py_BuildValue("sisO", file, line, msg, usrdata); |
| 426 |
if (!PyCallable_Check(func)) { |
| 427 |
PyGILState_Release(state); |
| 428 |
return 1; |
| 429 |
} |
| 430 |
result = PyObject_CallObject(func,arglist); |
| 431 |
if (result == NULL) { |
| 432 |
if (PyErr_Occurred() != NULL) |
| 433 |
PyErr_PrintEx(0); |
| 434 |
PyErr_Print(); |
| 435 |
Py_DECREF(arglist); |
| 436 |
Py_XDECREF(result); |
| 437 |
PyGILState_Release(state); |
| 438 |
return -1; |
| 439 |
} |
| 440 |
Py_DECREF(arglist); |
| 441 |
dres = PyInt_AsLong(result); |
| 442 |
Py_XDECREF(result); |
| 443 |
PyGILState_Release(state); |
| 444 |
return dres; |
| 445 |
} |
| 446 |
|
| 447 |
char * sub_callback_wrapper(xccdf_subst_type_t type, const char *id, void *arg) |
| 448 |
{ |
| 449 |
PyGILState_STATE state; |
| 450 |
PyObject *arglist; |
| 451 |
PyObject *func, *usrdata; |
| 452 |
struct internal_usr *data; |
| 453 |
PyObject *result; |
| 454 |
char *dres = NULL; |
| 455 |
|
| 456 |
state = PyGILState_Ensure(); |
| 457 |
data = (struct internal_usr *) arg; |
| 458 |
func = data->func; |
| 459 |
usrdata = data->usr; |
| 460 |
|
| 461 |
arglist = Py_BuildValue("isO", type, id, usrdata); |
| 462 |
if (!PyCallable_Check(func)) { |
| 463 |
PyGILState_Release(state); |
| 464 |
return NULL; |
| 465 |
} |
| 466 |
result = PyObject_CallObject(func, arglist); |
| 467 |
if (result == NULL) { |
| 468 |
if (PyErr_Occurred() != NULL) |
| 469 |
PyErr_PrintEx(0); |
| 470 |
PyErr_Print(); |
| 471 |
Py_DECREF(arglist); |
| 472 |
Py_XDECREF(result); |
| 473 |
PyGILState_Release(state); |
| 474 |
return NULL; |
| 475 |
} |
| 476 |
Py_DECREF(arglist); |
| 477 |
dres = PyString_AsString(result); |
| 478 |
if (dres == NULL) { |
| 479 |
if (PyErr_Occurred() != NULL) |
| 480 |
PyErr_PrintEx(0); |
| 481 |
PyErr_Print(); |
| 482 |
Py_DECREF(arglist); |
| 483 |
Py_XDECREF(result); |
| 484 |
PyGILState_Release(state); |
| 485 |
return NULL; |
| 486 |
} |
| 487 |
Py_XDECREF(result); |
| 488 |
PyGILState_Release(state); |
| 489 |
return strdup(dres); |
| 490 |
} |
| 491 |
|
| 492 |
%} |
| 493 |
|
| 494 |
%inline %{ |
| 495 |
|
| 496 |
bool xccdf_policy_model_register_output_callback_py(struct xccdf_policy_model *model, PyObject *func, PyObject *usr) { |
| 497 |
struct internal_usr *new_usrdata; |
| 498 |
Py_INCREF(func); |
| 499 |
Py_INCREF(usr); |
| 500 |
new_usrdata = malloc(sizeof(struct internal_usr)); |
| 501 |
if (new_usrdata == NULL) return false; |
| 502 |
|
| 503 |
new_usrdata->func = func; |
| 504 |
new_usrdata->usr = usr; |
| 505 |
|
| 506 |
return xccdf_policy_model_register_output_callback(model, rule_result_output_callback_wrapper, (void *)new_usrdata); |
| 507 |
} |
| 508 |
|
| 509 |
bool xccdf_policy_model_register_start_callback_py(struct xccdf_policy_model *model, PyObject *func, PyObject *usr) { |
| 510 |
struct internal_usr *new_usrdata; |
| 511 |
Py_INCREF(func); |
| 512 |
Py_INCREF(usr); |
| 513 |
new_usrdata = malloc(sizeof(struct internal_usr)); |
| 514 |
if (new_usrdata == NULL) return false; |
| 515 |
|
| 516 |
new_usrdata->func = func; |
| 517 |
new_usrdata->usr = usr; |
| 518 |
|
| 519 |
return xccdf_policy_model_register_start_callback(model, rule_start_callback_wrapper, (void *)new_usrdata); |
| 520 |
} |
| 521 |
|
| 522 |
int oval_agent_eval_system_py(oval_agent_session_t * asess, PyObject * func, PyObject *usr) { |
| 523 |
struct internal_usr *new_usrdata; |
| 524 |
Py_INCREF(func); |
| 525 |
Py_INCREF(usr); |
| 526 |
new_usrdata = malloc(sizeof(struct internal_usr)); |
| 527 |
if (new_usrdata == NULL) return false; |
| 528 |
|
| 529 |
new_usrdata->func = func; |
| 530 |
new_usrdata->usr = usr; |
| 531 |
|
| 532 |
return oval_agent_eval_system(asess, agent_reporter_callback_wrapper, (void *) new_usrdata); |
| 533 |
} |
| 534 |
|
| 535 |
/* we only recopy the first part of the struct, in order to free the rule property |
| 536 |
* since it's defined in xccdf_session.c and not xccdf_session.h, this struct is unknown |
| 537 |
* and so it's not possible to access to the rule property without defining it |
| 538 |
*/ |
| 539 |
struct xccdf_session { |
| 540 |
char *filename; |
| 541 |
char *rule; |
| 542 |
}; |
| 543 |
|
| 544 |
void xccdf_session_set_rule_py(struct xccdf_session *sess, char *rule) { |
| 545 |
xccdf_session_set_rule(sess, rule); |
| 546 |
} |
| 547 |
|
| 548 |
void xccdf_session_free_py(struct xccdf_session *sess){ |
| 549 |
free(sess->rule); |
| 550 |
xccdf_session_free(sess); |
| 551 |
} |
| 552 |
|
| 553 |
%} |
| 554 |
#endif |