From 94240130bef7d6682c0067547b6498caee2c8bd2 Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Fri, 29 Apr 2016 14:42:35 -0700 Subject: [PATCH] Report full paths for files containing blacklisted characters To better track which files are excluded from manifests because they contain blacklisted characters, the full path is more useful to log rather than the file basename. Signed-off-by: Patrick McCarty --- src/analyze_fs.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/analyze_fs.c b/src/analyze_fs.c index c8f4207..788891f 100644 --- a/src/analyze_fs.c +++ b/src/analyze_fs.c @@ -286,18 +286,15 @@ static bool illegal_characters(char *filename) // these breaks the tar transform sed-like expression, // hopefully can remove this check after moving to libtar if (strncmp(filename, "+", 1) == 0) { - printf("WARNING: Filename %s begins with '+'! ...skipping.\n", filename); return true; } if (strstr(filename, "+package+") != NULL) { - printf("WARNING: Filename %s contains \"+package+\"! ...skipping.\n", filename); return true; } for (i = 0; i < BAD_CHAR_COUNT; i++) { c = bad_chars[i]; if (strchr(filename, c) != NULL) { - printf("WARNING: Filename %s includes illegal character '%c'! ...skipping.\n", filename, c); return true; } } @@ -323,6 +320,7 @@ static void iterate_directory(struct manifest *manifest, char *pathprefix, while (dir) { struct file *file; + char *sub_filename; char *fullname; entry = readdir(dir); @@ -331,8 +329,15 @@ static void iterate_directory(struct manifest *manifest, char *pathprefix, } if ((strcmp(entry->d_name, ".") == 0) || - (strcmp(entry->d_name, "..") == 0) || - (illegal_characters(entry->d_name))) { + (strcmp(entry->d_name, "..") == 0)) { + continue; + } + + string_or_die(&sub_filename, "%s/%s", subpath, entry->d_name); + + if (illegal_characters(entry->d_name)) { + printf("WARNING: Filename %s includes illegal character(s) ...skipping.\n", sub_filename); + free(sub_filename); continue; } @@ -342,7 +347,7 @@ static void iterate_directory(struct manifest *manifest, char *pathprefix, } file->last_change = manifest->version; - string_or_die(&file->filename, "%s/%s", subpath, entry->d_name); + file->filename = sub_filename; string_or_die(&fullname, "%s/%s", fullpath, entry->d_name); populate_file_struct(file, fullname);