Reduces the permission to stat files in Windows.

Check explicitely to have read permission in scanning.
This commit is contained in:
Andrea Mazzoleni 2011-05-04 00:22:12 +02:00
parent 5a2e118c38
commit 64f4d59adb
4 changed files with 13 additions and 4 deletions

View file

@ -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

View file

@ -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) {

7
scan.c
View file

@ -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) {

View file

@ -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
=========