jcifs-1.2.16 from tgz
authorFelix Schumacher <p0354740@isib001.(none)>
Wed, 6 Aug 2008 14:43:12 +0000 (16:43 +0200)
committerFelix Schumacher <p0354740@isib001.(none)>
Wed, 6 Aug 2008 14:43:12 +0000 (16:43 +0200)
Mon Jul 16 13:26:26 EDT 2007
jcifs-1.2.15 released

This release includes some significant changes. Most of these changes
are related to NetApp compatibility. The changes in this release are:

An SMB signing failure related to DFS has been fixed.

The DCERPC bind did not exactly mimic Windows which uses
SMB_COM_{WRITE,READ}_ANDX. We were using TransactNmPipe throughout which
could result in an 'Incorrect function' error when querying the LSA on
a NetApp server. JCIFS now implements the bind exactly like Windows to
help ensure compatibility with other servers.

Other changes related to NetApp compatibility include falling back to
SamrConnect2 if an DCERPC_FAULT_OP_RNG_ERROR error occurs, more closely
mimicing the SMB_COM_NT_CREATE_ANDX "extended" response, adjusting various
RPC handle operation access masks, uncommenting some padding code that
was commented out for what appeared to be a NetWare problem, disabling
some logic to used port 139 if the jcifs.netbios.hostname was set and
finally adding code to include LsarQosInfo structures in the MSRPC bind.

Some new error code information has been added.

Constants for common SIDs have been added to the SID class.

The SID.getGroupMemberSids() method will now return an empty SID array
if the SID is not of type SID_TYPE_DOM_GRP or SID_TYPE_ALIAS.

A minor performance flaw in the DCERPC code was found and fixed.

121 files changed:
README.txt
build.xml
examples/10883563.doc [new file with mode: 0644]
examples/AclCrawler.class [new file with mode: 0644]
examples/AllocInfo.class [new file with mode: 0644]
examples/Append.class [new file with mode: 0644]
examples/AuthListFiles.class [new file with mode: 0644]
examples/CallNamedPipe.class [new file with mode: 0644]
examples/CifsTime.java [deleted file]
examples/CopyTo.class [new file with mode: 0644]
examples/CountPerms.class [new file with mode: 0644]
examples/CreateFile.class [new file with mode: 0644]
examples/Delete.class [new file with mode: 0644]
examples/Equals.class [new file with mode: 0644]
examples/Exists.class [new file with mode: 0644]
examples/FileInfo.class [new file with mode: 0644]
examples/FileOps.class [new file with mode: 0644]
examples/FilterFiles$BigFileFilter.class [new file with mode: 0644]
examples/FilterFiles$ShortFilenameFilter.class [new file with mode: 0644]
examples/FilterFiles.class [new file with mode: 0644]
examples/Format.class [new file with mode: 0644]
examples/Get.class [new file with mode: 0644]
examples/GetDate.class [new file with mode: 0644]
examples/GetDfsPath.class [new file with mode: 0644]
examples/GetGroupMemberSidsFromURL.class [new file with mode: 0644]
examples/GetGroupMemberSidsFromURL.java [new file with mode: 0644]
examples/GetSecurity.class [new file with mode: 0644]
examples/GetShareSecurity.class [new file with mode: 0644]
examples/GetType.class [new file with mode: 0644]
examples/GetURL.class [new file with mode: 0644]
examples/GrowWrite.class [new file with mode: 0644]
examples/HttpURL.class [new file with mode: 0644]
examples/Interleave$IThread.class [new file with mode: 0644]
examples/Interleave.class [new file with mode: 0644]
examples/InterruptTest.class [new file with mode: 0644]
examples/IsDir.class [new file with mode: 0644]
examples/LargeListFiles.class [new file with mode: 0644]
examples/Length.class [new file with mode: 0644]
examples/List.class [new file with mode: 0644]
examples/ListACL.class [new file with mode: 0644]
examples/ListACL.java
examples/ListFiles.class [new file with mode: 0644]
examples/ListTypes.class [new file with mode: 0644]
examples/Makefile
examples/Mkdir.class [new file with mode: 0644]
examples/NodeStatus.class [new file with mode: 0644]
examples/OpenExclusive.class [new file with mode: 0644]
examples/PeekNamedPipe$ReceiverThread.class [new file with mode: 0644]
examples/PeekNamedPipe.class [new file with mode: 0644]
examples/PipeTalk$ReceiverThread.class [new file with mode: 0644]
examples/PipeTalk.class [new file with mode: 0644]
examples/Put.class [new file with mode: 0644]
examples/Query.class [new file with mode: 0644]
examples/RenameTo.class [new file with mode: 0644]
examples/SetAttrs.class [new file with mode: 0644]
examples/SetTime.class [new file with mode: 0644]
examples/SidCacheTest.class [new file with mode: 0644]
examples/SidCrawler.class [new file with mode: 0644]
examples/SidLookup.class [new file with mode: 0644]
examples/SidLookup.java
examples/SlowRead.class [new file with mode: 0644]
examples/SlowWrite.class [new file with mode: 0644]
examples/SmbCrawler.class [new file with mode: 0644]
examples/SmbShell.class [new file with mode: 0644]
examples/SmbTableFile.class [new file with mode: 0644]
examples/SmbTableFileRecord.class [new file with mode: 0644]
examples/SmbThreadTest.class [new file with mode: 0644]
examples/T2Crawler$CrawlerThread.class [new file with mode: 0644]
examples/T2Crawler$Semaphore.class [new file with mode: 0644]
examples/T2Crawler.class [new file with mode: 0644]
examples/TestRandomAccess$TestRecord.class [new file with mode: 0644]
examples/TestRandomAccess.class [new file with mode: 0644]
examples/TestSmbURL.class [new file with mode: 0644]
examples/TestUnicode.class [new file with mode: 0644]
examples/ThreadedNbtQuery$QThread.class [new file with mode: 0644]
examples/ThreadedNbtQuery.class [new file with mode: 0644]
examples/ThreadedSmbCrawler$DirEntry.class [new file with mode: 0644]
examples/ThreadedSmbCrawler$SmbCrawlerThread.class [new file with mode: 0644]
examples/ThreadedSmbCrawler.class [new file with mode: 0644]
examples/ThreadedUniQuery$QThread.class [new file with mode: 0644]
examples/ThreadedUniQuery.class [new file with mode: 0644]
examples/Torture1.class [new file with mode: 0644]
examples/Torture2.class [new file with mode: 0644]
examples/TortureTest5.class [new file with mode: 0644]
examples/TransactNamedPipe.class [new file with mode: 0644]
examples/URLTest.class [new file with mode: 0644]
examples/VerifyGuest.class [new file with mode: 0644]
examples/VerifyIO.class [new file with mode: 0644]
examples/VerifyReads.class [new file with mode: 0644]
examples/Worker.class [new file with mode: 0644]
examples/run1.sh
examples/runtests.sh
src/jcifs/UniAddress.java
src/jcifs/dcerpc/DcerpcHandle.java
src/jcifs/dcerpc/DcerpcPipeHandle.java
src/jcifs/dcerpc/msrpc/MsrpcLsarOpenPolicy2.java
src/jcifs/dcerpc/msrpc/MsrpcSamrConnect2.java [new file with mode: 0644]
src/jcifs/dcerpc/msrpc/MsrpcShareEnum.java
src/jcifs/dcerpc/msrpc/SamrPolicyHandle.java
src/jcifs/dcerpc/msrpc/samr.idl
src/jcifs/dcerpc/msrpc/samr.java
src/jcifs/smb/.SmbConstants.java.swp [new file with mode: 0644]
src/jcifs/smb/AndXServerMessageBlock.java
src/jcifs/smb/NetShareEnumResponse.java
src/jcifs/smb/NtStatus.java
src/jcifs/smb/NtlmPasswordAuthentication.java
src/jcifs/smb/SID.java
src/jcifs/smb/ServerMessageBlock.java
src/jcifs/smb/SigningDigest.java
src/jcifs/smb/SmbComNTCreateAndX.java
src/jcifs/smb/SmbComNTCreateAndXResponse.java
src/jcifs/smb/SmbComReadAndX.java
src/jcifs/smb/SmbComTransaction.java
src/jcifs/smb/SmbComWriteAndX.java
src/jcifs/smb/SmbFile.java
src/jcifs/smb/SmbFileInputStream.java
src/jcifs/smb/SmbFileOutputStream.java
src/jcifs/smb/SmbShareInfo.java [new file with mode: 0644]
src/jcifs/smb/SmbTransport.java
src/jcifs/smb/SmbTree.java
src/jcifs/smb/TransactNamedPipeOutputStream.java

index d1e88e7..17bd96a 100644 (file)
@@ -1,3 +1,34 @@
+Mon Jul 16 13:26:26 EDT 2007
+jcifs-1.2.15 released
+
+This release includes some significant changes. Most of these changes
+are related to NetApp compatibility. The changes in this release are:
+
+An SMB signing failure related to DFS has been fixed.
+
+The DCERPC bind did not exactly mimic Windows which uses
+SMB_COM_{WRITE,READ}_ANDX. We were using TransactNmPipe throughout which
+could result in an 'Incorrect function' error when querying the LSA on
+a NetApp server. JCIFS now implements the bind exactly like Windows to
+help ensure compatibility with other servers.
+
+Other changes related to NetApp compatibility include falling back to
+SamrConnect2 if an DCERPC_FAULT_OP_RNG_ERROR error occurs, more closely
+mimicing the SMB_COM_NT_CREATE_ANDX "extended" response, adjusting various
+RPC handle operation access masks, uncommenting some padding code that
+was commented out for what appeared to be a NetWare problem, disabling
+some logic to used port 139 if the jcifs.netbios.hostname was set and
+finally adding code to include LsarQosInfo structures in the MSRPC bind.
+
+Some new error code information has been added.
+
+Constants for common SIDs have been added to the SID class.
+
+The SID.getGroupMemberSids() method will now return an empty SID array
+if the SID is not of type SID_TYPE_DOM_GRP or SID_TYPE_ALIAS.
+
+A minor performance flaw in the DCERPC code was found and fixed.
+
 Wed Jun 20 13:09:10 EDT 2007
 jcifs-1.2.14 released
 
index f047973..bbd3cc8 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -1,7 +1,7 @@
 <project name="jcifs" default="usage" basedir=".">
 
-    <property name="version" value="1.2.14"/>
-    <property name="reldate" value="Jun 20, 2007"/>
+    <property name="version" value="1.2.16"/>
+    <property name="reldate" value="Aug 2, 2007"/>
 
     <target name="usage">
         <echo>
