From: Jeff Layton Date: Thu, 8 Dec 2016 15:10:07 +0000 (-0500) Subject: client: set CEPH_SETATTR_KILL_SGUID on truncate X-Git-Tag: v11.1.1~22^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=03076a6924a7f82e33c7b2434a6cd367290884b7;p=ceph.git client: set CEPH_SETATTR_KILL_SGUID on truncate On a size change, try to clobber the S_ISUID and S_ISGID bits if we have Ax caps. If we don't have them, then ask the server to do it for us using CEPH_SETATTR_KILL_SGUID. Signed-off-by: Jeff Layton --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 6f39c082ffe..41f6b70a4f2 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -6494,7 +6494,7 @@ int Client::_do_setattr(Inode *in, struct ceph_statx *stx, int mask, } if (in->caps_issued_mask(CEPH_CAP_AUTH_EXCL)) { - bool kill_sguid = mask & CEPH_SETATTR_KILL_SGUID; + bool kill_sguid = mask & (CEPH_SETATTR_SIZE|CEPH_SETATTR_KILL_SGUID); mask &= ~CEPH_SETATTR_KILL_SGUID; @@ -6544,7 +6544,11 @@ int Client::_do_setattr(Inode *in, struct ceph_statx *stx, int mask, mask &= ~CEPH_SETATTR_BTIME; ldout(cct,10) << "changing btime to " << in->btime << dendl; } + } else if (mask & CEPH_SETATTR_SIZE) { + /* If we don't have Ax, then we must ask the server to clear them on truncate */ + mask |= CEPH_SETATTR_KILL_SGUID; } + if (in->caps_issued_mask(CEPH_CAP_FILE_EXCL)) { if (mask & (CEPH_SETATTR_MTIME|CEPH_SETATTR_ATIME)) { if (mask & CEPH_SETATTR_MTIME)