aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-11-08 18:24:19 +0100
committerMax Kellermann <max@duempel.org>2010-11-08 18:24:19 +0100
commit5a3aa1262a471b842e95b2e6e1dcdfbce035b75c (patch)
treee7e3530cd7755d177c6beb586d3ee4184845450a /src
parentd2c2cbd0ae1afe3714f507307c5e1fc159cabba7 (diff)
downloadmpd-5a3aa1262a471b842e95b2e6e1dcdfbce035b75c.tar.gz
mpd-5a3aa1262a471b842e95b2e6e1dcdfbce035b75c.tar.xz
mpd-5a3aa1262a471b842e95b2e6e1dcdfbce035b75c.zip
update_walk: explicitly check for permission problems
Call access() and print an extra error message when EACCES is returned. Hopefully this will reduce the number of support requests due to wrong file permissions.
Diffstat (limited to '')
-rw-r--r--src/update_walk.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/update_walk.c b/src/update_walk.c
index a8e09793a..95d5854a8 100644
--- a/src/update_walk.c
+++ b/src/update_walk.c
@@ -546,6 +546,31 @@ update_container_file( struct directory* directory,
return true;
}
+/**
+ * Checks if the given permissions on the mapped file are given.
+ */
+static bool
+directory_child_access(const struct directory *directory,
+ const char *name, int mode)
+{
+#ifdef WIN32
+ /* access() is useless on WIN32 */
+ (void)directory;
+ (void)name;
+ return true;
+#else
+ char *path = map_directory_child_fs(directory, name);
+ if (path == NULL)
+ /* something went wrong, but that isn't a permission
+ problem */
+ return true;
+
+ bool success = access(path, mode) == 0 || errno != EACCES;
+ g_free(path);
+ return success;
+#endif
+}
+
static void
update_regular_file(struct directory *directory,
const char *name, const struct stat *st)
@@ -562,6 +587,14 @@ update_regular_file(struct directory *directory,
{
struct song* song = songvec_find(&directory->songs, name);
+ if (!directory_child_access(directory, name, R_OK)) {
+ g_warning("no read permissions on %s/%s",
+ directory_get_path(directory), name);
+ if (song != NULL)
+ delete_song(directory, song);
+ return;
+ }
+
if (!(song != NULL && st->st_mtime == song->mtime &&
!walk_discard) &&
plugin->container_scan != NULL)