@@ -362,6 +362,7 @@ xccdf_test_result_type_t sce_engine_eval_rule(struct xccdf_policy *policy, const
362
362
{
363
363
struct sce_parameters * parameters = (struct sce_parameters * )usr ;
364
364
const char * xccdf_directory = parameters -> xccdf_directory ;
365
+ bool use_sce_wrapper = false; // use osca-run-sce-script ?
365
366
366
367
char * tmp_href = oscap_sprintf ("%s/%s" , xccdf_directory , href );
367
368
@@ -381,27 +382,26 @@ xccdf_test_result_type_t sce_engine_eval_rule(struct xccdf_policy *policy, const
381
382
382
383
if (access (tmp_href , F_OK | X_OK ))
383
384
{
384
- // again, only to provide helpful error message
385
- oscap_seterr (OSCAP_EFAMILY_SCE , "SCE has found script file '%s' at '%s' "
386
- "but it isn't executable!" , href , tmp_href );
387
- free (tmp_href );
388
- return XCCDF_RESULT_ERROR ;
385
+ // use the sce wrapper if it's not possible to acquire +x rights
386
+ use_sce_wrapper = true;
387
+ dI ("%s isn't executable, oscap-run-sce-script will be used." , tmp_href );
389
388
}
390
389
391
390
// all the result codes are shifted by 100, because otherwise syntax errors in scripts
392
391
// or even their nonexistence would cause XCCDF_RESULT_PASS to be the result
393
392
394
- char * argvp [1 + 1 ] = {
393
+ char * argvp [3 ] = {
395
394
tmp_href ,
396
- NULL
395
+ tmp_href , // the second tmp_href is added in case we use the wrapper (oscap-run-sce-script)
396
+ NULL // which need the path of the script to eval as first parameter.
397
397
};
398
398
399
399
// bound values in KEY=VALUE form, ready to be passed as environment variables
400
400
char * * env_values = malloc (10 * sizeof (char * ));
401
401
size_t env_value_count = 10 ;
402
402
const size_t index_of_first_env_value_not_compiled_in = 10 ;
403
403
404
- env_values [0 ] = "PATH=/bin:/sbin:/usr/bin:/usr/sbin" ;
404
+ env_values [0 ] = "PATH=/bin:/sbin:/usr/bin:/usr/local/bin:/usr/ sbin" ;
405
405
406
406
env_values [1 ] = "XCCDF_RESULT_PASS=101" ;
407
407
env_values [2 ] = "XCCDF_RESULT_FAIL=102" ;
@@ -539,7 +539,11 @@ xccdf_test_result_type_t sce_engine_eval_rule(struct xccdf_policy *policy, const
539
539
#endif
540
540
541
541
// we are the child process
542
- execve (tmp_href , argvp , env_values );
542
+
543
+ if (use_sce_wrapper )
544
+ execvpe ("oscap-run-sce-script" , argvp , env_values );
545
+ else
546
+ execve (tmp_href , argvp , env_values );
543
547
544
548
free_env_values (env_values , index_of_first_env_value_not_compiled_in , env_value_count );
545
549
0 commit comments