dCache / nfs4j

Pure Java NFSv3 and NFSv4.2 implementation
Other
240 stars 76 forks source link

respect the gid and uid sent in creation attributes #33

Closed svenin closed 8 years ago

svenin commented 8 years ago

This originates form using SimpleNfsServer in https://github.com/kofemann/simple-nfs to implement a local nfs server to test an nfs v3 client application. Our client was doing a directory creation as root, but was sending different uid and gid for the directory creation. The SimpleNfsServer ignored that and created the directory with root uid and gid. I tracked the root cause to PseudoFs ignoring the attributes received on creation. The suggested fix is prettry simple but maybe I am optimistic here and a more general solution is needed here. Let me know what you think. One thing is that I am not sure this should be allowed to all users, maybe only root, I can add that check if needed.

dcache-ci commented 8 years ago

Can one of the admins verify this patch?

kofemann commented 8 years ago

Thanks for the patch. Two issues with it:

  1. Please add Signed-off-by line in the comment ( git commit/amend -s)
  2. As you pointed out yourself, setting file owner ship is allowed only to root user.
svenin commented 8 years ago

Done.

kofemann commented 8 years ago

looking at the code again I see a simpler/nicer solution. The VirtualFileSystem#create already takes Subject as an argument. You can update v3 code to create a new subject if farrd3 contains uid and gid. Inside PseudoFs@create you can check that effective uid is root and pass provided subject to underling filesystem. I thinks it's cleaner. What do you think?

svenin commented 8 years ago

Note that this applies to both create and mkdir. So you are suggesting:

No problem, will do that.

svenin commented 8 years ago

Updated the PR, let me know what you think.

svenin commented 8 years ago

Done.

kofemann commented 8 years ago

ok to test.

kofemann commented 8 years ago

Thanks!

svenin commented 8 years ago

Thank you!