Fix root access to VitastorFS files
This commit is contained in:
@@ -94,6 +94,10 @@ uint32_t kv_get_access(const authsys_parms & auth_sys, const json11::Json & attr
|
|||||||
uint32_t uid = attrs["uid"].uint64_value();
|
uint32_t uid = attrs["uid"].uint64_value();
|
||||||
uint32_t gid = attrs["gid"].uint64_value();
|
uint32_t gid = attrs["gid"].uint64_value();
|
||||||
uint32_t access = 0;
|
uint32_t access = 0;
|
||||||
|
if (!auth_sys.uid)
|
||||||
|
{
|
||||||
|
return (ACCESS3_READ|ACCESS3_LOOKUP|ACCESS3_MODIFY|ACCESS3_EXTEND|ACCESS3_DELETE|ACCESS3_EXECUTE);
|
||||||
|
}
|
||||||
if (uid == auth_sys.uid)
|
if (uid == auth_sys.uid)
|
||||||
{
|
{
|
||||||
access |= ((mode & (1 << 8)) ? ACCESS3_READ|ACCESS3_LOOKUP : 0);
|
access |= ((mode & (1 << 8)) ? ACCESS3_READ|ACCESS3_LOOKUP : 0);
|
||||||
@@ -120,6 +124,8 @@ uint32_t kv_get_access(const authsys_parms & auth_sys, const json11::Json & attr
|
|||||||
bool kv_is_accessible(const authsys_parms & auth_sys, const json11::Json & attrs, uint32_t access)
|
bool kv_is_accessible(const authsys_parms & auth_sys, const json11::Json & attrs, uint32_t access)
|
||||||
{
|
{
|
||||||
uint32_t mode = attrs["mode"].is_null() ? (attrs["type"] == "dir" ? 0755 : 0644) : attrs["mode"].uint64_value();
|
uint32_t mode = attrs["mode"].is_null() ? (attrs["type"] == "dir" ? 0755 : 0644) : attrs["mode"].uint64_value();
|
||||||
|
if (!auth_sys.uid)
|
||||||
|
return true;
|
||||||
uint32_t mask = 1 << (access == ACCESS3_EXECUTE ? 0
|
uint32_t mask = 1 << (access == ACCESS3_EXECUTE ? 0
|
||||||
: (access == ACCESS3_MODIFY || access == ACCESS3_EXTEND || access == ACCESS3_DELETE ? 1 : 2));
|
: (access == ACCESS3_MODIFY || access == ACCESS3_EXTEND || access == ACCESS3_DELETE ? 1 : 2));
|
||||||
if (mode & mask)
|
if (mode & mask)
|
||||||
|
|||||||
@@ -13,6 +13,12 @@ sudo mount localhost:/ ./testdata/nfs -o port=2050,mountport=2050,nfsvers=3,soft
|
|||||||
MNT=$(pwd)/testdata/nfs
|
MNT=$(pwd)/testdata/nfs
|
||||||
trap "sudo umount -f $MNT"' || true; kill -9 $(jobs -p)' EXIT
|
trap "sudo umount -f $MNT"' || true; kill -9 $(jobs -p)' EXIT
|
||||||
|
|
||||||
|
touch ./testdata/nfs/f1
|
||||||
|
chown 1000:1000 ./testdata/nfs/f1
|
||||||
|
chmod 600 ./testdata/nfs/f1
|
||||||
|
sudo cat ./testdata/nfs/f1
|
||||||
|
rm ./testdata/nfs/f1
|
||||||
|
|
||||||
# write small file
|
# write small file
|
||||||
ls -l ./testdata/nfs
|
ls -l ./testdata/nfs
|
||||||
dd if=/dev/urandom of=./testdata/f1 bs=100k count=1
|
dd if=/dev/urandom of=./testdata/f1 bs=100k count=1
|
||||||
|
|||||||
Reference in New Issue
Block a user