SecurityDescriptor.patch and jCifs-1.1.11 or jCifs-1.2.7

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

SecurityDescriptor.patch and jCifs-1.1.11 or jCifs-1.2.7

James Maupin
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.

Reply | Threaded
Open this post in threaded view
|

Re: SecurityDescriptor.patch and jCifs-1.1.11 or jCifs-1.2.7

Michael B Allen-4
On Sun, 11 Dec 2005 19:44:20 +0000 (UTC)
James Maupin <[hidden email]> wrote:

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

Excellent. Just to make things as easy as possible for people can you
post a new diff -Nuar old/src new/src? Then I can add it to the patches
directory.

Thanks,
Mike