From 42d2ba45f360e8dcc3530ab3d62e23cf7a1dbc46 Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Sat, 14 Nov 2026 11:03:07 -0500 Subject: [PATCH] Added the target of symbolic links to --simulate-json entries An entry for a symbolic link now carries its target, mapped out of the changes chroot. Ticket: none Changelog: Title Signed-off-by: Daniel JB Clark Co-Authored-By: Claude Fable 5.1 Co-Authored-By: Claude Opus 5.5 Co-Authored-By: Claude Sonnet 5.5 --- cf-agent/simulate_mode.c | 10 ++++++++++ .../29_simulate_mode/simulate_json.cf.expected | 1 + 2 files changed, 11 insertions(+) diff --git a/cf-agent/simulate_mode.c b/cf-agent/simulate_mode.c index 0335781fe6a..ef6faa33aa4 100644 --- a/cf-agent/simulate_mode.c +++ b/cf-agent/simulate_mode.c @@ -1183,6 +1183,16 @@ static JsonElement *ChangedFileAsJson(const char *path) /* The permissions of a symbolic link are meaningless. */ if (S_ISLNK(st.st_mode)) { + char target[PATH_MAX] = {0}; + if (readlink(chrooted_path, target, sizeof(target) - 1) > 0) + { + const char *real_target = target; + if (IsAbsoluteFileName(target)) + { + real_target = ToNormalRoot(target); + } + JsonObjectAppendString(file_info, "target", real_target); + } return file_info; } #endif /* !__MINGW32__ */ diff --git a/tests/acceptance/29_simulate_mode/simulate_json.cf.expected b/tests/acceptance/29_simulate_mode/simulate_json.cf.expected index 14ec57a300b..7a6782c7a93 100644 --- a/tests/acceptance/29_simulate_mode/simulate_json.cf.expected +++ b/tests/acceptance/29_simulate_mode/simulate_json.cf.expected @@ -28,6 +28,7 @@ "change": "created", "gid": GID, "path": "WORKDIR/tmp/link", + "target": "WORKDIR/tmp/modify-me", "type": "symbolic link", "uid": UID }