Fix has_permission (bug #33644)

This commit is contained in:
wbaumann 2013-08-15 17:22:24 +00:00
parent f7ea24cd4c
commit 06e1569677
2 changed files with 25 additions and 14 deletions

View File

@ -1,6 +1,10 @@
ChangeLog for davfs2 ChangeLog for davfs2
-------------------- --------------------


2013-08-15 Werner Baumann (werner.baumann@onlinehome.de)
* cache.c:
Fix has_permission (bug #33644).

2013-08-13 Werner Baumann (werner.baumann@onlinehome.de) 2013-08-13 Werner Baumann (werner.baumann@onlinehome.de)
* defaults.h, mount_davfs.c: * defaults.h, mount_davfs.c:
Fix evaluation of default modes. Fix evaluation of default modes.

View File

@ -2278,28 +2278,35 @@ has_permission(const dav_node *node, uid_t uid, int how)
a_mode |= (how & W_OK) ? (S_IWUSR | S_IWGRP | S_IWOTH) : 0; a_mode |= (how & W_OK) ? (S_IWUSR | S_IWGRP | S_IWOTH) : 0;
a_mode |= (how & X_OK) ? (S_IXUSR | S_IXGRP | S_IXOTH) : 0; a_mode |= (how & X_OK) ? (S_IXUSR | S_IXGRP | S_IXOTH) : 0;


if (!(~node->mode & S_IRWXO & a_mode)) if (node->uid == uid) {
return 1; if (~node->mode & S_IRWXU & a_mode)

return 0;
if (node->uid == uid && !(~node->mode & S_IRWXU & a_mode))
return 1; return 1;
}


struct passwd *pw = getpwuid(uid); struct passwd *pw = getpwuid(uid);
if (!pw) if (!pw)
return 0; return 0;
if (pw->pw_gid != node->gid) { if (pw->pw_gid == node->gid) {
struct group *grp = getgrgid(node->gid); if (~node->mode & S_IRWXG & a_mode)
if (!grp)
return 0; return 0;
char **members = grp->gr_mem;
while (*members && strcmp(*members, pw->pw_name) != 0)
members++;
if (!*members)
return 0;
}
if (!(~node->mode & S_IRWXG & a_mode))
return 1; return 1;
}


struct group *grp = getgrgid(node->gid);
if (!grp)
return 0;
char **members = grp->gr_mem;
while (*members && strcmp(*members, pw->pw_name) != 0)
members++;
if (*members) {
if (~node->mode & S_IRWXG & a_mode)
return 0;
return 1;
}
if (!(~node->mode & S_IRWXO & a_mode))
return 1;
return 0; return 0;
} }