From c1bc3aa1ddc3dbfb834c1829ee8482ff81c55ff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renaud=20M=C3=A9trich?= Date: Tue, 3 Mar 2026 09:32:13 +0100 Subject: [PATCH] Inform the admin symlinks were skipped when adding paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When adding path in the trust database, symbolic links are silently skipped, which makes it difficult for the admin to know that more paths must be added to the trust database. This patch adds information message that the symlink was skipped and warning message if the symlink is dangling or cannot be resolved for some reason. Signed-off-by: Renaud Métrich --- src/cli/file-cli.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/cli/file-cli.c b/src/cli/file-cli.c index de91cd8f..e13ce078 100644 --- a/src/cli/file-cli.c +++ b/src/cli/file-cli.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -72,6 +73,26 @@ static int ftw_add_list_append(const char *fpath, } else { msg(LOG_INFO, "Skipping non regular file: %s", fpath); } + } else if (typeflag == FTW_SL) { + char target[PATH_MAX]; + ssize_t len = readlink(fpath, target, sizeof (target) - 1); + if (len == -1) { + msg(LOG_ERR, "Cannot read value of symbolic link %s: %s", + fpath, strerror(errno)); + return FTW_CONTINUE; + } + target[len] = '\0'; + struct stat st; + if (stat(fpath, &st) == -1) { + msg(LOG_WARNING, "Cannot stat symbolic link %s pointing to %s: %s", + fpath, target, strerror(errno)); + } else if (target[0] != '/' && realpath(fpath, target) == NULL) { + msg(LOG_WARNING, "Cannot resolve symbolic link %s: %s", + fpath, strerror(errno)); + } else { + msg(LOG_INFO, "Skipping symbolic link %s: " + "consider adding target %s", fpath, target); + } } return FTW_CONTINUE; }