summaryrefslogtreecommitdiffstats
path: root/xlators/system/posix-acl/src/posix-acl.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/system/posix-acl/src/posix-acl.c')
-rw-r--r--xlators/system/posix-acl/src/posix-acl.c203
1 files changed, 31 insertions, 172 deletions
diff --git a/xlators/system/posix-acl/src/posix-acl.c b/xlators/system/posix-acl/src/posix-acl.c
index 38e48b8ced3..fc227364b31 100644
--- a/xlators/system/posix-acl/src/posix-acl.c
+++ b/xlators/system/posix-acl/src/posix-acl.c
@@ -10,8 +10,7 @@
#include <errno.h>
-#include <glusterfs/xlator.h>
-#include <glusterfs/glusterfs.h>
+#include <glusterfs/defaults.h>
#include "posix-acl.h"
#include "posix-acl-xattr.h"
@@ -51,8 +50,8 @@ r00t()
return conf->super_uid;
}
-int
-whitelisted_xattr(const char *key)
+static int
+allowed_xattr(const char *key)
{
if (!key)
return 0;
@@ -608,9 +607,8 @@ posix_acl_set_specific(inode_t *inode, xlator_t *this, struct posix_acl *acl,
}
UNLOCK(&conf->acl_lock);
- if (oldret == 0) {
- if (old_acl)
- posix_acl_unref(this, old_acl);
+ if (!oldret && old_acl) {
+ posix_acl_unref(this, old_acl);
}
return ret;
@@ -875,6 +873,13 @@ posix_acl_ctx_update(inode_t *inode, xlator_t *this, struct iatt *buf,
int ret = 0;
int i = 0;
+ if (!buf || !buf->ia_ctime) {
+ /* No need to update ctx if buf is empty */
+ gf_log_callingfn(this->name, GF_LOG_DEBUG, "iatt struct is empty (%d)",
+ fop);
+ goto out;
+ }
+
LOCK(&inode->lock);
{
ctx = __posix_acl_ctx_get(inode, this, _gf_true);
@@ -928,6 +933,7 @@ posix_acl_ctx_update(inode_t *inode, xlator_t *this, struct iatt *buf,
}
unlock:
UNLOCK(&inode->lock);
+out:
return ret;
}
@@ -1113,17 +1119,6 @@ unwind:
}
int
-posix_acl_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
-{
- STACK_UNWIND_STRICT(truncate, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
-
- return 0;
-}
-
-int
posix_acl_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t off,
dict_t *xdata)
{
@@ -1146,21 +1141,12 @@ posix_acl_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t off,
return 0;
green:
- STACK_WIND(frame, posix_acl_truncate_cbk, FIRST_CHILD(this),
+ STACK_WIND(frame, default_truncate_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->truncate, loc, off, xdata);
return 0;
}
int
-posix_acl_open_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, fd_t *fd, dict_t *xdata)
-{
- STACK_UNWIND_STRICT(open, frame, op_ret, op_errno, fd, xdata);
-
- return 0;
-}
-
-int
posix_acl_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
fd_t *fd, dict_t *xdata)
{
@@ -1193,7 +1179,7 @@ posix_acl_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
else
goto red;
green:
- STACK_WIND(frame, posix_acl_open_cbk, FIRST_CHILD(this),
+ STACK_WIND(frame, default_open_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->open, loc, flags, fd, xdata);
return 0;
red:
@@ -1202,16 +1188,6 @@ red:
}
int
-posix_acl_readv_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, struct iovec *vector, int count,
- struct iatt *stbuf, struct iobref *iobref, dict_t *xdata)
-{
- STACK_UNWIND_STRICT(readv, frame, op_ret, op_errno, vector, count, stbuf,
- iobref, xdata);
- return 0;
-}
-
-int
posix_acl_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
off_t offset, uint32_t flags, dict_t *xdata)
{
@@ -1224,7 +1200,7 @@ posix_acl_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
goto red;
green:
- STACK_WIND(frame, posix_acl_readv_cbk, FIRST_CHILD(this),
+ STACK_WIND(frame, default_readv_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->readv, fd, size, offset, flags, xdata);
return 0;
red:
@@ -1233,16 +1209,6 @@ red:
}
int
-posix_acl_writev_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
-{
- STACK_UNWIND_STRICT(writev, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
- return 0;
-}
-
-int
posix_acl_writev(call_frame_t *frame, xlator_t *this, fd_t *fd,
struct iovec *vector, int count, off_t offset, uint32_t flags,
struct iobref *iobref, dict_t *xdata)
@@ -1256,7 +1222,7 @@ posix_acl_writev(call_frame_t *frame, xlator_t *this, fd_t *fd,
goto red;
green:
- STACK_WIND(frame, posix_acl_writev_cbk, FIRST_CHILD(this),
+ STACK_WIND(frame, default_writev_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->writev, fd, vector, count, offset,
flags, iobref, xdata);
return 0;
@@ -1266,16 +1232,6 @@ red:
}
int
-posix_acl_ftruncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
-{
- STACK_UNWIND_STRICT(ftruncate, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
- return 0;
-}
-
-int
posix_acl_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
dict_t *xdata)
{
@@ -1288,7 +1244,7 @@ posix_acl_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
goto red;
green:
- STACK_WIND(frame, posix_acl_ftruncate_cbk, FIRST_CHILD(this),
+ STACK_WIND(frame, default_ftruncate_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->ftruncate, fd, offset, xdata);
return 0;
red:
@@ -1297,15 +1253,6 @@ red:
}
int
-posix_acl_opendir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, fd_t *fd, dict_t *xdata)
-{
- STACK_UNWIND_STRICT(opendir, frame, op_ret, op_errno, fd, xdata);
-
- return 0;
-}
-
-int
posix_acl_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
dict_t *xdata)
{
@@ -1314,7 +1261,7 @@ posix_acl_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
else
goto red;
green:
- STACK_WIND(frame, posix_acl_opendir_cbk, FIRST_CHILD(this),
+ STACK_WIND(frame, default_opendir_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->opendir, loc, fd, xdata);
return 0;
red:
@@ -1478,16 +1425,6 @@ red:
}
int
-posix_acl_unlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
-{
- STACK_UNWIND_STRICT(unlink, frame, op_ret, op_errno, preparent, postparent,
- xdata);
- return 0;
-}
-
-int
posix_acl_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag,
dict_t *xdata)
{
@@ -1499,7 +1436,7 @@ posix_acl_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag,
else
goto red;
green:
- STACK_WIND(frame, posix_acl_unlink_cbk, FIRST_CHILD(this),
+ STACK_WIND(frame, default_unlink_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->unlink, loc, xflag, xdata);
return 0;
red:
@@ -1508,16 +1445,6 @@ red:
}
int
-posix_acl_rmdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
-{
- STACK_UNWIND_STRICT(rmdir, frame, op_ret, op_errno, preparent, postparent,
- xdata);
- return 0;
-}
-
-int
posix_acl_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
dict_t *xdata)
{
@@ -1529,7 +1456,7 @@ posix_acl_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
else
goto red;
green:
- STACK_WIND(frame, posix_acl_rmdir_cbk, FIRST_CHILD(this),
+ STACK_WIND(frame, default_rmdir_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->rmdir, loc, flags, xdata);
return 0;
red:
@@ -1538,18 +1465,6 @@ red:
}
int
-posix_acl_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, struct iatt *buf,
- struct iatt *preoldparent, struct iatt *postoldparent,
- struct iatt *prenewparent, struct iatt *postnewparent,
- dict_t *xdata)
-{
- STACK_UNWIND_STRICT(rename, frame, op_ret, op_errno, buf, preoldparent,
- postoldparent, prenewparent, postnewparent, xdata);
- return 0;
-}
-
-int
posix_acl_rename(call_frame_t *frame, xlator_t *this, loc_t *old, loc_t *new,
dict_t *xdata)
{
@@ -1567,7 +1482,7 @@ posix_acl_rename(call_frame_t *frame, xlator_t *this, loc_t *old, loc_t *new,
goto red;
}
- STACK_WIND(frame, posix_acl_rename_cbk, FIRST_CHILD(this),
+ STACK_WIND(frame, default_rename_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->rename, old, new, xdata);
return 0;
red:
@@ -1577,17 +1492,6 @@ red:
}
int
-posix_acl_link_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, inode_t *inode, struct iatt *buf,
- struct iatt *preparent, struct iatt *postparent,
- dict_t *xdata)
-{
- STACK_UNWIND_STRICT(link, frame, op_ret, op_errno, inode, buf, preparent,
- postparent, xdata);
- return 0;
-}
-
-int
posix_acl_link(call_frame_t *frame, xlator_t *this, loc_t *old, loc_t *new,
dict_t *xdata)
{
@@ -1610,7 +1514,7 @@ posix_acl_link(call_frame_t *frame, xlator_t *this, loc_t *old, loc_t *new,
goto red;
}
- STACK_WIND(frame, posix_acl_link_cbk, FIRST_CHILD(this),
+ STACK_WIND(frame, default_link_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->link, old, new, xdata);
return 0;
red:
@@ -1621,15 +1525,6 @@ red:
}
int
-posix_acl_readdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, gf_dirent_t *entries,
- dict_t *xdata)
-{
- STACK_UNWIND_STRICT(readdir, frame, op_ret, op_errno, entries, xdata);
- return 0;
-}
-
-int
posix_acl_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
off_t offset, dict_t *xdata)
{
@@ -1638,7 +1533,7 @@ posix_acl_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
else
goto red;
green:
- STACK_WIND(frame, posix_acl_readdir_cbk, FIRST_CHILD(this),
+ STACK_WIND(frame, default_readdir_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->readdir, fd, size, offset, xdata);
return 0;
red:
@@ -2094,15 +1989,6 @@ red:
}
int
-posix_acl_fsetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, dict_t *xdata)
-{
- STACK_UNWIND_STRICT(fsetxattr, frame, op_ret, op_errno, xdata);
-
- return 0;
-}
-
-int
posix_acl_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
dict_t *xattr, int flags, dict_t *xdata)
{
@@ -2117,7 +2003,7 @@ posix_acl_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
dict_get(xattr, POSIX_ACL_DEFAULT_XATTR))
posix_acl_setxattr_update(this, fd->inode, xattr);
- STACK_WIND(frame, posix_acl_fsetxattr_cbk, FIRST_CHILD(this),
+ STACK_WIND(frame, default_fsetxattr_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->fsetxattr, fd, xattr, flags, xdata);
return 0;
red:
@@ -2127,19 +2013,10 @@ red:
}
int
-posix_acl_getxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, dict_t *xattr, dict_t *xdata)
-{
- STACK_UNWIND_STRICT(getxattr, frame, op_ret, op_errno, xattr, xdata);
-
- return 0;
-}
-
-int
posix_acl_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc,
const char *name, dict_t *xdata)
{
- if (whitelisted_xattr(name))
+ if (allowed_xattr(name))
goto green;
if (acl_permits(frame, loc->inode, POSIX_ACL_READ))
@@ -2148,7 +2025,7 @@ posix_acl_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc,
goto red;
green:
- STACK_WIND(frame, posix_acl_getxattr_cbk, FIRST_CHILD(this),
+ STACK_WIND(frame, default_getxattr_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->getxattr, loc, name, xdata);
return 0;
@@ -2159,19 +2036,10 @@ red:
}
int
-posix_acl_fgetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, dict_t *xattr, dict_t *xdata)
-{
- STACK_UNWIND_STRICT(fgetxattr, frame, op_ret, op_errno, xattr, xdata);
-
- return 0;
-}
-
-int
posix_acl_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
const char *name, dict_t *xdata)
{
- if (whitelisted_xattr(name))
+ if (allowed_xattr(name))
goto green;
if (acl_permits(frame, fd->inode, POSIX_ACL_READ))
@@ -2179,7 +2047,7 @@ posix_acl_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
else
goto red;
green:
- STACK_WIND(frame, posix_acl_fgetxattr_cbk, FIRST_CHILD(this),
+ STACK_WIND(frame, default_fgetxattr_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->fgetxattr, fd, name, xdata);
return 0;
red:
@@ -2189,15 +2057,6 @@ red:
}
int
-posix_acl_removexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, dict_t *xdata)
-{
- STACK_UNWIND_STRICT(removexattr, frame, op_ret, op_errno, xdata);
-
- return 0;
-}
-
-int
posix_acl_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc,
const char *name, dict_t *xdata)
{
@@ -2213,7 +2072,7 @@ posix_acl_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc,
goto red;
}
- if (whitelisted_xattr(name)) {
+ if (allowed_xattr(name)) {
if (!frame_is_user(frame, ctx->uid)) {
op_errno = EPERM;
goto red;
@@ -2225,7 +2084,7 @@ posix_acl_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc,
else
goto red;
green:
- STACK_WIND(frame, posix_acl_removexattr_cbk, FIRST_CHILD(this),
+ STACK_WIND(frame, default_removexattr_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->removexattr, loc, name, xdata);
return 0;
red: