From: Felix Schumacher Date: Wed, 6 Aug 2008 14:09:39 +0000 (+0200) Subject: jcifs-0.7.16 from tgz X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=56d3c715ff18a4a92fd653dfe65cf1148f6c167c;p=jcifs_without_docs.git jcifs-0.7.16 from tgz 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. --- diff --git a/CHANGES.txt b/CHANGES.txt index 9eb88ad..2d5e568 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 diff --git a/README.txt b/README.txt index ce37c7a..2750947 100644 --- a/README.txt +++ b/README.txt @@ -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 diff --git a/build.xml b/build.xml index 18c3c97..4846284 100644 --- a/build.xml +++ b/build.xml @@ -66,24 +66,24 @@ - + - + - - - + + + - + - + diff --git a/src/jcifs/smb/ServerMessageBlock.java b/src/jcifs/smb/ServerMessageBlock.java index fe46815..980baee 100644 --- a/src/jcifs/smb/ServerMessageBlock.java +++ b/src/jcifs/smb/ServerMessageBlock.java @@ -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 index 0000000..12fd33f --- /dev/null +++ b/src/jcifs/smb/SmbComWrite.java @@ -0,0 +1,99 @@ +/* jcifs smb client library in Java + * Copyright (C) 2003 "Michael B. Allen" + * + * 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 index 0000000..91fa552 --- /dev/null +++ b/src/jcifs/smb/SmbComWriteResponse.java @@ -0,0 +1,52 @@ +/* jcifs smb client library in Java + * Copyright (C) 2003 "Michael B. Allen" + * + * 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 java.io.IOException; +import java.io.InputStream; + +class SmbComWriteResponse extends ServerMessageBlock { + + long count; + + SmbComWriteResponse() { + } + + int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { + return 0; + } + int writeBytesWireFormat( byte[] dst, int dstIndex ) { + return 0; + } + int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { + count = readInt2( buffer, bufferIndex ) & 0xFFFFL; + return 8; + } + int readBytesWireFormat( byte[] buffer, int bufferIndex ) { + return 0; + } + int readBytesDirectWireFormat( InputStream in, int byteCount ) throws IOException { + return 0; + } + public String toString() { + return new String( "SmbComWriteResponse[" + + super.toString() + + ",count=" + count + "]" ); + } +} diff --git a/src/jcifs/smb/SmbFile.java b/src/jcifs/smb/SmbFile.java index d3d4f2d..08a6d09 100644 --- a/src/jcifs/smb/SmbFile.java +++ b/src/jcifs/smb/SmbFile.java @@ -1542,11 +1542,21 @@ The shareAccess 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 shareAccess 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 shareAccess 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, diff --git a/src/jcifs/smb/SmbFileOutputStream.java b/src/jcifs/smb/SmbFileOutputStream.java index 72a8dc4..44674a0 100644 --- a/src/jcifs/smb/SmbFileOutputStream.java +++ b/src/jcifs/smb/SmbFileOutputStream.java @@ -31,10 +31,14 @@ import java.net.MalformedURLException; public class SmbFileOutputStream extends OutputStream { private SmbFile file; - private boolean append; + private boolean append, useNTSmbs; private int openFlags, writeSize; private long fp; private byte[] tmp = new byte[1]; + private SmbComWriteAndX reqx; + private SmbComWriteAndXResponse rspx; + private SmbComWrite req; + private SmbComWriteResponse rsp; /** * Creates an {@link java.io.OutputStream} for writing to a file @@ -131,6 +135,15 @@ write, and/or delete the file while the jCIFS user has the file open. file.open( openFlags ); writeSize = Math.min( file.tree.session.transport.snd_buf_size - 70, file.tree.session.transport.server.maxBufferSize - 70 ); + + useNTSmbs = file.tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS ); + if( useNTSmbs ) { + reqx = new SmbComWriteAndX(); + rspx = new SmbComWriteAndXResponse(); + } else { + req = new SmbComWrite(); + rsp = new SmbComWriteResponse(); + } } /** @@ -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 ); */ int w; - SmbComWriteAndXResponse rsp = new SmbComWriteAndXResponse(); do { w = len > writeSize ? writeSize : len; - file.send( new SmbComWriteAndX( file.fid, fp, len - w, b, off, w, null ), rsp ); - fp += rsp.count; - len -= rsp.count; - off += rsp.count; + if( useNTSmbs ) { + reqx.setParam( file.fid, fp, len - w, b, off, w ); + file.send( reqx, rspx ); + fp += rspx.count; + len -= rspx.count; + off += rspx.count; + } else { + req.setParam( file.fid, fp, len - w, b, off, w ); + fp += rsp.count; + len -= rsp.count; + off += rsp.count; + file.send( req, rsp ); + } } while( len > 0 ); } } diff --git a/src/jcifs/smb/SmbTransport.java b/src/jcifs/smb/SmbTransport.java index 609295e..8f5ce3f 100644 --- a/src/jcifs/smb/SmbTransport.java +++ b/src/jcifs/smb/SmbTransport.java @@ -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 ) { diff --git a/src/jcifs/smb/SmbTree.java b/src/jcifs/smb/SmbTree.java index de27bab..879ecbf 100644 --- a/src/jcifs/smb/SmbTree.java +++ b/src/jcifs/smb/SmbTree.java @@ -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: