+Fri Mar 24 23:14:35 EST 2006
+jcifs-1.2.8 released / Deadlock Fix, ACLs, DFS, NTLM HTTP Filter, and More
+
+There are several significant changes in this release. These include:
+
+ o A deadlock could occur if the client tried to logoff and logon at
+ the same instant. This has been fixed.
+ o It was discovered that in at least some cases "preauthentication"
+ did not work properly. A very simple logical error would cause the
+ wrong signing digest to be installed. This has been fixed.
+ o The ACL patch has been integrated. The SmbFile.getSecurity() method
+ is now available.
+ o The jcifs.smb.client.responseTimeout and jcifs.smb.client.soTimeout
+ values have been increased from 10000ms and 15000ms to 30000ms and
+ 35000 respectively. Users with crawler type applications will almost
+ certainly want to reduce these values.
+ o Several logical errors in DFS referral handling have been fixed
+ (still no fix for the mystery preemtive behavior observed by Windows
+ clients).
+ o Documentation has been updated significantly.
+
Fri Nov 18 17:08:56 EST 2005
jcifs-1.2.7 released / Transport Error, Filter Changes, Integer Overflow,
User Contributed Patches, and More
<project name="jcifs" default="usage" basedir=".">
- <property name="version" value="1.2.7"/>
- <property name="reldate" value="Nov 18, 2005"/>
+ <property name="version" value="1.2.8"/>
+ <property name="reldate" value="Mar 28, 2006"/>
<target name="usage">
<echo>
<target name="compile" depends="dependencies">
<mkdir dir="build"/>
- <javac srcdir="src" destdir="build" debug="on"/>
+ <javac srcdir="src" destdir="build" debug="on">
+<!--
+ <compilerarg line="-Xlint:deprecation -Xlint:unchecked"/>
+-->
+ </javac>
<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"/>
</target>
author="true"
version="true"
use="true"
- sourcefiles="src/jcifs/Config.java,src/jcifs/UniAddress.java,src/jcifs/netbios/NbtAddress.java,src/jcifs/smb/DosFileFilter.java,src/jcifs/smb/NtlmAuthenticator.java,src/jcifs/smb/NtlmPasswordAuthentication.java,src/jcifs/smb/SmbAuthException.java,src/jcifs/smb/SmbException.java,src/jcifs/smb/SmbFile.java,src/jcifs/smb/SmbFileFilter.java,src/jcifs/smb/SmbFileInputStream.java,src/jcifs/smb/SmbFilenameFilter.java,src/jcifs/smb/SmbFileOutputStream.java,src/jcifs/smb/SmbNamedPipe.java,src/jcifs/smb/SmbRandomAccessFile.java,src/jcifs/smb/SmbSession.java"
+ sourcefiles="src/jcifs/smb/ACE.java,src/jcifs/smb/SID.java,src/jcifs/Config.java,src/jcifs/UniAddress.java,src/jcifs/netbios/NbtAddress.java,src/jcifs/smb/DosFileFilter.java,src/jcifs/smb/NtlmAuthenticator.java,src/jcifs/smb/NtlmPasswordAuthentication.java,src/jcifs/smb/SmbAuthException.java,src/jcifs/smb/SmbException.java,src/jcifs/smb/SmbFile.java,src/jcifs/smb/SmbFileFilter.java,src/jcifs/smb/SmbFileInputStream.java,src/jcifs/smb/SmbFilenameFilter.java,src/jcifs/smb/SmbFileOutputStream.java,src/jcifs/smb/SmbNamedPipe.java,src/jcifs/smb/SmbRandomAccessFile.java,src/jcifs/smb/SmbSession.java"
windowtitle="JCIFS API">
<sourcepath path="src"/>
public class GrowWrite {
- static final int SIZE = 0x4FFF;
+ static final int SIZE = 0x1FFF;
public static void main( String argv[] ) throws Exception {
int n, tot;
public class ListACL {
public static void main( String[] args ) throws Exception {
+ if (args.length < 1) {
+ System.err.println( "usage: ListACL <smburl>\n" );
+ return 0;
+ }
SmbFile f = new SmbFile( args[0] );
ACE[] acl = f.getSecurity();
for (int i = 0; i < acl.length; i++) {
--- /dev/null
+import jcifs.smb.*;
+
+public class MultiLogon {
+
+ public static void main( String argv[] ) throws Exception {
+ if (argv.length < 1) {
+ System.err.println( "usage: Dual <cred1> <cred2> <smburl>\n");
+ return;
+ }
+
+ NtlmPasswordAuthentication auth1 = new NtlmPasswordAuthentication( argv[0] );
+ NtlmPasswordAuthentication auth2 = new NtlmPasswordAuthentication( argv[1] );
+
+ SmbFile f1 = new SmbFile( argv[2], auth1 );
+ SmbFile f2 = new SmbFile( argv[2], auth2 );
+
+ f1.exists();
+ f2.exists();
+ }
+}
+
--- /dev/null
+import jcifs.smb.SmbFile;
+
+public class SmbTimeout {
+
+ public static void jcifsScan(String root, int sleepTime) throws Exception {
+ long start = System.currentTimeMillis();
+ SmbFile smbRoot = new SmbFile(root);
+ SmbFile[] files = smbRoot.listFiles();
+ for(SmbFile f : files) {
+ System.out.println( f + ": " + f.canRead()+" : "+ f.length() + ": " + (System.currentTimeMillis()-start));
+ Thread.sleep(sleepTime);
+ }
+ }
+
+ public static void main(String[] p_args) throws Exception {
+ if(p_args.length!=2) {
+ System.out.println("Usage: <smbroot> <sleeptime(ms)>");
+ return;
+ }
+ String smbRoot = p_args[0];
+ int sleepTime = Integer.parseInt(p_args[1]);
+ jcifsScan(smbRoot,sleepTime);
+ }
+
+}
PROPERTIES=../../miallen.prp
RUN="${JAVA_HOME}/bin/java -cp ${CLASSPATH} -Djcifs.properties=${PROPERTIES}"
-SERVER=rnyxwbf8s5v31
-SHARE=pub
+SERVER=xp1
+SHARE=temp
WRITE_DIR=test/
SRC_DIR=test/Junk
FILE1=test/Junk/10883563.doc
PROPERTIES=../../miallen.prp
RUN="${JAVA_HOME}/bin/java -cp ${CLASSPATH} -Djcifs.properties=${PROPERTIES}"
-SERVER=rnyxwbf8s5v31
-SHARE=pub
+SERVER=xp1
+SHARE=temp
WRITE_DIR=test/
SRC_DIR=test/Junk
FILE1=test/Junk/10883563.doc
conveinience. If you port a patch to a newer version of jCIFS please
resubmit it to the mailing list.
-SecurityDescriptors.patch:
-
-This patch add an SmbFile.getSecurity() method that returns an ACE[]
-array for the target file. Note however that there is still no way to
-resolve SIDs to names or visa versa. This patch is also rather intrusive
-so it will take a bit of work to apply. There are file that go with this
-patch that I placed into the smb directory rather than putting them in
-the patch. They are ACE.java NtTransQuerySecurityDesc*.java SID.java
-SmbComNtTransaction*.java but some have been renamed to .jav to disable
-them from being compiled. So to apply the patch you will need to go
-through each of the affected files adjusting as necessary to the 1.2.7
-codebase and then also rename the .jav files to .java and try to compile.
-
-Also see examples/ListACL.java and examples/AclCrawler.java.
-
-The ListACL.java example will list the ACEs of a specified path. Consider
-the following commandline with resulting output of ListACL:
-
-$ java -Djcifs.properties=../miallen.prp ListACL smb://svr01/pub/a/b/c/d
-direct allow 0x001F01FF S-1-5-21-839522115-1425521274-1417001333-61012
-inherited deny 0x000F01FF S-1-5-21-839522115-1425521274-1417001333-61011
-inherited allow 0x001F01FF S-1-5-21-839522115-1425521274-1417001333-61007
-inherited deny 0x000F01FF S-1-5-21-839522115-1425521274-1417001333-61012
-inherited allow 0x001F01FF S-1-5-32-544
-inherited allow 0x001F01FF S-1-5-18
-inherited allow 0x001200A9 S-1-5-32-545
-
LargeReadWrite.patch:
This patch adds two SMBs that supposedly improves read and write
+++ /dev/null
-diff -Naur jcifs_1.1.11/src/jcifs/smb/ServerMessageBlock.java jcifs_1.1.11acl2/src/jcifs/smb/ServerMessageBlock.java
---- jcifs_1.1.11/src/jcifs/smb/ServerMessageBlock.java 2005-05-04 23:10:46.000000000 -0400
-+++ jcifs_1.1.11acl2/src/jcifs/smb/ServerMessageBlock.java 2005-05-10 22:09:32.000000000 -0400
-@@ -274,6 +274,8 @@
- static final byte SMB_COM_SESSION_SETUP_ANDX = (byte)0x73;
- static final byte SMB_COM_LOGOFF_ANDX = (byte)0x74;
- static final byte SMB_COM_TREE_CONNECT_ANDX = (byte)0x75;
-+ static final byte SMB_COM_NT_TRANSACT = (byte)0xA0;
-+ static final byte SMB_COM_NT_TRANSACT_SECONDARY = (byte)0xA1;
- static final byte SMB_COM_NT_CREATE_ANDX = (byte)0xA2;
-
- /*
-@@ -622,6 +624,12 @@
- case SMB_COM_CREATE_DIRECTORY:
- c = "SMB_COM_CREATE_DIRECTORY";
- break;
-+ case SMB_COM_NT_TRANSACT:
-+ c = "SMB_COM_NT_TRANSACT";
-+ break;
-+ case SMB_COM_NT_TRANSACT_SECONDARY:
-+ c = "SMB_COM_NT_TRANSACT_SECONDARY";
-+ break;
- default:
- c = "UNKNOWN";
- }
-diff -Naur jcifs_1.1.11/src/jcifs/smb/SmbComNTCreateAndX.java jcifs_1.1.11acl2/src/jcifs/smb/SmbComNTCreateAndX.java
---- jcifs_1.1.11/src/jcifs/smb/SmbComNTCreateAndX.java 2005-05-04 23:10:46.000000000 -0400
-+++ jcifs_1.1.11acl2/src/jcifs/smb/SmbComNTCreateAndX.java 2005-05-10 22:09:32.000000000 -0400
-@@ -107,6 +107,7 @@
- private int namelen_index;
-
- SmbComNTCreateAndX( String name, int flags,
-+ int access,
- int shareAccess,
- int extFileAttributes,
- int createOptions,
-@@ -116,7 +117,7 @@
- command = SMB_COM_NT_CREATE_ANDX;
-
- // desiredAccess
-- desiredAccess = ( flags >>> 16 ) & 0xFFFF;
-+ desiredAccess = access;
- desiredAccess |= FILE_READ_EA | FILE_READ_ATTRIBUTES;
-
- // extFileAttributes
-diff -Naur jcifs_1.1.11/src/jcifs/smb/SmbComOpenAndX.java jcifs_1.1.11acl2/src/jcifs/smb/SmbComOpenAndX.java
---- jcifs_1.1.11/src/jcifs/smb/SmbComOpenAndX.java 2005-05-04 23:10:46.000000000 -0400
-+++ jcifs_1.1.11acl2/src/jcifs/smb/SmbComOpenAndX.java 2005-05-10 22:09:32.000000000 -0400
-@@ -58,13 +58,13 @@
-
- // flags is NOT the same as flags member
-
-- SmbComOpenAndX( String fileName, int flags, ServerMessageBlock andx ) {
-+ SmbComOpenAndX( String fileName, int flags, int access, ServerMessageBlock andx ) {
- super( andx );
- this.path = fileName;
- command = SMB_COM_OPEN_ANDX;
-
- // desiredAccess
-- desiredAccess = ( flags >>> 16 ) & 0x3;
-+ desiredAccess = access & 0x3;
- if( desiredAccess == 0x3 ) {
- desiredAccess = 0x2; /* Mmm, I thought 0x03 was RDWR */
- }
-diff -Naur jcifs_1.1.11/src/jcifs/smb/SmbComTransaction.java jcifs_1.1.11acl2/src/jcifs/smb/SmbComTransaction.java
---- jcifs_1.1.11/src/jcifs/smb/SmbComTransaction.java 2005-05-04 23:10:46.000000000 -0400
-+++ jcifs_1.1.11acl2/src/jcifs/smb/SmbComTransaction.java 2005-05-10 22:09:32.000000000 -0400
-@@ -32,44 +32,47 @@
- private static final int PRIMARY_SETUP_OFFSET = 61;
- private static final int SECONDARY_PARAMETER_OFFSET = 51;
-
-- private static final int DISCONNECT_TID = 0x01;
-+ private static final int DISCONNECT_TID = 0x01;
- private static final int ONE_WAY_TRANSACTION = 0x02;
-
- private static final int PADDING_SIZE = 2;
-
- private int flags = 0x00;
-- private int parameterCount;
-- private int parameterOffset;
-- private int parameterDisplacement;
-- private int dataCount;
-- private int dataOffset;
-- private int dataDisplacement;
- private int fid;
-- private int pad = 0;
-- private int pad1 = 0;
-- private boolean hasMore = true;
-- private boolean isPrimary = true;
-- private int bufParameterOffset;
-- private int bufDataOffset;
-
- static final int TRANSACTION_BUF_SIZE = 0xFFFF;
-
- static final byte TRANS2_FIND_FIRST2 = (byte)0x01;
-- static final byte TRANS2_FIND_NEXT2 = (byte)0x02;
-+ static final byte TRANS2_FIND_NEXT2 = (byte)0x02;
- static final byte TRANS2_QUERY_FS_INFORMATION = (byte)0x03;
- static final byte TRANS2_QUERY_PATH_INFORMATION = (byte)0x05;
-- static final byte TRANS2_GET_DFS_REFERRAL = (byte)0x10;
-+ static final byte TRANS2_GET_DFS_REFERRAL = (byte)0x10;
- static final byte TRANS2_SET_FILE_INFORMATION = (byte)0x08;
-
- static final int NET_SHARE_ENUM = 0x0000;
- static final int NET_SERVER_ENUM2 = 0x0068;
- static final int NET_SERVER_ENUM3 = 0x00D7;
-
-- static final byte TRANS_PEEK_NAMED_PIPE = (byte)0x23;
-- static final byte TRANS_WAIT_NAMED_PIPE = (byte)0x53;
-- static final byte TRANS_CALL_NAMED_PIPE = (byte)0x54;
-+ static final byte TRANS_PEEK_NAMED_PIPE = (byte)0x23;
-+ static final byte TRANS_WAIT_NAMED_PIPE = (byte)0x53;
-+ static final byte TRANS_CALL_NAMED_PIPE = (byte)0x54;
- static final byte TRANS_TRANSACT_NAMED_PIPE = (byte)0x26;
-
-+ protected int primarySetupOffset;
-+ protected int secondaryParameterOffset;
-+ protected int parameterCount;
-+ protected int parameterOffset;
-+ protected int parameterDisplacement;
-+ protected int dataCount;
-+ protected int dataOffset;
-+ protected int dataDisplacement;
-+ protected int pad = 0;
-+ protected int pad1 = 0;
-+ protected boolean hasMore = true;
-+ protected boolean isPrimary = true;
-+ protected int bufParameterOffset;
-+ protected int bufDataOffset;
-+
- int totalParameterCount;
- int totalDataCount;
- int maxParameterCount;
-@@ -85,6 +88,8 @@
-
- SmbComTransaction() {
- maxParameterCount = 1024;
-+ primarySetupOffset = PRIMARY_SETUP_OFFSET;
-+ secondaryParameterOffset = SECONDARY_PARAMETER_OFFSET;
- }
-
- void reset() {
-@@ -100,9 +105,13 @@
- if( isPrimary ) {
- isPrimary = false;
-
-- parameterOffset = PRIMARY_SETUP_OFFSET + ( setupCount * 2 ) + 2;
-- if( command == SMB_COM_TRANSACTION && isResponse() == false ) {
-- parameterOffset += stringWireLength( name, parameterOffset );
-+ parameterOffset = primarySetupOffset + ( setupCount * 2 ) + 2;
-+ if (command != SMB_COM_NT_TRANSACT) {
-+ if( command == SMB_COM_TRANSACTION && isResponse() == false ) {
-+ parameterOffset += stringWireLength( name, parameterOffset );
-+ }
-+ } else if (command == SMB_COM_NT_TRANSACT) {
-+ parameterOffset += 2;
- }
- pad = parameterOffset % PADDING_SIZE;
- pad = pad == 0 ? 0 : PADDING_SIZE - pad;
-@@ -124,7 +133,11 @@
-
- dataCount = Math.min( totalDataCount, available );
- } else {
-- command = SMB_COM_TRANSACTION_SECONDARY;
-+ if (command != SMB_COM_NT_TRANSACT) {
-+ command = SMB_COM_TRANSACTION_SECONDARY;
-+ } else {
-+ command = SMB_COM_NT_TRANSACT_SECONDARY;
-+ }
- // totalParameterCount and totalDataCount are set ok from primary
-
- parameterOffset = SECONDARY_PARAMETER_OFFSET;
-@@ -170,12 +183,12 @@
- writeInt2( maxDataCount, dst, dstIndex );
- dstIndex += 2;
- dst[dstIndex++] = maxSetupCount;
-- dst[dstIndex++] = (byte)0x00; // Reserved1
-+ dst[dstIndex++] = (byte)0x00; // Reserved1
- writeInt2( flags, dst, dstIndex );
- dstIndex += 2;
- writeInt4( timeout, dst, dstIndex );
- dstIndex += 4;
-- dst[dstIndex++] = (byte)0x00; // Reserved2
-+ dst[dstIndex++] = (byte)0x00; // Reserved2
- dst[dstIndex++] = (byte)0x00;
- }
- writeInt2( parameterCount, dst, dstIndex );
-@@ -195,7 +208,7 @@
- dstIndex += 2;
- } else {
- dst[dstIndex++] = (byte)setupCount;
-- dst[dstIndex++] = (byte)0x00; // Reserved3
-+ dst[dstIndex++] = (byte)0x00; // Reserved3
- dstIndex += writeSetupWireFormat( dst, dstIndex );
- }
-
-@@ -211,7 +224,7 @@
-
- if( parameterCount > 0 ) {
- while( p-- > 0 ) {
-- dst[dstIndex++] = (byte)0x00; // Pad
-+ dst[dstIndex++] = (byte)0x00; // Pad
- }
-
- System.arraycopy( txn_buf, bufParameterOffset, dst, dstIndex, parameterCount );
-@@ -221,7 +234,7 @@
- if( dataCount > 0 ) {
- p = pad1;
- while( p-- > 0 ) {
-- dst[dstIndex++] = (byte)0x00; // Pad1
-+ dst[dstIndex++] = (byte)0x00; // Pad1
- }
- System.arraycopy( txn_buf, bufDataOffset, dst, dstIndex, dataCount );
- bufDataOffset += dataCount;
-diff -Naur jcifs_1.1.11/src/jcifs/smb/SmbComTransactionResponse.java jcifs_1.1.11acl2/src/jcifs/smb/SmbComTransactionResponse.java
---- jcifs_1.1.11/src/jcifs/smb/SmbComTransactionResponse.java 2005-05-04 23:10:46.000000000 -0400
-+++ jcifs_1.1.11acl2/src/jcifs/smb/SmbComTransactionResponse.java 2005-05-10 22:09:32.000000000 -0400
-@@ -22,26 +22,26 @@
-
- abstract class SmbComTransactionResponse extends ServerMessageBlock implements Enumeration {
-
-- // relative to headerStart
-- private static final int SETUP_OFFSET = 61;
-
- private static final int DISCONNECT_TID = 0x01;
- private static final int ONE_WAY_TRANSACTION = 0x02;
-
-- private int totalParameterCount;
-- private int totalDataCount;
-- private int parameterCount;
-- private int parameterOffset;
-- private int parameterDisplacement;
-- private int dataOffset;
-- private int dataDisplacement;
-- private int setupCount;
-- private int pad;
-- private int pad1;
-- private boolean parametersDone, dataDone;
-+ protected int totalParameterCount;
-+ protected int totalDataCount;
-+ protected int parameterCount;
-+ protected int parameterOffset;
-+ protected int parameterDisplacement;
-+ protected int dataOffset;
-+ protected int dataDisplacement;
-+ protected int setupCount;
-+ protected int pad;
-+ protected int pad1;
-+ protected boolean parametersDone, dataDone;
-
-- private int bufParameterStart;
-- private int bufDataStart;
-+ protected int bufParameterStart;
-+ protected int bufDataStart;
-+
-+ static final int SETUP_OFFSET = 61;
-
- int dataCount;
- byte subCommand;
-diff -Naur jcifs_1.1.11/src/jcifs/smb/SmbFileInputStream.java jcifs_1.1.11acl2/src/jcifs/smb/SmbFileInputStream.java
---- jcifs_1.1.11/src/jcifs/smb/SmbFileInputStream.java 2005-05-04 23:10:46.000000000 -0400
-+++ jcifs_1.1.11acl2/src/jcifs/smb/SmbFileInputStream.java 2005-05-10 22:09:32.000000000 -0400
-@@ -65,7 +65,7 @@
- SmbFileInputStream( SmbFile file, int openFlags ) throws SmbException, MalformedURLException, UnknownHostException {
- this.file = file;
- this.openFlags = openFlags;
-- file.open( openFlags, SmbFile.ATTR_NORMAL, 0 );
-+ file.open( openFlags, 0, SmbFile.ATTR_NORMAL, 0 );
- readSize = Math.min( file.tree.session.transport.rcv_buf_size - 70,
- file.tree.session.transport.server.maxBufferSize - 70 );
- }
-@@ -121,7 +121,7 @@
- throw new IOException( "Bad file descriptor" );
- }
- // ensure file is open
-- file.open( openFlags, SmbFile.ATTR_NORMAL, 0 );
-+ file.open( openFlags, 0, SmbFile.ATTR_NORMAL, 0 );
-
- /*
- * Read AndX Request / Response
-@@ -179,7 +179,7 @@
- }
-
- pipe = (SmbNamedPipe)file;
-- file.open(( pipe.pipeType & 0xFF0000 ) | SmbFile.O_EXCL, SmbFile.ATTR_NORMAL, 0 );
-+ file.open( SmbFile.O_EXCL, pipe.pipeType, SmbFile.ATTR_NORMAL, 0 );
-
- req = new TransPeekNamedPipe( file.unc, file.fid );
- resp = new TransPeekNamedPipeResponse( pipe );
-diff -Naur jcifs_1.1.11/src/jcifs/smb/SmbFile.java jcifs_1.1.11acl2/src/jcifs/smb/SmbFile.java
---- jcifs_1.1.11/src/jcifs/smb/SmbFile.java 2005-05-04 23:10:46.000000000 -0400
-+++ jcifs_1.1.11acl2/src/jcifs/smb/SmbFile.java 2005-05-10 22:09:32.000000000 -0400
-@@ -265,11 +265,10 @@
-
- public class SmbFile extends URLConnection {
-
-- // these are shifted for use in flags
-- static final int O_RDONLY = 0x010000;
-- static final int O_WRONLY = 0x020000;
-- static final int O_RDWR = 0x030000;
-- static final int O_APPEND = 0x040000;
-+ static final int O_RDONLY = 0x01;
-+ static final int O_WRONLY = 0x02;
-+ static final int O_RDWR = 0x04;
-+ static final int O_APPEND = 0x08;
-
- // share access
- /**
-@@ -846,7 +845,7 @@
- boolean isConnected() {
- return (connected = tree != null && tree.treeConnected);
- }
-- int open0( int flags, int attrs, int options ) throws SmbException {
-+ int open0( int flags, int access, int attrs, int options ) throws SmbException {
- int f;
-
- connect0();
-@@ -860,7 +859,7 @@
-
- if( tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS )) {
- SmbComNTCreateAndXResponse response = new SmbComNTCreateAndXResponse();
-- send( new SmbComNTCreateAndX( unc, flags, shareAccess,
-+ send( new SmbComNTCreateAndX( unc, flags, access, shareAccess,
- attrs, options, null ), response );
- f = response.fid;
- attributes = response.extFileAttributes & ATTR_GET_MASK;
-@@ -868,17 +867,17 @@
- isExists = true;
- } else {
- SmbComOpenAndXResponse response = new SmbComOpenAndXResponse();
-- send( new SmbComOpenAndX( unc, flags, null ), response );
-+ send( new SmbComOpenAndX( unc, flags, access, null ), response );
- f = response.fid;
- }
-
- return f;
- }
-- void open( int flags, int attrs, int options ) throws SmbException {
-+ void open( int flags, int access, int attrs, int options ) throws SmbException {
- if( isOpen() ) {
- return;
- }
-- fid = open0( flags, attrs, options );
-+ fid = open0( flags, access, attrs, options );
- opened = true;
- }
- boolean isOpen() {
-@@ -1933,17 +1932,17 @@
- int off;
-
- try {
-- open( SmbFile.O_RDONLY, ATTR_NORMAL, 0 );
-+ open( SmbFile.O_RDONLY, 0, ATTR_NORMAL, 0 );
- try {
-- dest.open( SmbFile.O_CREAT | SmbFile.O_WRONLY | SmbFile.O_TRUNC |
-- SmbComNTCreateAndX.FILE_WRITE_ATTRIBUTES << 16, attributes, 0 );
-+ dest.open( SmbFile.O_CREAT | SmbFile.O_WRONLY | SmbFile.O_TRUNC,
-+ SmbComNTCreateAndX.FILE_WRITE_ATTRIBUTES, attributes, 0 );
- } catch( SmbAuthException sae ) {
- if(( dest.attributes & ATTR_READONLY ) != 0 ) {
- /* Remove READONLY and try again
- */
- dest.setPathInformation( dest.attributes & ~ATTR_READONLY, 0L, 0L );
-- dest.open( SmbFile.O_CREAT | SmbFile.O_WRONLY | SmbFile.O_TRUNC |
-- SmbComNTCreateAndX.FILE_WRITE_ATTRIBUTES << 16, attributes, 0 );
-+ dest.open( SmbFile.O_CREAT | SmbFile.O_WRONLY | SmbFile.O_TRUNC,
-+ SmbComNTCreateAndX.FILE_WRITE_ATTRIBUTES, attributes, 0 );
- } else {
- throw sae;
- }
-@@ -2262,7 +2261,7 @@
- if( getUncPath0().length() == 1 ) {
- throw new SmbException( "Invalid operation for workgroups, servers, or shares" );
- }
-- close( open0( O_RDWR | O_CREAT | O_EXCL, ATTR_NORMAL, 0 ), 0L );
-+ close( open0( O_RDWR | O_CREAT | O_EXCL, 0, ATTR_NORMAL, 0 ), 0L );
- }
-
- void setPathInformation( int attrs, long ctime, long mtime ) throws SmbException {
-@@ -2272,7 +2271,7 @@
- options = 1;
- }
-
-- f = open0( O_RDONLY | SmbComNTCreateAndX.FILE_WRITE_ATTRIBUTES << 16, attrs, options );
-+ f = open0( O_RDONLY, SmbComNTCreateAndX.FILE_WRITE_ATTRIBUTES, attrs, options );
- sendTransaction( new Trans2SetFileInformation( f, attrs, ctime, mtime ),
- new Trans2SetFileInformationResponse() );
- close( f, 0L );
-@@ -2502,4 +2501,19 @@
- public OutputStream getOutputStream() throws IOException {
- return new SmbFileOutputStream( this );
- }
-+
-+ public ACE[] getSecurity() throws IOException {
-+ int f = open0( O_RDONLY, SmbComNTCreateAndX.READ_CONTROL, 0, isDirectory() ? 1 : 0 );
-+
-+ /*
-+ * NtTrans Query Security Desc Request / Response
-+ */
-+
-+ NtTransQuerySecurityDesc request = new NtTransQuerySecurityDesc( f, 0x04 );
-+ NtTransQuerySecurityDescResponse response = new NtTransQuerySecurityDescResponse();
-+ sendTransaction( request, response );
-+
-+ close( f, 0L );
-+ return response.aces;
-+ }
- }
-diff -Naur jcifs_1.1.11/src/jcifs/smb/SmbFileOutputStream.java jcifs_1.1.11acl2/src/jcifs/smb/SmbFileOutputStream.java
---- jcifs_1.1.11/src/jcifs/smb/SmbFileOutputStream.java 2005-05-04 23:10:46.000000000 -0400
-+++ jcifs_1.1.11acl2/src/jcifs/smb/SmbFileOutputStream.java 2005-05-10 22:09:32.000000000 -0400
-@@ -136,7 +136,7 @@
- file.sendTransaction( new TransWaitNamedPipe( "\\pipe" + file.unc ),
- new TransWaitNamedPipeResponse() );
- }
-- file.open( openFlags, SmbFile.ATTR_NORMAL, 0 );
-+ file.open( openFlags, openFlags >>> 16, SmbFile.ATTR_NORMAL, 0 );
- this.openFlags &= ~(SmbFile.O_CREAT | SmbFile.O_TRUNC); /* in case close and reopen */
- writeSize = file.tree.session.transport.snd_buf_size - 70;
-
-@@ -206,7 +206,7 @@
- file.sendTransaction( new TransWaitNamedPipe( "\\pipe" + file.unc ),
- new TransWaitNamedPipeResponse() );
- }
-- file.open( openFlags, SmbFile.ATTR_NORMAL, 0 );
-+ file.open( openFlags, openFlags >>> 16, SmbFile.ATTR_NORMAL, 0 );
- if( append ) {
- fp = file.length();
- }
-diff -Naur jcifs_1.1.11/src/jcifs/smb/SmbRandomAccessFile.java jcifs_1.1.11acl2/src/jcifs/smb/SmbRandomAccessFile.java
---- jcifs_1.1.11/src/jcifs/smb/SmbRandomAccessFile.java 2005-05-04 23:10:46.000000000 -0400
-+++ jcifs_1.1.11acl2/src/jcifs/smb/SmbRandomAccessFile.java 2005-05-10 22:09:32.000000000 -0400
-@@ -53,7 +53,7 @@
- } else {
- throw new IllegalArgumentException( "Invalid mode" );
- }
-- file.open( openFlags, SmbFile.ATTR_NORMAL, options );
-+ file.open( openFlags, 0, SmbFile.ATTR_NORMAL, options );
- readSize = file.tree.session.transport.rcv_buf_size - 70;
- writeSize = file.tree.session.transport.snd_buf_size - 70;
- fp = 0L;
-@@ -76,7 +76,7 @@
-
- // ensure file is open
- if( file.isOpen() == false ) {
-- file.open( openFlags, SmbFile.ATTR_NORMAL, options );
-+ file.open( openFlags, 0, SmbFile.ATTR_NORMAL, options );
- }
-
- int r, n;
-@@ -129,7 +129,7 @@
-
- // ensure file is open
- if( file.isOpen() == false ) {
-- file.open( openFlags, SmbFile.ATTR_NORMAL, options );
-+ file.open( openFlags, 0, SmbFile.ATTR_NORMAL, options );
- }
-
- int w;
-@@ -153,7 +153,7 @@
- public void setLength( long newLength ) throws SmbException {
- // ensure file is open
- if( file.isOpen() == false ) {
-- file.open( openFlags, SmbFile.ATTR_NORMAL, options );
-+ file.open( openFlags, 0, SmbFile.ATTR_NORMAL, options );
- }
- SmbComWriteResponse rsp = new SmbComWriteResponse();
- file.send( new SmbComWrite( file.fid, (int)(newLength & 0xFFFFFFFFL), 0, tmp, 0, 0 ), rsp );
-diff -Naur jcifs_1.1.11/src/jcifs/smb/TransactNamedPipeOutputStream.java jcifs_1.1.11acl2/src/jcifs/smb/TransactNamedPipeOutputStream.java
---- jcifs_1.1.11/src/jcifs/smb/TransactNamedPipeOutputStream.java 2005-05-04 23:10:46.000000000 -0400
-+++ jcifs_1.1.11acl2/src/jcifs/smb/TransactNamedPipeOutputStream.java 2005-05-10 22:09:32.000000000 -0400
-@@ -57,7 +57,7 @@
- new TransCallNamedPipeResponse( pipe ));
- } else if(( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_TRANSACT ) ==
- SmbNamedPipe.PIPE_TYPE_TRANSACT ) {
-- pipe.open(( pipe.pipeType & 0xFFFF0000 ) | SmbFile.O_EXCL, SmbFile.ATTR_NORMAL, 0 );
-+ pipe.open( SmbFile.O_EXCL, pipe.pipeType, SmbFile.ATTR_NORMAL, 0 );
- TransTransactNamedPipe req = new TransTransactNamedPipe( pipe.fid, b, off, len );
- if (dcePipe) {
- req.maxDataCount = 1024;
while (entries.hasNext()) {
Map.Entry entry = (Map.Entry) entries.next();
if (key.equalsIgnoreCase((String) entry.getKey())) {
- entry.setValue(value);
+ entry.setValue(values);
found = true;
break;
}
(byte) 'S', (byte) 'S', (byte) 'P', (byte) 0
};
- private static final String OEM_ENCODING =
- Config.getProperty("jcifs.encoding",
- System.getProperty("file.encoding"));
+ private static final String OEM_ENCODING = Config.getProperty("jcifs.encoding", "Cp850" );
private int flags;
+++ /dev/null
-/* jcifs smb client library in Java
- * Copyright (C) 2005 "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;
-
-class NtTransQuerySecurityDesc extends SmbComNtTransaction {
-
- int fid;
- int securityInformation;
-
- NtTransQuerySecurityDesc( int fid, int securityInformation ) {
- this.fid = fid;
- this.securityInformation = securityInformation;
- command = SMB_COM_NT_TRANSACT;
- function = NT_TRANSACT_QUERY_SECURITY_DESC;
- setupCount = 0;
- totalDataCount = 0;
- maxParameterCount = 4;
- maxDataCount = 4096;
- maxSetupCount = (byte)0x00;
- }
-
- int writeSetupWireFormat( byte[] dst, int dstIndex ) {
- return 0;
- }
- int writeParametersWireFormat( byte[] dst, int dstIndex ) {
- int start = dstIndex;
-
- writeInt2( fid, dst, dstIndex );
- dstIndex += 2;
- dst[dstIndex++] = (byte)0x00; // Reserved
- dst[dstIndex++] = (byte)0x00; // Reserved
- writeInt4( securityInformation, dst, dstIndex );
- dstIndex += 4;
-
- return dstIndex - start;
- }
- int writeDataWireFormat( byte[] dst, int dstIndex ) {
- return 0;
- }
- int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) {
- return 0;
- }
- int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) {
- return 0;
- }
- int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) {
- return 0;
- }
- public String toString() {
- return new String( "NtTransGetSecurityDesc[" + super.toString() +
- ",fid=0x" + Hexdump.toHexString( fid, 4 ) +
- ",securityInformation=0x" + Hexdump.toHexString( securityInformation, 8 ) + "]" );
- }
-}
--- /dev/null
+/* jcifs smb client library in Java
+ * Copyright (C) 2005 "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;
+
+class NtTransQuerySecurityDesc extends SmbComNtTransaction {
+
+ int fid;
+ int securityInformation;
+
+ NtTransQuerySecurityDesc( int fid, int securityInformation ) {
+ this.fid = fid;
+ this.securityInformation = securityInformation;
+ command = SMB_COM_NT_TRANSACT;
+ function = NT_TRANSACT_QUERY_SECURITY_DESC;
+ setupCount = 0;
+ totalDataCount = 0;
+ maxParameterCount = 4;
+ maxDataCount = 4096;
+ maxSetupCount = (byte)0x00;
+ }
+
+ int writeSetupWireFormat( byte[] dst, int dstIndex ) {
+ return 0;
+ }
+ int writeParametersWireFormat( byte[] dst, int dstIndex ) {
+ int start = dstIndex;
+
+ writeInt2( fid, dst, dstIndex );
+ dstIndex += 2;
+ dst[dstIndex++] = (byte)0x00; // Reserved
+ dst[dstIndex++] = (byte)0x00; // Reserved
+ writeInt4( securityInformation, dst, dstIndex );
+ dstIndex += 4;
+
+ return dstIndex - start;
+ }
+ int writeDataWireFormat( byte[] dst, int dstIndex ) {
+ return 0;
+ }
+ int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) {
+ return 0;
+ }
+ int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) {
+ return 0;
+ }
+ int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) {
+ return 0;
+ }
+ public String toString() {
+ return new String( "NtTransGetSecurityDesc[" + super.toString() +
+ ",fid=0x" + Hexdump.toHexString( fid, 4 ) +
+ ",securityInformation=0x" + Hexdump.toHexString( securityInformation, 8 ) + "]" );
+ }
+}
+++ /dev/null
-/* jcifs smb client library in Java
- * Copyright (C) 2005 "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;
-
-class NtTransQuerySecurityDescResponse extends SmbComNtTransactionResponse {
-
- int type;
- ACE[] aces;
-
- NtTransQuerySecurityDescResponse() {
- super();
- }
-
- int writeSetupWireFormat( byte[] dst, int dstIndex ) {
- return 0;
- }
- int writeParametersWireFormat( byte[] dst, int dstIndex ) {
- return 0;
- }
- int writeDataWireFormat( byte[] dst, int dstIndex ) {
- return 0;
- }
- int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) {
- return 0;
- }
- int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) {
- length = readInt4( buffer, bufferIndex );
- return 4;
- }
- int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) {
- int start = bufferIndex;
-
- bufferIndex++; // revision
- bufferIndex++;
- type = readInt2(buffer, bufferIndex);
- bufferIndex += 2;
- readInt4(buffer, bufferIndex); // offset to owner sid
- bufferIndex += 4;
- readInt4(buffer, bufferIndex); // offset to group sid
- bufferIndex += 4;
- readInt4(buffer, bufferIndex); // offset to sacl
- bufferIndex += 4;
- int daclOffset = readInt4(buffer, bufferIndex);
-
- bufferIndex = start + daclOffset;
-
- bufferIndex++; // revision
- bufferIndex++;
- int size = readInt2(buffer, bufferIndex);
- bufferIndex += 2;
- int numAces = readInt4(buffer, bufferIndex);
- bufferIndex += 4;
-
- if (numAces > 4096)
- throw new RuntimeException( "Invalid SecurityDescriptor" );
-
- aces = new ACE[numAces];
- for (int i = 0; i < numAces; i++) {
- aces[i] = new ACE();
- bufferIndex += aces[i].decode(buffer, bufferIndex);
- }
-
- return bufferIndex - start;
- }
- public String toString() {
- return new String( "NtTransQuerySecurityResponse[" +
- super.toString() + "]" );
- }
-}
--- /dev/null
+/* jcifs smb client library in Java
+ * Copyright (C) 2005 "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;
+
+class NtTransQuerySecurityDescResponse extends SmbComNtTransactionResponse {
+
+ int type;
+ ACE[] aces;
+
+ NtTransQuerySecurityDescResponse() {
+ super();
+ }
+
+ int writeSetupWireFormat( byte[] dst, int dstIndex ) {
+ return 0;
+ }
+ int writeParametersWireFormat( byte[] dst, int dstIndex ) {
+ return 0;
+ }
+ int writeDataWireFormat( byte[] dst, int dstIndex ) {
+ return 0;
+ }
+ int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) {
+ return 0;
+ }
+ int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) {
+ length = readInt4( buffer, bufferIndex );
+ return 4;
+ }
+ int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) {
+ int start = bufferIndex;
+
+ bufferIndex++; // revision
+ bufferIndex++;
+ type = readInt2(buffer, bufferIndex);
+ bufferIndex += 2;
+ readInt4(buffer, bufferIndex); // offset to owner sid
+ bufferIndex += 4;
+ readInt4(buffer, bufferIndex); // offset to group sid
+ bufferIndex += 4;
+ readInt4(buffer, bufferIndex); // offset to sacl
+ bufferIndex += 4;
+ int daclOffset = readInt4(buffer, bufferIndex);
+
+ bufferIndex = start + daclOffset;
+
+ bufferIndex++; // revision
+ bufferIndex++;
+ int size = readInt2(buffer, bufferIndex);
+ bufferIndex += 2;
+ int numAces = readInt4(buffer, bufferIndex);
+ bufferIndex += 4;
+
+ if (numAces > 4096)
+ throw new RuntimeException( "Invalid SecurityDescriptor" );
+
+ aces = new ACE[numAces];
+ for (int i = 0; i < numAces; i++) {
+ aces[i] = new ACE();
+ bufferIndex += aces[i].decode(buffer, bufferIndex);
+ }
+
+ return bufferIndex - start;
+ }
+ public String toString() {
+ return new String( "NtTransQuerySecurityResponse[" +
+ super.toString() + "]" );
+ }
+}
static final byte SMB_COM_SESSION_SETUP_ANDX = (byte)0x73;
static final byte SMB_COM_LOGOFF_ANDX = (byte)0x74;
static final byte SMB_COM_TREE_CONNECT_ANDX = (byte)0x75;
+ static final byte SMB_COM_NT_TRANSACT = (byte)0xA0;
+ static final byte SMB_COM_NT_TRANSACT_SECONDARY = (byte)0xA1;
static final byte SMB_COM_NT_CREATE_ANDX = (byte)0xA2;
/*
case SMB_COM_CREATE_DIRECTORY:
c = "SMB_COM_CREATE_DIRECTORY";
break;
+ case SMB_COM_NT_TRANSACT:
+ c = "SMB_COM_NT_TRANSACT";
+ break;
+ case SMB_COM_NT_TRANSACT_SECONDARY:
+ c = "SMB_COM_NT_TRANSACT_SECONDARY";
+ break;
default:
c = "UNKNOWN";
}
+++ /dev/null
-/* jcifs smb client library in Java
- * Copyright (C) 2000 "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;
-
-class SmbComMove extends ServerMessageBlock {
-
- String oldFileName;
- String newFileName;
- int tid2;
- int openFunction;
- int flags;
-
- SmbComMove( String oldFileName, String newFileName, int tid2 ) {
- command = SMB_COM_MOVE;
- this.oldFileName = oldFileName;
- this.newFileName = newFileName;
- this.tid2 = tid2 == 0 ? -1 : tid2;
-
- // these will need to be adjusted
- openFunction = OPEN_FUNCTION_FAIL_IF_EXISTS;
- flags = FLAGS_TARGET_MUST_BE_FILE;
- }
-
- int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) {
- writeInt2( tid2, dst, dstIndex );
- dstIndex += 2;
- writeInt2( openFunction, dst, dstIndex );
- dstIndex += 2;
- writeInt2( flags, dst, dstIndex );
- return 6;
- }
- int writeBytesWireFormat( byte[] dst, int dstIndex ) {
- int start = dstIndex;
-
- dst[dstIndex++] = (byte)0x04;
- dstIndex += writeString( oldFileName, dst, dstIndex );
- dst[dstIndex++] = (byte)0x04;
- dstIndex += writeString( newFileName, dst, dstIndex );
-
- return dstIndex - start;
- }
- int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) {
- return 0;
- }
- int readBytesWireFormat( byte[] buffer, int bufferIndex ) {
- return 0;
- }
- public String toString() {
- return new String( "SmbComMove[" +
- super.toString() +
- ",oldFileName=" + oldFileName +
- ",newFileName=" + newFileName +
- ",tid2=" + tid2 +
- ",openFunction=" + openFunction +
- ",flags=" + flags + "]" );
- }
-}
+++ /dev/null
-/* jcifs smb client library in Java
- * Copyright (C) 2000 "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;
-
-class SmbComMoveResponse extends ServerMessageBlock {
-
- int count;
- String errorFileName;
-
- SmbComMoveResponse() {
- count = 0;
- errorFileName = "";
- }
-
- 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 );
- return 2;
- }
- int readBytesWireFormat( byte[] buffer, int bufferIndex ) {
- bufferIndex++;
- errorFileName = readString( buffer, bufferIndex );
- return stringWireLength( errorFileName, bufferIndex );
- }
- public String toString() {
- return new String( "SmbComMoveResponse[" +
- super.toString() +
- ",count=" + count +
- ",errorFileName=" + errorFileName + "]" );
- }
-}
class SmbComNTCreateAndX extends AndXServerMessageBlock {
- // access mask encoding
- static final int FILE_READ_DATA = 0x00000001; // 1
- static final int FILE_WRITE_DATA = 0x00000002; // 2
- static final int FILE_APPEND_DATA = 0x00000004; // 3
- static final int FILE_READ_EA = 0x00000008; // 4
- static final int FILE_WRITE_EA = 0x00000010; // 5
- static final int FILE_EXECUTE = 0x00000020; // 6
- static final int FILE_DELETE = 0x00000040; // 7
- static final int FILE_READ_ATTRIBUTES = 0x00000080; // 8
- static final int FILE_WRITE_ATTRIBUTES = 0x00000100; // 9
- static final int DELETE = 0x00010000; // 16
- static final int READ_CONTROL = 0x00020000; // 17
- static final int WRITE_DAC = 0x00040000; // 18
- static final int WRITE_OWNER = 0x00080000; // 19
- static final int SYNCHRONIZE = 0x00100000; // 20
- static final int GENERIC_ALL = 0x10000000; // 28
- static final int GENERIC_EXECUTE = 0x20000000; // 29
- static final int GENERIC_WRITE = 0x40000000; // 30
- static final int GENERIC_READ = 0x80000000; // 31
-
// share access specified in SmbFile
// create disposition
private int namelen_index;
SmbComNTCreateAndX( String name, int flags,
+ int access,
int shareAccess,
int extFileAttributes,
int createOptions,
this.path = name;
command = SMB_COM_NT_CREATE_ANDX;
- // desiredAccess
- desiredAccess = ( flags >>> 16 ) & 0xFFFF;
- desiredAccess |= FILE_READ_EA | FILE_READ_ATTRIBUTES;
+ desiredAccess = access;
+ desiredAccess |= FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES;
// extFileAttributes
this.extFileAttributes = extFileAttributes;
+++ /dev/null
-/* jcifs smb client library in Java
- * Copyright (C) 2005 "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;
-
-abstract class SmbComNtTransaction extends SmbComTransaction {
-
- // relative to headerStart
- private static final int NTT_PRIMARY_SETUP_OFFSET = 69;
- private static final int NTT_SECONDARY_PARAMETER_OFFSET = 51;
-
- static final int NT_TRANSACT_QUERY_SECURITY_DESC = 6;
-
- int function;
-
- SmbComNtTransaction() {
- super();
- primarySetupOffset = NTT_PRIMARY_SETUP_OFFSET;
- secondaryParameterOffset = NTT_SECONDARY_PARAMETER_OFFSET;
- }
-
- int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) {
- int start = dstIndex;
-
- if (command != SMB_COM_NT_TRANSACT_SECONDARY) {
- dst[dstIndex++] = maxSetupCount;
- } else {
- dst[dstIndex++] = (byte)0x00; // Reserved
- }
- dst[dstIndex++] = (byte)0x00; // Reserved
- dst[dstIndex++] = (byte)0x00; // Reserved
- writeInt4( totalParameterCount, dst, dstIndex );
- dstIndex += 4;
- writeInt4( totalDataCount, dst, dstIndex );
- dstIndex += 4;
- if (command != SMB_COM_NT_TRANSACT_SECONDARY) {
- writeInt4( maxParameterCount, dst, dstIndex );
- dstIndex += 4;
- writeInt4( maxDataCount, dst, dstIndex );
- dstIndex += 4;
- }
- writeInt4( parameterCount, dst, dstIndex );
- dstIndex += 4;
- writeInt4(( parameterCount == 0 ? 0 : parameterOffset ), dst, dstIndex );
- dstIndex += 4;
- if (command == SMB_COM_NT_TRANSACT_SECONDARY) {
- writeInt4( parameterDisplacement, dst, dstIndex );
- dstIndex += 4;
- }
- writeInt4( dataCount, dst, dstIndex );
- dstIndex += 4;
- writeInt4(( dataCount == 0 ? 0 : dataOffset ), dst, dstIndex );
- dstIndex += 4;
- if (command == SMB_COM_NT_TRANSACT_SECONDARY) {
- writeInt4( dataDisplacement, dst, dstIndex );
- dstIndex += 4;
- dst[dstIndex++] = (byte)0x00; // Reserved1
- } else {
- dst[dstIndex++] = (byte)setupCount;
- writeInt2( function, dst, dstIndex );
- dstIndex += 2;
- dstIndex += writeSetupWireFormat( dst, dstIndex );
- }
-
- return dstIndex - start;
- }
-}
--- /dev/null
+/* jcifs smb client library in Java
+ * Copyright (C) 2005 "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;
+
+abstract class SmbComNtTransaction extends SmbComTransaction {
+
+ // relative to headerStart
+ private static final int NTT_PRIMARY_SETUP_OFFSET = 69;
+ private static final int NTT_SECONDARY_PARAMETER_OFFSET = 51;
+
+ static final int NT_TRANSACT_QUERY_SECURITY_DESC = 6;
+
+ int function;
+
+ SmbComNtTransaction() {
+ super();
+ primarySetupOffset = NTT_PRIMARY_SETUP_OFFSET;
+ secondaryParameterOffset = NTT_SECONDARY_PARAMETER_OFFSET;
+ }
+
+ int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) {
+ int start = dstIndex;
+
+ if (command != SMB_COM_NT_TRANSACT_SECONDARY) {
+ dst[dstIndex++] = maxSetupCount;
+ } else {
+ dst[dstIndex++] = (byte)0x00; // Reserved
+ }
+ dst[dstIndex++] = (byte)0x00; // Reserved
+ dst[dstIndex++] = (byte)0x00; // Reserved
+ writeInt4( totalParameterCount, dst, dstIndex );
+ dstIndex += 4;
+ writeInt4( totalDataCount, dst, dstIndex );
+ dstIndex += 4;
+ if (command != SMB_COM_NT_TRANSACT_SECONDARY) {
+ writeInt4( maxParameterCount, dst, dstIndex );
+ dstIndex += 4;
+ writeInt4( maxDataCount, dst, dstIndex );
+ dstIndex += 4;
+ }
+ writeInt4( parameterCount, dst, dstIndex );
+ dstIndex += 4;
+ writeInt4(( parameterCount == 0 ? 0 : parameterOffset ), dst, dstIndex );
+ dstIndex += 4;
+ if (command == SMB_COM_NT_TRANSACT_SECONDARY) {
+ writeInt4( parameterDisplacement, dst, dstIndex );
+ dstIndex += 4;
+ }
+ writeInt4( dataCount, dst, dstIndex );
+ dstIndex += 4;
+ writeInt4(( dataCount == 0 ? 0 : dataOffset ), dst, dstIndex );
+ dstIndex += 4;
+ if (command == SMB_COM_NT_TRANSACT_SECONDARY) {
+ writeInt4( dataDisplacement, dst, dstIndex );
+ dstIndex += 4;
+ dst[dstIndex++] = (byte)0x00; // Reserved1
+ } else {
+ dst[dstIndex++] = (byte)setupCount;
+ writeInt2( function, dst, dstIndex );
+ dstIndex += 2;
+ dstIndex += writeSetupWireFormat( dst, dstIndex );
+ }
+
+ return dstIndex - start;
+ }
+}
+++ /dev/null
-/* jcifs smb client library in Java
- * Copyright (C) 2005 "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;
-
-abstract class SmbComNtTransactionResponse extends SmbComTransactionResponse {
-
- SmbComNtTransactionResponse() {
- super();
- }
-
- int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) {
- int start = bufferIndex;
-
- buffer[bufferIndex++] = (byte)0x00; // Reserved
- buffer[bufferIndex++] = (byte)0x00; // Reserved
- buffer[bufferIndex++] = (byte)0x00; // Reserved
-
- totalParameterCount = readInt4( buffer, bufferIndex );
- if( bufDataStart == 0 ) {
- bufDataStart = totalParameterCount;
- }
- bufferIndex += 4;
- totalDataCount = readInt4( buffer, bufferIndex );
- bufferIndex += 4;
- parameterCount = readInt4( buffer, bufferIndex );
- bufferIndex += 4;
- parameterOffset = readInt4( buffer, bufferIndex );
- bufferIndex += 4;
- parameterDisplacement = readInt4( buffer, bufferIndex );
- bufferIndex += 4;
- dataCount = readInt4( buffer, bufferIndex );
- bufferIndex += 4;
- dataOffset = readInt4( buffer, bufferIndex );
- bufferIndex += 4;
- dataDisplacement = readInt4( buffer, bufferIndex );
- bufferIndex += 4;
- setupCount = buffer[bufferIndex] & 0xFF;
- bufferIndex += 2;
- if( setupCount != 0 ) {
- if( log.level > 2 )
- log.println( "setupCount is not zero: " + setupCount );
- }
-
- return bufferIndex - start;
- }
-}
--- /dev/null
+/* jcifs smb client library in Java
+ * Copyright (C) 2005 "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;
+
+abstract class SmbComNtTransactionResponse extends SmbComTransactionResponse {
+
+ SmbComNtTransactionResponse() {
+ super();
+ }
+
+ int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) {
+ int start = bufferIndex;
+
+ buffer[bufferIndex++] = (byte)0x00; // Reserved
+ buffer[bufferIndex++] = (byte)0x00; // Reserved
+ buffer[bufferIndex++] = (byte)0x00; // Reserved
+
+ totalParameterCount = readInt4( buffer, bufferIndex );
+ if( bufDataStart == 0 ) {
+ bufDataStart = totalParameterCount;
+ }
+ bufferIndex += 4;
+ totalDataCount = readInt4( buffer, bufferIndex );
+ bufferIndex += 4;
+ parameterCount = readInt4( buffer, bufferIndex );
+ bufferIndex += 4;
+ parameterOffset = readInt4( buffer, bufferIndex );
+ bufferIndex += 4;
+ parameterDisplacement = readInt4( buffer, bufferIndex );
+ bufferIndex += 4;
+ dataCount = readInt4( buffer, bufferIndex );
+ bufferIndex += 4;
+ dataOffset = readInt4( buffer, bufferIndex );
+ bufferIndex += 4;
+ dataDisplacement = readInt4( buffer, bufferIndex );
+ bufferIndex += 4;
+ setupCount = buffer[bufferIndex] & 0xFF;
+ bufferIndex += 2;
+ if( setupCount != 0 ) {
+ if( log.level > 2 )
+ log.println( "setupCount is not zero: " + setupCount );
+ }
+
+ return bufferIndex - start;
+ }
+}
// flags is NOT the same as flags member
- SmbComOpenAndX( String fileName, int flags, ServerMessageBlock andx ) {
+ SmbComOpenAndX( String fileName, int access, int flags, ServerMessageBlock andx ) {
super( andx );
this.path = fileName;
command = SMB_COM_OPEN_ANDX;
- // desiredAccess
- desiredAccess = ( flags >>> 16 ) & 0x3;
+ desiredAccess = access & 0x3;
if( desiredAccess == 0x3 ) {
desiredAccess = 0x2; /* Mmm, I thought 0x03 was RDWR */
}
private static final int PADDING_SIZE = 2;
private int flags = 0x00;
- private int parameterCount;
- private int parameterOffset;
- private int parameterDisplacement;
- private int dataCount;
- private int dataOffset;
- private int dataDisplacement;
private int fid;
private int pad = 0;
private int pad1 = 0;
static final byte TRANS_CALL_NAMED_PIPE = (byte)0x54;
static final byte TRANS_TRANSACT_NAMED_PIPE = (byte)0x26;
+ protected int primarySetupOffset;
+ protected int secondaryParameterOffset;
+ protected int parameterCount;
+ protected int parameterOffset;
+ protected int parameterDisplacement;
+ protected int dataCount;
+ protected int dataOffset;
+ protected int dataDisplacement;
+
int totalParameterCount;
int totalDataCount;
int maxParameterCount;
SmbComTransaction() {
maxParameterCount = 1024;
+ primarySetupOffset = PRIMARY_SETUP_OFFSET;
+ secondaryParameterOffset = SECONDARY_PARAMETER_OFFSET;
}
void reset() {
if( isPrimary ) {
isPrimary = false;
- parameterOffset = PRIMARY_SETUP_OFFSET + ( setupCount * 2 ) + 2;
- if( command == SMB_COM_TRANSACTION && isResponse() == false ) {
- parameterOffset += stringWireLength( name, parameterOffset );
+ parameterOffset = primarySetupOffset + ( setupCount * 2 ) + 2;
+ if (command != SMB_COM_NT_TRANSACT) {
+ if( command == SMB_COM_TRANSACTION && isResponse() == false ) {
+ parameterOffset += stringWireLength( name, parameterOffset );
+ }
+ } else if (command == SMB_COM_NT_TRANSACT) {
+ parameterOffset += 2;
}
pad = parameterOffset % PADDING_SIZE;
pad = pad == 0 ? 0 : PADDING_SIZE - pad;
dataCount = Math.min( totalDataCount, available );
} else {
- command = SMB_COM_TRANSACTION_SECONDARY;
+ if (command != SMB_COM_NT_TRANSACT) {
+ command = SMB_COM_TRANSACTION_SECONDARY;
+ } else {
+ command = SMB_COM_NT_TRANSACT_SECONDARY;
+ }
// totalParameterCount and totalDataCount are set ok from primary
parameterOffset = SECONDARY_PARAMETER_OFFSET;
private static final int DISCONNECT_TID = 0x01;
private static final int ONE_WAY_TRANSACTION = 0x02;
- private int totalParameterCount;
- private int totalDataCount;
- private int parameterCount;
- private int parameterOffset;
- private int parameterDisplacement;
- private int dataOffset;
- private int dataDisplacement;
- private int setupCount;
private int pad;
private int pad1;
private boolean parametersDone, dataDone;
- private int bufParameterStart;
- private int bufDataStart;
+ protected int totalParameterCount;
+ protected int totalDataCount;
+ protected int parameterCount;
+ protected int parameterOffset;
+ protected int parameterDisplacement;
+ protected int dataOffset;
+ protected int dataDisplacement;
+ protected int setupCount;
+ protected int bufParameterStart;
+ protected int bufDataStart;
int dataCount;
byte subCommand;
static final int DEFAULT_PORT = 445;
static final int DEFAULT_MAX_MPX_COUNT = 10;
- static final int DEFAULT_RESPONSE_TIMEOUT = 10000;
- static final int DEFAULT_SO_TIMEOUT = 15000;
+ static final int DEFAULT_RESPONSE_TIMEOUT = 30000;
+ static final int DEFAULT_SO_TIMEOUT = 35000;
static final int DEFAULT_RCV_BUF_SIZE = 60416;
static final int DEFAULT_SND_BUF_SIZE = 16644;
static final int DEFAULT_SSN_LIMIT = 250;
static final int ATTR_NORMAL = 0x080;
static final int ATTR_TEMPORARY = 0x100;
+ // access mask encoding
+ static final int FILE_READ_DATA = 0x00000001; // 1
+ static final int FILE_WRITE_DATA = 0x00000002; // 2
+ static final int FILE_APPEND_DATA = 0x00000004; // 3
+ static final int FILE_READ_EA = 0x00000008; // 4
+ static final int FILE_WRITE_EA = 0x00000010; // 5
+ static final int FILE_EXECUTE = 0x00000020; // 6
+ static final int FILE_DELETE = 0x00000040; // 7
+ static final int FILE_READ_ATTRIBUTES = 0x00000080; // 8
+ static final int FILE_WRITE_ATTRIBUTES = 0x00000100; // 9
+ static final int DELETE = 0x00010000; // 16
+ static final int READ_CONTROL = 0x00020000; // 17
+ static final int WRITE_DAC = 0x00040000; // 18
+ static final int WRITE_OWNER = 0x00080000; // 19
+ static final int SYNCHRONIZE = 0x00100000; // 20
+ static final int GENERIC_ALL = 0x10000000; // 28
+ static final int GENERIC_EXECUTE = 0x20000000; // 29
+ static final int GENERIC_WRITE = 0x40000000; // 30
+ static final int GENERIC_READ = 0x80000000; // 31
+
+
// flags for move and copy
static final int FLAGS_TARGET_MUST_BE_FILE = 0x0001;
static final int FLAGS_TARGET_MUST_BE_DIRECTORY = 0x0002;
static final TimeZone TZ = TimeZone.getDefault();
static final boolean USE_BATCHING = Config.getBoolean( "jcifs.smb.client.useBatching", true );
- static final String OEM_ENCODING =
- Config.getProperty( "jcifs.encoding",
- System.getProperty( "file.encoding" ));
+ static final String OEM_ENCODING = Config.getProperty( "jcifs.encoding", "Cp850" );
static final int DEFAULT_FLAGS2 =
FLAGS2_LONG_FILENAMES |
FLAGS2_EXTENDED_ATTRIBUTES |
* @see java.io.File
*/
-public class SmbFile extends URLConnection {
+public class SmbFile extends URLConnection implements SmbConstants {
- // these are shifted for use in flags
- static final int O_RDONLY = 0x010000;
- static final int O_WRONLY = 0x020000;
- static final int O_RDWR = 0x030000;
- static final int O_APPEND = 0x040000;
+ static final int O_RDONLY = 0x01;
+ static final int O_WRONLY = 0x02;
+ static final int O_RDWR = 0x03;
+ static final int O_APPEND = 0x04;
// share access
/**
if( context.share != null ) {
this.tree = context.tree;
+ this.dfsReferral = context.dfsReferral;
}
int last = name.length() - 1;
if( name.charAt( last ) == '/' ) {
trans = SmbTransport.getSmbTransport( addr, url.getPort() );
tree = trans.getSmbSession( auth ).getSmbTree( dr.share, null );
- unc = dr.nodepath + unc.substring( dr.path.length() );
- if( request.path.charAt( request.path.length() - 1 ) == '\\' ) {
- request.path = unc + '\\'; /* preserve trailing slash */
- } else {
- request.path = unc;
- }
- dfsReferral = dr; /* for getDfsPath */
+
+ if (log.level > 2)
+ System.out.println( dr );
+
+ dfsReferral = dr;
+ request.path = getDfsUncPath0();
}
request.flags2 |= ServerMessageBlock.FLAGS2_RESOLVE_PATHS_IN_DFS;
} else {
boolean isConnected() {
return (connected = tree != null && tree.treeConnected);
}
- int open0( int flags, int attrs, int options ) throws SmbException {
+ int open0( int flags, int access, int attrs, int options ) throws SmbException {
int f;
connect0();
if( tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS )) {
SmbComNTCreateAndXResponse response = new SmbComNTCreateAndXResponse();
- send( new SmbComNTCreateAndX( unc, flags, shareAccess,
+ send( new SmbComNTCreateAndX( unc, flags, access, shareAccess,
attrs, options, null ), response );
f = response.fid;
attributes = response.extFileAttributes & ATTR_GET_MASK;
isExists = true;
} else {
SmbComOpenAndXResponse response = new SmbComOpenAndXResponse();
- send( new SmbComOpenAndX( unc, flags, null ), response );
+ send( new SmbComOpenAndX( unc, flags, access, null ), response );
f = response.fid;
}
return f;
}
- void open( int flags, int attrs, int options ) throws SmbException {
+ void open( int flags, int access, int attrs, int options ) throws SmbException {
if( isOpen() ) {
return;
}
- fid = open0( flags, attrs, options );
+ fid = open0( flags, access, attrs, options );
opened = true;
tree_num = tree.tree_num;
}
Info queryPath( String path, int infoLevel ) throws SmbException {
connect0();
+ if (dfsReferral != null) {
+ path = dfsReferral.nodepath + path.substring( dfsReferral.path.length() );
+ }
+
if( log.level > 2 )
log.println( "queryPath: " + path );
return ( attributes & ATTR_HIDDEN ) == ATTR_HIDDEN;
}
+ String getDfsUncPath0() throws SmbException {
+ getUncPath0();
+ if( dfsReferral == null ) {
+ return null;
+ }
+ String dunc = dfsReferral.nodepath + unc.substring( dfsReferral.path.length() );
+ return "".equals( dunc ) ? "\\" : dunc;
+ }
/**
* If the path of this <code>SmbFile</code> falls within a DFS volume,
* this method will return the referral path to which it maps. Otherwise
if( dfsReferral == null ) {
return null;
}
- String path = "smb:/" + (new String( dfsReferral.node + unc )).replace( '\\', '/' );
+ String path = "smb:/" + dfsReferral.node + getDfsUncPath0();
+ path = path.replace( '\\', '/' );
if (isDirectory()) {
path += '/';
}
int off;
try {
- open( SmbFile.O_RDONLY, ATTR_NORMAL, 0 );
+ open( SmbFile.O_RDONLY, 0, ATTR_NORMAL, 0 );
try {
- dest.open( SmbFile.O_CREAT | SmbFile.O_WRONLY | SmbFile.O_TRUNC |
- SmbComNTCreateAndX.FILE_WRITE_ATTRIBUTES << 16, attributes, 0 );
+ dest.open( SmbFile.O_CREAT | SmbFile.O_WRONLY | SmbFile.O_TRUNC,
+ FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES,
+ attributes, 0 );
} catch( SmbAuthException sae ) {
if(( dest.attributes & ATTR_READONLY ) != 0 ) {
/* Remove READONLY and try again
*/
dest.setPathInformation( dest.attributes & ~ATTR_READONLY, 0L, 0L );
- dest.open( SmbFile.O_CREAT | SmbFile.O_WRONLY | SmbFile.O_TRUNC |
- SmbComNTCreateAndX.FILE_WRITE_ATTRIBUTES << 16, attributes, 0 );
+ dest.open( SmbFile.O_CREAT | SmbFile.O_WRONLY | SmbFile.O_TRUNC,
+ FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES,
+ attributes, 0 );
} else {
throw sae;
}
if( getUncPath0().length() == 1 ) {
throw new SmbException( "Invalid operation for workgroups, servers, or shares" );
}
- close( open0( O_RDWR | O_CREAT | O_EXCL, ATTR_NORMAL, 0 ), 0L );
+ close( open0( O_RDWR | O_CREAT | O_EXCL, 0, ATTR_NORMAL, 0 ), 0L );
}
void setPathInformation( int attrs, long ctime, long mtime ) throws SmbException {
exists();
dir = attributes & ATTR_DIRECTORY;
- f = open0( O_RDONLY | SmbComNTCreateAndX.FILE_WRITE_ATTRIBUTES << 16,
+ f = open0( O_RDONLY, FILE_WRITE_ATTRIBUTES,
dir, dir != 0 ? 0x0001 : 0x0040 );
send( new Trans2SetFileInformation( f, attrs | dir, ctime, mtime ),
new Trans2SetFileInformationResponse() );
public OutputStream getOutputStream() throws IOException {
return new SmbFileOutputStream( this );
}
+
+ public ACE[] getSecurity() throws IOException {
+ int f = open0( O_RDONLY, READ_CONTROL, 0, isDirectory() ? 1 : 0 );
+
+ /*
+ * NtTrans Query Security Desc Request / Response
+ */
+
+ NtTransQuerySecurityDesc request = new NtTransQuerySecurityDesc( f, 0x04 );
+ NtTransQuerySecurityDescResponse response = new NtTransQuerySecurityDescResponse();
+ send( request, response );
+
+ close( f, 0L );
+ return response.aces;
+ }
}
this.file = file;
this.openFlags = openFlags;
if (file.type != SmbFile.TYPE_NAMED_PIPE) {
- file.open( openFlags, SmbFile.ATTR_NORMAL, 0 );
+ file.open( openFlags, 0, SmbFile.ATTR_NORMAL, 0 );
this.openFlags &= ~(SmbFile.O_CREAT | SmbFile.O_TRUNC);
} else {
file.connect0();
throw new IOException( "Bad file descriptor" );
}
// ensure file is open
- file.open( openFlags, SmbFile.ATTR_NORMAL, 0 );
+ file.open( openFlags, 0, SmbFile.ATTR_NORMAL, 0 );
/*
* Read AndX Request / Response
}
pipe = (SmbNamedPipe)file;
- file.open(( pipe.pipeType & 0xFF0000 ) | SmbFile.O_EXCL, SmbFile.ATTR_NORMAL, 0 );
+ file.open(SmbFile.O_EXCL, pipe.pipeType & 0xFF0000, SmbFile.ATTR_NORMAL, 0 );
req = new TransPeekNamedPipe( file.unc, file.fid );
resp = new TransPeekNamedPipeResponse( pipe );
file.send( new TransWaitNamedPipe( "\\pipe" + file.unc ),
new TransWaitNamedPipeResponse() );
}
- file.open( openFlags, SmbFile.ATTR_NORMAL, 0 );
+ file.open( openFlags, SmbConstants.FILE_WRITE_DATA, SmbFile.ATTR_NORMAL, 0 );
this.openFlags &= ~(SmbFile.O_CREAT | SmbFile.O_TRUNC); /* in case close and reopen */
writeSize = file.tree.session.transport.snd_buf_size - 70;
file.send( new TransWaitNamedPipe( "\\pipe" + file.unc ),
new TransWaitNamedPipeResponse() );
}
- file.open( openFlags, SmbFile.ATTR_NORMAL, 0 );
+ file.open( openFlags, SmbConstants.FILE_WRITE_DATA, SmbFile.ATTR_NORMAL, 0 );
if( append ) {
fp = file.length();
}
private SmbFile file;
private long fp;
- private int openFlags, readSize, writeSize, ch, options = 0;
+ private int openFlags, access = 0, readSize, writeSize, ch, options = 0;
private byte[] tmp = new byte[8];
private SmbComWriteAndXResponse write_andx_resp = null;
this.openFlags = SmbFile.O_CREAT | SmbFile.O_RDWR | SmbFile.O_APPEND;
write_andx_resp = new SmbComWriteAndXResponse();
options = WRITE_OPTIONS;
+ access = SmbConstants.FILE_READ_DATA | SmbConstants.FILE_WRITE_DATA;
} else {
throw new IllegalArgumentException( "Invalid mode" );
}
- file.open( openFlags, SmbFile.ATTR_NORMAL, options );
+ file.open( openFlags, access, SmbFile.ATTR_NORMAL, options );
readSize = file.tree.session.transport.rcv_buf_size - 70;
writeSize = file.tree.session.transport.snd_buf_size - 70;
fp = 0L;
// ensure file is open
if( file.isOpen() == false ) {
- file.open( openFlags, SmbFile.ATTR_NORMAL, options );
+ file.open( openFlags, 0, SmbFile.ATTR_NORMAL, options );
}
int r, n;
// ensure file is open
if( file.isOpen() == false ) {
- file.open( openFlags, SmbFile.ATTR_NORMAL, options );
+ file.open( openFlags, 0, SmbFile.ATTR_NORMAL, options );
}
int w;
public void setLength( long newLength ) throws SmbException {
// ensure file is open
if( file.isOpen() == false ) {
- file.open( openFlags, SmbFile.ATTR_NORMAL, options );
+ file.open( openFlags, 0, SmbFile.ATTR_NORMAL, options );
}
SmbComWriteResponse rsp = new SmbComWriteResponse();
file.send( new SmbComWrite( file.fid, (int)(newLength & 0xFFFFFFFFL), 0, tmp, 0, 0 ), rsp );
if( response != null ) {
response.received = false;
}
- expiration = System.currentTimeMillis() + SmbTransport.SO_TIMEOUT;
- sessionSetup( request, response );
- if( response != null && response.received ) {
- return;
+
+ synchronized(transport.setupDiscoLock) {
+ expiration = System.currentTimeMillis() + SmbTransport.SO_TIMEOUT;
+ sessionSetup( request, response );
+ if( response != null && response.received ) {
+ return;
+ }
+ request.uid = uid;
+ request.auth = auth;
+ transport.send( request, response );
}
- request.uid = uid;
- request.auth = auth;
- transport.send( request, response );
}
+int x = 0;
void sessionSetup( ServerMessageBlock andx,
ServerMessageBlock andxResponse ) throws SmbException {
synchronized( transport() ) {
/* preauthentication
*/
transport.getSmbSession( NtlmPasswordAuthentication.DEFAULT ).getSmbTree( LOGON_SHARE, null ).treeConnect( null, null );
+ } else {
+ request.digest = new SigningDigest( transport, auth );
}
- request.digest = new SigningDigest( transport, auth );
}
request.auth = auth;
if (digest != null && resp.errorCode == 0) {
digest.verify( BUF, 4, resp );
}
+
+ if (log.level > 3) {
+ log.println( response );
+ if (log.level > 5) {
+ Hexdump.hexdump( log, BUF, 4, size );
+ }
+ }
}
}
protected void doSkip() throws IOException {
void treeConnect( ServerMessageBlock andx,
ServerMessageBlock andxResponse ) throws SmbException {
String unc;
-synchronized( session.transport() ) {
+ SmbTransport transport = session.transport();
+
+synchronized(transport.setupDiscoLock) {
+synchronized(transport) {
if (treeConnected) {
return;
treeConnected = true;
tree_num = tree_conn_counter++;
}
+}
}
void treeDisconnect( boolean inError ) {
synchronized( session.transport ) {
new TransCallNamedPipeResponse( pipe ));
} else if(( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_TRANSACT ) ==
SmbNamedPipe.PIPE_TYPE_TRANSACT ) {
- pipe.open(( pipe.pipeType & 0xFFFF0000 ) | SmbFile.O_EXCL, SmbFile.ATTR_NORMAL, 0 );
+ pipe.open(SmbFile.O_EXCL, pipe.pipeType & 0xFFFF0000, SmbFile.ATTR_NORMAL, 0 );
TransTransactNamedPipe req = new TransTransactNamedPipe( pipe.fid, b, off, len );
if (dcePipe) {
req.maxDataCount = 1024;
protected abstract void doRecv( Response response ) throws IOException;
protected abstract void doSkip() throws IOException;
+ public Object setupDiscoLock = new Object();
+
public void sendrecv( Request request,
Response response,
long timeout ) throws IOException {
response_map.notifyAll();
}
}
- } catch( IOException ex ) {
+ } catch( Exception ex ) {
String msg = ex.getMessage();
boolean hard = true;
}
}
}
- public synchronized void disconnect( boolean hard ) throws IOException {
- switch (state) {
- case 0: /* not connected - just return */
- return;
- case 3: /* connected - go ahead and disconnect */
- if (response_map.size() != 0 && !hard) {
- break; /* outstanding requests */
+ public void disconnect( boolean hard ) throws IOException {
+ synchronized(setupDiscoLock) {
+ synchronized(this) {
+ switch (state) {
+ case 0: /* not connected - just return */
+ return;
+ case 3: /* connected - go ahead and disconnect */
+ if (response_map.size() != 0 && !hard) {
+ break; /* outstanding requests */
+ }
+ doDisconnect( hard );
+ case 4: /* in error - reset the transport */
+ thread = null;
+ state = 0;
+ break;
+ default:
+ throw new TransportException( "Invalid state: " + state );
}
- doDisconnect( hard );
- case 4: /* in error - reset the transport */
- thread = null;
- state = 0;
- break;
- default:
- throw new TransportException( "Invalid state: " + state );
+ }
}
}
public void run() {