From 80fbfef5c70b67838a391041e80a67e41c9142b6 Mon Sep 17 00:00:00 2001 From: luneo7 Date: Tue, 10 Oct 2017 17:08:22 -0300 Subject: features/worm: Adding check to newloc when doing rename Problem: Since rename didn't check if newloc exists and it's retention state it was possible to rename a new file that wasn't in retention over a existing file that was in read-only state. Cherry picked from commit 00a4dc0: > Change-Id: I63c6bbabb7bb456ebedf201cc77b878ffda62229 > BUG: 1484490 > Signed-off-by: luneo7 > Reviewed-on: https://review.gluster.org/18104 > Tested-by: jiffin tony Thottan > Tested-by: Prashanth Pai > Smoke: Gluster Build System > CentOS-regression: Gluster Build System > Reviewed-by: Prashanth Pai > Reviewed-by: Karthik U S > Reviewed-by: Amar Tumballi Change-Id: I63c6bbabb7bb456ebedf201cc77b878ffda62229 BUG: 1484489 Signed-off-by: luneo7 --- xlators/features/read-only/src/worm.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'xlators') diff --git a/xlators/features/read-only/src/worm.c b/xlators/features/read-only/src/worm.c index 74bf0072e4c..e4916402f8e 100644 --- a/xlators/features/read-only/src/worm.c +++ b/xlators/features/read-only/src/worm.c @@ -137,10 +137,24 @@ worm_rename (call_frame_t *frame, xlator_t *this, gf_uuid_copy (oldloc->gfid, oldloc->inode->gfid); if (is_wormfile (this, _gf_false, oldloc)) { op_errno = 0; - goto out; + goto check_newloc; } op_errno = gf_worm_state_transition (this, _gf_false, oldloc, - GF_FOP_RENAME); + GF_FOP_RENAME); + + if (op_errno == 0) { +check_newloc: + if (newloc->inode != NULL) { + gf_uuid_copy (newloc->gfid, newloc->inode->gfid); + if (is_wormfile (this, _gf_false, newloc)) { + op_errno = 0; + goto out; + } + op_errno = gf_worm_state_transition (this, _gf_false, + newloc, + GF_FOP_RENAME); + } + } out: if (op_errno) -- cgit