From 64f4d59adb4ffa38975cdb588e17904bb2f9711c Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Wed, 4 May 2011 00:22:12 +0200 Subject: [PATCH] Reduces the permission to stat files in Windows. Check explicitely to have read permission in scanning. --- configure.ac | 2 +- portable.h | 2 +- scan.c | 7 +++++++ snapraid.txt | 6 ++++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 53e9552d..c46b8ee1 100644 --- a/configure.ac +++ b/configure.ac @@ -42,7 +42,7 @@ dnl Checks for library functions. AC_SYS_LARGEFILE AC_CHECK_FUNCS([memset strchr strerror strrchr mkdir]) AC_CHECK_FUNCS([getopt getopt_long snprintf vsnprintf]) -AC_CHECK_FUNCS([ftruncate fsync posix_fallocate posix_fadvise pread pwrite fgetc_unlocked ferror_unlocked fnmatch]) +AC_CHECK_FUNCS([ftruncate fsync access posix_fallocate posix_fadvise pread pwrite fgetc_unlocked ferror_unlocked fnmatch]) dnl Checks for architecture AC_C_BIGENDIAN diff --git a/portable.h b/portable.h index dd89ffe6..4b131b76 100644 --- a/portable.h +++ b/portable.h @@ -203,7 +203,7 @@ static inline int windows_stat(const char* file, struct windows_stat* st) BY_HANDLE_FILE_INFORMATION info; HANDLE h; - h = CreateFile(file, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); + h = CreateFile(file, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); if (h == INVALID_HANDLE_VALUE) { DWORD error = GetLastError(); switch (error) { diff --git a/scan.c b/scan.c index 620a8b14..4852710f 100644 --- a/scan.c +++ b/scan.c @@ -226,6 +226,13 @@ static void scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, s if (S_ISREG(st.st_mode)) { if (filter_path(&state->filterlist, sub_next, 0) == 0) { + /* check for having read permission */ + if (access(path_next, R_OK) != 0) { + fprintf(stderr, "You do not have read permissions for file '%s'\n", path_next); + fprintf(stderr, "Fix the permissions or exclude it in the configuration with:\n\texclude /%s\n", sub_next); + fprintf(stderr, "or exclude the whole directory with:\n\texclude /%s\n", sub); + exit(EXIT_FAILURE); + } scan_file(scan, state, disk, sub_next, &st); } else { if (state->verbose) { diff --git a/snapraid.txt b/snapraid.txt index 2371dea5..65914e36 100644 --- a/snapraid.txt +++ b/snapraid.txt @@ -387,8 +387,7 @@ There are four different types of patterns: directory slash. This pattern is applied only to directories and not to files. -Note that when globbing chars are used in the command line, you have to -quote them in Unix. Otherwise the shell will try to expand them. +In Windows you can freely use the backslash \ instead of the forward slash /. In the configuration file, you can use different strategies to filter the files to process. @@ -432,6 +431,9 @@ patterns. For example: # Note the "" use to avoid globbing expansion by the shell in Unix. snapraid -f "*.mp3" check +In Unix, when using globbing chars in the command line, you have to quote them. +Otherwise the shell will try to expand them. + 9 CONTENT =========