diff --git a/examples/10883563.doc b/examples/10883563.doc
new file mode 100644 (file)
index 0000000..62644d9
--- /dev/null
@@ -0,0 +1,6 @@
+C:\tmp>ktpass /princ HTTP/www.foo.net@WIN.NET /ptype KRB5_NT_PRINCIPAL /desonly /pass asj7j112233hh4455 /mapuser test2\r
+Targeting domain controller: ts0.win.net\r
+Using legacy password setting method\r
+Successfully mapped HTTP/www.foo.net to test2.\r
+Key created.\r
+Account test2 has been set for DES-only encryption.
\ No newline at end of file
diff --git a/examples/AclCrawler.class b/examples/AclCrawler.class
new file mode 100644 (file)
index 0000000..c12c07a
Binary files /dev/null and b/examples/AclCrawler.class differ
diff --git a/examples/AllocInfo.class b/examples/AllocInfo.class
new file mode 100644 (file)
index 0000000..d052675
Binary files /dev/null and b/examples/AllocInfo.class differ
diff --git a/examples/Append.class b/examples/Append.class
new file mode 100644 (file)
index 0000000..584b1f0
Binary files /dev/null and b/examples/Append.class differ
diff --git a/examples/AuthListFiles.class b/examples/AuthListFiles.class
new file mode 100644 (file)
index 0000000..851ae58
Binary files /dev/null and b/examples/AuthListFiles.class differ
diff --git a/examples/CallNamedPipe.class b/examples/CallNamedPipe.class
new file mode 100644 (file)
index 0000000..1378730
Binary files /dev/null and b/examples/CallNamedPipe.class differ
diff --git a/examples/CifsTime.java b/examples/CifsTime.java
deleted file mode 100644 (file)
index 0331b17..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-import java.util.Date;
-import java.util.TimeZone;
-
-public class CifsTime {
-
-    // Observed dates reporting ServerTimeZone=240
-    // file last modified date = { low, high };
-
-    // Mon Mar 26 23:14:42 EST 2001 (no DST)
-    static final int[] D = { 0x10BE3D00, 0x01C0B66C };
-
-    // Mon Apr 30 03:17:14 EST 2001 (in DST)
-    //static final int[] D = { 0x9474B900, 0x01C0D145 };
-
-    static final long MILLISECONDS_BETWEEN_1970_AND_1601 = 11644473600000L;
-
-    static long calcDate() {
-        int lo, hi;
-        long t;
-
-        t = ((long)D[1] << 32 ) | ( (long)D[0] & 0xFFFFFFFFL );
-        t = ( t / 10000L - MILLISECONDS_BETWEEN_1970_AND_1601 );
-
-        if( TimeZone.getDefault().inDaylightTime( new Date() )) {
-            // in dst
-
-            if( TimeZone.getDefault().inDaylightTime( new Date( t ))) {
-                // t was also generated in dst too so no correction
-                return t;
-            }
-            // t was not generated during dst so add 1 hour
-            return t + 3600000L;
-        } else {
-            // not in dst
-
-            if( TimeZone.getDefault().inDaylightTime( new Date( t ))) {
-                // t was generated in dst so subtract 1 hour
-                return t - 3600000L;
-            }
-            // t was also not generated in dst so no correction
-            return t;
-        }
-    }
-    public static void main( String[] argv ) throws Exception {
-        System.out.println( new Date( calcDate() ));
-    }
-}
diff --git a/examples/CopyTo.class b/examples/CopyTo.class
new file mode 100644 (file)
index 0000000..1eec536
Binary files /dev/null and b/examples/CopyTo.class differ
diff --git a/examples/CountPerms.class b/examples/CountPerms.class
new file mode 100644 (file)
index 0000000..6632e6e
Binary files /dev/null and b/examples/CountPerms.class differ
diff --git a/examples/CreateFile.class b/examples/CreateFile.class
new file mode 100644 (file)
index 0000000..9ae7ab1
Binary files /dev/null and b/examples/CreateFile.class differ
diff --git a/examples/Delete.class b/examples/Delete.class
new file mode 100644 (file)
index 0000000..b52be49
Binary files /dev/null and b/examples/Delete.class differ
diff --git a/examples/Equals.class b/examples/Equals.class
new file mode 100644 (file)
index 0000000..d1ea38a
Binary files /dev/null and b/examples/Equals.class differ
diff --git a/examples/Exists.class b/examples/Exists.class
new file mode 100644 (file)
index 0000000..9f03ca4
Binary files /dev/null and b/examples/Exists.class differ
diff --git a/examples/FileInfo.class b/examples/FileInfo.class
new file mode 100644 (file)
index 0000000..fbdcf11
Binary files /dev/null and b/examples/FileInfo.class differ
diff --git a/examples/FileOps.class b/examples/FileOps.class
new file mode 100644 (file)
index 0000000..9a0e176
Binary files /dev/null and b/examples/FileOps.class differ
diff --git a/examples/FilterFiles$BigFileFilter.class b/examples/FilterFiles$BigFileFilter.class
new file mode 100644 (file)
index 0000000..1cd1710
Binary files /dev/null and b/examples/FilterFiles$BigFileFilter.class differ
diff --git a/examples/FilterFiles$ShortFilenameFilter.class b/examples/FilterFiles$ShortFilenameFilter.class
new file mode 100644 (file)
index 0000000..0b43d22
Binary files /dev/null and b/examples/FilterFiles$ShortFilenameFilter.class differ
diff --git a/examples/FilterFiles.class b/examples/FilterFiles.class
new file mode 100644 (file)
index 0000000..e8f82a5
Binary files /dev/null and b/examples/FilterFiles.class differ
diff --git a/examples/Format.class b/examples/Format.class
new file mode 100644 (file)
index 0000000..998801f
Binary files /dev/null and b/examples/Format.class differ
diff --git a/examples/Get.class b/examples/Get.class
new file mode 100644 (file)
index 0000000..8192c4a
Binary files /dev/null and b/examples/Get.class differ
diff --git a/examples/GetDate.class b/examples/GetDate.class
new file mode 100644 (file)
index 0000000..8a82eaa
Binary files /dev/null and b/examples/GetDate.class differ
diff --git a/examples/GetDfsPath.class b/examples/GetDfsPath.class
new file mode 100644 (file)
index 0000000..751b59a
Binary files /dev/null and b/examples/GetDfsPath.class differ
diff --git a/examples/GetGroupMemberSidsFromURL.class b/examples/GetGroupMemberSidsFromURL.class
new file mode 100644 (file)
index 0000000..5334b1f
Binary files /dev/null and b/examples/GetGroupMemberSidsFromURL.class differ
diff --git a/examples/GetGroupMemberSidsFromURL.java b/examples/GetGroupMemberSidsFromURL.java
new file mode 100644 (file)
index 0000000..4b6a5b6
--- /dev/null
@@ -0,0 +1,34 @@
+import java.util.*;
+import jcifs.smb.*;
+
+public class GetGroupMemberSidsFromURL {
+
+    public static void main( String[] argv ) throws Exception {
+        if (argv.length < 1) {
+            System.err.println("usage: GetGroupMemberSidsFromURL <smburl>");
+            System.exit(1);
+        }
+
+        SmbFile file = new SmbFile(argv[0]);
+        String server = file.getServer();
+        NtlmPasswordAuthentication auth = (NtlmPasswordAuthentication)file.getPrincipal();
+        ACE[] security = file.getSecurity(true);
+
+        for (int ai = 0; ai < security.length; ai++) {
+            ACE ace = security[ai];
+            SID sid = ace.getSID();
+            if (sid.equals(SID.EVERYONE) ||
+                        sid.equals(SID.CREATOR_OWNER) ||
+                        sid.equals(SID.SYSTEM))
+                continue;
+
+            System.out.println(sid.toString() + " (" + sid.toDisplayString() + ") members:");
+
+            SID[] mems = sid.getGroupMemberSids(server, auth, SID.SID_FLAG_RESOLVE_SIDS);
+            for (int mi = 0; mi < mems.length; mi++) {
+                SID mem = mems[mi];
+                System.out.println("  " + mem.getType() + " " + mem.toDisplayString());
+            }
+        }
+    }
+}
diff --git a/examples/GetSecurity.class b/examples/GetSecurity.class
new file mode 100644 (file)
index 0000000..0f1b2d2
Binary files /dev/null and b/examples/GetSecurity.class differ
diff --git a/examples/GetShareSecurity.class b/examples/GetShareSecurity.class
new file mode 100644 (file)
index 0000000..6d0f992
Binary files /dev/null and b/examples/GetShareSecurity.class differ
diff --git a/examples/GetType.class b/examples/GetType.class
new file mode 100644 (file)
index 0000000..1028177
Binary files /dev/null and b/examples/GetType.class differ
diff --git a/examples/GetURL.class b/examples/GetURL.class
new file mode 100644 (file)
index 0000000..e473c42
Binary files /dev/null and b/examples/GetURL.class differ
diff --git a/examples/GrowWrite.class b/examples/GrowWrite.class
new file mode 100644 (file)
index 0000000..2d0ecbb
Binary files /dev/null and b/examples/GrowWrite.class differ
diff --git a/examples/HttpURL.class b/examples/HttpURL.class
new file mode 100644 (file)
index 0000000..55faf3c
Binary files /dev/null and b/examples/HttpURL.class differ
diff --git a/examples/Interleave$IThread.class b/examples/Interleave$IThread.class
new file mode 100644 (file)
index 0000000..12d7d51
Binary files /dev/null and b/examples/Interleave$IThread.class differ
diff --git a/examples/Interleave.class b/examples/Interleave.class
new file mode 100644 (file)
index 0000000..4ea28d5
Binary files /dev/null and b/examples/Interleave.class differ
diff --git a/examples/InterruptTest.class b/examples/InterruptTest.class
new file mode 100644 (file)
index 0000000..8daf426
Binary files /dev/null and b/examples/InterruptTest.class differ
diff --git a/examples/IsDir.class b/examples/IsDir.class
new file mode 100644 (file)
index 0000000..712a60e
Binary files /dev/null and b/examples/IsDir.class differ
diff --git a/examples/LargeListFiles.class b/examples/LargeListFiles.class
new file mode 100644 (file)
index 0000000..83f6e76
Binary files /dev/null and b/examples/LargeListFiles.class differ
diff --git a/examples/Length.class b/examples/Length.class
new file mode 100644 (file)
index 0000000..b096ceb
Binary files /dev/null and b/examples/Length.class differ
diff --git a/examples/List.class b/examples/List.class
new file mode 100644 (file)
index 0000000..2d2e7b0
Binary files /dev/null and b/examples/List.class differ
diff --git a/examples/ListACL.class b/examples/ListACL.class
new file mode 100644 (file)
index 0000000..6c591f9
Binary files /dev/null and b/examples/ListACL.class differ
index 5db5783..cbc33da 100644 (file)
@@ -13,7 +13,7 @@ public class ListACL {
             System.out.println( acl[i] );
             SID sid = acl[i].getSID();
             System.out.println("      toString: " + sid.toString());
-            System.out.println("   toSidString: " + sid.toSidString());
+            System.out.println("   toSidString: " + sid.toDisplayString());
             System.out.println("       getType: " + sid.getType());
             System.out.println("   getTypeText: " + sid.getTypeText());
             System.out.println(" getDomainName: " + sid.getDomainName());
diff --git a/examples/ListFiles.class b/examples/ListFiles.class
new file mode 100644 (file)
index 0000000..190cd04
Binary files /dev/null and b/examples/ListFiles.class differ
diff --git a/examples/ListTypes.class b/examples/ListTypes.class
new file mode 100644 (file)
index 0000000..6da499c
Binary files /dev/null and b/examples/ListTypes.class differ
index 4eb71d0..820d0e8 100644 (file)
@@ -3,7 +3,7 @@ CLASSPATH=../build:.
 
 .SUFFIXES: .java .class
 
-CLASSFILES=SidCacheTest.class GetSecurity.class SidCrawler.class InterruptTest.class AllocInfo.class Append.class AuthListFiles.class CallNamedPipe.class CopyTo.class CreateFile.class Delete.class Equals.class Exists.class FileInfo.class FileOps.class FilterFiles.class Format.class GetDate.class GetDfsPath.class Get.class GetType.class GetURL.class GrowWrite.class HttpURL.class Interleave.class IsDir.class Length.class ListFiles.class List.class ListTypes.class Mkdir.class NodeStatus.class OpenExclusive.class PeekNamedPipe.class PipeTalk.class Put.class Query.class RenameTo.class SetAttrs.class SetTime.class SlowRead.class SlowWrite.class SmbCrawler.class SmbShell.class SmbTableFile.class SmbTableFileRecord.class T2Crawler.class TestRandomAccess.class TestSmbURL.class TestUnicode.class ThreadedNbtQuery.class ThreadedSmbCrawler.class ThreadedUniQuery.class Torture1.class Torture2.class TortureTest5.class TransactNamedPipe.class URLTest.class VerifyGuest.class VerifyIO.class VerifyReads.class
+CLASSFILES=GetGroupMemberSidsFromURL.class ListACL.class LargeListFiles.class GetShareSecurity.class CountPerms.class AclCrawler.class SidCacheTest.class GetSecurity.class SidCrawler.class InterruptTest.class AllocInfo.class Append.class AuthListFiles.class CallNamedPipe.class CopyTo.class CreateFile.class Delete.class Equals.class Exists.class FileInfo.class FileOps.class FilterFiles.class Format.class GetDate.class GetDfsPath.class Get.class GetType.class GetURL.class GrowWrite.class HttpURL.class Interleave.class IsDir.class Length.class ListFiles.class List.class ListTypes.class Mkdir.class NodeStatus.class OpenExclusive.class PeekNamedPipe.class PipeTalk.class Put.class Query.class RenameTo.class SetAttrs.class SetTime.class SlowRead.class SlowWrite.class SmbCrawler.class SmbShell.class SmbTableFile.class SmbTableFileRecord.class T2Crawler.class TestRandomAccess.class TestSmbURL.class TestUnicode.class ThreadedNbtQuery.class ThreadedSmbCrawler.class ThreadedUniQuery.class Torture1.class Torture2.class TortureTest5.class TransactNamedPipe.class URLTest.class VerifyGuest.class VerifyIO.class VerifyReads.class
 
 all: ${CLASSFILES}
 
diff --git a/examples/Mkdir.class b/examples/Mkdir.class
new file mode 100644 (file)
index 0000000..4c96536
Binary files /dev/null and b/examples/Mkdir.class differ
diff --git a/examples/NodeStatus.class b/examples/NodeStatus.class
new file mode 100644 (file)
index 0000000..12e8052
Binary files /dev/null and b/examples/NodeStatus.class differ
diff --git a/examples/OpenExclusive.class b/examples/OpenExclusive.class
new file mode 100644 (file)
index 0000000..1802220
Binary files /dev/null and b/examples/OpenExclusive.class differ
diff --git a/examples/PeekNamedPipe$ReceiverThread.class b/examples/PeekNamedPipe$ReceiverThread.class
new file mode 100644 (file)
index 0000000..642652c
Binary files /dev/null and b/examples/PeekNamedPipe$ReceiverThread.class differ
diff --git a/examples/PeekNamedPipe.class b/examples/PeekNamedPipe.class
new file mode 100644 (file)
index 0000000..dcbf77f
Binary files /dev/null and b/examples/PeekNamedPipe.class differ
diff --git a/examples/PipeTalk$ReceiverThread.class b/examples/PipeTalk$ReceiverThread.class
new file mode 100644 (file)
index 0000000..d05ca7a
Binary files /dev/null and b/examples/PipeTalk$ReceiverThread.class differ
diff --git a/examples/PipeTalk.class b/examples/PipeTalk.class
new file mode 100644 (file)
index 0000000..d297503
Binary files /dev/null and b/examples/PipeTalk.class differ
diff --git a/examples/Put.class b/examples/Put.class
new file mode 100644 (file)
index 0000000..43b1e70
Binary files /dev/null and b/examples/Put.class differ
diff --git a/examples/Query.class b/examples/Query.class
new file mode 100644 (file)
index 0000000..0112790
Binary files /dev/null and b/examples/Query.class differ
diff --git a/examples/RenameTo.class b/examples/RenameTo.class
new file mode 100644 (file)
index 0000000..c169e35
Binary files /dev/null and b/examples/RenameTo.class differ
diff --git a/examples/SetAttrs.class b/examples/SetAttrs.class
new file mode 100644 (file)
index 0000000..d36bada
Binary files /dev/null and b/examples/SetAttrs.class differ
diff --git a/examples/SetTime.class b/examples/SetTime.class
new file mode 100644 (file)
index 0000000..79b5e36
Binary files /dev/null and b/examples/SetTime.class differ
diff --git a/examples/SidCacheTest.class b/examples/SidCacheTest.class
new file mode 100644 (file)
index 0000000..fd2890b
Binary files /dev/null and b/examples/SidCacheTest.class differ
diff --git a/examples/SidCrawler.class b/examples/SidCrawler.class
new file mode 100644 (file)
index 0000000..ba712c5
Binary files /dev/null and b/examples/SidCrawler.class differ
diff --git a/examples/SidLookup.class b/examples/SidLookup.class
new file mode 100644 (file)
index 0000000..69d1103
Binary files /dev/null and b/examples/SidLookup.class differ
index 2c2a7bf..aa410eb 100644 (file)
@@ -11,7 +11,7 @@ public class SidLookup {
         SID sid = new SID(argv[0]);
         sid.resolve("ts0", null);
         System.out.println("      toString: " + sid.toString());
-        System.out.println("   toSidString: " + sid.toSidString());
+        System.out.println("   toSidString: " + sid.toDisplayString());
         System.out.println("       getType: " + sid.getType());
         System.out.println("   getTypeText: " + sid.getTypeText());
         System.out.println(" getDomainName: " + sid.getDomainName());
diff --git a/examples/SlowRead.class b/examples/SlowRead.class
new file mode 100644 (file)
index 0000000..de72174
Binary files /dev/null and b/examples/SlowRead.class differ
diff --git a/examples/SlowWrite.class b/examples/SlowWrite.class
new file mode 100644 (file)
index 0000000..84a1cff
Binary files /dev/null and b/examples/SlowWrite.class differ
diff --git a/examples/SmbCrawler.class b/examples/SmbCrawler.class
new file mode 100644 (file)
index 0000000..efdb5e3
Binary files /dev/null and b/examples/SmbCrawler.class differ
diff --git a/examples/SmbShell.class b/examples/SmbShell.class
new file mode 100644 (file)
index 0000000..b9096fa
Binary files /dev/null and b/examples/SmbShell.class differ
diff --git a/examples/SmbTableFile.class b/examples/SmbTableFile.class
new file mode 100644 (file)
index 0000000..c1bfe46
Binary files /dev/null and b/examples/SmbTableFile.class differ
diff --git a/examples/SmbTableFileRecord.class b/examples/SmbTableFileRecord.class
new file mode 100644 (file)
index 0000000..b5d68ff
Binary files /dev/null and b/examples/SmbTableFileRecord.class differ
diff --git a/examples/SmbThreadTest.class b/examples/SmbThreadTest.class
new file mode 100644 (file)
index 0000000..6acf867
Binary files /dev/null and b/examples/SmbThreadTest.class differ
diff --git a/examples/T2Crawler$CrawlerThread.class b/examples/T2Crawler$CrawlerThread.class
new file mode 100644 (file)
index 0000000..0b40e5c
Binary files /dev/null and b/examples/T2Crawler$CrawlerThread.class differ
diff --git a/examples/T2Crawler$Semaphore.class b/examples/T2Crawler$Semaphore.class
new file mode 100644 (file)
index 0000000..af3b771
Binary files /dev/null and b/examples/T2Crawler$Semaphore.class differ
diff --git a/examples/T2Crawler.class b/examples/T2Crawler.class
new file mode 100644 (file)
index 0000000..4176b41
Binary files /dev/null and b/examples/T2Crawler.class differ
diff --git a/examples/TestRandomAccess$TestRecord.class b/examples/TestRandomAccess$TestRecord.class
new file mode 100644 (file)
index 0000000..872eb31
Binary files /dev/null and b/examples/TestRandomAccess$TestRecord.class differ
diff --git a/examples/TestRandomAccess.class b/examples/TestRandomAccess.class
new file mode 100644 (file)
index 0000000..5fdf0df
Binary files /dev/null and b/examples/TestRandomAccess.class differ
diff --git a/examples/TestSmbURL.class b/examples/TestSmbURL.class
new file mode 100644 (file)
index 0000000..d73dd32
Binary files /dev/null and b/examples/TestSmbURL.class differ
diff --git a/examples/TestUnicode.class b/examples/TestUnicode.class
new file mode 100644 (file)
index 0000000..92304e8
Binary files /dev/null and b/examples/TestUnicode.class differ
diff --git a/examples/ThreadedNbtQuery$QThread.class b/examples/ThreadedNbtQuery$QThread.class
new file mode 100644 (file)
index 0000000..1259b6d
Binary files /dev/null and b/examples/ThreadedNbtQuery$QThread.class differ
diff --git a/examples/ThreadedNbtQuery.class b/examples/ThreadedNbtQuery.class
new file mode 100644 (file)
index 0000000..0d21e06
Binary files /dev/null and b/examples/ThreadedNbtQuery.class differ
diff --git a/examples/ThreadedSmbCrawler$DirEntry.class b/examples/ThreadedSmbCrawler$DirEntry.class
new file mode 100644 (file)
index 0000000..f849d93
Binary files /dev/null and b/examples/ThreadedSmbCrawler$DirEntry.class differ
diff --git a/examples/ThreadedSmbCrawler$SmbCrawlerThread.class b/examples/ThreadedSmbCrawler$SmbCrawlerThread.class
new file mode 100644 (file)
index 0000000..a95e988
Binary files /dev/null and b/examples/ThreadedSmbCrawler$SmbCrawlerThread.class differ
diff --git a/examples/ThreadedSmbCrawler.class b/examples/ThreadedSmbCrawler.class
new file mode 100644 (file)
index 0000000..e0747bf
Binary files /dev/null and b/examples/ThreadedSmbCrawler.class differ
diff --git a/examples/ThreadedUniQuery$QThread.class b/examples/ThreadedUniQuery$QThread.class
new file mode 100644 (file)
index 0000000..02d02e0
Binary files /dev/null and b/examples/ThreadedUniQuery$QThread.class differ
diff --git a/examples/ThreadedUniQuery.class b/examples/ThreadedUniQuery.class
new file mode 100644 (file)
index 0000000..08632f7
Binary files /dev/null and b/examples/ThreadedUniQuery.class differ
diff --git a/examples/Torture1.class b/examples/Torture1.class
new file mode 100644 (file)
index 0000000..72d5f77
Binary files /dev/null and b/examples/Torture1.class differ
diff --git a/examples/Torture2.class b/examples/Torture2.class
new file mode 100644 (file)
index 0000000..e688b4f
Binary files /dev/null and b/examples/Torture2.class differ
diff --git a/examples/TortureTest5.class b/examples/TortureTest5.class
new file mode 100644 (file)
index 0000000..cadf7c2
Binary files /dev/null and b/examples/TortureTest5.class differ
diff --git a/examples/TransactNamedPipe.class b/examples/TransactNamedPipe.class
new file mode 100644 (file)
index 0000000..faea615
Binary files /dev/null and b/examples/TransactNamedPipe.class differ
diff --git a/examples/URLTest.class b/examples/URLTest.class
new file mode 100644 (file)
index 0000000..5263435
Binary files /dev/null and b/examples/URLTest.class differ
diff --git a/examples/VerifyGuest.class b/examples/VerifyGuest.class
new file mode 100644 (file)
index 0000000..6a8ce08
Binary files /dev/null and b/examples/VerifyGuest.class differ
diff --git a/examples/VerifyIO.class b/examples/VerifyIO.class
new file mode 100644 (file)
index 0000000..1168477
Binary files /dev/null and b/examples/VerifyIO.class differ
diff --git a/examples/VerifyReads.class b/examples/VerifyReads.class
new file mode 100644 (file)
index 0000000..ff0d0a1
Binary files /dev/null and b/examples/VerifyReads.class differ
diff --git a/examples/Worker.class b/examples/Worker.class
new file mode 100644 (file)
index 0000000..25fa3b2
Binary files /dev/null and b/examples/Worker.class differ
index 80b3da7..84c1d10 100644 (file)
@@ -2,21 +2,29 @@
 
 JAVA_HOME=/usr/local/java
 CLASSPATH=../build:.
-PROPERTIES=../../miallen.prp
+PROPERTIES=../../user10.prp
 RUN="${JAVA_HOME}/bin/java -cp ${CLASSPATH} -Djcifs.properties=${PROPERTIES}"
 
-SERVER=ts0
+SERVER=dc1.w.net
 SHARE=tmp
 WRITE_DIR=test/
 SRC_DIR=test/Junk
 FILE1=test/Junk/10883563.doc
 
-URL_SHARE=smb://${SERVER}/${SHARE}/
+URL_SERVER=smb://${SERVER}/
+URL_SHARE=${URL_SERVER}${SHARE}/
 URL_WRITE_DIR=${URL_SHARE}${WRITE_DIR}
 
+[ "$1" = "ListACL" ] && $RUN ListACL ${URL_WRITE_DIR}
+[ "$1" = "LargeListFiles" ] && $RUN LargeListFiles ${URL_WRITE_DIR}
+[ "$1" = "CountPerms" ] && $RUN CountPerms ${URL_WRITE_DIR} 100
+[ "$1" = "AclCrawler" ] && $RUN AclCrawler ${URL_WRITE_DIR} 100
 [ "$1" = "SidCacheTest" ] && $RUN SidCacheTest ${URL_WRITE_DIR}
 [ "$1" = "GetSecurity" ] && $RUN GetSecurity ${URL_WRITE_DIR}
+[ "$1" = "GetSecurityS" ] && $RUN GetSecurity ${URL_SHARE}
+[ "$1" = "GetShareSecurity" ] && $RUN GetShareSecurity ${URL_WRITE_DIR}
 [ "$1" = "SidCrawler" ] && $RUN SidCrawler ${URL_WRITE_DIR} 5
+[ "$1" = "GetGroupMemberSidsFromURL" ] && $RUN GetGroupMemberSidsFromURL ${URL_WRITE_DIR}
 [ "$1" = "InterruptTest" ] && $RUN InterruptTest ${URL_WRITE_DIR}Append.txt
 [ "$1" = "AllocInfo" ] && $RUN AllocInfo ${URL_SHARE}
 [ "$1" = "Append" ] && $RUN Append ${URL_WRITE_DIR}Append.txt
@@ -39,6 +47,7 @@ URL_WRITE_DIR=${URL_SHARE}${WRITE_DIR}
 [ "$1" = "IsDir" ] && $RUN IsDir ${URL_SHARE}${SRC_DIR}/
 [ "$1" = "Length" ] && $RUN Length ${URL_SHARE}${FILE1}
 [ "$1" = "ListFiles" ] && $RUN ListFiles ${URL_WRITE_DIR}
+[ "$1" = "ListShares" ] && $RUN ListFiles ${URL_SERVER}
 [ "$1" = "List" ] && $RUN List ${URL_WRITE_DIR}
 [ "$1" = "ListTypes" ] && $RUN ListTypes ${URL_WRITE_DIR}
 [ "$1" = "Mkdir" ] && $RUN Mkdir ${URL_WRITE_DIR}Mkdir
index 235ded2..2353870 100644 (file)
@@ -2,23 +2,31 @@
 
 JAVA_HOME=/usr/local/java
 CLASSPATH=../build:.
-PROPERTIES=../../miallen.prp
+PROPERTIES=../../user10.prp
 RUN="${JAVA_HOME}/bin/java -cp ${CLASSPATH} -Djcifs.properties=${PROPERTIES}"
 
-SERVER=ts0
+SERVER=dc1.w.net
 SHARE=tmp
 WRITE_DIR=test/
 SRC_DIR=test/Junk
 FILE1=test/Junk/10883563.doc
 
-URL_SHARE=smb://${SERVER}/${SHARE}/
+URL_SERVER=smb://${SERVER}/
+URL_SHARE=${URL_SERVER}${SHARE}/
 URL_WRITE_DIR=${URL_SHARE}${WRITE_DIR}
 
 set -x
 
+$RUN ListACL ${URL_WRITE_DIR}
+$RUN LargeListFiles ${URL_WRITE_DIR}
+$RUN CountPerms ${URL_WRITE_DIR} 100
+$RUN AclCrawler ${URL_WRITE_DIR} 100
 $RUN SidCacheTest ${URL_WRITE_DIR}
 $RUN GetSecurity ${URL_WRITE_DIR}
+$RUN GetSecurity ${URL_SHARE}
+$RUN GetShareSecurity ${URL_WRITE_DIR}
 $RUN SidCrawler ${URL_WRITE_DIR} 5
+$RUN GetGroupMemberSidsFromURL ${URL_WRITE_DIR}
 $RUN InterruptTest ${URL_WRITE_DIR}Append.txt
 $RUN AllocInfo ${URL_SHARE}
 $RUN Append ${URL_WRITE_DIR}Append.txt
@@ -41,6 +49,7 @@ $RUN Interleave ${URL_WRITE_DIR} 3
 $RUN IsDir ${URL_SHARE}${SRC_DIR}/
 $RUN Length ${URL_SHARE}${FILE1}
 $RUN ListFiles ${URL_WRITE_DIR}
+$RUN ListFiles ${URL_SERVER}
 $RUN List ${URL_WRITE_DIR}
 $RUN ListTypes ${URL_WRITE_DIR}
 $RUN Mkdir ${URL_WRITE_DIR}Mkdir
index 1d341e4..063eea8 100644 (file)
@@ -242,6 +242,12 @@ public class UniAddress {
     public static UniAddress getByName( String hostname,
                                         boolean possibleNTDomainOrWorkgroup )
                                         throws UnknownHostException {
+        UniAddress[] addrs = UniAddress.getAllByName(hostname, possibleNTDomainOrWorkgroup);
+        return addrs[0];
+    }
+    public static UniAddress[] getAllByName( String hostname,
+                                        boolean possibleNTDomainOrWorkgroup )
+                                        throws UnknownHostException {
         Object addr;
         int i;
 
@@ -250,7 +256,9 @@ public class UniAddress {
         }
 
         if( isDotQuadIP( hostname )) {
-            return new UniAddress( NbtAddress.getByName( hostname ));
+            UniAddress[] addrs = new UniAddress[1];
+            addrs[0] = new UniAddress( NbtAddress.getByName( hostname ));
+            return addrs;
         }
 
         for( i = 0; i < resolveOrder.length; i++ ) {
@@ -288,12 +296,18 @@ public class UniAddress {
                         if( isAllDigits( hostname )) {
                             throw new UnknownHostException( hostname );
                         }
-                        addr = InetAddress.getByName( hostname );
-                        break;
+                        InetAddress[] iaddrs = InetAddress.getAllByName( hostname );
+                        UniAddress[] addrs = new UniAddress[iaddrs.length];
+                        for (int ii = 0; ii < iaddrs.length; ii++) {
+                            addrs[ii] = new UniAddress(iaddrs[ii]);
+                        }
+                        return addrs; // Success
                     default:
                         throw new UnknownHostException( hostname );
                 }
-                return new UniAddress( addr ); // Success
+                UniAddress[] addrs = new UniAddress[1];
+                addrs[0] = new UniAddress( addr );
+                return addrs; // Success
             } catch( IOException ioe ) {
                 // Failure
             }
index 449946f..193fd30 100644 (file)
@@ -106,7 +106,7 @@ public abstract class DcerpcHandle implements DcerpcConstants {
     protected int max_xmit = 4280;
     protected int max_recv = max_xmit;
     protected int state = 0;
-    private static int call_id = 0;
+    private static int call_id = 1;
 
     public static DcerpcHandle getHandle(String url,
                 NtlmPasswordAuthentication auth)
@@ -120,7 +120,7 @@ public abstract class DcerpcHandle implements DcerpcConstants {
     public void sendrecv(DcerpcMessage msg) throws DcerpcException, IOException {
         byte[] stub, frag;
         NdrBuffer buf, fbuf;
-        boolean isLast;
+        boolean isLast, isDirect;
         DcerpcException de;
 
         if (state == 0) {
@@ -129,6 +129,8 @@ public abstract class DcerpcHandle implements DcerpcConstants {
             sendrecv(bind);
         }
 
+        isDirect = msg instanceof DcerpcBind;
+
         stub = jcifs.smb.BufferCache.getBuffer();
         try {
             int off, tot, n;
@@ -159,11 +161,11 @@ public abstract class DcerpcHandle implements DcerpcConstants {
                     n = tot - off;
                 }
 
-                doSendFragment(stub, off, n);
+                doSendFragment(stub, off, n, isDirect);
                 off += n;
             }
 
-            doReceiveFragment(stub);
+            doReceiveFragment(stub, isDirect);
             buf.reset();
             msg.decode_header(buf);
 
@@ -181,7 +183,7 @@ public abstract class DcerpcHandle implements DcerpcConstants {
                     fbuf = new NdrBuffer(frag, 0);
                 }
 
-                doReceiveFragment(frag);
+                doReceiveFragment(frag, isDirect);
                 fbuf.reset();
                 msg.decode_header(fbuf);
                 stub_frag_len = msg.length - 24;
@@ -221,7 +223,10 @@ public abstract class DcerpcHandle implements DcerpcConstants {
         return binding.toString();
     }
 
-    protected abstract void doSendFragment(byte[] buf, int off, int length) throws IOException;
-    protected abstract void doReceiveFragment(byte[] buf) throws IOException;
+    protected abstract void doSendFragment(byte[] buf,
+                int off,
+                int length,
+                boolean isDirect) throws IOException;
+    protected abstract void doReceiveFragment(byte[] buf, boolean isDirect) throws IOException;
     public abstract void close() throws IOException;
 }
index 5f2b931..6be7f8c 100644 (file)
@@ -29,8 +29,8 @@ import jcifs.util.*;
 public class DcerpcPipeHandle extends DcerpcHandle {
 
     SmbNamedPipe pipe;
-    SmbFileInputStream in;
-    OutputStream out = null;
+    SmbFileInputStream in = null;
+    SmbFileOutputStream out = null;
     boolean isStart = true;
 
     public DcerpcPipeHandle(String url,
@@ -44,18 +44,27 @@ public class DcerpcPipeHandle extends DcerpcHandle {
                 auth);
     }
 
-    protected void doSendFragment(byte[] buf, int off, int length) throws IOException {
-        in = (SmbFileInputStream)pipe.getNamedPipeInputStream();
-        out = pipe.getNamedPipeOutputStream();
+    protected void doSendFragment(byte[] buf,
+                    int off,
+                    int length,
+                    boolean isDirect) throws IOException {
+        if (in == null)
+            in = (SmbFileInputStream)pipe.getNamedPipeInputStream();
+        if (out == null)
+            out = (SmbFileOutputStream)pipe.getNamedPipeOutputStream();
+        if (isDirect) {
+            out.writeDirect( buf, off, length, 1 );
+            return;
+        }
         out.write(buf, off, length);
     }
-    protected void doReceiveFragment(byte[] buf) throws IOException {
+    protected void doReceiveFragment(byte[] buf, boolean isDirect) throws IOException {
         int off, flags, length;
 
         if (buf.length < max_recv)
             throw new IllegalArgumentException("buffer too small");
 
-        if (isStart) { // start of new frag, do trans
+        if (isStart && !isDirect) { // start of new frag, do trans
             off = in.read(buf, 0, 1024);
         } else {
             off = in.readDirect(buf, 0, buf.length);
index 8f09e66..d82d635 100644 (file)
@@ -24,6 +24,12 @@ public class MsrpcLsarOpenPolicy2 extends lsarpc.LsarOpenPolicy2 {
     public MsrpcLsarOpenPolicy2(String server, int access, LsaPolicyHandle policyHandle) {
         super(server, new lsarpc.LsarObjectAttributes(), access, policyHandle);
         object_attributes.length = 24;
+lsarpc.LsarQosInfo qos = new lsarpc.LsarQosInfo();
+qos.length = 12;
+qos.impersonation_level = 2;
+qos.context_mode = 1;
+qos.effective_only = 0;
+object_attributes.security_quality_of_service = qos;
         ptype = 0;
         flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG;
     }
diff --git a/src/jcifs/dcerpc/msrpc/MsrpcSamrConnect2.java b/src/jcifs/dcerpc/msrpc/MsrpcSamrConnect2.java
new file mode 100644 (file)
index 0000000..3d2efc6
--- /dev/null
@@ -0,0 +1,28 @@
+/* jcifs msrpc client library in Java
+ * Copyright (C) 2007  "Michael B. Allen" <jcifs at samba dot org>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+package jcifs.dcerpc.msrpc;
+
+public class MsrpcSamrConnect2 extends samr.SamrConnect2 {
+
+    public MsrpcSamrConnect2(String server, int access, SamrPolicyHandle policyHandle) {
+        super(server, access, policyHandle);
+        ptype = 0;
+        flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG;
+    }
+}
index 040e872..3b4e5c6 100644 (file)
@@ -24,51 +24,13 @@ import jcifs.util.Hexdump;
 
 public class MsrpcShareEnum extends srvsvc.ShareEnumAll {
 
-    class MsrpcShareInfo1 implements FileEntry {
-
-        String netname;
-        int type;
-        String remark;
+    class MsrpcShareInfo1 extends SmbShareInfo {
 
         MsrpcShareInfo1(srvsvc.ShareInfo1 info1) {
-            this.netname = info1.netname;
+            this.netName = info1.netname;
             this.type = info1.type;
             this.remark = info1.remark;
         }
-
-        public String getName() {
-            return netname;
-        }
-        public int getType() {
-            /* 0x80000000 means hidden but SmbFile.isHidden() checks for $ at end
-             */
-            switch(type & 0xFFFF) {
-                case 1:
-                    return SmbFile.TYPE_PRINTER;
-                case 3:
-                    return SmbFile.TYPE_NAMED_PIPE;
-            }
-            return SmbFile.TYPE_SHARE;
-        }
-        public int getAttributes() {
-            return SmbFile.ATTR_READONLY | SmbFile.ATTR_DIRECTORY;
-        }
-        public long createTime() {
-            return 0L;
-        }
-        public long lastModified() {
-            return 0L;
-        }
-        public long length() {
-            return 0L;
-        }
-
-        public String toString() {
-            return new String( "MsrpcShareInfo1[" +
-                    "netName=" + netname +
-                    ",type=0x" + Hexdump.toHexString( type, 8 ) +
-                    ",remark=" + remark + "]" );
-        }
     }
 
     public MsrpcShareEnum(String server) {
index a0e0b4e..666b052 100644 (file)
@@ -28,7 +28,15 @@ public class SamrPolicyHandle extends rpc.policy_handle {
         if (server == null)
             server = "\\\\";
         MsrpcSamrConnect4 rpc = new MsrpcSamrConnect4(server, access, this);
-        handle.sendrecv(rpc);
+        try {
+            handle.sendrecv(rpc);
+        } catch (DcerpcException de) {
+            if (de.getErrorCode() != DcerpcError.DCERPC_FAULT_OP_RNG_ERROR)
+                throw de;
+
+            MsrpcSamrConnect2 rpc2 = new MsrpcSamrConnect2(server, access, this);
+            handle.sendrecv(rpc2);
+        }
     }
 
     public void close() throws IOException {
index 065950f..9204327 100644 (file)
@@ -10,6 +10,11 @@ interface samr
        [op(0x01)]
        int SamrCloseHandle([in] policy_handle *handle);
 
+       [op(0x39)]
+       int SamrConnect2([in,string,unique] wchar_t *system_name,
+                       [in] uint32_t access_mask,
+                       [out] policy_handle *handle);
+
        [op(0x3e)]
        int SamrConnect4([in,string,unique] wchar_t *system_name,
                        [in] uint32_t unknown,
index 7b355db..99fd5fe 100644 (file)
@@ -27,6 +27,34 @@ public class samr {
             retval = (int)_src.dec_ndr_long();
         }
     }
+    public static class SamrConnect2 extends DcerpcMessage {
+
+        public int getOpnum() { return 0x39; }
+
+        public int retval;
+        public String system_name;
+        public int access_mask;
+        public rpc.policy_handle handle;
+
+        public SamrConnect2(String system_name, int access_mask, rpc.policy_handle handle) {
+            this.system_name = system_name;
+            this.access_mask = access_mask;
+            this.handle = handle;
+        }
+
+        public void encode_in(NdrBuffer _dst) throws NdrException {
+            _dst.enc_ndr_referent(system_name, 1);
+            if (system_name != null) {
+                _dst.enc_ndr_string(system_name);
+
+            }
+            _dst.enc_ndr_long(access_mask);
+        }
+        public void decode_out(NdrBuffer _src) throws NdrException {
+            handle.decode(_src);
+            retval = (int)_src.dec_ndr_long();
+        }
+    }
     public static class SamrConnect4 extends DcerpcMessage {
 
         public int getOpnum() { return 0x3e; }
diff --git a/src/jcifs/smb/.SmbConstants.java.swp b/src/jcifs/smb/.SmbConstants.java.swp
new file mode 100644 (file)
index 0000000..c8e2999
Binary files /dev/null and b/src/jcifs/smb/.SmbConstants.java.swp differ
index 07287f1..6f28953 100644 (file)
@@ -120,8 +120,10 @@ abstract class AndXServerMessageBlock extends ServerMessageBlock {
 
             dst[start + ANDX_COMMAND_OFFSET] = (byte)0xFF;
             dst[start + ANDX_RESERVED_OFFSET] = (byte)0x00;
-            dst[start + ANDX_OFFSET_OFFSET] = (byte)0x00;
-            dst[start + ANDX_OFFSET_OFFSET + 1] = (byte)0x00;
+//            dst[start + ANDX_OFFSET_OFFSET] = (byte)0x00;
+//            dst[start + ANDX_OFFSET_OFFSET + 1] = (byte)0x00;
+            dst[start + ANDX_OFFSET_OFFSET] = (byte)0xde;
+            dst[start + ANDX_OFFSET_OFFSET + 1] = (byte)0xde;
 
             // andx not used; return
             return dstIndex - start;
@@ -183,6 +185,8 @@ abstract class AndXServerMessageBlock extends ServerMessageBlock {
         int start = bufferIndex;
 
         wordCount = buffer[bufferIndex++];
+if (command == SMB_COM_NT_CREATE_ANDX)
+    wordCount = 42;
 
         if( wordCount != 0 ) {
             /*
@@ -204,6 +208,12 @@ abstract class AndXServerMessageBlock extends ServerMessageBlock {
  
             if( wordCount > 2 ) {
                 bufferIndex += readParameterWordsWireFormat( buffer, bufferIndex );
+/* required for signing verification
+ */
+if (command == SMB_COM_NT_CREATE_ANDX) {
+    if (((SmbComNTCreateAndXResponse)this).isExtended)
+        bufferIndex += 32;
+}
             }
         }
 
index 23c5ed4..004ed45 100644 (file)
@@ -24,44 +24,6 @@ import jcifs.util.Hexdump;
 
 class NetShareEnumResponse extends SmbComTransactionResponse {
 
-    class ShareInfo1 implements FileEntry {
-        String netName;
-        int type;
-        String remark;
-
-        public String getName() {
-            return netName;
-        }
-        public int getType() {
-            switch( type ) {
-                case 1:
-                    return SmbFile.TYPE_PRINTER;
-                case 3:
-                    return SmbFile.TYPE_NAMED_PIPE;
-            }
-            return SmbFile.TYPE_SHARE;
-        }
-        public int getAttributes() {
-            return SmbFile.ATTR_READONLY | SmbFile.ATTR_DIRECTORY;
-        }
-        public long createTime() {
-            return 0L;
-        }
-        public long lastModified() {
-            return 0L;
-        }
-        public long length() {
-            return 0L;
-        }
-
-        public String toString() {
-            return new String( "ShareInfo1[" +
-                    "netName=" + netName +
-                    ",type=0x" + Hexdump.toHexString( type, 4 ) +
-                    ",remark=" + remark + "]" );
-        }
-    }
-
     private int converter, totalAvailableEntries;
 
     NetShareEnumResponse() {
@@ -95,13 +57,13 @@ class NetShareEnumResponse extends SmbComTransactionResponse {
     }
     int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) {
         int start = bufferIndex;
-        ShareInfo1 e;
+        SmbShareInfo e;
 
         useUnicode = false;
 
-        results = new ShareInfo1[numEntries];
+        results = new SmbShareInfo[numEntries];
         for( int i = 0; i < numEntries; i++ ) {
-            results[i] = e = new ShareInfo1();
+            results[i] = e = new SmbShareInfo();
             e.netName = readString( buffer, bufferIndex, 13, false );
             bufferIndex += 14;
             e.type = readInt2( buffer, bufferIndex );
index f3da6f6..1df7e48 100644 (file)
@@ -33,17 +33,20 @@ public interface NtStatus {
     public static final int NT_STATUS_INVALID_PARAMETER = 0xC000000d;
     public static final int NT_STATUS_NO_SUCH_DEVICE = 0xC000000e;
     public static final int NT_STATUS_NO_SUCH_FILE = 0xC000000f;
+    public static final int NT_STATUS_MORE_PROCESSING_REQUIRED = 0xC0000016;
     public static final int NT_STATUS_ACCESS_DENIED = 0xC0000022;
     public static final int NT_STATUS_BUFFER_TOO_SMALL = 0xC0000023;
     public static final int NT_STATUS_OBJECT_NAME_INVALID = 0xC0000033;
     public static final int NT_STATUS_OBJECT_NAME_NOT_FOUND = 0xC0000034;
     public static final int NT_STATUS_OBJECT_NAME_COLLISION = 0xC0000035;
     public static final int NT_STATUS_PORT_DISCONNECTED = 0xC0000037;
+    public static final int NT_STATUS_OBJECT_PATH_INVALID = 0xC0000039;
     public static final int NT_STATUS_OBJECT_PATH_NOT_FOUND = 0xC000003a;
     public static final int NT_STATUS_OBJECT_PATH_SYNTAX_BAD = 0xC000003b;
     public static final int NT_STATUS_SHARING_VIOLATION = 0xC0000043;
     public static final int NT_STATUS_DELETE_PENDING = 0xC0000056;
     public static final int NT_STATUS_NO_LOGON_SERVERS = 0xC000005e;
+    public static final int NT_STATUS_USER_EXISTS = 0xC0000063;
     public static final int NT_STATUS_NO_SUCH_USER = 0xC0000064;
     public static final int NT_STATUS_WRONG_PASSWORD = 0xC000006a;
     public static final int NT_STATUS_LOGON_FAILURE = 0xC000006d;
@@ -72,6 +75,7 @@ public interface NtStatus {
     public static final int NT_STATUS_NOT_A_DIRECTORY = 0xC0000103;
     public static final int NT_STATUS_CANNOT_DELETE = 0xC0000121;
     public static final int NT_STATUS_PIPE_BROKEN = 0xC000014b;
+    public static final int NT_STATUS_NO_SUCH_ALIAS = 0xC0000151;
     public static final int NT_STATUS_LOGON_TYPE_NOT_GRANTED = 0xC000015b;
     public static final int NT_STATUS_TRUSTED_DOMAIN_FAILURE = 0xC000018c;
     public static final int NT_STATUS_PASSWORD_MUST_CHANGE = 0xC0000224;
@@ -89,17 +93,20 @@ public interface NtStatus {
         NT_STATUS_INVALID_PARAMETER,
         NT_STATUS_NO_SUCH_DEVICE,
         NT_STATUS_NO_SUCH_FILE,
+        NT_STATUS_MORE_PROCESSING_REQUIRED,
         NT_STATUS_ACCESS_DENIED,
         NT_STATUS_BUFFER_TOO_SMALL,
         NT_STATUS_OBJECT_NAME_INVALID,
         NT_STATUS_OBJECT_NAME_NOT_FOUND,
         NT_STATUS_OBJECT_NAME_COLLISION,
         NT_STATUS_PORT_DISCONNECTED,
+        NT_STATUS_OBJECT_PATH_INVALID,
         NT_STATUS_OBJECT_PATH_NOT_FOUND,
         NT_STATUS_OBJECT_PATH_SYNTAX_BAD,
         NT_STATUS_SHARING_VIOLATION,
         NT_STATUS_DELETE_PENDING,
         NT_STATUS_NO_LOGON_SERVERS,
+        NT_STATUS_USER_EXISTS,
         NT_STATUS_NO_SUCH_USER,
         NT_STATUS_WRONG_PASSWORD,
         NT_STATUS_LOGON_FAILURE,
@@ -128,6 +135,7 @@ public interface NtStatus {
         NT_STATUS_NOT_A_DIRECTORY,
         NT_STATUS_CANNOT_DELETE,
         NT_STATUS_PIPE_BROKEN,
+        NT_STATUS_NO_SUCH_ALIAS,
         NT_STATUS_LOGON_TYPE_NOT_GRANTED,
         NT_STATUS_TRUSTED_DOMAIN_FAILURE,
         NT_STATUS_PASSWORD_MUST_CHANGE,
@@ -146,17 +154,20 @@ public interface NtStatus {
         "The parameter is incorrect.",
         "The system cannot find the file specified.",
         "The system cannot find the file specified.",
+        "More data is available.",
         "Access is denied.",
         "The data area passed to a system call is too small.",
         "The filename, directory name, or volume label syntax is incorrect.",
         "The system cannot find the file specified.",
         "Cannot create a file when that file already exists.",
         "The handle is invalid.",
+        "The specified path is invalid.",
         "The system cannot find the path specified.",
         "The specified path is invalid.",
         "The process cannot access the file because it is being used by another process.",
         "Access is denied.",
         "There are currently no logon servers available to service the logon request.",
+        "The specified user already exists.",
         "The specified user does not exist.",
         "The specified network password is not correct.",
         "Logon failure: unknown user name or bad password.",
@@ -185,6 +196,7 @@ public interface NtStatus {
         "The directory name is invalid.",
         "Access is denied.",
         "The pipe has been ended.",
+        "The specified local group does not exist.",
         "Logon failure: the user has not been granted the requested logon type at this computer.",
         "The trust relationship between the primary domain and the trusted domain failed.",
         "The user must change his password before he logs on the first time.",
index e550fe0..73c26e9 100644 (file)
@@ -25,10 +25,7 @@ import java.security.Principal;
 import java.util.Random;
 import java.util.Arrays;
 import jcifs.Config;
-import jcifs.util.LogStream;
-import jcifs.util.DES;
-import jcifs.util.MD4;
-import jcifs.util.HMACT64;
+import jcifs.util.*;
 
 /**
  * This class stores and encrypts NTLM user credentials. The default
index 3102e93..5b98f31 100644 (file)
@@ -70,6 +70,19 @@ public class SID extends rpc.sid_t {
 
     public static final int SID_FLAG_RESOLVE_SIDS = 0x0001;
 
+    public static SID EVERYONE = null;
+    public static SID CREATOR_OWNER = null;
+    public static SID SYSTEM = null;
+
+    static {
+        try {
+            EVERYONE = new SID("S-1-1-0");
+            CREATOR_OWNER = new SID("S-1-3-0");
+            SYSTEM = new SID("S-1-5-18");
+        } catch (SmbException se) {
+        }
+    }
+
     static Map sid_cache = Collections.synchronizedMap(new HashMap());
 
     static void resolveSids(DcerpcHandle handle,
@@ -116,7 +129,11 @@ public class SID extends rpc.sid_t {
         try {
             handle = DcerpcHandle.getHandle("ncacn_np:" + authorityServerName +
                     "[\\PIPE\\lsarpc]", auth);
-            policyHandle = new LsaPolicyHandle(handle, null, 0x00000800);
+            String server = authorityServerName;
+            int dot = server.indexOf('.');
+            if (dot > 0 && Character.isDigit(server.charAt(0)) == false)
+                server = server.substring(0, dot);
+            policyHandle = new LsaPolicyHandle(handle, "\\\\" + server, 0x00000800);
             SID.resolveSids(handle, policyHandle, sids);
         } finally {
             if (handle != null) {
@@ -505,7 +522,7 @@ public class SID extends rpc.sid_t {
         MsrpcGetMembersInAlias rpc = null;
 
         try {
-            aliasHandle = new SamrAliasHandle(handle, domainHandle, 0x02000000, rid);
+            aliasHandle = new SamrAliasHandle(handle, domainHandle, 0x0002000c, rid);
             rpc = new MsrpcGetMembersInAlias(aliasHandle, sidarray);
             handle.sendrecv(rpc);
             if (rpc.retval != 0)
@@ -539,6 +556,9 @@ public class SID extends rpc.sid_t {
     public SID[] getGroupMemberSids(String authorityServerName,
                     NtlmPasswordAuthentication auth,
                     int flags) throws IOException {
+        if (type != SID_TYPE_DOM_GRP && type != SID_TYPE_ALIAS)
+            return new SID[0];
+
         DcerpcHandle handle = null;
         SamrPolicyHandle policyHandle = null;
         SamrDomainHandle domainHandle = null;
@@ -547,8 +567,8 @@ public class SID extends rpc.sid_t {
         try {
             handle = DcerpcHandle.getHandle("ncacn_np:" + authorityServerName +
                     "[\\PIPE\\samr]", auth);
-            policyHandle = new SamrPolicyHandle(handle, authorityServerName, 0x02000000);
-            domainHandle = new SamrDomainHandle(handle, policyHandle, 0x02000000, domsid);
+            policyHandle = new SamrPolicyHandle(handle, authorityServerName, 0x00000030);
+            domainHandle = new SamrDomainHandle(handle, policyHandle, 0x00000200, domsid);
             return SID.getGroupMemberSids0(handle,
                         domainHandle,
                         domsid,
index 83e6550..875dc08 100644 (file)
@@ -196,6 +196,7 @@ abstract class ServerMessageBlock extends Response implements Request, SmbConsta
         flags2 = 0;
         errorCode = 0;
         received = false;
+        digest = null;
     }
     int writeString( String str, byte[] dst, int dstIndex ) {
         return writeString( str, dst, dstIndex, useUnicode );
index 1fdee9b..2c7c7bc 100644 (file)
@@ -58,14 +58,14 @@ public class SigningDigest {
         } catch( Exception ex ) {
             throw new SmbException( "", ex );
         }
-        if( log.level >= 4 ) {
+        if( log.level >= 5 ) {
             log.println( "LM_COMPATIBILITY=" + LM_COMPATIBILITY );
             Hexdump.hexdump( log, macSigningKey, 0, macSigningKey.length );
         }
     }
 
     public void update( byte[] input, int offset, int len ) {
-        if( log.level >= 4 ) {
+        if( log.level >= 5 ) {
             log.println( "update: " + updates + " " + offset + ":" + len );
             Hexdump.hexdump( log, input, offset, Math.min( len, 256 ));
             log.flush();
@@ -81,7 +81,7 @@ public class SigningDigest {
 
         b = digest.digest();
 
-        if( log.level >= 4 ) {
+        if( log.level >= 5 ) {
             log.println( "digest: " );
             Hexdump.hexdump( log, b, 0, b.length );
             log.flush();
@@ -166,5 +166,8 @@ public class SigningDigest {
 
         return response.verifyFailed = false;
     }
+    public String toString() {
+        return "LM_COMPATIBILITY=" + LM_COMPATIBILITY + " MacSigningKey=" + Hexdump.toHexString(macSigningKey, 0, macSigningKey.length);
+    }
 }
 
index 7c219fe..7bb0eb5 100644 (file)
@@ -72,9 +72,7 @@ class SmbComNTCreateAndX extends AndXServerMessageBlock {
     static final int SECURITY_CONTEXT_TRACKING = 0x01;
     static final int SECURITY_EFFECTIVE_ONLY   = 0x02;
 
-    private int flags,
-        rootDirectoryFid,
-        desiredAccess,
+    private int rootDirectoryFid,
         extFileAttributes,
         shareAccess,
         createDisposition,
@@ -84,6 +82,8 @@ class SmbComNTCreateAndX extends AndXServerMessageBlock {
     private byte securityFlags;
     private int namelen_index;
 
+int flags0, desiredAccess;
+
     SmbComNTCreateAndX( String name, int flags,
                 int access,
                 int shareAccess,
@@ -143,7 +143,7 @@ class SmbComNTCreateAndX extends AndXServerMessageBlock {
         // name length without counting null termination
         namelen_index = dstIndex;
         dstIndex += 2;
-        writeInt4( flags, dst, dstIndex );
+        writeInt4( flags0, dst, dstIndex );
         dstIndex += 4;
         writeInt4( rootDirectoryFid, dst, dstIndex );
         dstIndex += 4;
@@ -180,7 +180,7 @@ class SmbComNTCreateAndX extends AndXServerMessageBlock {
     public String toString() {
         return new String( "SmbComNTCreateAndX[" +
             super.toString() +
-            ",flags=0x" + Hexdump.toHexString( flags, 2 ) +
+            ",flags=0x" + Hexdump.toHexString( flags0, 2 ) +
             ",rootDirectoryFid=" + rootDirectoryFid +
             ",desiredAccess=0x" + Hexdump.toHexString( desiredAccess, 4 ) +
             ",allocationSize=" + allocationSize +
index e030512..ccdcf36 100644 (file)
@@ -40,6 +40,7 @@ class SmbComNTCreateAndXResponse extends AndXServerMessageBlock {
         allocationSize,
         endOfFile;
     boolean directory;
+boolean isExtended;
 
     SmbComNTCreateAndXResponse() {
     }
index 46176c6..6e3506b 100644 (file)
@@ -26,10 +26,8 @@ class SmbComReadAndX extends AndXServerMessageBlock {
 
     private long offset;
     private int fid,
-        maxCount,
-        minCount,
-        openTimeout,
-        remaining;
+        openTimeout;
+int maxCount, minCount, remaining;
 
     SmbComReadAndX() {
         super( null );
index 10f194c..91dd3b1 100644 (file)
@@ -194,7 +194,8 @@ abstract class SmbComTransaction extends ServerMessageBlock implements Enumerati
         }
         writeInt2( parameterCount, dst, dstIndex );
         dstIndex += 2;
-        writeInt2(( parameterCount == 0 ? 0 : parameterOffset ), dst, dstIndex );
+//        writeInt2(( parameterCount == 0 ? 0 : parameterOffset ), dst, dstIndex );
+        writeInt2(parameterOffset, dst, dstIndex );
         dstIndex += 2;
         if( command == SMB_COM_TRANSACTION_SECONDARY ) {
             writeInt2( parameterDisplacement, dst, dstIndex );
index 9042957..edaf55f 100644 (file)
@@ -19,6 +19,7 @@
 package jcifs.smb;
 
 import jcifs.Config;
+import jcifs.util.*;
 
 class SmbComWriteAndX extends AndXServerMessageBlock {
 
@@ -28,7 +29,6 @@ class SmbComWriteAndX extends AndXServerMessageBlock {
                             Config.getInt( "jcifs.smb.client.WriteAndX.Close", 1 );
 
     private int fid,
-        writeMode,
         remaining,
         dataLength,
         dataOffset,
@@ -36,6 +36,10 @@ class SmbComWriteAndX extends AndXServerMessageBlock {
     private byte[] b;
     private long offset;
 
+private int pad;
+
+    int writeMode;
+
     SmbComWriteAndX() {
         super( null );
         command = SMB_COM_WRITE_ANDX;
@@ -77,18 +81,17 @@ class SmbComWriteAndX extends AndXServerMessageBlock {
         int start = dstIndex;
 
         dataOffset = (dstIndex - headerStart) + 26; // 26 = off from here to pad
-/*
- *      pad = ( dataOffset - headerStart ) % 4;
- *      pad = pad == 0 ? 0 : 4 - pad;
- *      dataOffset += pad;
- */
+
+pad = ( dataOffset - headerStart ) % 4;
+pad = pad == 0 ? 0 : 4 - pad;
+dataOffset += pad;
 
         writeInt2( fid, dst, dstIndex );
         dstIndex += 2;
         writeInt4( offset, dst, dstIndex );
         dstIndex += 4;
         for( int i = 0; i < 4; i++ ) {
-            dst[dstIndex++] = (byte)0x00;
+            dst[dstIndex++] = (byte)0xFF;
         }
         writeInt2( writeMode, dst, dstIndex );
         dstIndex += 2;
@@ -108,11 +111,9 @@ class SmbComWriteAndX extends AndXServerMessageBlock {
     int writeBytesWireFormat( byte[] dst, int dstIndex ) {
         int start = dstIndex;
 
-/* Netware doesn't like this
- *      while( pad-- > 0 ) {
- *          dst[dstIndex++] = (byte)0x00;
- *      }
- */
+while( pad-- > 0 ) {
+    dst[dstIndex++] = (byte)0xEE;
+}
         System.arraycopy( b, off, dst, dstIndex, dataLength );
         dstIndex += dataLength;
 
index ec5a9d7..8cde3a4 100644 (file)
@@ -26,6 +26,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
 import java.security.Principal;
 import jcifs.Config;
 import jcifs.util.LogStream;
@@ -732,7 +734,17 @@ public class SmbFile extends URLConnection implements SmbConstants {
         return null;
     }
 
+UniAddress[] addresses;
+int addressIndex;
+
     UniAddress getAddress() throws UnknownHostException {
+        if (addressIndex == 0)
+            return getFirstAddress();
+        return addresses[addressIndex - 1];
+    }
+    UniAddress getFirstAddress() throws UnknownHostException {
+        addressIndex = 0;
+
         String host = url.getHost();
         String path = url.getPath();
         String query = url.getQuery();
@@ -740,27 +752,41 @@ public class SmbFile extends URLConnection implements SmbConstants {
         if( query != null ) {
             String server = queryLookup( query, "server" );
             if( server != null && server.length() > 0 ) {
-                return UniAddress.getByName( server );
+                addresses = new UniAddress[1];
+                addresses[0] = UniAddress.getByName( server );
+                return getNextAddress();
             }
         }
 
-        if( host.length() == 0 ) {
+        if (host.length() == 0) {
             try {
                 NbtAddress addr = NbtAddress.getByName(
                         NbtAddress.MASTER_BROWSER_NAME, 0x01, null);
-                return UniAddress.getByName( addr.getHostAddress() );
+                addresses = new UniAddress[1];
+                addresses[0] = UniAddress.getByName( addr.getHostAddress() );
             } catch( UnknownHostException uhe ) {
                 NtlmPasswordAuthentication.initDefaults();
                 if( NtlmPasswordAuthentication.DEFAULT_DOMAIN.equals( "?" )) {
                     throw uhe;
                 }
-                return UniAddress.getByName( NtlmPasswordAuthentication.DEFAULT_DOMAIN, true );
+                addresses = UniAddress.getAllByName( NtlmPasswordAuthentication.DEFAULT_DOMAIN, true );
             }
         } else if( path.length() == 0 || path.equals( "/" )) {
-            return UniAddress.getByName( host, true );
+            addresses = UniAddress.getAllByName( host, true );
         } else {
-            return UniAddress.getByName( host );
+            addresses = UniAddress.getAllByName(host, false);
         }
+
+        return getNextAddress();
+    }
+    UniAddress getNextAddress() {
+        UniAddress addr = null;
+        if (addressIndex < addresses.length)
+            addr = addresses[addressIndex++];
+        return addr;
+    }
+    boolean hasNextAddress() {
+        return addressIndex < addresses.length;
     }
     void connect0() throws SmbException {
         try {
@@ -773,6 +799,41 @@ public class SmbFile extends URLConnection implements SmbConstants {
             throw new SmbException( "Failed to connect to server", ioe );
         }
     }
+    void doConnect() throws IOException {
+        SmbTransport trans;
+        SmbSession ssn;
+        UniAddress addr;
+
+        addr = getAddress();
+        trans = SmbTransport.getSmbTransport(addr, url.getPort());
+        ssn = trans.getSmbSession(auth);
+        tree = ssn.getSmbTree(share, null);
+
+        try {
+            if( log.level >= 3 )
+                log.println( "doConnect: " + addr );
+
+            tree.treeConnect(null, null);
+        } catch (SmbAuthException sae) {
+            NtlmPasswordAuthentication a;
+
+            if (share == null) { // IPC$ - try "anonymous" credentials
+                ssn = trans.getSmbSession(NtlmPasswordAuthentication.NULL);
+                tree = ssn.getSmbTree(null, null);
+                tree.treeConnect(null, null);
+            } else if ((a = NtlmAuthenticator.requestNtlmPasswordAuthentication(
+                        url.toString(), sae)) != null) {
+                auth = a;
+                ssn = trans.getSmbSession(auth);
+                tree = ssn.getSmbTree(share, null);
+                tree.treeConnect(null, null);
+            } else {
+                if (log.level >= 1 && hasNextAddress())
+                    sae.printStackTrace(log);
+                throw sae;
+            }
+        }
+    }
 /**
  * It is not necessary to call this method directly. This is the
  * <tt>URLConnection</tt> implementation of <tt>connect()</tt>.
@@ -787,34 +848,21 @@ public class SmbFile extends URLConnection implements SmbConstants {
         }
 
         getUncPath0();
-        addr = getAddress();
-
-        trans = SmbTransport.getSmbTransport( addr, url.getPort() );
-        ssn = trans.getSmbSession( auth );
-        tree = ssn.getSmbTree( share, null );
-
-        try {
-            tree.treeConnect( null, null );
-        } catch( SmbAuthException sae ) {
-            NtlmPasswordAuthentication a;
-
-            if( share == null ) { // IPC$ - try "anonymous" credentials
-                ssn = trans.getSmbSession( NtlmPasswordAuthentication.NULL );
-                tree = ssn.getSmbTree( null, null );
-                tree.treeConnect( null, null );
-            } else if(( a = NtlmAuthenticator.requestNtlmPasswordAuthentication(
-                        url.toString(), sae )) != null ) {
-                auth = a;
-                ssn = trans.getSmbSession( auth );
-                tree = ssn.getSmbTree( share, null );
-                tree.treeConnect( null, null );
-            } else {
-                throw sae;
+        getFirstAddress();
+        for ( ;; ) {
+            try {
+                doConnect();
+                return;
+            } catch(SmbException se) {
+                if (getNextAddress() == null) 
+                    throw se;
+                if (log.level >= 3)
+                    se.printStackTrace(log);
             }
         }
     }
     boolean isConnected() {
-        return (connected = tree != null && tree.treeConnected);
+        return tree != null && tree.treeConnected;
     }
     int open0( int flags, int access, int attrs, int options ) throws SmbException {
         int f;
@@ -830,8 +878,17 @@ public class SmbFile extends URLConnection implements SmbConstants {
 
         if( tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS )) {
             SmbComNTCreateAndXResponse response = new SmbComNTCreateAndXResponse();
-            send( new SmbComNTCreateAndX( unc, flags, access, shareAccess,
-                    attrs, options, null ), response );
+SmbComNTCreateAndX request = new SmbComNTCreateAndX( unc, flags, access, shareAccess, attrs, options, null );
+if (this instanceof SmbNamedPipe) {
+    request.flags0 |= 0x16;
+    request.desiredAccess |= 0x20000;
+    response.isExtended = true;
+}
+try {
+            send( request, response );
+} catch( Exception e) {
+    e.printStackTrace();
+}
             f = response.fid;
             attributes = response.extFileAttributes & ATTR_GET_MASK;
             attrExpiration = System.currentTimeMillis() + attrExpirationPeriod;
@@ -853,7 +910,8 @@ public class SmbFile extends URLConnection implements SmbConstants {
         tree_num = tree.tree_num;
     }
     boolean isOpen() {
-        return opened && isConnected() && tree_num == tree.tree_num;
+        boolean ans =  opened && isConnected() && tree_num == tree.tree_num;
+        return ans;
     }
     void close( int f, long lastWriteTime ) throws SmbException {
 
@@ -1148,7 +1206,7 @@ public class SmbFile extends URLConnection implements SmbConstants {
                 } else {
                     type = TYPE_SHARE;
                 }
-            } else if( url.getAuthority().length() == 0 ) {
+            } else if( url.getAuthority() == null || url.getAuthority().length() == 0 ) {
                 type = TYPE_WORKGROUP;
             } else {
                 UniAddress addr;
@@ -1568,127 +1626,221 @@ public class SmbFile extends URLConnection implements SmbConstants {
     String[] list( String wildcard, int searchAttributes,
                 SmbFilenameFilter fnf, SmbFileFilter ff ) throws SmbException {
         ArrayList list = new ArrayList();
-
-        try {
-            int hostlen = url.getHost().length();
-            if( hostlen == 0 || share == null ) {
-                boolean done = false;
-                if (hostlen != 0 && getType() == TYPE_SERVER) {
-                    try {
-                        doMsrpcEnum(list, false, wildcard, searchAttributes, fnf, ff);
-                        done = true;
-                    } catch(IOException ioe) {
-                        if (log.level >= 3)
-                            ioe.printStackTrace(log);
-                    }
-                }
-                if (!done)
-                    doNetEnum( list, false, wildcard, searchAttributes, fnf, ff );
-            } else {
-                doFindFirstNext( list, false, wildcard, searchAttributes, fnf, ff );
-            }
-        } catch( UnknownHostException uhe ) {
-            throw new SmbException( url.toString(), uhe );
-        } catch( MalformedURLException mue ) {
-            throw new SmbException( url.toString(), mue );
-        }
-
+        doEnum(list, false, wildcard, searchAttributes, fnf, ff);
         return (String[])list.toArray(new String[list.size()]);
     }
     SmbFile[] listFiles( String wildcard, int searchAttributes,
                 SmbFilenameFilter fnf, SmbFileFilter ff ) throws SmbException {
         ArrayList list = new ArrayList();
-
-        if( ff != null && ff instanceof DosFileFilter ) {
+        doEnum(list, true, wildcard, searchAttributes, fnf, ff);
+        return (SmbFile[])list.toArray(new SmbFile[list.size()]);
+    }
+    void doEnum(ArrayList list,
+                    boolean files,
+                    String wildcard,
+                    int searchAttributes,
+                    SmbFilenameFilter fnf,
+                    SmbFileFilter ff) throws SmbException {
+        if (ff != null && ff instanceof DosFileFilter) {
             DosFileFilter dff = (DosFileFilter)ff;
-            if( dff.wildcard != null ) {
+            if (dff.wildcard != null)
                 wildcard = dff.wildcard;
-            }
             searchAttributes = dff.attributes;
         }
 
         try {
             int hostlen = url.getHost().length();
-            if( hostlen == 0 || share == null ) {
-                boolean done = false;
-                if (hostlen != 0 && getType() == TYPE_SERVER) {
-                    try {
-                        doMsrpcEnum(list, true, wildcard, searchAttributes, fnf, ff);
-                        done = true;
-                    } catch(IOException ioe) {
-                        if (log.level >= 3)
-                            ioe.printStackTrace(log);
-                    }
-                }
-                if (!done)
-                    doNetEnum( list, true, wildcard, searchAttributes, fnf, ff );
+            if (hostlen == 0 || getType() == TYPE_WORKGROUP) {
+                doNetServerEnum(list, files, wildcard, searchAttributes, fnf, ff);
+            } else if (share == null) {
+                doShareEnum(list, files, wildcard, searchAttributes, fnf, ff);
             } else {
-                doFindFirstNext( list, true, wildcard, searchAttributes, fnf, ff );
+                doFindFirstNext(list, files, wildcard, searchAttributes, fnf, ff);
             }
-        } catch( UnknownHostException uhe ) {
-            throw new SmbException( url.toString(), uhe );
-        } catch( MalformedURLException mue ) {
-            throw new SmbException( url.toString(), mue );
+        } catch (UnknownHostException uhe) {
+            throw new SmbException(url.toString(), uhe);
+        } catch (MalformedURLException mue) {
+            throw new SmbException(url.toString(), mue);
         }
-
-        return (SmbFile[])list.toArray(new SmbFile[list.size()]);
     }
-    void doMsrpcEnum( ArrayList list,
+    void doShareEnum(ArrayList list,
                 boolean files,
                 String wildcard,
                 int searchAttributes,
                 SmbFilenameFilter fnf,
-                SmbFileFilter ff ) throws IOException,
-                        UnknownHostException,
-                        MalformedURLException {
+                SmbFileFilter ff) throws SmbException,
+                                UnknownHostException,
+                                MalformedURLException {
         String p = url.getPath();
-        MsrpcShareEnum rpc;
-        DcerpcHandle handle;
+        IOException last = null;
+        FileEntry[] entries;
+        UniAddress addr;
+        FileEntry e;
+        HashMap map;
 
-        if( p.lastIndexOf( '/' ) != ( p.length() - 1 )) {
-            throw new SmbException( url.toString() + " directory must end with '/'" );
-        }
+        if (p.lastIndexOf('/') != (p.length() - 1))
+            throw new SmbException(url.toString() + " directory must end with '/'");
         if (getType() != TYPE_SERVER)
-            throw new SmbException( "The requested list operations is invalid: " + url.toString() );
+            throw new SmbException("The requested list operations is invalid: " + url.toString());
+
+        map = new HashMap();
+
+        addr = getFirstAddress();
+        while (addr != null) {
+            try {
+                doConnect();
+                try {
+                    entries = doMsrpcShareEnum();
+                } catch(IOException ioe) {
+                    if (log.level >= 3)
+                        ioe.printStackTrace(log);
+                    entries = doNetShareEnum();
+                }
+                for (int ei = 0; ei < entries.length; ei++) {
+                    e = entries[ei];
+                    if (map.containsKey(e) == false)
+                        map.put(e, e);
+                }
+            } catch(IOException ioe) {
+                if (log.level >= 3)
+                    ioe.printStackTrace(log);
+                last = ioe;
+            }
+            addr = getNextAddress();
+        }
+
+        if (last != null && map.isEmpty()) {
+            if (last instanceof SmbException == false)
+                throw new SmbException(url.toString(), last);
+            throw (SmbException)last;
+        }
+
+        Iterator iter = map.keySet().iterator();
+        while (iter.hasNext()) {
+            e = (FileEntry)iter.next();
+            String name = e.getName();
+            if (fnf != null && fnf.accept(this, name) == false)
+                continue;
+            if (name.length() > 0) {
+                // if !files we don't need to create SmbFiles here
+                SmbFile f = new SmbFile(this, name, e.getType(),
+                            ATTR_READONLY | ATTR_DIRECTORY, 0L, 0L, 0L );
+                if (ff != null && ff.accept(f) == false)
+                    continue;
+                if (files) {
+                    list.add(f);
+                } else {
+                    list.add(name);
+                }
+            }
+        }
+    }
+    FileEntry[] doMsrpcShareEnum() throws IOException {
+        MsrpcShareEnum rpc;
+        DcerpcHandle handle;
 
         rpc = new MsrpcShareEnum(url.getHost());
-        handle = DcerpcHandle.getHandle("ncacn_np:" + url.getHost() + "[\\PIPE\\srvsvc]", auth);
+
+        /* JCIFS will build a composite list of shares if the target host has
+         * multiple IP addresses such as when domain-based DFS is in play. Because
+         * of this, to ensure that we query each IP individually without re-resolving
+         * the hostname and getting a different IP, we must use the current addresses
+         * IP rather than just url.getHost() like we were using prior to 1.2.16.
+         */
+
+        handle = DcerpcHandle.getHandle("ncacn_np:" +
+                    getAddress().getHostAddress() +
+                    "[\\PIPE\\srvsvc]", auth);
 
         try {
             handle.sendrecv(rpc);
             if (rpc.retval != 0)
                 throw new SmbException(rpc.retval, true);
-            FileEntry[] entries = rpc.getEntries();
-            for( int i = 0; i < entries.length; i++ ) {
-                FileEntry e = entries[i];
+            return rpc.getEntries();
+        } finally {
+            try {
+                handle.close();
+            } catch(IOException ioe) {
+                if (log.level >= 4)
+                    ioe.printStackTrace(log);
+            }
+        }
+    }
+    FileEntry[] doNetShareEnum() throws SmbException {
+        SmbComTransaction req = new NetShareEnum();
+        SmbComTransactionResponse resp = new NetShareEnumResponse();
+
+        send(req, resp);
+
+        if (resp.status != SmbException.ERROR_SUCCESS)
+            throw new SmbException(resp.status, true);
+
+        return resp.results;
+    }
+    void doNetServerEnum(ArrayList list,
+                boolean files,
+                String wildcard,
+                int searchAttributes,
+                SmbFilenameFilter fnf,
+                SmbFileFilter ff) throws SmbException,
+                                UnknownHostException,
+                                MalformedURLException {
+        int listType = url.getHost().length() == 0 ? 0 : getType();
+        SmbComTransaction req;
+        SmbComTransactionResponse resp;
+
+        if (listType == 0) {
+            connect0();
+            req = new NetServerEnum2(tree.session.transport.server.oemDomainName,
+                        NetServerEnum2.SV_TYPE_DOMAIN_ENUM );
+            resp = new NetServerEnum2Response();
+        } else if (listType == TYPE_WORKGROUP) {
+            req = new NetServerEnum2(url.getHost(), NetServerEnum2.SV_TYPE_ALL);
+            resp = new NetServerEnum2Response();
+        } else {
+            throw new SmbException( "The requested list operations is invalid: " + url.toString() );
+        }
+
+        boolean more;
+        do {
+            int n;
+
+            send(req, resp);
+
+            if (resp.status != SmbException.ERROR_SUCCESS &&
+                    resp.status != SmbException.ERROR_MORE_DATA) {
+                throw new SmbException( resp.status, true );
+            }
+            more = resp.status == SmbException.ERROR_MORE_DATA;
+
+            n = more ? resp.numEntries - 1 : resp.numEntries;
+            for (int i = 0; i < n; i++) {
+                FileEntry e = resp.results[i];
                 String name = e.getName();
-                if( fnf != null && fnf.accept( this, name ) == false ) {
+                if (fnf != null && fnf.accept(this, name) == false)
                     continue;
-                }
-                if( name.length() > 0 ) {
-                    SmbFile f = new SmbFile( this, name,
-                                e.getType(),
+                if (name.length() > 0) {
+                    // if !files we don't need to create SmbFiles here
+                    SmbFile f = new SmbFile(this, name, e.getType(),
                                 ATTR_READONLY | ATTR_DIRECTORY, 0L, 0L, 0L );
-                    if( ff != null && ff.accept( f ) == false ) {
+                    if (ff != null && ff.accept(f) == false)
                         continue;
-                    }
-                    if( files ) {
-                        list.add( f );
+                    if (files) {
+                        list.add(f);
                     } else {
-                        list.add( name );
+                        list.add(name);
                     }
                 }
             }
-        } finally {
-            try {
-                handle.close();
-            } catch(IOException ioe) {
-                if (log.level >= 4)
-                    ioe.printStackTrace(log);
+            if (getType() != TYPE_WORKGROUP) {
+                break;
             }
-        }
+            req.subCommand = (byte)SmbComTransaction.NET_SERVER_ENUM3;
+            req.reset(0, ((NetServerEnum2Response)resp).lastName);
+            resp.reset();
+        } while(more);
     }
-    void doNetEnum( ArrayList list,
+    void doNetEnumX( ArrayList list,
                 boolean files,
                 String wildcard,
                 int searchAttributes,
index 0e06adf..bd75f90 100644 (file)
@@ -153,7 +153,11 @@ public class SmbFileInputStream extends InputStream {
                 file.log.println( "read: len=" + len + ",r=" + r + ",fp=" + fp );
 
             try {
-                file.send( new SmbComReadAndX( file.fid, fp, r, null ), response );
+SmbComReadAndX request = new SmbComReadAndX( file.fid, fp, r, null );
+if( file.type == SmbFile.TYPE_NAMED_PIPE ) {
+    request.minCount = request.maxCount = request.remaining = 1024;
+}
+                file.send( request, response );
             } catch( SmbException se ) {
                 if( file.type == SmbFile.TYPE_NAMED_PIPE &&
                         se.getNtStatus() == NtStatus.NT_STATUS_PIPE_BROKEN ) {
index cfe9934..ccf6800 100644 (file)
@@ -187,6 +187,15 @@ write, and/or delete the file while the jCIFS user has the file open.
         write( b, 0, b.length );
     }
 
+    void ensureOpen() throws IOException {
+        // ensure file is open
+        if( file.isOpen() == false ) {
+            file.open( openFlags, access | SmbConstants.FILE_WRITE_DATA, SmbFile.ATTR_NORMAL, 0 );
+            if( append ) {
+                fp = file.length();
+            }
+        }
+    }
 /**
  * Writes len bytes from the specified byte array starting at
  * offset off to this file output stream.
@@ -196,6 +205,16 @@ write, and/or delete the file while the jCIFS user has the file open.
  */
 
     public void write( byte[] b, int off, int len ) throws IOException {
+        if( file.isOpen() == false && file instanceof SmbNamedPipe ) {
+            file.send( new TransWaitNamedPipe( "\\pipe" + file.unc ),
+                                    new TransWaitNamedPipeResponse() );
+        }
+        writeDirect( b, off, len, 0 );
+    }
+/**
+ * Just bypasses TransWaitNamedPipe - used by DCERPC bind.
+ */
+    public void writeDirect( byte[] b, int off, int len, int flags ) throws IOException {
         if( len <= 0 ) {
             return;
         }
@@ -203,17 +222,7 @@ write, and/or delete the file while the jCIFS user has the file open.
         if( tmp == null ) {
             throw new IOException( "Bad file descriptor" );
         }
-        // ensure file is open
-        if( file.isOpen() == false ) {
-            if( file instanceof SmbNamedPipe ) {
-                file.send( new TransWaitNamedPipe( "\\pipe" + file.unc ),
-                                        new TransWaitNamedPipeResponse() );
-            }
-            file.open( openFlags, access | SmbConstants.FILE_WRITE_DATA, SmbFile.ATTR_NORMAL, 0 );
-            if( append ) {
-                fp = file.length();
-            }
-        }
+        ensureOpen();
 
         if( file.log.level >= 4 )
             file.log.println( "write: fid=" + file.fid + ",off=" + off + ",len=" + len );
@@ -223,6 +232,12 @@ write, and/or delete the file while the jCIFS user has the file open.
             w = len > writeSize ? writeSize : len;
             if( useNTSmbs ) {
                 reqx.setParam( file.fid, fp, len - w, b, off, w );
+if ((flags & 1) != 0) {
+    reqx.setParam( file.fid, fp, len, b, off, w );
+    reqx.writeMode = 0x8;
+} else {
+    reqx.writeMode = 0;
+}
                 file.send( reqx, rspx );
                 fp += rspx.count;
                 len -= rspx.count;
diff --git a/src/jcifs/smb/SmbShareInfo.java b/src/jcifs/smb/SmbShareInfo.java
new file mode 100644 (file)
index 0000000..ac71f25
--- /dev/null
@@ -0,0 +1,74 @@
+/* jcifs smb client library in Java
+ * Copyright (C) 2007  "Michael B. Allen" <jcifs at samba dot org>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+package jcifs.smb;
+
+import jcifs.util.Hexdump;
+
+public class SmbShareInfo implements FileEntry {
+
+    protected String netName;
+    protected int type;
+    protected String remark;
+
+    public String getName() {
+        return netName;
+    }
+    public int getType() {
+        /* 0x80000000 means hidden but SmbFile.isHidden() checks for $ at end
+         */
+        switch (type & 0xFFFF) {
+            case 1:
+                return SmbFile.TYPE_PRINTER;
+            case 3:
+                return SmbFile.TYPE_NAMED_PIPE;
+        }
+        return SmbFile.TYPE_SHARE;
+    }
+    public int getAttributes() {
+        return SmbFile.ATTR_READONLY | SmbFile.ATTR_DIRECTORY;
+    }
+    public long createTime() {
+        return 0L;
+    }
+    public long lastModified() {
+        return 0L;
+    }
+    public long length() {
+        return 0L;
+    }
+
+    public boolean equals(Object obj) {
+        if (obj instanceof SmbShareInfo) {
+            SmbShareInfo si = (SmbShareInfo)obj;
+            return netName.equals(si.netName);
+        }
+        return false;
+    }
+    public int hashCode() {
+        int hashCode = netName.hashCode();
+        return hashCode;
+    }
+
+    public String toString() {
+        return new String( "SmbShareInfo[" +
+                "netName=" + netName +
+                ",type=0x" + Hexdump.toHexString( type, 8 ) +
+                ",remark=" + remark + "]" );
+    }
+}
index 9712b43..208b941 100644 (file)
@@ -230,7 +230,7 @@ public class SmbTransport extends Transport implements SmbConstants {
              * is a policy regarding which hosts a user can connect from. This
              * requires communicating over port 139 rather than 445.
              */
-            if (NETBIOS_HOSTNAME != null && NETBIOS_HOSTNAME.equals( "" ) == false) {
+            if (false && NETBIOS_HOSTNAME != null && NETBIOS_HOSTNAME.equals( "" ) == false) {
                 port = 139;
             }
             if (port == 139) {
index 131a557..4319652 100644 (file)
@@ -95,7 +95,7 @@ class SmbTree {
             }
         }
         request.tid = tid;
-        if( inDfs && request.path != null && request.path.length() > 0 ) {
+        if( inDfs && !service.equals("IPC") && request.path != null && request.path.length() > 0 ) {
             /* When DFS is in action all request paths are
              * full UNC paths minus the first backslash like
              *   \server\share\path\to\file
index f94375e..9a0e8ab 100644 (file)
@@ -21,7 +21,7 @@ package jcifs.smb;
 import java.io.OutputStream;
 import java.io.IOException;
 
-class TransactNamedPipeOutputStream extends OutputStream {
+class TransactNamedPipeOutputStream extends SmbFileOutputStream {
 
     private String path;
     private SmbNamedPipe pipe;
@@ -29,6 +29,7 @@ class TransactNamedPipeOutputStream extends OutputStream {
     private boolean dcePipe;
 
     TransactNamedPipeOutputStream( SmbNamedPipe pipe ) throws IOException {
+        super(pipe, false, (pipe.pipeType & 0xFFFF00FF) | SmbFile.O_EXCL);
         this.pipe = pipe;
         this.dcePipe = ( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT ) == SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT;
         path = pipe.unc;
@@ -56,10 +57,7 @@ class TransactNamedPipeOutputStream extends OutputStream {
                                         new TransCallNamedPipeResponse( pipe ));
         } else if(( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_TRANSACT ) ==
                                                     SmbNamedPipe.PIPE_TYPE_TRANSACT ) {
-            pipe.open((pipe.pipeType & 0xFF) | SmbFile.O_EXCL,
-                        pipe.pipeType >>> 16,
-                        SmbFile.ATTR_NORMAL,
-                        0);
+            ensureOpen();
             TransTransactNamedPipe req = new TransTransactNamedPipe( pipe.fid, b, off, len );
             if (dcePipe) {
                 req.maxDataCount = 1024;