From: Felix Schumacher Date: Wed, 6 Aug 2008 14:33:20 +0000 (+0200) Subject: jcifs-1.2.4 from tgz X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=6e8c1188239d33569be4822eb4abd79c2beff1e2;p=jcifs_without_docs.git jcifs-1.2.4 from tgz Wed Sep 21 01:53:28 EDT 2005 jcifs-1.2.4 released / Timeout Transport Exception, Bogus Signature Error, and More A NetBIOS keep-alive message (received after ~10 minutes) would break message processesing with a timedout waiting for response Exception. This has been fixed. JCIFS would fail to validate responses with a status that is not zero. Assuming we are calculating the verfication signature correctly I can only assume the affected servers choose not to generate the correct signature for error responses (perhaps for DOS reasons). Because JCIFS checked the signature before the message status, an error response would fail with "signature verification failure". This behavior has been changed so that signatures are not verified if the status is non zero. It was discovered that the new transport (as of 1.2.x) could not cleanly recover from temporary server failure (e.g. a restart). This has been fixed. Methods will still throw Exceptions but moment the server comes back online the client gracefully recover. Wed Aug 24 13:29:44 EDT 2005 jcifs-1.2.3 released / Port 445 Fixed A mistake in the 1.2.2 release broke port 445 communication entirely. It has been fixed. The exact error (with a sufficiently high loglevel) was "Invalid payload size: 1". Sat Aug 20 00:26:11 EDT 2005 jcifs-1.2.2 released / Exception "cannot assign requested address" Fixed, Clusters, NetApp Filer, and More There have been a number of small fixes. These are: o The "cannot assign requested address" exception caused by trying to bind the local address 127.0.0.1 has been fixed. o In a cluster environment the NTLM HTTP Filter could fail with "account currently disabled" or "Access denied" errors due to a deserialization issue of "preauthentication" credentials stored in the HttpSession. The initialization of default credentials has been changed however it is not clear that the change will have any effect as I do not have a clustered environment in which to test. o The combination of plain text passwords and Unicode (largely specific to Samba 3) has been fixed. o A bogus debugging statement has been discovered and removed. Who left that in there?! o A Socket.shutdownOutput() call has been added to doDisconnect as it is believed to reduce spurrious RST frames observed when abruptly shutting down transports. These are believed to be harmless but they have been associated with unsightly messages in Samba log files. o The copyTo() method will now check to see if the source path is a child, parent or equal to the destination path and if so throw a Source and destination paths overlap exception. o An additional debugging statement has been added to the NTLM HTTP Filter domain controller interrogation code. o The getDiskFreeSpace call could fail with NetApp Filer. It has been repaired. --- diff --git a/README.txt b/README.txt index c510c37..afe8479 100644 --- a/README.txt +++ b/README.txt @@ -1,3 +1,61 @@ +Wed Sep 21 01:53:28 EDT 2005 +jcifs-1.2.4 released / Timeout Transport Exception, Bogus Signature Error, + and More + +A NetBIOS keep-alive message (received after ~10 minutes) would break +message processesing with a timedout waiting for response Exception. This +has been fixed. + +JCIFS would fail to validate responses with a status that is not zero. +Assuming we are calculating the verfication signature correctly I can only +assume the affected servers choose not to generate the correct signature +for error responses (perhaps for DOS reasons). Because JCIFS checked the +signature before the message status, an error response would fail with +"signature verification failure". This behavior has been changed so that +signatures are not verified if the status is non zero. + +It was discovered that the new transport (as of 1.2.x) could not cleanly +recover from temporary server failure (e.g. a restart). This has been +fixed. Methods will still throw Exceptions but moment the server comes back +online the client gracefully recover. + +Wed Aug 24 13:29:44 EDT 2005 +jcifs-1.2.3 released / Port 445 Fixed + +A mistake in the 1.2.2 release broke port 445 communication entirely. It +has been fixed. The exact error (with a sufficiently high loglevel) was +"Invalid payload size: 1". + +Sat Aug 20 00:26:11 EDT 2005 +jcifs-1.2.2 released / Exception "cannot assign requested address" Fixed, + Clusters, NetApp Filer, and More + +There have been a number of small fixes. These are: + +o The "cannot assign requested address" exception caused by trying to bind + the local address 127.0.0.1 has been fixed. +o In a cluster environment the NTLM HTTP Filter could fail with "account + currently disabled" or "Access denied" errors due to a deserialization + issue of "preauthentication" credentials stored in the HttpSession. The + initialization of default credentials has been changed however it is not + clear that the change will have any effect as I do not have a clustered + environment in which to test. +o The combination of plain text passwords and Unicode (largely specific to + Samba 3) has been fixed. +o A bogus debugging statement has been discovered and removed. Who left that + in there?! +o A Socket.shutdownOutput() call has been added to doDisconnect as it is + believed to reduce spurrious RST frames observed when abruptly shutting + down transports. These are believed to be harmless but they have been + associated with unsightly messages in Samba log files. +o The copyTo() method will now check to see if the source path is a child, + parent or equal to the destination path and if so throw a Source and + destination paths overlap exception. +o An additional debugging statement has been added to the NTLM HTTP Filter + domain controller interrogation code. +o The getDiskFreeSpace call could fail with NetApp Filer. It has been + repaired. + Sun Jul 3 23:33:03 EDT 2005 jcifs-1.2.1 released diff --git a/build.xml b/build.xml index 137ce17..a883a90 100644 --- a/build.xml +++ b/build.xml @@ -1,7 +1,7 @@ - - + + diff --git a/src/jcifs/Config.java b/src/jcifs/Config.java index 512be81..bf70a10 100644 --- a/src/jcifs/Config.java +++ b/src/jcifs/Config.java @@ -275,15 +275,15 @@ public class Config { } public static InetAddress getLocalHost() { String addr = prp.getProperty( "jcifs.smb.client.laddr" ); - try { - if( addr == null ) { - return InetAddress.getLocalHost(); - } - return InetAddress.getByName( addr ); - } catch( UnknownHostException uhe ) { - if( log.level > 0 ) { - log.println( addr ); - uhe.printStackTrace( log ); + + if (addr != null) { + try { + return InetAddress.getByName( addr ); + } catch( UnknownHostException uhe ) { + if( log.level > 0 ) { + log.println( "Ignoring jcifs.smb.client.laddr address: " + addr ); + uhe.printStackTrace( log ); + } } } diff --git a/src/jcifs/smb/NtStatus.java b/src/jcifs/smb/NtStatus.java index 5d93786..7f15c24 100644 --- a/src/jcifs/smb/NtStatus.java +++ b/src/jcifs/smb/NtStatus.java @@ -60,12 +60,14 @@ public interface NtStatus { public static final int NT_STATUS_FILE_IS_A_DIRECTORY = 0xC00000ba; public static final int NT_STATUS_DUPLICATE_NAME = 0xC00000bd; public static final int NT_STATUS_NETWORK_NAME_DELETED = 0xC00000c9; + public static final int NT_STATUS_NETWORK_ACCESS_DENIED = 0xC00000ca; public static final int NT_STATUS_BAD_NETWORK_NAME = 0xC00000cc; public static final int NT_STATUS_NOT_A_DIRECTORY = 0xC0000103; public static final int NT_STATUS_CANNOT_DELETE = 0xC0000121; public static final int NT_STATUS_PIPE_BROKEN = 0xC000014b; public static final int NT_STATUS_LOGON_TYPE_NOT_GRANTED = 0xC000015b; public static final int NT_STATUS_TRUSTED_DOMAIN_FAILURE = 0xC000018c; + public static final int NT_STATUS_NOT_FOUND = 0xC0000225; public static final int NT_STATUS_ACCOUNT_LOCKED_OUT = 0xC0000234; public static final int NT_STATUS_PATH_NOT_COVERED = 0xC0000257; @@ -106,12 +108,14 @@ public interface NtStatus { NT_STATUS_FILE_IS_A_DIRECTORY, NT_STATUS_DUPLICATE_NAME, NT_STATUS_NETWORK_NAME_DELETED, + NT_STATUS_NETWORK_ACCESS_DENIED, NT_STATUS_BAD_NETWORK_NAME, NT_STATUS_NOT_A_DIRECTORY, NT_STATUS_CANNOT_DELETE, NT_STATUS_PIPE_BROKEN, NT_STATUS_LOGON_TYPE_NOT_GRANTED, NT_STATUS_TRUSTED_DOMAIN_FAILURE, + NT_STATUS_NOT_FOUND, NT_STATUS_ACCOUNT_LOCKED_OUT, NT_STATUS_PATH_NOT_COVERED, }; @@ -153,12 +157,14 @@ public interface NtStatus { "Access is denied.", "A duplicate name exists on the network.", "The specified network name is no longer available.", + "Network access is denied.", "The network name cannot be found.", "The directory name is invalid.", "Access is denied.", "The pipe has been ended.", "Logon failure: the user has not been granted the requested logon type at this computer.", "The trust relationship between the primary domain and the trusted domain failed.", + "NT_STATUS_NOT_FOUND", "The referenced account is currently locked out and may not be logged on to.", "The remote system is not reachable by the transport.", }; diff --git a/src/jcifs/smb/NtlmPasswordAuthentication.java b/src/jcifs/smb/NtlmPasswordAuthentication.java index b0e1939..72b1fc9 100644 --- a/src/jcifs/smb/NtlmPasswordAuthentication.java +++ b/src/jcifs/smb/NtlmPasswordAuthentication.java @@ -45,16 +45,6 @@ public final class NtlmPasswordAuthentication implements Principal, Serializable private static final int LM_COMPATIBILITY = Config.getInt("jcifs.smb.lmCompatibility", 0); - static final String DEFAULT_DOMAIN = - Config.getProperty("jcifs.smb.client.domain", "?"); - - private static final String DEFAULT_USERNAME = - Config.getProperty("jcifs.smb.client.username", "GUEST"); - - static final String BLANK = ""; - static final String DEFAULT_PASSWORD = - Config.getProperty("jcifs.smb.client.password", BLANK); - private static final Random RANDOM = new Random(); private static LogStream log = LogStream.getInstance(); @@ -75,6 +65,19 @@ public final class NtlmPasswordAuthentication implements Principal, Serializable System.arraycopy( e8, 0, e, i * 8, 8 ); } } + + static String DEFAULT_DOMAIN; + static String DEFAULT_USERNAME; + static String DEFAULT_PASSWORD; + static final String BLANK = ""; + + static void initDefaults() { + if (DEFAULT_DOMAIN != null) return; + DEFAULT_DOMAIN = Config.getProperty("jcifs.smb.client.domain", "?"); + DEFAULT_USERNAME = Config.getProperty("jcifs.smb.client.username", "GUEST"); + DEFAULT_PASSWORD = Config.getProperty("jcifs.smb.client.password", BLANK); + } + /** * Generate the ANSI DES hash for the password associated with these credentials. */ @@ -200,6 +203,8 @@ public final class NtlmPasswordAuthentication implements Principal, Serializable username = userInfo.substring( u, i ); } + initDefaults(); + if( domain == null ) this.domain = DEFAULT_DOMAIN; if( username == null ) this.username = DEFAULT_USERNAME; if( password == null ) this.password = DEFAULT_PASSWORD; @@ -215,6 +220,9 @@ public final class NtlmPasswordAuthentication implements Principal, Serializable this.domain = domain; this.username = username; this.password = password; + + initDefaults(); + if( domain == null ) this.domain = DEFAULT_DOMAIN; if( username == null ) this.username = DEFAULT_USERNAME; if( password == null ) this.password = DEFAULT_PASSWORD; diff --git a/src/jcifs/smb/ServerMessageBlock.java b/src/jcifs/smb/ServerMessageBlock.java index 7580f49..2a9e52d 100644 --- a/src/jcifs/smb/ServerMessageBlock.java +++ b/src/jcifs/smb/ServerMessageBlock.java @@ -190,6 +190,10 @@ abstract class ServerMessageBlock extends Response implements Request, SmbConsta } void reset() { + flags = (byte)( FLAGS_PATH_NAMES_CASELESS | FLAGS_PATH_NAMES_CANONICALIZED ); + flags2 = 0; + errorCode = 0; + received = false; } int writeString( String str, byte[] dst, int dstIndex ) { return writeString( str, dst, dstIndex, useUnicode ); diff --git a/src/jcifs/smb/SmbComDelete.java b/src/jcifs/smb/SmbComDelete.java index 63aba98..c79981f 100644 --- a/src/jcifs/smb/SmbComDelete.java +++ b/src/jcifs/smb/SmbComDelete.java @@ -23,10 +23,9 @@ import jcifs.util.Hexdump; class SmbComDelete extends ServerMessageBlock { private int searchAttributes; - private String fileName; SmbComDelete( String fileName ) { - this.fileName = fileName; + this.path = fileName; command = SMB_COM_DELETE; searchAttributes = ATTR_HIDDEN | ATTR_HIDDEN | ATTR_SYSTEM; } @@ -39,7 +38,7 @@ class SmbComDelete extends ServerMessageBlock { int start = dstIndex; dst[dstIndex++] = (byte)0x04; - dstIndex += writeString( fileName, dst, dstIndex ); + dstIndex += writeString( path, dst, dstIndex ); return dstIndex - start; } @@ -53,6 +52,6 @@ class SmbComDelete extends ServerMessageBlock { return new String( "SmbComDelete[" + super.toString() + ",searchAttributes=0x" + Hexdump.toHexString( searchAttributes, 4 ) + - ",fileName=" + fileName + "]" ); + ",fileName=" + path + "]" ); } } diff --git a/src/jcifs/smb/SmbComSessionSetupAndX.java b/src/jcifs/smb/SmbComSessionSetupAndX.java index 4c4bd18..125511b 100644 --- a/src/jcifs/smb/SmbComSessionSetupAndX.java +++ b/src/jcifs/smb/SmbComSessionSetupAndX.java @@ -117,13 +117,16 @@ class SmbComSessionSetupAndX extends AndXServerMessageBlock { ( auth.hashesExternal || auth.password.length() > 0 )) { System.arraycopy( accountPassword, 0, dst, dstIndex, passwordLength ); dstIndex += passwordLength; + if (session.transport.server.encryptedPasswords == false && useUnicode) { + /* Align Unicode plain text password manually + */ + if ((( dstIndex - headerStart ) % 2 ) != 0 ) { + dst[dstIndex++] = (byte)'\0'; + } + } System.arraycopy( unicodePassword, 0, dst, dstIndex, unicodePasswordLength ); dstIndex += unicodePasswordLength; } - if( useUnicode ) { - // at least NT 4 observed needing this only with unicode - dst[dstIndex++] = (byte)'\0'; - } dstIndex += writeString( accountName, dst, dstIndex ); dstIndex += writeString( primaryDomain, dst, dstIndex ); diff --git a/src/jcifs/smb/SmbComTransaction.java b/src/jcifs/smb/SmbComTransaction.java index 6896e01..ca38b7a 100644 --- a/src/jcifs/smb/SmbComTransaction.java +++ b/src/jcifs/smb/SmbComTransaction.java @@ -88,6 +88,7 @@ abstract class SmbComTransaction extends ServerMessageBlock implements Enumerati } void reset() { + super.reset(); isPrimary = hasMore = true; } void reset( int key, String lastName ) { diff --git a/src/jcifs/smb/SmbComTransactionResponse.java b/src/jcifs/smb/SmbComTransactionResponse.java index f421b97..b10e1bd 100644 --- a/src/jcifs/smb/SmbComTransactionResponse.java +++ b/src/jcifs/smb/SmbComTransactionResponse.java @@ -59,10 +59,10 @@ abstract class SmbComTransactionResponse extends ServerMessageBlock implements E } void reset() { + super.reset(); bufDataStart = 0; isPrimary = hasMore = true; parametersDone = dataDone = false; - received = false; } public boolean hasMoreElements() { return errorCode == 0 && hasMore; diff --git a/src/jcifs/smb/SmbFile.java b/src/jcifs/smb/SmbFile.java index 32535a8..fc0ad88 100644 --- a/src/jcifs/smb/SmbFile.java +++ b/src/jcifs/smb/SmbFile.java @@ -672,9 +672,9 @@ public class SmbFile extends URLConnection { trans = SmbTransport.getSmbTransport( addr, url.getPort() ); tree = trans.getSmbSession( auth ).getSmbTree( dr.share, null ); - unc = request.path = dr.nodepath + unc.substring( dr.path.length() ); + unc = dr.nodepath + unc.substring( dr.path.length() ); if( request.path.charAt( request.path.length() - 1 ) == '\\' ) { - request.path = unc + '\\'; + request.path = unc + '\\'; /* preserve trailing slash */ } else { request.path = unc; } @@ -745,6 +745,7 @@ public class SmbFile extends URLConnection { NbtAddress.MASTER_BROWSER_NAME, 0x01, null); return UniAddress.getByName( addr.getHostAddress() ); } catch( UnknownHostException uhe ) { + NtlmPasswordAuthentication.initDefaults(); if( NtlmPasswordAuthentication.DEFAULT_DOMAIN.equals( "?" )) { throw uhe; } @@ -1372,7 +1373,11 @@ public class SmbFile extends URLConnection { if( dfsReferral == null ) { return null; } - return "smb:/" + (new String( dfsReferral.node + unc )).replace( '\\', '/' ); + String path = "smb:/" + (new String( dfsReferral.node + unc )).replace( '\\', '/' ); + if (isDirectory()) { + path += '/'; + } + return path; } /** @@ -1702,7 +1707,6 @@ public class SmbFile extends URLConnection { if( name.length() > 0 ) { SmbFile f = new SmbFile( this, name, TYPE_FILESYSTEM, e.getAttributes(), e.createTime(), e.lastModified(), e.length() ); -System.out.print(" " + name ); if( ff != null && ff.accept( f ) == false ) { continue; } @@ -2001,6 +2005,18 @@ try { dest.exists(); } + /* It is invalid for the source path to be a child of the destination + * path or visa versa. + */ + try { + if (getAddress().equals( dest.getAddress() ) && + canon.regionMatches( true, 0, dest.canon, 0, + Math.min( canon.length(), dest.canon.length() ))) { + throw new SmbException( "Source and destination paths overlap." ); + } + } catch (UnknownHostException uhe) { + } + w = new WriterThread(); w.setDaemon( true ); w.start(); @@ -2152,10 +2168,12 @@ try { try { return queryFSInformation(level); } catch( SmbException ex ) { - if(ex.getNtStatus() == NtStatus.NT_STATUS_INVALID_INFO_CLASS) { - // SMB_FS_FULL_SIZE_INFORMATION not supported by the server. - level = Trans2QueryFSInformationResponse.SMB_INFO_ALLOCATION; - return queryFSInformation(level); + switch (ex.getNtStatus()) { + case NtStatus.NT_STATUS_INVALID_INFO_CLASS: + case NtStatus.NT_STATUS_UNSUCCESSFUL: // NetApp Filer + // SMB_FS_FULL_SIZE_INFORMATION not supported by the server. + level = Trans2QueryFSInformationResponse.SMB_INFO_ALLOCATION; + return queryFSInformation(level); } throw ex; } diff --git a/src/jcifs/smb/SmbSession.java b/src/jcifs/smb/SmbSession.java index 68777c1..37e6b0b 100644 --- a/src/jcifs/smb/SmbSession.java +++ b/src/jcifs/smb/SmbSession.java @@ -110,9 +110,11 @@ public final class SmbSession { try { return interrogate( dc_list[i] ); } catch (SmbException se) { - if (SmbTransport.log.level > 1) - SmbTransport.log.println( "Failed validate DC: " + dc_list[i] + - ": " + se.getMessage() ); + if (SmbTransport.log.level > 1) { + SmbTransport.log.println( "Failed validate DC: " + dc_list[i] ); + if (SmbTransport.log.level > 2) + se.printStackTrace( SmbTransport.log ); + } } dc_list[i] = null; } diff --git a/src/jcifs/smb/SmbTransport.java b/src/jcifs/smb/SmbTransport.java index 942d9ae..adc4231 100644 --- a/src/jcifs/smb/SmbTransport.java +++ b/src/jcifs/smb/SmbTransport.java @@ -150,11 +150,11 @@ public class SmbTransport extends Transport implements SmbConstants { boolean matches( UniAddress address, int port, InetAddress localAddr, int localPort ) { int p1 = ( port == 0 || port == DEFAULT_PORT ) ? 0 : port; int p2 = ( this.port == 0 || this.port == DEFAULT_PORT ) ? 0 : this.port; - InetAddress la1 = localAddr == null ? LADDR : localAddr; - InetAddress la2 = this.localAddr == null ? LADDR : this.localAddr; return address.equals( this.address ) && p1 == p2 && - la1.equals( la2 ) && + (localAddr == this.localAddr || + (localAddr != null && + localAddr.equals( this.localAddr ))) && localPort == this.localPort; } boolean hasCapability( int cap ) throws SmbException { @@ -175,7 +175,11 @@ public class SmbTransport extends Transport implements SmbConstants { void ssn139() throws IOException { Name calledName = new Name( address.firstCalledName(), 0x20, null ); do { - socket = new Socket( address.getHostAddress(), 139, localAddr, localPort ); + if (localAddr == null) { + socket = new Socket( address.getHostAddress(), 139 ); + } else { + socket = new Socket( address.getHostAddress(), 139, localAddr, localPort ); + } socket.setSoTimeout( SO_TIMEOUT ); out = socket.getOutputStream(); in = socket.getInputStream(); @@ -225,7 +229,11 @@ public class SmbTransport extends Transport implements SmbConstants { if (port == 139) { ssn139(); } else { - socket = new Socket( address.getHostAddress(), port, localAddr, localPort ); + if (localAddr == null) { + socket = new Socket( address.getHostAddress(), port ); + } else { + socket = new Socket( address.getHostAddress(), port, localAddr, localPort ); + } socket.setSoTimeout( SO_TIMEOUT ); out = socket.getOutputStream(); in = socket.getInputStream(); @@ -302,6 +310,7 @@ public class SmbTransport extends Transport implements SmbConstants { ssn.logoff( hard ); iter.remove(); } + socket.shutdownOutput(); out.close(); in.close(); socket.close(); @@ -317,8 +326,8 @@ public class SmbTransport extends Transport implements SmbConstants { int n; do { n = readn( in, sbuf, 0, 4 ); - } while (sbuf[0] == 0x85); /* Dodge NetBIOS keep-alive */ - /* read smb header */ + } while (sbuf[0] == (byte)0x85); /* Dodge NetBIOS keep-alive */ + /* read smb header */ if ((n = readn( in, sbuf, 4, 32 )) < 32) { return null; /* stream closed */ } @@ -345,12 +354,12 @@ public class SmbTransport extends Transport implements SmbConstants { } /* out of phase maybe? */ /* inch forward 1 byte and try again */ - for (int i = 0; i < 7; i++) { + for (int i = 0; i < 35; i++) { sbuf[i] = sbuf[i + 1]; } int b; - if ((b = in.read()) == 0) return null; - sbuf[7] = (byte)b; + if ((b = in.read()) == -1) return null; + sbuf[35] = (byte)b; } key.mid = Encdec.dec_uint16le( sbuf, 34 ); @@ -381,6 +390,20 @@ public class SmbTransport extends Transport implements SmbConstants { out.write( BUF, 0, 4 + n ); } } + protected void doSend0( Request request ) throws IOException { + try { + doSend( request ); + } catch( IOException ioe ) { + if (log.level > 2) + ioe.printStackTrace( log ); + try { + disconnect( true ); + } catch( IOException ioe2 ) { + ioe2.printStackTrace( log ); + } + throw ioe; + } + } protected void doRecv( Response response ) throws IOException { ServerMessageBlock resp = (ServerMessageBlock)response; @@ -410,7 +433,11 @@ public class SmbTransport extends Transport implements SmbConstants { } } - if (digest != null) { + /* Verification fails (w/ W2K3 server at least) if status is not 0. This + * suggests MS doesn't compute the signature (correctly) for error responses + * (perhaps for DOS reasons). + */ + if (digest != null && resp.errorCode == 0) { digest.verify( BUF, 4, resp ); } } @@ -468,7 +495,7 @@ public class SmbTransport extends Transport implements SmbConstants { try { if (response == null) { - doSend( request ); + doSend0( request ); return; } else if (request instanceof SmbComTransaction) { response.command = request.command; @@ -508,7 +535,7 @@ public class SmbTransport extends Transport implements SmbConstants { */ do { - doSend( req ); + doSend0( req ); } while( req.hasMoreElements() && req.nextElement() != null ); /* diff --git a/src/jcifs/smb/SmbTree.java b/src/jcifs/smb/SmbTree.java index 06b9e21..78e5c73 100644 --- a/src/jcifs/smb/SmbTree.java +++ b/src/jcifs/smb/SmbTree.java @@ -68,6 +68,7 @@ class SmbTree { case ServerMessageBlock.SMB_COM_TREE_DISCONNECT: break; case ServerMessageBlock.SMB_COM_TRANSACTION: + case ServerMessageBlock.SMB_COM_TRANSACTION2: switch( ((SmbComTransaction)request).subCommand & 0xFF ) { case SmbComTransaction.NET_SHARE_ENUM: case SmbComTransaction.NET_SERVER_ENUM2: @@ -83,11 +84,17 @@ class SmbTree { } break; default: - throw new SmbException( "Invalid operation for " + service + " service" ); + throw new SmbException( "Invalid operation for " + service + " service" + request ); } } request.tid = tid; if( inDfs && request.path != null && request.path.length() > 0 ) { + /* When DFS is in action all request paths are + * full UNC paths minus the first backslash like + * \server\share\path\to\file + * as opposed to normally + * \path\to\file + */ request.flags2 = ServerMessageBlock.FLAGS2_RESOLVE_PATHS_IN_DFS; request.path = '\\' + session.transport().tconHostName + '\\' + share + request.path; } diff --git a/src/jcifs/util/transport/Transport.java b/src/jcifs/util/transport/Transport.java index c180f6d..8f262d1 100644 --- a/src/jcifs/util/transport/Transport.java +++ b/src/jcifs/util/transport/Transport.java @@ -76,6 +76,15 @@ public abstract class Transport implements Runnable { request ); } } + } catch( IOException ioe ) { + if (log.level > 2) + ioe.printStackTrace( log ); + try { + disconnect( true ); + } catch( IOException ioe2 ) { + ioe2.printStackTrace( log ); + } + throw ioe; } catch( InterruptedException ie ) { throw new TransportException( ie ); } finally {