Fix has_permission (bug #33644)
This commit is contained in:
parent
f7ea24cd4c
commit
06e1569677
@ -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.
|
||||||
|
23
src/cache.c
23
src/cache.c
@ -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) {
|
||||||
|
if (~node->mode & S_IRWXG & a_mode)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
struct group *grp = getgrgid(node->gid);
|
struct group *grp = getgrgid(node->gid);
|
||||||
if (!grp)
|
if (!grp)
|
||||||
return 0;
|
return 0;
|
||||||
char **members = grp->gr_mem;
|
char **members = grp->gr_mem;
|
||||||
while (*members && strcmp(*members, pw->pw_name) != 0)
|
while (*members && strcmp(*members, pw->pw_name) != 0)
|
||||||
members++;
|
members++;
|
||||||
if (!*members)
|
if (*members) {
|
||||||
|
if (~node->mode & S_IRWXG & a_mode)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
if (!(~node->mode & S_IRWXG & a_mode))
|
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(~node->mode & S_IRWXO & a_mode))
|
||||||
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user