@@ -392,10 +392,10 @@ xccdf_test_result_type_t sce_engine_eval_rule(struct xccdf_policy *policy, const
392
392
393
393
char * argvp [3 ] = {
394
394
tmp_href ,
395
- 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
- dI ( "arvp[0] = %s" , argvp [ 0 ]);
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 ;
@@ -491,7 +491,7 @@ xccdf_test_result_type_t sce_engine_eval_rule(struct xccdf_policy *policy, const
491
491
env_values [env_value_count ] = env_operator_entry ;
492
492
env_value_count ++ ;
493
493
}
494
- dI ( "debug0 .." );
494
+
495
495
env_values = realloc (env_values , (env_value_count + 1 ) * sizeof (char * ));
496
496
env_values [env_value_count ] = NULL ;
497
497
@@ -507,8 +507,6 @@ xccdf_test_result_type_t sce_engine_eval_rule(struct xccdf_policy *policy, const
507
507
508
508
// FIXME: We definitely want to impose security restrictions in the forked child process in the future.
509
509
// This would prevent scripts from writing to files or deleting them.
510
-
511
- dI ("debug1 .." );
512
510
513
511
int fork_result = fork ();
514
512
if (fork_result >= 0 )
@@ -517,21 +515,21 @@ xccdf_test_result_type_t sce_engine_eval_rule(struct xccdf_policy *policy, const
517
515
518
516
if (fork_result == 0 )
519
517
{
520
- dI ( "debug2 .." );
518
+
521
519
// we won't read from the pipes, so close the reading fd
522
520
close (stdout_pipefd [0 ]);
523
521
close (stderr_pipefd [0 ]);
524
- dI ( "debug2.1 .." );
522
+
525
523
// forward stdout and stderr to our custom opened pipes
526
- // dup2(stdout_pipefd[1], fileno(stdout));
527
- // dup2(stderr_pipefd[1], fileno(stderr));
528
- dI ( "debug2.2 .." );
524
+ dup2 (stdout_pipefd [1 ], fileno (stdout ));
525
+ dup2 (stderr_pipefd [1 ], fileno (stderr ));
526
+
529
527
// we duplicated the file descriptors twice, we can close the original
530
528
// ones now, stdout and stderr will be closed properly after the execved
531
529
// script/executable finishes
532
530
close (stdout_pipefd [1 ]);
533
531
close (stderr_pipefd [1 ]);
534
- dI ( "debug3 .." );
532
+
535
533
// before we execute the script, lets make sure we get SIGTERM when
536
534
// oscap is killed, crashes or otherwise terminates
537
535
#ifdef PR_SET_PDEATHSIG
@@ -542,14 +540,14 @@ xccdf_test_result_type_t sce_engine_eval_rule(struct xccdf_policy *policy, const
542
540
#endif
543
541
544
542
// we are the child process
545
- dI ("argvp[0<] = %s" , argvp [0 ]);
546
- dI ("env<(0 %s" , env_values [0 ]);
547
-
548
- if (use_sce_wrapper )
549
- execvp ("oscap-run-sce-script" , argvp , env_values );
550
- else
551
- execve (tmp_href , argvp , env_values );
552
543
544
+ if (use_sce_wrapper ) {
545
+ dI ("Eval sce script using oscap-run-sce-script because %s isn't +x" , tmp_href );
546
+ execvpe ("oscap-run-sce-script" , argvp , env_values );
547
+ } else {
548
+ execve (tmp_href , argvp , env_values );
549
+ }
550
+
553
551
free_env_values (env_values , index_of_first_env_value_not_compiled_in , env_value_count );
554
552
555
553
// no need to check the return value of execve, if it returned at all we are in trouble
0 commit comments