+Thu Feb 10 22:29:12 EST 2005
+jcifs-1.1.8 released
+
+The blocked thread bug wasn't quite fixed in the last release. A lookup
+exception (e.g. caused by an unresponsive domain controller) could leave a
+thread blocked if many requests are being processed simultaneously.
+Similarly the fix for the DC lookup code wasn't complete enough to handle
+the unusual scenario where all DCs are unresponsive. Also, a malfomed
+NetBIOS name query response could cause the name service thread to exit
+incorrectly. These issues have been fixed. Finally, the URL handling of
+smb://@/ (meaning "null" credentials) has been fixed.
+
Sun Jan 16 17:30:17 EST 2005
jcifs-1.1.7 released
<project name="jcifs" default="usage" basedir=".">
- <property name="version" value="1.1.7"/>
- <property name="reldate" value="Jan 16, 2005"/>
+ <property name="version" value="1.1.8"/>
+ <property name="reldate" value="Feb 10, 2005"/>
<target name="usage">
<echo>
.SUFFIXES: .java .class
-CLASSFILES=AllocInfo.class Append.class AuthListFiles.class CallNamedPipe.class CifsTime.class CopyTo.class CreateFile.class Delete.class Equals.class Exists.class FileInfo.class FileOps.class FilterFiles.class Format.class GetDate.class GetDfsPath.class Get.class GetType.class GetURL.class GrowWrite.class HttpURL.class Interleave.class IsDir.class Length.class ListFiles.class List.class ListTypes.class Mkdir.class NodeStatus.class OpenExclusive.class PeekNamedPipe.class PipeTalk.class Put.class Query.class RenameTo.class SetAttrs.class SetTime.class SlowRead.class SlowWrite.class SmbCrawler.class SmbShell.class SmbTableFile.class SmbTableFileRecord.class T2Crawler.class TestRandomAccess.class TestSmbURL.class TestUnicode.class ThreadedNbtQuery.class ThreadedSmbCrawler.class ThreadedUniQuery.class Torture1.class Torture2.class TortureTest5.class TransactNamedPipe.class URLTest.class VerifyGuest.class VerifyIO.class VerifyReads.class
+CLASSFILES=AllocInfo.class Append.class AuthListFiles.class CallNamedPipe.class CopyTo.class CreateFile.class Delete.class Equals.class Exists.class FileInfo.class FileOps.class FilterFiles.class Format.class GetDate.class GetDfsPath.class Get.class GetType.class GetURL.class GrowWrite.class HttpURL.class Interleave.class IsDir.class Length.class ListFiles.class List.class ListTypes.class Mkdir.class NodeStatus.class OpenExclusive.class PeekNamedPipe.class PipeTalk.class Put.class Query.class RenameTo.class SetAttrs.class SetTime.class SlowRead.class SlowWrite.class SmbCrawler.class SmbShell.class SmbTableFile.class SmbTableFileRecord.class T2Crawler.class TestRandomAccess.class TestSmbURL.class TestUnicode.class ThreadedNbtQuery.class ThreadedSmbCrawler.class ThreadedUniQuery.class Torture1.class Torture2.class TortureTest5.class TransactNamedPipe.class URLTest.class VerifyGuest.class VerifyIO.class VerifyReads.class
all: ${CLASSFILES}
--- /dev/null
+import java.net.*;
+import java.io.*;
+
+public class UrlReader extends Thread {
+
+ URL url;
+ byte[] buf;
+
+ public UrlReader( String u, int bufsiz ) throws Exception {
+ url = new URL( u );
+ buf = new byte[bufsiz];
+ }
+
+ public void run() {
+ try {
+ InputStream in = url.openStream();
+ int n;
+ while ((n = in.read( buf )) > 0) {
+ System.out.write( buf, 0, n );
+ }
+ in.close();
+ System.err.println( url + " read complete" );
+ } catch( Exception ex ) {
+ ex.printStackTrace( System.err );
+ }
+ }
+
+ public static void main( String[] args ) throws Exception {
+ UrlReader[] readers = new UrlReader[args.length];
+
+ jcifs.Config.registerSmbURLHandler();
+
+ int i;
+ for( i = 0; i < args.length; i++) {
+ readers[i] = new UrlReader( args[i], (i + 1) * 128 );
+ }
+ for( i = 0; i < args.length; i++) {
+ readers[i].start();
+ }
+ }
+}
PROPERTIES=../../miallen.prp
RUN="${JAVA_HOME}/bin/java -cp ${CLASSPATH} -Djcifs.properties=${PROPERTIES}"
-SERVER=servername
+SERVER=rnyxwbf8s5v31
SHARE=pub
WRITE_DIR=test
SRC_DIR=test/Junk
int nameTrnId;
NameServicePacket response;
- while( thread == Thread.currentThread() ) {
- in.setLength( RCV_BUF_SIZE );
- try {
+ try {
+ while( thread == Thread.currentThread() ) {
+ in.setLength( RCV_BUF_SIZE );
+
socket.setSoTimeout( closeTimeout );
socket.receive( in );
- } catch( IOException ioe ) {
- tryClose();
- break;
- }
- if( log.level > 3 )
- log.println( "NetBIOS: new data read from socket" );
+ if( log.level > 3 )
+ log.println( "NetBIOS: new data read from socket" );
- nameTrnId = NameServicePacket.readNameTrnId( rcv_buf, 0 );
- response = (NameServicePacket)responseTable.get( new Integer( nameTrnId ));
- if( response == null || response.received ) {
- continue;
- }
- synchronized( response ) {
- response.readWireFormat( rcv_buf, 0 );
- response.received = true;
-
- if( log.level > 3 ) {
- log.println( response );
- Hexdump.hexdump( log, rcv_buf, 0, in.getLength() );
+ nameTrnId = NameServicePacket.readNameTrnId( rcv_buf, 0 );
+ response = (NameServicePacket)responseTable.get( new Integer( nameTrnId ));
+ if( response == null || response.received ) {
+ continue;
}
+ synchronized( response ) {
+ response.readWireFormat( rcv_buf, 0 );
+ response.received = true;
- response.notify();
+ if( log.level > 3 ) {
+ log.println( response );
+ Hexdump.hexdump( log, rcv_buf, 0, in.getLength() );
+ }
+
+ response.notify();
+ }
}
+ } catch( Exception ex ) {
+ if( log.level > 2 )
+ ex.printStackTrace( log );
+ tryClose();
}
}
void send( NameServicePacket request, NameServicePacket response,
UnknownHostException, MalformedURLException {
SmbComTransaction req;
SmbComTransactionResponse resp;
- int listType = url.getAuthority().length() == 0 ? 0 : getType();
+ int listType = url.getHost().length() == 0 ? 0 : getType();
String p = url.getPath();
if( p.lastIndexOf( '/' ) != ( p.length() - 1 )) {
SmbTransport trans = SmbTransport.getSmbTransport( dc, 0 );
if( USERNAME == null ) {
if( SmbTransport.log.level > 2 )
- SmbTransport.log.println( "Default credentials (jcifs.smb.client.username/password) not specified. SMB signing may not work propertly. Skipping DC interrogation." );
+ SmbTransport.log.println(
+ "Default credentials (jcifs.smb.client.username/password)" +
+ " not specified. SMB signing may not work propertly." +
+ " Skipping DC interrogation." );
trans.negotiate();
} else {
- trans.getSmbSession( NtlmPasswordAuthentication.DEFAULT ).getSmbTree( LOGON_SHARE, null ).treeConnect( null, null );
+ trans.getSmbSession( NtlmPasswordAuthentication.DEFAULT ).getSmbTree(
+ LOGON_SHARE, null ).treeConnect( null, null );
}
synchronized( trans ) {
if( trans.sessions.size() > (trans.SSN_LIMIT / 10)) {
return new NtlmChallenge( trans.server.encryptionKey, dc );
} catch( SmbException se ) {
if( SmbTransport.log.level > 1 )
- SmbTransport.log.println( "Failed validate DC: " + addr + ": " + se.getMessage() );
+ SmbTransport.log.println( "Failed validate DC: " + addr +
+ ": " + se.getMessage() );
}
dc_list[dc_list_index] = null; /* dc no good */
incr_dc_list_range();
} while( dc_list_index != starting_index );
}
- throw new UnknownHostException( "Failed to negotiate with a suitable domain controller for " + DOMAIN );
+ dc_list_expiration = System.currentTimeMillis() + 10000; /* 10sec */
+ throw new UnknownHostException(
+ "Failed to negotiate with a suitable domain controller for " + DOMAIN );
}
request.auth = auth;
transport.send( request, response );
- if( response.isLoggedInAsGuest && "GUEST".equalsIgnoreCase( auth.username ) == false ) {
+ if( response.isLoggedInAsGuest &&
+ "GUEST".equalsIgnoreCase( auth.username ) == false) {
throw new SmbAuthException( NtStatus.NT_STATUS_LOGON_FAILURE );
}
}
state = ST_GROUND;
}
- void start() throws SmbException {
- try {
- thread = new Thread( this, "JCIFS-SmbTransport" );
- thread.setDaemon( true );
- thread.start();
+ void start() throws Exception {
+ thread = new Thread( this, "JCIFS-SmbTransport" );
+ thread.setDaemon( true );
+ thread.start();
- wait( RESPONSE_TIMEOUT ); /* wait for the thread to be started and socket opened */
+ wait( RESPONSE_TIMEOUT ); /* wait for the thread to be started and socket opened */
- if( socket == null ) { /* failed to open socket for some reason */
- tryClose( true );
- throw new SmbException( "Timeout trying to open socket (probably no ACK to SYN) for address", socketException );
- }
- } catch( InterruptedException ie ) {
- tryClose( true );
- throw new SmbException( "Interrupted opening socket", ie );
+ if( socket == null ) { /* failed to open socket for some reason */
+ throw new SmbException( "Timeout trying to open socket", socketException );
}
}
public void run() {
throw new SmbException( response.errorCode, null );
}
}
- synchronized void negotiate() throws SmbException {
-
- if( state == ST_GROUND ) {
- state = ST_NEGOTIATING;
- } else {
- while( state != ST_NEGOTIATED ) {
- try {
- wait();
- } catch( InterruptedException ie ) {
- tryClose( true );
- throw new SmbException( "Interrupted opening socket", ie );
- }
- }
- return;
- }
-
+ synchronized void negotiate0() throws Exception {
start(); /* start the transport thread (which opens the socket) */
if( this == NULL_TRANSPORT ) {
send( new SmbComNegotiate(), response );
if( response.dialectIndex > 10 ) {
- tryClose( true );
throw new SmbException( "This client does not support the negotiated dialect." );
}
flags2 &= 0xFFFF ^ ServerMessageBlock.FLAGS2_UNICODE;
}
}
+ }
+ synchronized void negotiate() throws SmbException {
+ if( state == ST_GROUND ) {
+ state = ST_NEGOTIATING;
+ } else {
+ while( state != ST_NEGOTIATED ) {
+ try {
+ wait();
+ } catch( InterruptedException ie ) {
+ tryClose( true );
+ throw new SmbException( "Interrupted opening socket", ie );
+ }
+ }
+ return;
+ }
- state = ST_NEGOTIATED;
- notifyAll();
+ try {
+ negotiate0();
+ state = ST_NEGOTIATED;
+ } catch( Exception ex ) {
+ if( log.level > 1 )
+ ex.printStackTrace( log );
+ tryClose( true );
+ throw new SmbException( "Failed to negotiate", ex );
+ } finally {
+ notifyAll();
+ }
}
public String toString() {
String ret = "SmbTransport[address=" + address;