FUSEX: fix chmod/chown behaviour to revoke current valid caps and add test - fixes EOS-2873

parent 6fda4478
Pipeline #507155 passed with stages
in 93 minutes and 4 seconds
......@@ -285,6 +285,24 @@ echo "010 all done"
) || exit 10
fi
if [ "$1" = "11" ] ; then
time (
echo "===================================================================="
echo "011 ... chmod test"
mkdir 011-eos-chmod-test
cd 011-eos-chmod-test
mkdir newdir || exit 11
chmod a-w newdir || exit 11
mkdir newdir/forbidden >& /dev/null
if [ $? -ne 0 ] ; then echo OK > /dev/null; else exit 11; fi
chmod a+w newdir || exit 11
mkdir newdir/forbidden >& /dev/null
if [ $? -ne 0 ] ; then exit 11; else echo OK > /dev/null; fi
rmdir newdir/forbidden || exit 11;
rmdir newdir || exit 11;
) || exit 11
fi
echo "===================================================================="
echo "... :-) passed !"
echo "===================================================================="
......@@ -199,7 +199,6 @@ cap::get(fuse_req_t req,
cap->set_vtime(0);
cap->set_vtime_ns(0);
capmap[cid] = cap;
// mds->increase_cap(ino, lock);
return cap;
}
}
......@@ -493,6 +492,17 @@ cap::capx::lifetime()
return lifetime;
}
/* -------------------------------------------------------------------------- */
void
/* -------------------------------------------------------------------------- */
cap::capx::invalidate()
/* -------------------------------------------------------------------------- */
{
XrdSysMutexHelper cLock(Locker());
set_vtime(0);
}
/* -------------------------------------------------------------------------- */
void
/* -------------------------------------------------------------------------- */
......
......@@ -113,6 +113,8 @@ public:
double lifetime();
void invalidate();
void use()
{
lastusage = time(NULL);
......
......@@ -1687,6 +1687,15 @@ EosFuse::setattr(fuse_req_t req, fuse_ino_t ino, struct stat* attr, int op,
ADD_FUSE_STAT("setattr:chmod", req);
EXEC_TIMING_BEGIN("setattr:chmod");
md->set_mode(attr->st_mode);
if (S_ISDIR(md->mode())) {
// if this is a directory we have to revoke a potential existing cap for that directory
cap::shared_cap cap = Instance().caps.get(req, md->id());
cap->invalidate();
// we have also to wait for the upstream flush
Instance().mds.wait_flush(req, md);
}
EXEC_TIMING_END("setattr:chmod");
}
......@@ -1736,6 +1745,14 @@ EosFuse::setattr(fuse_req_t req, fuse_ino_t ino, struct stat* attr, int op,
md->set_gid(attr->st_gid);
}
if (S_ISDIR(md->mode())) {
// if this is a directory we have to revoke a potential existing cap for that directory
cap::shared_cap cap = Instance().caps.get(req, md->id());
cap->invalidate();
// we have also to wait for the upstream flush
Instance().mds.wait_flush(req, md);
}
EXEC_TIMING_END("setattr:chown");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment