Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
53ae7d3
Made format() reject specifiers that read unpassed printf arguments
Dhanu-dynamic Oct 17, 2026
800f183
Fixed stack buffer overflow in GetServerLiteral for TLS VAR requests
Dhanu-dynamic Oct 19, 2026
995e6fd
Fixed out-of-bounds read of extended attribute values in filestat()
Dhanu-dynamic Oct 21, 2026
80d3d5b
Updated plucked.sub.cf from masterfiles
nickanderson Oct 27, 2026
37beeca
Run reactor tests in jenkins
victormlg Oct 27, 2026
5f352d3
Added better logging of the cf-reactor tests
victormlg Oct 27, 2026
51a2014
Fixed out of range scalar value for guest environments
victormlg Oct 28, 2026
f0f66f4
Fixed build against OpenSSL 4
larsewi Oct 28, 2026
23ba797
Made testall fail regular acceptance tests which log errors
aleksandrychev Oct 14, 2026
97d4249
Added fileexists() guards to file reads in acceptance tests
aleksandrychev Oct 15, 2026
5398b14
Indented command output in dcs_passif_output() DEBUG report
aleksandrychev Oct 15, 2026
bbf547b
Added guards to reads of files created later in acceptance tests
aleksandrychev Oct 15, 2026
8af7a04
Renamed 00_basics/def.json test directory to def_json
aleksandrychev Oct 15, 2026
cb51dff
Fixed execresult_action_immediate.cf logging errors
aleksandrychev Oct 15, 2026
f5197a4
Fixed classic_evaluation_custom_promise_types.cf logging errors
aleksandrychev Oct 15, 2026
26fc014
Fixed changes_silent.cf logging errors
aleksandrychev Oct 15, 2026
dd93368
Fixed wrong-bundle-type.cf and ifelse.cf logging errors
aleksandrychev Oct 15, 2026
350760c
Renamed acceptance tests which log errors on purpose to .error.pass.cf
aleksandrychev Oct 15, 2026
22cab40
Fixed linting issues
aleksandrychev Oct 15, 2026
14691f5
Fixed unsafe and check_syntax.cf acceptance tests logging errors
nickanderson Oct 22, 2026
5c6c043
Fixed formatting of acceptance tests
nickanderson Oct 22, 2026
3e5e690
Fixed mapdata_json_pipe.cf logging errors
nickanderson Oct 23, 2026
a73a0c1
Made .error.pass.cf tests respect soft fails and skips
aleksandrychev Oct 26, 2026
4cb9088
Fixed diff_mode_ownership.cf logging errors
nickanderson Oct 28, 2026
bb0b18f
fix stack buffer overflow in SaveAsFile backup path construction
Dhanu-dynamic Oct 18, 2026
72405c5
libpromises: Added empty package_module_wrapper.{c,h}
larsewi Oct 29, 2026
28b3cc3
Moved package module wrapper code from cf-agent to libpromises
larsewi Oct 29, 2026
16ad8db
package_module_wrapper.c: Made PackageWrapperCommunicate() and ParseO…
larsewi Oct 29, 2026
f871307
package_module_wrapper.h: Added doc comments
larsewi Oct 29, 2026
6bba782
Renamed ParseOptions() to PackageModuleFormatOptions()
larsewi Oct 29, 2026
eba270c
Added timeout parameter to NewPackageModuleWrapper()
larsewi Oct 29, 2026
045402d
Fixed cf-reactor users test failing when run as root
victormlg Oct 28, 2026
6c12476
package_module_wrapper.c: Added asserts for pointer arguments
larsewi Oct 29, 2026
9b841d1
cf-reactor: Passed EvalContext to watcher state constructors
larsewi Oct 29, 2026
00b2d52
reactor_transform.c: Added optional extra args to event types
larsewi Oct 29, 2026
92f7d8f
reactor_transform.c: Now fails events promise if watcher state can't …
larsewi Oct 29, 2026
cc474c0
Moved FreePackageManager() from eval_context.c to package_module_wrap…
larsewi Oct 29, 2026
073fd6d
package_module_wrapper.c: Made FreePackageManager() public
larsewi Oct 29, 2026
ca1ff8e
Renamed FreePackageManager() to PackageModuleBodyDestroy()
larsewi Oct 29, 2026
52782b0
package_module_wrapper.c: PackageModuleBodyDestroy() now accepts NULL
larsewi Oct 29, 2026
f381917
package_module_wrapper.c: Added PackageModuleBodyCopy()
larsewi Oct 29, 2026
a3e4645
Merge pull request #6449 from larsewi/openssl4-x509-name
larsewi Oct 30, 2026
97f0547
Merge pull request #6451 from larsewi/reactor-event-types
larsewi Oct 30, 2026
2866b97
Merge pull request #6450 from larsewi/package-module-wrapper
larsewi Oct 30, 2026
fc37174
cf-reactor: Added user_added and user_removed events
larsewi Oct 27, 2026
6734d28
Merge pull request #6405 from aleksandrychev/CFE-3041
olehermanse Oct 30, 2026
bc22e81
Merge pull request #6447 from victormlg/cf-reactor.RunTestsInJenkins
larsewi Oct 30, 2026
34f90cf
Merge pull request #6446 from larsewi/reactor-user-events
larsewi Oct 30, 2026
c4c352c
cf-reactor: added package_installed and package_uninstalled
larsewi Oct 30, 2026
de84f4f
package_watcher_test.c: Added unit tests for package watcher
larsewi Oct 30, 2026
d67e0b8
tests/reactor: Added test for package events
larsewi Oct 30, 2026
2614151
tests/reactor: Added test for package_module attribute of package events
larsewi Oct 30, 2026
5ac9805
Merge pull request #6420 from Dhanu-dynamic/saveasfile-backup-path-ov…
larsewi Oct 30, 2026
0a2e234
Followed up on adding reactor to make check
victormlg Nov 2, 2026
99e4733
Merge pull request #6453 from larsewi/reactor-package-events
larsewi Nov 2, 2026
159721a
Merge pull request #6448 from nickanderson/CFE-3898/master
larsewi Nov 3, 2026
8344601
Merge pull request #6457 from victormlg/cf-reactor.RunTestsInJenkinsF…
larsewi Nov 3, 2026
9d5c84d
Added workflow to backport labeled PRs to LTS branches
larsewi Nov 3, 2026
baea119
Merge pull request #6460 from larsewi/backport-workflow
larsewi Nov 3, 2026
7b6260b
Fixed typo in SECURITY.md
larsewi Nov 3, 2026
7c73c29
Merge pull request #6461 from larsewi/fix-security-md-typo
larsewi Nov 3, 2026
4dec79a
Fixed cf-serverd crash when policy reload races with a new connection
aleksandrychev Nov 4, 2026
acb5df5
Merge pull request #6423 from Dhanu-dynamic/getserverliteral-sendbuff…
larsewi Nov 4, 2026
68213d3
Merge pull request #6429 from Dhanu-dynamic/filestat-xattr-nul-terminate
larsewi Nov 4, 2026
a58ea98
[create-pull-request] automated change
github-actions[bot] Nov 4, 2026
2e128b5
Added RHEL 8 and 9 support to ci/dependencies.sh
aleksandrychev Nov 4, 2026
f66fbb3
Merge pull request #6470 from aleksandrychev/ENT-14716_rhel_support
aleksandrychev Nov 4, 2026
794c9b4
Curated 3.29.0 changelog entries shared with 3.27.x
larsewi Nov 4, 2026
904852a
Added support for OPTS environment variable to ci/configure.sh
craigcomstock Nov 4, 2026
96ed837
Added ldconfig to build_lmdb() in ci/dependencies.sh
craigcomstock Nov 5, 2026
9495bd4
cf-check: Fix segfault on missing state directory
btriller Sep 21, 2026
962136b
Merge pull request #6473 from craigcomstock/ent-14716/master
aleksandrychev Nov 5, 2026
1a50361
cf-reactor: fixed file owner detection on windows
victormlg Nov 4, 2026
8820b4f
cf-reactor: Fixed error messages of failed file checks on Windows
victormlg Nov 4, 2026
47cc0c5
Merge pull request #6359 from btriller/cf-check-segfault
larsewi Nov 5, 2026
cf51a03
Merge pull request #6419 from Dhanu-dynamic/format-reject-unpassed-args
larsewi Nov 5, 2026
b82206f
job-backport.yml: renamed from backport.yml
larsewi Nov 5, 2026
ed21ac6
Apply batched suggestions from code review
aleksandrychev Nov 5, 2026
3836d6e
job-backport.yml: made reusable, called from backport.yml
larsewi Nov 5, 2026
1580121
Merge pull request #6471 from victormlg/cf-reactor-windows-error-mess…
larsewi Nov 5, 2026
30b6c73
Merge pull request #6476 from larsewi/reusable-backport
larsewi Nov 5, 2026
73d79ae
Merge pull request #6469 from cfengine/changelog/auto-update-changelo…
aleksandrychev Nov 6, 2026
dac3db2
fix stack overflow building absolute path from relative symlink target
Dhanu-dynamic Nov 6, 2026
5030bf8
Merge pull request #6425 from Dhanu-dynamic/symlink-target-path-overflow
larsewi Nov 6, 2026
243e617
Now removes the cherry-pick? label after successful backports
larsewi Nov 6, 2026
1b9190c
Bumped .CFVERSION number to 3.30.0
aleksandrychev Nov 6, 2026
9fd6642
Merge pull request #6482 from aleksandrychev/cfversion-3.30.0
craigcomstock Nov 6, 2026
f532dd7
Added isvalidip: function for validating IP addresses
victormlg Nov 9, 2026
390f893
Merge pull request #6481 from larsewi/backport-remove-label
craigcomstock Nov 9, 2026
9b98229
Merge pull request #6464 from aleksandrychev/ENT-14927
olehermanse Nov 10, 2026
ab0408f
Fixed simulate diff mode aborting on repeated unversioned package ins…
djbclark Nov 10, 2026
60cc554
Merge pull request #6486 from victormlg/isvalidip
larsewi Nov 10, 2026
acb4267
Checked RAND_bytes() result when creating bootstrap_id.dat
nickanderson Nov 11, 2026
b77bf13
Merge pull request #6424 from djbclark/fix/simulate-pkg-unversioned-i…
larsewi Nov 12, 2026
345cc37
Changed backport branch name to backport/<PR>-<branch>
aleksandrychev Nov 12, 2026
270e6c3
Merge pull request #6501 from aleksandrychev/backport_workflow
larsewi Nov 12, 2026
b5db5f0
Merge pull request #6498 from nickanderson/bootstrap-id-rand-check
nickanderson Nov 12, 2026
21aa78d
Fixed typo
olehermanse Nov 13, 2026
a8ac0dc
Merge pull request #6505 from olehermanse/master
olehermanse Nov 13, 2026
bfc2e1d
Added --simulate-json option to write the changed files of a simulate…
djbclark Nov 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .CFVERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.29.0
3.30.0
14 changes: 14 additions & 0 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Backport

on:
push:
branches: [master]

permissions:
contents: write
pull-requests: write

jobs:
backport:
if: github.repository == 'cfengine/core'
uses: ./.github/workflows/job-backport.yml
118 changes: 118 additions & 0 deletions .github/workflows/job-backport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Backport

# Opens backport pull requests to the LTS branches when a pull request with the
# `cherry-pick?` label is merged to master. Commits are cherry-picked with `-x`.
# Each branch comments on the original pull request with the backport link, or
# says that a manual backport is needed. If all branches succeed, the label is
# removed.
#
# The label must be set before merging.
#
# Call it from a workflow triggered on push to master. The caller must grant
# `contents: write` and `pull-requests: write`.

on: workflow_call

jobs:
backport:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
branch: [3.27.x, 3.24.x]
steps:
- name: Check for the label
id: find_pr
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
MERGE_SHA: ${{ github.sha }}
run: |
# For a commit on master, this returns the merged PR that added it.
pr=$(gh api "repos/$GH_REPO/commits/$MERGE_SHA/pulls" \
--jq 'first(.[] | select(any(.labels[]; .name == "cherry-pick?")))')
if [ -z "$pr" ]; then
echo "No merged PR with the cherry-pick? label, nothing to do"
exit 0
fi
echo "number=$(jq -r .number <<< "$pr")" >> "$GITHUB_OUTPUT"
echo "title=$(jq -r .title <<< "$pr")" >> "$GITHUB_OUTPUT"
echo "author=$(jq -r .user.login <<< "$pr")" >> "$GITHUB_OUTPUT"

