AgNO3 / jcifs-ng

A cleaned-up and improved version of the jCIFS library
GNU Lesser General Public License v2.1
313 stars 104 forks source link

Support to Update File Metadata: Need SMBFile setSecurity() and setOwnerUser() APIs #129

Open rkordeDev opened 5 years ago

rkordeDev commented 5 years ago

jcifs-ng version: 2.0.7

I am working on a use case which needs to update File Metadata on CIFS shares. jcifs-ng has APIs to update the timestamps (created, accessed and modified), but unfortunately there is no support to update ACLs/owner of a file.

This support is not available in latest release (2.1.1) as well. Can we have setSecurity and setOwnerUser APIs in the upcoming release?

I came across a patch on jcifs (not sure if jcifs-ng can reuse the code): http://samba.2283325.n4.nabble.com/file/n4164396/jcifs-1.3.12-setSecurity.patch http://chrisdail.com/wp-content/uploads/2012/03/setSecurity.patch_.txt Discussion related to Updating ACEs: http://samba.2283325.n4.nabble.com/Updating-ACE-using-jcifs-td4091033.html

mbechler commented 5 years ago

We might be able to reuse some of the encoding code, but most other stuff will require some refactoring to handle SMB2. Also I'm not sure I like some of the API/design choices.

ronnybremer commented 5 years ago

Thats critical for me too. I am using an older library right now, which has this patch applied: SetSecurity Patch

Unfortunately, the old library has issues talking to a Windows 2016 server (all ACEs are reported as direct, even if they are inherited, for example), so I would need to upgrade to jcifs-ng 2.1. I am happy to assist in implementing the patch, however, I know very little about the many changes you have done from jcifs to jcifs-ng.

Any suggestions?

Yours, Ronny

mbechler commented 5 years ago

That should more or less come down to pulling out the security descriptor encoding stuff from NtTransSetSecurityDesc and move it to jcifs/internal/dtyp/SecurityDescriptor.java so that it can be use in a SMB2 SET_INFO request as well as the SMB1 NT_TRANSACT_SET_SECURITY_DESC request.

I would suggest to simplify to API to have just a single setSecurity(ACE[], SID owner, SID group) method, avoiding to expose the internals.