Skip to content
Open
Changes from all commits
Commits
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
23 changes: 23 additions & 0 deletions src/cli/file-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <ftw.h>
#include <stdbool.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -72,6 +73,28 @@ 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] == '/')
msg(LOG_INFO, "Skipping symbolic link %s: "
"consider adding target %s", fpath, target);
else if (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;
}
Expand Down
Loading