- uses: actions/checkout@v4
if: steps.find_pr.outputs.number != ''
with:
ref: ${{ matrix.branch }}
# 0 means full history. It is needed to reach the merged commits.
fetch-depth: 0

- name: Cherry-pick
id: cherry_pick
if: steps.find_pr.outputs.number != ''
continue-on-error: true
env:
MERGE_SHA: ${{ github.sha }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

# A merge commit has two parents: ^1 is master before the merge, ^2 is
# the tip of the PR branch. ^1..^2 is then the commits of the PR.
# shellcheck disable=SC2046 # word splitting is intended
if ! git cherry-pick -x $(git rev-list --reverse --no-merges "$MERGE_SHA^1..$MERGE_SHA^2"); then
git cherry-pick --abort || true
exit 1
fi

- name: Open a pull request
id: create_pr
if: steps.cherry_pick.outcome == 'success'
uses: cfengine/create-pull-request@v7.0.7a
with:
base: ${{ matrix.branch }}
branch: backport/${{ steps.find_pr.outputs.number }}-${{ matrix.branch }}
delete-branch: true
sign-commits: true
title: ${{ steps.find_pr.outputs.title }} (${{ matrix.branch }})
body: |
Backport of #${{ steps.find_pr.outputs.number }} by @${{ steps.find_pr.outputs.author }} to ${{ matrix.branch }}.

Opened automatically by [.github/workflows/backport.yml](${{ github.server_url }}/${{ github.repository }}/blob/master/.github/workflows/backport.yml).

Pull requests opened with `GITHUB_TOKEN` do not trigger other workflows, so CI has not started on its own.

- name: Comment on the original pull request
if: always() && steps.find_pr.outputs.number != ''
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
PR: ${{ steps.find_pr.outputs.number }}
BRANCH: ${{ matrix.branch }}
URL: ${{ steps.create_pr.outputs.pull-request-url }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
if [ -n "$URL" ]; then
gh pr comment "$PR" --body "Backport to $BRANCH: $URL"
else
gh pr comment "$PR" --body "Backport to $BRANCH failed, manual backport needed: $RUN_URL"
# Fail the job so the label is kept
exit 1
fi

remove_label:
needs: backport
runs-on: ubuntu-latest
steps:
- name: Remove the label
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
MERGE_SHA: ${{ github.sha }}
run: |
pr=$(gh api "repos/$GH_REPO/commits/$MERGE_SHA/pulls" \
--jq 'first(.[] | select(any(.labels[]; .name == "cherry-pick?")) | .number)')
if [ -z "$pr" ]; then
echo "No merged PR with the cherry-pick? label, nothing to do"
exit 0
fi
gh pr edit "$pr" --remove-label "cherry-pick?"
2 changes: 1 addition & 1 deletion .github/workflows/reactor_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
ln -s "$PWD/cf-reactor/cf-reactor" "$PWD/cf-promises/cf-promises" "$RUNNER_TEMP/bin/"
cd tests/reactor
chmod -R go-w .
CF_BINDIR="$RUNNER_TEMP/bin" sh run.sh
CF_BINDIR="$RUNNER_TEMP/bin" sh run.sh --unsafe
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ stamp-h1
/tests/acceptance/25_cf-execd/Makefile
/tests/acceptance/Makefile
/tests/load/Makefile
/tests/reactor/Makefile
/tests/unit/Makefile
/tests/static-check/Makefile
/tests/valgrind-check/Makefile
Expand Down
83 changes: 83 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,86 @@
## 3.29.0

- Added `--no-lock` long option to `cf-runagent`, matching the existing `-K` short option
- Added SELinux state and Federated Reporting transport metadata to `cf-support` (ENT-14405)
- Added Termux for `sys.os_name_human` when running in Termux Linux Environment (Android) (CFE-4427)
- Added `package_installed` and `package_uninstalled` watchers to `cf-reactor`
(ENT-14766)
- Added `file_older_than()` policy function (ENT-6065)
- Added inventory tag `Short hostname` to sys.uqhost (ENT-11265)
- Added opt-in remount reconciliation for storage mount options
(CFE-1864, CFE-3366, CFE-90)
- Added sshd logs to the `cf-support` Federated Reporting collection
(ENT-14405)
- Added the `silence` attribute to `body changes`, which suppresses the alert output of selected file-change categories while still setting the change classes and writing the audit log.
(CFE-159)
- Added the parameters of `string_mustache()` to the syntax description (CFE-4534)
- Added the promisee to verbose output for reports promises (CFE-4228)
- Added `validfiledata()` policy function (ENT-8193)
- Fixed policy function `IsReadable()` on Termux platform
(CFE-4401)
- Allowed modules to define empty lists (CFE-2139)
- Allowed modules to define lists with a trailing comma (CFE-2140)
- Allowed mount promises to target a specific server (CFE-2350)
- Community `files` promises using `hash => "best"` now use SHA-512 (previously MD5+SHA1) and no longer report a content change on two consecutive agent runs. Affected files are re-baselined on the first run after upgrade.
(CFE-3725)
- Extended string_replace with list arguments (CFE-4694)
- IPv6 masks in `iprange()` no longer need to be a multiple of 8 bits (CFE-2034)
- Fixed `--simulate` symlink errors to show the real target, not a chroot path
(ENT-14714)
- Fixed `--simulate=diff` to report permission and ownership changes
(ENT-14694)
- Fixed `--simulate=diff` to show the new target of a replaced symlink
(ENT-14713)
- Fixed Federated Reporting transport failing on RHEL 10 hubs (ENT-14405)
- Fixed a bug regarding the resolution of namespaces inside function-calls
(ENT-10199)
- Fixed `cf-agent` assertion failure when reading `/proc/<pid>/stat` (CFE-4285)
- Fixed `cf-check -V` (`--version`) short option
- Fixed `cf-net -t` (`--tls-version`) and `-c` (`--ciphers`) short options
- Fixed `cf-secret -v` (`--verbose`), `-g` (`--log-level`) and `-I` (`--inform`) short options
- Fixed `cf-serverd -L` (`--ld-library-path`) to accept its argument
- Fixed `insert_lines` ignoring `include_end_delimiter` when locating the region (CFE-3988)
- Fixed `insert_lines` prepending to the file instead of to the selected region (CFE-3987)
- Fixed lmdb maxkeysize assertion for macos
- Fixed macOS process start-time/state detection (`process_macos.c`) and the macOS ps syntax bug in `mon_processes_test.c`
(ENT-14471)
- Fixed out-of-bounds read when parsing a remote directory listing
- Fixed out-of-bounds read of extended attribute values in policy function `filestat()`
- Fixed `process_select` and `file_select` time ranges on Windows
- Fixed issue where reports promise was kept even though the report could not be written
(CFE-4699)
- Fixed simulate diff mode not reporting a removal with a version
- Fixed simulate mode reporting both removal and install of the same package (CFE-4742)
- Fixed simulate mode swapping package version and architecture
- Fixed stack buffer overflow in `cf-serverd` when serving `remotescalar()` and `hubknowledge()` requests
- Fixed `usemodule()` reporting success when the module exited non-zero (CFE-942)
- Increased the maximum number of `cf-monitord` measurement slots from 100 to 300
(ENT-6511)
- Made an unrecognized `action_policy` fatal instead of defaulting to fix
(CFE-1982)
- Made format function collect data container (CFE-3105)
- Maintained fstab entries for already-mounted filesystems (CFE-1539)
- Now mounts a single filesystem surgically instead of running `mount -a`
(CFE-1863)
- `cf-reactor` is now a part of CFEngine Community (ENT-14275)
- Raised `cf-apache.service` start timeout to avoid PID-file race (ENT-11189)
- The source tarball is now reproducible
- `cf-reactor` can now react to a user being added or removed, with the `user_added` and `user_removed` attributes of `when` bodies
(ENT-14765)
- `and()`, `or()`, `concat()`, `ifelse()`, `findfiles()`, `mergedata()` and the `classmatch()` family reported no parameters at all.
Only the leading arguments are described, as `bundlesmatching()` and `format()` already do. (CFE-4714)
- `cf-check` dump now reports measurement names instead of labeling them spare
(ENT-14329)
- `cf-check` now checks LMDB value size before reading lastseen and lock structs
- `cf-monitord` no longer silently truncates the `ts_key` measurement name file
(ENT-14329)
- `cf-monitord` now stores only in-use measurement slots (ENT-14329)
- Added missing option description in `--help` output of `cf-reactor`
- Fixed `cf-serverd` leaking uninitialized memory to clients when refusing a file copy request
- Fixed out-of-bounds read in `iprange()` and `isipinsubnet()` when the address is shorter than the range
- Fixed stack buffer overflow in `cf-agent` and `cf-monitord` on overly long lines in `mount` or `netstat` output
- Policy function `format()` now rejects format specifiers `*` and `$`

## 3.28.0

- Adapted date constraints to allow dates after Y2038 (CFE-4620)
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Supported versions

For information about versions which are supported and recieving security patches see https://docs.cfengine.com
For information about versions which are supported and receiving security patches see https://docs.cfengine.com

## Reporting a vulnerability

Expand Down
30 changes: 30 additions & 0 deletions cf-agent/cf-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ static bool ALLCLASSESREPORT = false; /* GLOBAL_P */
static bool ALWAYS_VALIDATE = false; /* GLOBAL_P */
static bool CFPARANOID = false; /* GLOBAL_P */
static bool PERFORM_DB_CHECK = false;
static char *SIMULATE_JSON_FILE = NULL;

static const Rlist *ACCESSLIST = NULL; /* GLOBAL_P */

Expand Down Expand Up @@ -185,6 +186,7 @@ static const struct option OPTIONS[] =
{"skip-bootstrap-service-start", no_argument, 0, 0 },
{"skip-db-check", optional_argument, 0, 0 },
{"simulate", required_argument, 0, 0},
{"simulate-json", required_argument, 0, 0},
{NULL, 0, 0, '\0'}
};

Expand Down Expand Up @@ -221,6 +223,7 @@ static const char *const HINTS[] =
"Do not start CFEngine services as part of the bootstrap process",
"Do not run database integrity checks and repairs at startup",
"Run in simulate mode, either 'manifest', 'manifest-full' or 'diff'",
"Write the changed files of a --simulate run to the given file as JSON (renames are not included)",
NULL
};

