Skip to content

Commit b533289

Browse files
committed
Merge branch 'maint-1.2' into maint-1.3
2 parents 8d541d9 + b641536 commit b533289

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

src/OVAL/probes/unix/linux/rpminfo_probe.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ static int collect_rpm_files(SEXP_t *item, const struct rpminfo_rep *rep, struct
334334
ret = -1;
335335
goto cleanup;
336336
}
337-
if (rpmdbSetIteratorRE(ts, RPMTAG_EPOCH, RPMMIRE_STRCMP, rep->epoch) != 0) {
337+
char *epoch_override = oscap_streq(rep->epoch, "(none)") ? "0" : rep->epoch;
338+
if (rpmdbSetIteratorRE(ts, RPMTAG_EPOCH, RPMMIRE_STRCMP, epoch_override) != 0) {
338339
ret = -1;
339340
goto cleanup;
340341
}

src/XCCDF_POLICY/xccdf_policy_remediate.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,7 @@ static int _write_script_header_to_fd(struct xccdf_policy *policy, struct xccdf_
900900
const char *oscap_version = oscap_get_version();
901901
const char *format = ansible_script ? "ansible" : "bash";
902902
const char *remediation_type = ansible_script ? "Ansible Playbook" : "Bash Remediation Script";
903+
const char *shebang_with_newline = ansible_script ? "" : "#!/bin/bash\n";
903904

904905
char *fix_header;
905906

@@ -934,6 +935,7 @@ static int _write_script_header_to_fd(struct xccdf_policy *policy, struct xccdf_
934935
const char *xccdf_version_name = xccdf_version_info_get_version(xccdf_version);
935936

936937
fix_header = oscap_sprintf(
938+
"%s"
937939
"###############################################################################\n"
938940
"#\n"
939941
"# %s for %s\n"
@@ -956,7 +958,7 @@ static int _write_script_header_to_fd(struct xccdf_policy *policy, struct xccdf_
956958
"%s\n"
957959
"#\n"
958960
"###############################################################################\n\n",
959-
remediation_type, profile_title,
961+
shebang_with_newline, remediation_type, profile_title,
960962
commented_profile_description,
961963
profile_id, benchmark_id, benchmark_version_info, xccdf_version_name,
962964
oscap_version, profile_id, format, remediation_type,
@@ -974,6 +976,7 @@ static int _write_script_header_to_fd(struct xccdf_policy *policy, struct xccdf_
974976
const char *xccdf_version_name = xccdf_version_info_get_version(xccdf_version);
975977

976978
fix_header = oscap_sprintf(
979+
"%s"
977980
"###############################################################################\n"
978981
"#\n"
979982
"# %s generated from evaluation of %s\n"
@@ -992,7 +995,7 @@ static int _write_script_header_to_fd(struct xccdf_policy *policy, struct xccdf_
992995
"%s\n"
993996
"#\n"
994997
"###############################################################################\n\n",
995-
remediation_type, profile_title, profile_id, xccdf_version_name,
998+
shebang_with_newline, remediation_type, profile_title, profile_id, xccdf_version_name,
996999
start_time != NULL ? start_time : "Unknown", end_time, oscap_version,
9971000
result_id, format, remediation_type, remediation_type, how_to_apply
9981001
);

tests/API/XCCDF/fix/all.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ function test_generate_fix {
1414

1515
# grep to strip out whitespace and comments
1616
# `tail -n +2` to skip the first line with progress reporting
17-
local GENERATED_FIX=$($OSCAP xccdf generate fix --result-id "$TESTRESULT_ID" "$INPUT" | grep -v -E "^([\t ]*|[\t ]*#.*)$" | tail -n +2)
17+
local GENERATED_FIX RELEVANT_FIX_CONTENTS
18+
GENERATED_FIX=$($OSCAP xccdf generate fix --result-id "$TESTRESULT_ID" "$INPUT")
19+
RELEVANT_FIX_CONTENTS=$(grep -v -E "^([\t ]*|[\t ]*#.*)$" <<< "$GENERATED_FIX" | tail -n +2)
1820
if [ "$?" != "0" ]; then
1921
return 1
2022
fi
2123
echo "$GENERATED_FIX"
2224

23-
if [ "$GENERATED_FIX" == "$EXPECTED_FIX" ]; then
25+
if [ "$RELEVANT_FIX_CONTENTS" == "$EXPECTED_FIX" ]; then
2426
return 0
2527
fi
2628

2729
echo "Generated fix doesn't match expected fix!"
28-
echo "'$GENERATED_FIX' != '$EXPECTED_FIX'"
30+
echo "'$RELEVANT_FIX_CONTENTS' != '$EXPECTED_FIX'"
2931

3032
return 1
3133
}

utils/oscap-xccdf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ int app_generate_fix(const struct oscap_action *action)
863863
} else if (strcmp(action->fix_type, "puppet") == 0) {
864864
template = "urn:xccdf:fix:script:puppet";
865865
} else if (strcmp(action->fix_type, "anaconda") == 0) {
866-
template = "urn:xccdf:fix:script:anaconda";
866+
template = "urn:redhat:anaconda:pre";
867867
} else {
868868
fprintf(stderr,
869869
"Unknown fix type '%s'.\n"

0 commit comments

Comments
 (0)