summaryrefslogtreecommitdiffstats
path: root/xlators/system
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/system')
-rw-r--r--xlators/system/posix-acl/src/posix-acl.c77
1 files changed, 74 insertions, 3 deletions
diff --git a/xlators/system/posix-acl/src/posix-acl.c b/xlators/system/posix-acl/src/posix-acl.c
index 9a425ff13dd..8c84231476e 100644
--- a/xlators/system/posix-acl/src/posix-acl.c
+++ b/xlators/system/posix-acl/src/posix-acl.c
@@ -1427,8 +1427,62 @@ int
posix_acl_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int op_ret, int op_errno, gf_dirent_t *entries)
{
- if (op_ret != 0)
+ gf_dirent_t *entry = NULL;
+ struct posix_acl *acl_access = NULL;
+ struct posix_acl *acl_default = NULL;
+ struct posix_acl *old_access = NULL;
+ struct posix_acl *old_default = NULL;
+ data_t *data = NULL;
+ int ret = 0;
+
+ if (op_ret <= 0)
goto unwind;
+
+ list_for_each_entry (entry, &entries->list, list) {
+ /* Update the inode ctx */
+ if (!entry->dict || !entry->inode)
+ continue;
+
+ ret = posix_acl_get (entry->inode, this,
+ &old_access, &old_default);
+
+ data = dict_get (entry->dict, POSIX_ACL_ACCESS_XATTR);
+ if (!data)
+ goto acl_default;
+
+ if (old_access &&
+ posix_acl_matches_xattr (this, old_access, data->data,
+ data->len)) {
+ acl_access = posix_acl_ref (this, old_access);
+ } else {
+ acl_access = posix_acl_from_xattr (this, data->data,
+ data->len);
+ }
+
+ acl_default:
+ data = dict_get (entry->dict, POSIX_ACL_DEFAULT_XATTR);
+ if (!data)
+ goto acl_set;
+
+ if (old_default &&
+ posix_acl_matches_xattr (this, old_default, data->data,
+ data->len)) {
+ acl_default = posix_acl_ref (this, old_default);
+ } else {
+ acl_default = posix_acl_from_xattr (this, data->data,
+ data->len);
+ }
+
+ acl_set:
+ posix_acl_ctx_update (entry->inode, this, &entry->d_stat);
+
+ ret = posix_acl_set (entry->inode, this,
+ acl_access, acl_default);
+ if (ret)
+ gf_log (this->name, GF_LOG_WARNING,
+ "failed to set ACL in context");
+ }
+
unwind:
STACK_UNWIND_STRICT (readdirp, frame, op_ret, op_errno, entries);
return 0;
@@ -1437,16 +1491,33 @@ unwind:
int
posix_acl_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
- off_t offset)
+ off_t offset, dict_t *dict)
{
+ int ret = 0;
+
if (acl_permits (frame, fd->inode, POSIX_ACL_READ))
goto green;
else
goto red;
green:
+ if (dict) {
+ ret = dict_set_int8 (dict, POSIX_ACL_ACCESS_XATTR, 0);
+ if (ret)
+ gf_log (this->name, GF_LOG_WARNING,
+ "failed to set key %s",
+ POSIX_ACL_ACCESS_XATTR);
+
+ ret = dict_set_int8 (dict, POSIX_ACL_DEFAULT_XATTR, 0);
+ if (ret)
+ gf_log (this->name, GF_LOG_WARNING,
+ "failed to set key %s",
+ POSIX_ACL_DEFAULT_XATTR);
+ }
+
STACK_WIND (frame, posix_acl_readdirp_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdirp,
- fd, size, offset);
+ fd, size, offset, dict);
+
return 0;
red:
STACK_UNWIND_STRICT (readdirp, frame, -1, EACCES, NULL);