Expand Down Expand Up @@ -338,6 +341,13 @@ int main(int argc, char *argv[])

Nova_NoteAgentExecutionPerformance(config->input_file, start);

if ((SIMULATE_JSON_FILE != NULL) &&
!WriteChangesJson(SIMULATE_JSON_FILE) && (ret == 0))
{
ret = EXIT_FAILURE;
}
free(SIMULATE_JSON_FILE);

GenericAgentFinalize(ctx, config);

StringSetDestroy(SINGLE_COPY_CACHE);
Expand Down Expand Up @@ -748,6 +758,19 @@ static GenericAgentConfig *CheckOpts(int argc, char **argv)
DoCleanupAndExit(EXIT_FAILURE);
}
}
else if (StringEqual(option_name, "simulate-json"))
{
/* The agent changes its working directory during the run. */
if (!IsAbsoluteFileName(optarg))
{
Log(LOG_LEVEL_ERR,
"Invalid argument for --simulate-json, an absolute path is required, not '%s'",
optarg);
DoCleanupAndExit(EXIT_FAILURE);
}
free(SIMULATE_JSON_FILE);
SIMULATE_JSON_FILE = xstrdup(optarg);
}
break;
}
default:
Expand Down Expand Up @@ -775,6 +798,13 @@ static GenericAgentConfig *CheckOpts(int argc, char **argv)
DoCleanupAndExit(EXIT_FAILURE);
}

if ((SIMULATE_JSON_FILE != NULL) && !ChrootChanges())
{
Log(LOG_LEVEL_ERR,
"Option --simulate-json can only be used together with --simulate");
DoCleanupAndExit(EXIT_FAILURE);
}

FreeFixedStringArray(argc_new, argv_new);

return config;
Expand Down
Loading
Loading