jcifs-0.7.16 from tgz
authorFelix Schumacher <p0354740@isib001.(none)>
Wed, 6 Aug 2008 14:09:39 +0000 (16:09 +0200)
committerFelix Schumacher <p0354740@isib001.(none)>
Wed, 6 Aug 2008 14:09:39 +0000 (16:09 +0200)
Tue Dec  9 18:13:25 EST 2003
jcifs-0.7.16 released

If  NT  SMBs are not negotiated jCIFS will now use SMB_COM_WRITE as opposed
to  SMB_COM_WRITE_ANDX. This was done to support NetWare 6 which apparently
does not implement this ANDX command.

CHANGES.txt
README.txt
build.xml
src/jcifs/smb/ServerMessageBlock.java
src/jcifs/smb/SmbComWrite.java [new file with mode: 0644]
src/jcifs/smb/SmbComWriteResponse.java [new file with mode: 0644]
src/jcifs/smb/SmbFile.java
src/jcifs/smb/SmbFileOutputStream.java
src/jcifs/smb/SmbTransport.java
src/jcifs/smb/SmbTree.java

index 9eb88ad..2d5e568 100644 (file)
@@ -1,3 +1,10 @@
+Tue Dec  9 18:13:25 EST 2003
+jcifs-0.7.16 released
+
+If  NT  SMBs are not negotiated jCIFS will now use SMB_COM_WRITE as opposed
+to  SMB_COM_WRITE_ANDX. This was done to support NetWare 6 which apparently
+does not implement this ANDX command. 
+
 Thu Oct 23 01:18:29 EDT 2003
 
 jcifs-0.7.15 released
index ce37c7a..2750947 100644 (file)
@@ -1,4 +1,7 @@
-Thu Oct 23 01:18:29 EDT 2003
+Tue Dec  9 18:13:25 EST 2003
+jcifs-0.7.16 released
+
+An issue regarding writing to NetWare 6 servers has been resolved.
 
 jcifs-0.7.15 released
 
index 18c3c97..4846284 100644 (file)
--- a/build.xml
+++ b/build.xml
        <target name="jar" depends="smb">
                <copy file="src/jcifs/util/mime.map" tofile="build/jcifs/util/mime.map" overwrite="yes"/>
                <copy file="src/jcifs/http/ne.css" tofile="build/jcifs/http/ne.css" overwrite="yes"/>
-               <jar jarfile="jcifs-0.7.15.jar" basedir="build"/>
+               <jar jarfile="jcifs-0.7.16.jar" basedir="build"/>
        </target>
 
        <target name="tgz">
-               <copy todir="dist_tmp/jcifs_0.7.15">
+               <copy todir="dist_tmp/jcifs_0.7.16">
                        <fileset dir="." excludes="ant,**/.*,build,jcifs.prp,**/*.tgz,**/*.zip"/>
                </copy>
-               <tar tarfile="jcifs-0.7.15.tar" basedir="dist_tmp"/>
-               <gzip src="jcifs-0.7.15.tar" zipfile="jcifs-0.7.15.tgz"/>
-               <delete file="jcifs-0.7.15.tar"/>
+               <tar tarfile="jcifs-0.7.16.tar" basedir="dist_tmp"/>
+               <gzip src="jcifs-0.7.16.tar" zipfile="jcifs-0.7.16.tgz"/>
+               <delete file="jcifs-0.7.16.tar"/>
                <delete dir="dist_tmp"/>
        </target>
        <target name="zip">
-               <copy todir="dist_tmp/jcifs_0.7.15">
+               <copy todir="dist_tmp/jcifs_0.7.16">
                        <fileset dir="." excludes="ant,**/.*,build,jcifs.prp,**/*.tgz,**/*.zip"/>
                </copy>
                <fixcrlf srcdir="dist_tmp" cr="add" tab="remove" tablength="4" excludes="**/*.jar,**/*.exe"/>
-               <zip zipfile="jcifs-0.7.15.zip" basedir="dist_tmp"/>
+               <zip zipfile="jcifs-0.7.16.zip" basedir="dist_tmp"/>
                <delete dir="dist_tmp"/>
        </target>
 
