diff options
author | shishir gowda <sgowda@redhat.com> | 2013-03-18 14:44:20 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2013-05-31 06:15:15 -0700 |
commit | 003713139c8a7830a90a40dfead72f8299c17e31 (patch) | |
tree | ae60963d8141af552c67e5f86faa0e5fe90583dc /tests/bugs/bug-884597.t | |
parent | 39ae62c39662a37fef9d0809438482ce441a98e0 (diff) |
cluster/dht: Linkfiles creation with correct uid/gid
If renames are done with different uid/gid (non-owners), then we would
end up with incorrect uid/gid.
The fix is to create linkfiles, and heal the uid/gid as root:root. This
preserves our notion of creation as root:root and heal the uid/gid as
root:root in all paths. Additionally, we need to consider uid/gid from
only src_cached subvol, and not from linkfiles.
rename is also done as root:root if done on linkfile, as setattr of ownership
on linkfile is done after the rename
Change-Id: Icb5d431dc42da9c02dfae81980e3fe769a47a274
BUG: 884597
Signed-off-by: shishir gowda <sgowda@redhat.com>
Reviewed-on: http://review.gluster.org/4682
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'tests/bugs/bug-884597.t')
-rwxr-xr-x | tests/bugs/bug-884597.t | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/bugs/bug-884597.t b/tests/bugs/bug-884597.t index 0d3495a6597..db82fbd6df6 100755 --- a/tests/bugs/bug-884597.t +++ b/tests/bugs/bug-884597.t @@ -107,3 +107,45 @@ BACKEND_UID=`stat --printf=%u $B0/${V0}$cached/link$i`; BACKEND_GID=`stat --printf=%g $B0/${V0}$cached/link$i`; EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID + +## UID/GID creation as different user +i=1 +NEW_UID=36 +NEW_GID=36 + +TEST touch $M0/user_file1 +TEST chown $NEW_UID:$NEW_GID $M0/user_file1; + +## Give permission on volume, so that different users can perform rename + +TEST chmod 0777 $M0 + +## Add a user known as ABC and perform renames +TEST `useradd -M ABC 2>/dev/null` + +TEST cd $M0 +## rename as different user till file gets a linkfile + +while [ $i -ne 0 ] +do + su -c "mv $M0/user_file$i $M0/user_file$(( $i+1 ))" ABC + let i++ + file_has_linkfile user_file$i + has_link=$? + if [ $has_link -eq 2 ] + then + break; + fi +done + +## del user ABC +TEST userdel ABC + +get_hashed_brick user_file$i +cached=$? + +# check if uid/gid on linkfile is created with correct uid/gid +BACKEND_UID=`stat --printf=%u $B0/${V0}$cached/user_file$i`; +BACKEND_GID=`stat --printf=%g $B0/${V0}$cached/user_file$i`; + +EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID |