[jcifs] SecurityDescriptor.patch and jCifs-1.1.11 or jCifs-1.2.7

James Maupin james.maupin at metacarta.com
Sun Dec 11 19:44:20 GMT 2005


Applying the SecurityDescriptor.patch to jCifs-1.1.11 adds a new method to 
SmbFile class. The SmbFile.getSecurity() method returns an ACE[] array for the 
target file (array of allow and deny ActiveDirectory SIDS). 

The method SmbFile.getSecurity() works if you apply the changes as defined in 
the SecurityDescriptor.patch. However, SmbFile.getInputStream().read() or 
SmbFileInputStream.read() fails. To get this to work you must add the 
following change in SmbComNtCreateAndX.java:

  super( andx );
  this.path = name;
  command = SMB_COM_NT_CREATE_ANDX;

  // desiredAccess
  desiredAccess = access;
- desiredAccess |= FILE_READ_EA | FILE_READ_ATTRIBUTES;
+ desiredAccess |= FILE_READ_EA | FILE_READ_ATTRIBUTES | FILE_READ_DATA;

  // extFileAttributes
  this.extFileAttributes = extFileAttributes;

  // shareAccess
  this.shareAccess = shareAccess;

------------------------------

Also, applying the changes to jCifs-1.2.7 were straight forword with the 
exception of SmbFile. The following changes should be made:

------------------------------
    void setPathInformation(int attrs, long ctime, long mtime) throws 
SmbException {
        int f, dir, options = 0;
        
+        if(( attrs & ATTR_DIRECTORY ) != 0 ) {
+            options = 1;
+        }

        exists();
        dir = attributes & ATTR_DIRECTORY;

        f = open0(O_RDONLY, SmbComNTCreateAndX.FILE_WRITE_ATTRIBUTES, attrs, 
options);
-        sendTransaction(new Trans2SetFileInformation(f, attrs, ctime, mtime), 
new Trans2SetFileInformationResponse());
+        send(new Trans2SetFileInformation(f, attrs, ctime, mtime), new 
Trans2SetFileInformationResponse());
        close(f, 0L);

        attrExpiration = 0;
    }

----------------------------------------

 NtTransQuerySecurityDesc request = new NtTransQuerySecurityDesc(f, 0x04);
 NtTransQuerySecurityDescResponse response = new 
NtTransQuerySecurityDescResponse();
        
- sendTransaction(request, response);
+ send(request, response);

  close(f, 0L);
  return response.aces;

----------------------------------------

Thanks.



More information about the jcifs mailing list