index fe46815..980baee 100644 (file)
@@ -222,6 +222,7 @@ abstract class ServerMessageBlock {
        static final byte SMB_COM_DELETE             = (byte)0x06;
        static final byte SMB_COM_RENAME             = (byte)0x07;
        static final byte SMB_COM_QUERY_INFORMATION  = (byte)0x08;
+       static final byte SMB_COM_WRITE              = (byte)0x0B;
        static final byte SMB_COM_CHECK_DIRECTORY    = (byte)0x10;
        static final byte SMB_COM_TRANSACTION        = (byte)0x25;
        static final byte SMB_COM_TRANSACTION_SECONDARY = (byte)0x26;
diff --git a/src/jcifs/smb/SmbComWrite.java b/src/jcifs/smb/SmbComWrite.java
new file mode 100644 (file)
index 0000000..12fd33f
--- /dev/null
@@ -0,0 +1,99 @@
+/* jcifs smb client library in Java
+ * Copyright (C) 2003  "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.Config;
+import java.io.IOException;
+import java.io.InputStream;
+
+class SmbComWrite extends ServerMessageBlock {
+
+       int fid,
+               count,
+               offset,
+               remaining,
+               off;
+       byte[] b;
+
+       SmbComWrite() {
+               super();
+               command = SMB_COM_WRITE;
+       }
+       SmbComWrite( int fid, int offset, int remaining, byte[] b, int off, int len ) {
+               this.fid = fid;
+               this.count = len;
+               this.offset = offset;
+               this.remaining = remaining;
+               this.b = b;
+               this.off = off;
+               command = SMB_COM_WRITE;
+       }
+
+       void setParam( int fid, long offset, int remaining,
+                                       byte[] b, int off, int len ) {
+               this.fid = fid;
+               this.offset = (int)(offset & 0xFFFFFFFFL);
+               this.remaining = remaining;
+               this.b = b;
+               this.off = off;
+               count = len;
+       }
+       int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) {
+               int start = dstIndex;
+
+               writeInt2( fid, dst, dstIndex );
+               dstIndex += 2;
+               writeInt2( count, dst, dstIndex );
+               dstIndex += 2;
+               writeInt4( offset, dst, dstIndex );
+               dstIndex += 4;
+               writeInt2( remaining, dst, dstIndex );
+               dstIndex += 2;
+
+               return dstIndex - start;
+       }
+       int writeBytesWireFormat( byte[] dst, int dstIndex ) {
+               int start = dstIndex;
+
+               dst[dstIndex++] = (byte)0x01; /* BufferFormat */
+               writeInt2( count, dst, dstIndex ); /* DataLength? */
+               dstIndex += 2;
+               System.arraycopy( b, off, dst, dstIndex, count );
+               dstIndex += count;
+
+               return dstIndex - start;
+       }
+       int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) {
+               return 0;
+       }
+       int readBytesWireFormat( byte[] buffer, int bufferIndex ) {
+               return 0;
+       }
+       int readBytesDirectWireFormat( InputStream in, int byteCount ) throws IOException {
+               return 0;
+       }
+       public String toString() {
+               return new String( "SmbComWrite[" +
+                       super.toString() +
+                       ",fid=" + fid +
+                       ",count=" + count +
+                       ",offset=" + offset +
+                       ",remaining=" + remaining + "]" );
+       }
+}
diff --git a/src/jcifs/smb/SmbComWriteResponse.java b/src/jcifs/smb/SmbComWriteResponse.java
new file mode 100644 (file)
index 0000000..91fa552
--- /dev/null
@@ -0,0 +1,52 @@
+/* jcifs smb client library in Java\r
+ * Copyright (C) 2003  "Michael B. Allen" <jcifs at samba dot org>\r
+ * \r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Lesser General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2.1 of the License, or (at your option) any later version.\r
+ * \r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+ * Lesser General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU Lesser General Public\r
+ * License along with this library; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ */\r
+\r
+package jcifs.smb;\r
+\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+\r
+class SmbComWriteResponse extends ServerMessageBlock {\r
+\r
+       long count;\r
+\r
+       SmbComWriteResponse() {\r
+       }\r
+\r
+       int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) {\r
+               return 0;\r
+       }\r
+       int writeBytesWireFormat( byte[] dst, int dstIndex ) {\r
+               return 0;\r
+       }\r
+       int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) {\r
+               count = readInt2( buffer, bufferIndex ) & 0xFFFFL;\r
+               return 8;\r
+       }\r
+       int readBytesWireFormat( byte[] buffer, int bufferIndex ) {\r
+               return 0;\r
+       }\r
+       int readBytesDirectWireFormat( InputStream in, int byteCount ) throws IOException {\r
+               return 0;\r
+       }\r
+       public String toString() {\r
+               return new String( "SmbComWriteResponse[" +\r
+                       super.toString() +\r
+                       ",count=" + count + "]" );\r
+       }\r
+}\r
index d3d4f2d..08a6d09 100644 (file)
@@ -1542,11 +1542,21 @@ The <tt>shareAccess</tt> parameter controls what permissions other clients have
                boolean ready = true;
                SmbFile dest;
                SmbException e = null;
-               SmbComWriteAndX req = new SmbComWriteAndX();
-               SmbComWriteAndXResponse resp = new SmbComWriteAndXResponse();
+               boolean useNTSmbs;
+               SmbComWriteAndX reqx;
+               SmbComWrite req;
+               ServerMessageBlock resp;
 
