From: Xiubo Li Date: Wed, 14 Sep 2022 05:07:05 +0000 (+0800) Subject: client: rename MAY_* to CLIENT_MAY_* to avoid conflicts X-Git-Tag: v18.2.4~114^2~19 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3c5b2d6bcf73635d2281cd7639a0b87864405be8;p=ceph.git client: rename MAY_* to CLIENT_MAY_* to avoid conflicts Fixes: https://tracker.ceph.com/issues/57154 Signed-off-by: Xiubo Li (cherry picked from commit 27f73a9b9e4c7efb11adb7dbb17035d8ca978727) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index ae892ea1ab14..f126957334f5 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -5885,7 +5885,7 @@ int Client::inode_permission(Inode *in, const UserPerm& perms, unsigned want) // For directories, DACs are overridable. // For files, Read/write DACs are always overridable but executable DACs are // overridable when there is at least one exec bit set - if(!S_ISDIR(in->mode) && (want & MAY_EXEC) && !(in->mode & S_IXUGO)) + if(!S_ISDIR(in->mode) && (want & CLIENT_MAY_EXEC) && !(in->mode & S_IXUGO)) return -CEPHFS_EACCES; return 0; } @@ -5911,7 +5911,7 @@ int Client::xattr_permission(Inode *in, const char *name, unsigned want, r = 0; if (strncmp(name, "system.", 7) == 0) { - if ((want & MAY_WRITE) && (perms.uid() != 0 && perms.uid() != in->uid)) + if ((want & CLIENT_MAY_WRITE) && (perms.uid() != 0 && perms.uid() != in->uid)) r = -CEPHFS_EPERM; } else { r = inode_permission(in, perms, want); @@ -5936,7 +5936,7 @@ int Client::may_setattr(Inode *in, struct ceph_statx *stx, int mask, goto out; if (mask & CEPH_SETATTR_SIZE) { - r = inode_permission(in, perms, MAY_WRITE); + r = inode_permission(in, perms, CLIENT_MAY_WRITE); if (r < 0) goto out; } @@ -5983,7 +5983,7 @@ int Client::may_setattr(Inode *in, struct ceph_statx *stx, int mask, if (check_mask & mask) { goto out; } else { - r = inode_permission(in, perms, MAY_WRITE); + r = inode_permission(in, perms, CLIENT_MAY_WRITE); if (r < 0) goto out; } @@ -6001,13 +6001,13 @@ int Client::may_open(Inode *in, int flags, const UserPerm& perms) unsigned want = 0; if ((flags & O_ACCMODE) == O_WRONLY) - want = MAY_WRITE; + want = CLIENT_MAY_WRITE; else if ((flags & O_ACCMODE) == O_RDWR) - want = MAY_READ | MAY_WRITE; + want = CLIENT_MAY_READ | CLIENT_MAY_WRITE; else if ((flags & O_ACCMODE) == O_RDONLY) - want = MAY_READ; + want = CLIENT_MAY_READ; if (flags & O_TRUNC) - want |= MAY_WRITE; + want |= CLIENT_MAY_WRITE; int r = 0; switch (in->mode & S_IFMT) { @@ -6015,7 +6015,7 @@ int Client::may_open(Inode *in, int flags, const UserPerm& perms) r = -CEPHFS_ELOOP; goto out; case S_IFDIR: - if (want & MAY_WRITE) { + if (want & CLIENT_MAY_WRITE) { r = -CEPHFS_EISDIR; goto out; } @@ -6039,7 +6039,7 @@ int Client::may_lookup(Inode *dir, const UserPerm& perms) if (r < 0) goto out; - r = inode_permission(dir, perms, MAY_EXEC); + r = inode_permission(dir, perms, CLIENT_MAY_EXEC); out: ldout(cct, 3) << __func__ << " " << dir << " = " << r << dendl; return r; @@ -6052,7 +6052,7 @@ int Client::may_create(Inode *dir, const UserPerm& perms) if (r < 0) goto out; - r = inode_permission(dir, perms, MAY_EXEC | MAY_WRITE); + r = inode_permission(dir, perms, CLIENT_MAY_EXEC | CLIENT_MAY_WRITE); out: ldout(cct, 3) << __func__ << " " << dir << " = " << r << dendl; return r; @@ -6065,7 +6065,7 @@ int Client::may_delete(Inode *dir, const char *name, const UserPerm& perms) if (r < 0) goto out; - r = inode_permission(dir, perms, MAY_EXEC | MAY_WRITE); + r = inode_permission(dir, perms, CLIENT_MAY_EXEC | CLIENT_MAY_WRITE); if (r < 0) goto out; @@ -6130,7 +6130,7 @@ int Client::may_hardlink(Inode *in, const UserPerm& perms) if ((in->mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) goto out; - r = inode_permission(in, perms, MAY_READ | MAY_WRITE); + r = inode_permission(in, perms, CLIENT_MAY_READ | CLIENT_MAY_WRITE); out: ldout(cct, 3) << __func__ << " " << in << " = " << r << dendl; return r; @@ -7932,7 +7932,7 @@ int Client::_do_setattr(Inode *in, struct ceph_statx *stx, int mask, auxsize = aux->size(); ldout(cct, 10) << __func__ << " mask " << mask << " issued " << - ccap_string(issued) << " aux size " << auxsize << dendl; + ccap_string(issued) << " aux size " << auxsize << " perms " << perms << dendl; if (in->snapid != CEPH_NOSNAP) { return -CEPHFS_EROFS; @@ -13035,7 +13035,7 @@ int Client::_getxattr(InodeRef &in, const char *name, void *value, size_t size, const UserPerm& perms) { if (cct->_conf->client_permissions) { - int r = xattr_permission(in.get(), name, MAY_READ, perms); + int r = xattr_permission(in.get(), name, CLIENT_MAY_READ, perms); if (r < 0) return r; } @@ -13058,7 +13058,7 @@ int Client::ll_getxattr(Inode *in, const char *name, void *value, std::scoped_lock lock(client_lock); if (!fuse_default_permissions) { - int r = xattr_permission(in, name, MAY_READ, perms); + int r = xattr_permission(in, name, CLIENT_MAY_READ, perms); if (r < 0) return r; } @@ -13238,7 +13238,7 @@ int Client::_setxattr(InodeRef &in, const char *name, const void *value, size_t size, int flags, const UserPerm& perms) { if (cct->_conf->client_permissions) { - int r = xattr_permission(in.get(), name, MAY_WRITE, perms); + int r = xattr_permission(in.get(), name, CLIENT_MAY_WRITE, perms); if (r < 0) return r; } @@ -13326,7 +13326,7 @@ int Client::ll_setxattr(Inode *in, const char *name, const void *value, std::scoped_lock lock(client_lock); if (!fuse_default_permissions) { - int r = xattr_permission(in, name, MAY_WRITE, perms); + int r = xattr_permission(in, name, CLIENT_MAY_WRITE, perms); if (r < 0) return r; } @@ -13368,7 +13368,7 @@ int Client::_removexattr(Inode *in, const char *name, const UserPerm& perms) int Client::_removexattr(InodeRef &in, const char *name, const UserPerm& perms) { if (cct->_conf->client_permissions) { - int r = xattr_permission(in.get(), name, MAY_WRITE, perms); + int r = xattr_permission(in.get(), name, CLIENT_MAY_WRITE, perms); if (r < 0) return r; } @@ -13390,7 +13390,7 @@ int Client::ll_removexattr(Inode *in, const char *name, const UserPerm& perms) std::scoped_lock lock(client_lock); if (!fuse_default_permissions) { - int r = xattr_permission(in, name, MAY_WRITE, perms); + int r = xattr_permission(in, name, CLIENT_MAY_WRITE, perms); if (r < 0) return r; } diff --git a/src/client/Client.h b/src/client/Client.h index 48d28e18d89b..a7c6051409d4 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1275,9 +1275,9 @@ private: }; enum { - MAY_EXEC = 1, - MAY_WRITE = 2, - MAY_READ = 4, + CLIENT_MAY_EXEC = 1, + CLIENT_MAY_WRITE = 2, + CLIENT_MAY_READ = 4, }; typedef std::function fill_readdir_args_cb_t;