-               WriterThread() {
+               WriterThread() throws SmbException {
                        super( "JCIFS-WriterThread" );
+                       useNTSmbs = tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS );
+                       if( useNTSmbs ) {
+                               reqx = new SmbComWriteAndX();
+                               resp = new SmbComWriteAndXResponse();
+                       } else {
+                               req = new SmbComWrite();
+                               resp = new SmbComWriteResponse();
+                       }
                }
 
                synchronized void write( byte[] b, int n, SmbFile dest, int off ) {
@@ -1569,8 +1579,13 @@ The <tt>shareAccess</tt> parameter controls what permissions other clients have
                                                if( n == -1 ) {
                                                        return;
                                                }
-                                               req.setParam( dest.fid, off, n, b, 0, n );
-                                               dest.send( req, resp );
+                                               if( useNTSmbs ) {
+                                                       reqx.setParam( dest.fid, off, n, b, 0, n );
+                                                       dest.send( reqx, resp );
+                                               } else {
+                                                       req.setParam( dest.fid, off, n, b, 0, n );
+                                                       dest.send( req, resp );
+                                               }
                                                notify();
                                        }
                                } catch( SmbException e ) {
@@ -1692,13 +1707,14 @@ The <tt>shareAccess</tt> parameter controls what permissions other clients have
 
                req = new SmbComReadAndX();
                resp = new SmbComReadAndXResponse();
-               w = new WriterThread();
-               w.setDaemon( true );
-               w.start();
 
                connect0();
                dest.connect0();
 
+               w = new WriterThread();
+               w.setDaemon( true );
+               w.start();
+
                bsize = Math.min( Math.min( tree.session.transport.rcv_buf_size - 70,
                                        dest.tree.session.transport.server.maxBufferSize - 70 ),
                                        Math.min( tree.session.transport.snd_buf_size - 70,
index 72a8dc4..44674a0 100644 (file)
@@ -31,10 +31,14 @@ import java.net.MalformedURLException;
 public class SmbFileOutputStream extends OutputStream {\r
 \r
        private SmbFile file;\r
-       private boolean append;\r
+       private boolean append, useNTSmbs;\r
        private int openFlags, writeSize;\r
        private long fp;\r
        private byte[] tmp = new byte[1];\r
+       private SmbComWriteAndX reqx;\r
+       private SmbComWriteAndXResponse rspx;\r
+       private SmbComWrite req;\r
+       private SmbComWriteResponse rsp;\r
 \r
 /**\r
  * Creates an {@link java.io.OutputStream} for writing to a file\r
@@ -131,6 +135,15 @@ write, and/or delete the file while the jCIFS user has the file open.
                file.open( openFlags );\r
                writeSize = Math.min( file.tree.session.transport.snd_buf_size - 70,\r
                                                        file.tree.session.transport.server.maxBufferSize - 70 );\r
+\r
+               useNTSmbs = file.tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS );\r
+               if( useNTSmbs ) {\r
+                       reqx = new SmbComWriteAndX();\r
+                       rspx = new SmbComWriteAndXResponse();\r
+               } else {\r
+                       req = new SmbComWrite();\r
+                       rsp = new SmbComWriteResponse();        \r
+               }\r
        }\r
 \r
 /**\r
@@ -192,13 +205,21 @@ write, and/or delete the file while the jCIFS user has the file open.
                                                " fid=" + file.fid + ",off=" + off + ",len=" + len );\r
 */\r
                int w;\r
-               SmbComWriteAndXResponse rsp = new SmbComWriteAndXResponse();\r
                do {\r
                        w = len > writeSize ? writeSize : len;\r
-                       file.send( new SmbComWriteAndX( file.fid, fp, len - w, b, off, w, null ), rsp );\r
-                       fp += rsp.count;\r
-                       len -= rsp.count;\r
-                       off += rsp.count;\r
+                       if( useNTSmbs ) {\r
+                               reqx.setParam( file.fid, fp, len - w, b, off, w );\r
+                               file.send( reqx, rspx );\r
+                               fp += rspx.count;\r
+                               len -= rspx.count;\r
+                               off += rspx.count;\r
+                       } else {\r
+                               req.setParam( file.fid, fp, len - w, b, off, w );\r
+                               fp += rsp.count;\r
+                               len -= rsp.count;\r
+                               off += rsp.count;\r
+                               file.send( req, rsp );\r
+                       }\r
                } while( len > 0 );\r
        }\r
 }\r
index 609295e..8f5ce3f 100644 (file)
@@ -178,8 +178,8 @@ private static byte[] rcv_buf = new byte[0xFFFF];
                        client.flags2 &= 0xFFFF ^ ServerMessageBlock.FLAGS2_UNICODE;
                        client.capabilities &= 0xFFFF ^ ServerMessageBlock.CAP_UNICODE;
                }
-               if( Config.getBoolean( "jcifs.smb.client.useNTSmbs", false ) == true ) {
-                       client.capabilities |= ServerMessageBlock.CAP_NT_SMBS;
+               if( Config.getBoolean( "jcifs.smb.client.useNTSmbs", true ) == false ) {
+                       client.capabilities &= ~ServerMessageBlock.CAP_NT_SMBS;
                }
                useSigning = Config.getBoolean("jcifs.smb.client.signingPreferred", false);
                if( useSigning ) {
index de27bab..879ecbf 100644 (file)
@@ -76,6 +76,7 @@ class SmbTree {
                }
                if( service.equals( "A:" ) == false ) {
                        switch( request.command ) {
+                               case ServerMessageBlock.SMB_COM_WRITE:
                                case ServerMessageBlock.SMB_COM_OPEN_ANDX:
                                case ServerMessageBlock.SMB_COM_NT_CREATE_ANDX:
                                case ServerMessageBlock.SMB_COM_READ_ANDX: