jcifs-0.9.6 from tgz
authorFelix Schumacher <p0354740@isib001.(none)>
Wed, 6 Aug 2008 14:19:40 +0000 (16:19 +0200)
committerFelix Schumacher <p0354740@isib001.(none)>
Wed, 6 Aug 2008 14:19:40 +0000 (16:19 +0200)
Thu Jul 22 23:06:47 EDT 2004
jcifs-0.9.6 released

A bug in copyTo() has been found that could result in the operation failing
and  timeing  out  if  the  negotiated  buffer  sizes  between  source  and
destination       servers       were       different.      The      default
jcifs.smb.client.snd_buf_size  has  been  changed  from 5000 to 16644. When
copying  data  between  servers  that  negotiate  larger  buffer sizes this
results in a noticable preformance increase.

Adjustments  have been made regarding a null pointer exception triggered in
releaseMid()  during certain error conditions. The releaseMid method should
not be passed null Mids.

Failover  to  the  jcifs.smb.client.domain DC for browser info if the local
master browser query fails.

Methods  have  been added to SmbSession.java that support the specification
of alternative port.

Fixed some debugging output.

Added clause to SmbFile.delete() to subvert exception "cannot find the file
specified"  exception  generated  because  Oracle FilesOnline version 9.0.4
doesn't send '.' and '..' like other servers.

Ammended  the  ntlm http doc to mention that the domain or domainController
property  is  required and that it will be suitable to authenticate clients
for  which  it  is  an  authority  as  well  as  domains  with which it has
established trust relationships.

README.txt
build.xml
src/jcifs/http/NtlmHttpFilter.java
src/jcifs/smb/NtlmPasswordAuthentication.java
src/jcifs/smb/SmbComReadAndX.java
src/jcifs/smb/SmbFile.java
src/jcifs/smb/SmbSession.java
src/jcifs/smb/SmbTransport.java

index da60127..4eb3921 100644 (file)
@@ -1,3 +1,34 @@
+Thu Jul 22 23:06:47 EDT 2004
+jcifs-0.9.6 released
+
+A bug in copyTo() has been found that could result in the operation failing
+and  timeing  out  if  the  negotiated  buffer  sizes  between  source  and
+destination       servers       were       different.      The      default
+jcifs.smb.client.snd_buf_size  has  been  changed  from 5000 to 16644. When
+copying  data  between  servers  that  negotiate  larger  buffer sizes this
+results in a noticable preformance increase.
+
+Adjustments  have been made regarding a null pointer exception triggered in
+releaseMid()  during certain error conditions. The releaseMid method should
+not be passed null Mids.
+
+Failover  to  the  jcifs.smb.client.domain DC for browser info if the local
+master browser query fails.
+
+Methods  have  been added to SmbSession.java that support the specification
+of alternative port.
+
+Fixed some debugging output.
+
+Added clause to SmbFile.delete() to subvert exception "cannot find the file
+specified"  exception  generated  because  Oracle FilesOnline version 9.0.4
+doesn't send '.' and '..' like other servers.
+
+Ammended  the  ntlm http doc to mention that the domain or domainController
+property  is  required and that it will be suitable to authenticate clients
+for  which  it  is  an  authority  as  well  as  domains  with which it has
+established trust relationships. 
+
 Thu Jul  1 18:53:20 EDT 2004
 jcifs-0.9.5
 
index 09d2756..7f3aa10 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -1,6 +1,6 @@
 <project name="jcifs" default="usage" basedir=".">
 
-    <property name="version" value="0.9.5"/>
+    <property name="version" value="0.9.6"/>
 
     <target name="usage">
         <echo>
@@ -181,8 +181,8 @@ dependencies: Checks that all class dependencies are met.
     <target name="docs">
         <style basedir="docs" destdir="docs" extension=".html" style="plain.xsl"
                 includes="pipes.xml,faq.xml,wins.xml,capture.xml,httpclient.xml,resolver.xml,authhandler.xml,ntlmhttpauth.xml">
-<param name="date" expression="Jul 2, 2004"/>
-<param name="lib" expression="jcifs-0.9.5"/>
+<param name="date" expression="Jul 22, 2004"/>
+<param name="lib" expression="jcifs-0.9.6"/>
 <param name="title" expression="JCIFS"/>
 <param name="copyright" expression="The JCIFS Project"/>
 <param name="edge" expression="#808080"/>
@@ -195,8 +195,8 @@ dependencies: Checks that all class dependencies are met.
         </style>
         <style basedir="docs" destdir="docs" extension=".html" style="proj.xsl"
                 includes="index.xml">
-<param name="date" expression="Jul 2, 2004"/>
-<param name="lib" expression="jcifs-0.9.5"/>
+<param name="date" expression="Jul 22, 2004"/>
+<param name="lib" expression="jcifs-0.9.6"/>
 <param name="title" expression="JCIFS"/>
 <param name="copyright" expression="The JCIFS Project"/>
 <param name="edge" expression="#808080"/>
index 730f138..7a064a4 100644 (file)
@@ -133,6 +133,7 @@ public class NtlmHttpFilter implements Filter {
                     /* Server challenge no longer valid for
                      * externally supplied password hashes.
                      */
+System.err.println("ACCESS_VIOLATION");
                     HttpSession ssn = req.getSession(false);
                     if (ssn != null) {
                         ssn.removeAttribute( "NtlmHttpAuth" );
index a25bf29..635e98c 100644 (file)
@@ -45,7 +45,7 @@ public final class NtlmPasswordAuthentication implements Principal, Serializable
     private static final int LM_COMPATIBILITY =
             Config.getInt("jcifs.smb.lmCompatibility", 0);
 
-    private static final String DEFAULT_DOMAIN =
+    static final String DEFAULT_DOMAIN =
             Config.getProperty("jcifs.smb.client.domain", "?");
 
     private static final String DEFAULT_USERNAME =
index c231c68..7c920f0 100644 (file)
@@ -97,7 +97,7 @@ class SmbComReadAndX extends AndXServerMessageBlock {
             ",minCount=" + minCount +
             ",openTimeout=" + openTimeout +
             ",remaining=" + remaining +
-            ",offset=" + maxCount +
+            ",offset=" + offset +
              "]" );
     }
 }
index adbf7e2..7bdce21 100644 (file)
@@ -747,8 +747,16 @@ public class SmbFile extends URLConnection {
         }
 
         if( host.length() == 0 ) {
-            return UniAddress.getByName( NbtAddress.getByName(
-                    NbtAddress.MASTER_BROWSER_NAME, 0x01, null).getHostAddress() );
+            try {
+                NbtAddress addr = NbtAddress.getByName(
+                        NbtAddress.MASTER_BROWSER_NAME, 0x01, null);
+                return UniAddress.getByName( addr.getHostAddress() );
+            } catch( UnknownHostException uhe ) {
+                if( NtlmPasswordAuthentication.DEFAULT_DOMAIN.equals( "?" )) {
+                    throw uhe;
+                }
+                return UniAddress.getByName( NtlmPasswordAuthentication.DEFAULT_DOMAIN, true );
+            }
         } else if( path.length() == 0 || path.equals( "/" )) {
             return UniAddress.getByName( host, true );
         } else {
@@ -1979,8 +1987,20 @@ public class SmbFile extends URLConnection {
         w.setDaemon( true );
         w.start();
 
-        bsize = Math.min( tree.session.transport.rcv_buf_size - 70,
-                        tree.session.transport.snd_buf_size - 70 );
+        /* Downgrade one transport to the lower of the negotiated buffer sizes
+         * so we can just send whatever is received.
+         */
+
+        SmbTransport t1 = tree.session.transport;
+        SmbTransport t2 = dest.tree.session.transport;
+
+        if( t1.snd_buf_size < t2.snd_buf_size ) {
+            t2.snd_buf_size = t1.snd_buf_size;
+        } else {
+            t1.snd_buf_size = t2.snd_buf_size;
+        }
+
+        bsize = Math.min( t1.rcv_buf_size - 70, t1.snd_buf_size - 70 );
         b = new byte[2][bsize];
 
         copyTo0( dest, b, bsize, w, req, resp );
@@ -2041,11 +2061,19 @@ public class SmbFile extends URLConnection {
             /* Recursively delete directory contents
              */
 
-            SmbFile[] l = listFiles( "*",
-                    ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, null );
-
-            for( int i = 0; i < l.length; i++ ) {
-                l[i].delete();
+            try {
+                SmbFile[] l = listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, null );
+                for( int i = 0; i < l.length; i++ ) {
+                    l[i].delete();
+                }
+            } catch( SmbException se ) {
+                /* Oracle FilesOnline version 9.0.4 doesn't send '.' and '..' so
+                 * listFiles may generate undesireable "cannot find
+                 * the file specified".
+                 */
+                if( se.getNtStatus() != SmbException.NT_STATUS_NO_SUCH_FILE ) {
+                    throw se;
+                }
             }
 
             send( new SmbComDeleteDirectory( fileName ), blank_resp() );
index ec54b9f..56a6298 100644 (file)
@@ -55,7 +55,12 @@ public final class SmbSession {
 
     public static byte[] getChallenge( UniAddress dc )
                 throws SmbException, UnknownHostException {
-        SmbTransport trans = SmbTransport.getSmbTransport( dc, 0 );
+        return getChallenge(dc, 0);
+    }
+
+    public static byte[] getChallenge( UniAddress dc, int port )
+                throws SmbException, UnknownHostException {
+        SmbTransport trans = SmbTransport.getSmbTransport( dc, port );
         trans.negotiate();
         return trans.server.encryptionKey;
     }
@@ -72,7 +77,12 @@ public final class SmbSession {
  */
     public static void logon( UniAddress dc,
                         NtlmPasswordAuthentication auth ) throws SmbException {
-        SmbTransport.getSmbTransport( dc, 0 ).getSmbSession( auth ).getSmbTree( LOGON_SHARE, null ).treeConnect( null, null );
+        logon(dc, 0, auth);
+    }
+
+    public static void logon( UniAddress dc, int port,
+                        NtlmPasswordAuthentication auth ) throws SmbException {
+        SmbTransport.getSmbTransport( dc, port ).getSmbSession( auth ).getSmbTree( LOGON_SHARE, null ).treeConnect( null, null );
     }
 
     private int uid;
index 445825a..2fbc70f 100644 (file)
@@ -50,7 +50,7 @@ class SmbTransport implements Runnable {
     private static final int DEFAULT_RESPONSE_TIMEOUT = 10000;
     private static final int DEFAULT_SO_TIMEOUT = 15000;
     private static final int DEFAULT_RCV_BUF_SIZE = 60416;
-    private static final int DEFAULT_SND_BUF_SIZE = 5000;
+    private static final int DEFAULT_SND_BUF_SIZE = 16644;
     private static final int DEFAULT_SSN_LIMIT = 250;
 
     private static final InetAddress LADDR = Config.getInetAddress( "jcifs.smb.client.laddr", null );
@@ -451,7 +451,7 @@ synchronized( rcv_buf ) {
                                     log.println( smb );
                                 } while( smb instanceof AndXServerMessageBlock &&
                                             ( smb = ((AndXServerMessageBlock)smb).andx ) != null );
-                                if( log.level > 5 ) {
+                                    if( log.level > 5 ) {
                                     Hexdump.hexdump( log, rcv_buf, 0, Math.min( response.length, 1024 ));
                                 }
                             }
@@ -553,8 +553,8 @@ synchronized( rcv_buf ) {
         request.useUnicode = useUnicode;
 
         if( response == null ) {
-            try {
-                synchronized( outLock ) {
+            synchronized( outLock ) {
+                try {
                     mid = aquireMid();
                     request.mid = mid.mid;
                     ensureOpen();
@@ -564,10 +564,10 @@ synchronized( snd_buf ) {
                     int length = request.writeWireFormat(snd_buf, 4);
                     out.write(snd_buf, 4, length);
                     out.flush();
-
+    
                     if( log.level > 2 ) {
                         ServerMessageBlock smb = request;
-
+    
                         do {
                             log.println( smb );
                         } while( smb instanceof AndXServerMessageBlock &&
@@ -577,12 +577,10 @@ synchronized( snd_buf ) {
                         }
                     }
 }
-                }
-            } catch( IOException ioe ) {
-                tryClose( true );
-                throw new SmbException( "An error occured sending the request.", ioe );
-            } finally {
-                synchronized( outLock ) {
+                } catch( IOException ioe ) {
+                    tryClose( true );
+                    throw new SmbException( "An error occured sending the request.", ioe );
+                } finally {
                     releaseMid( mid );
                 }
             }
@@ -592,8 +590,8 @@ synchronized( snd_buf ) {
 
         // now for the normal case where response is not null
 
-        try {
-            synchronized( response ) {
+        synchronized( response ) {
+            try {
                 synchronized( outLock ) {
                     response.received = false;
                     mid = aquireMid();
@@ -608,10 +606,10 @@ synchronized( snd_buf ) {
                     int length = request.writeWireFormat(snd_buf, 4);
                     out.write(snd_buf, 4, length);
                     out.flush();
-
+    
                     if( log.level > 2 ) {
                         ServerMessageBlock smb = request;
-
+    
                         do {
                             log.println( smb );
                         } while( smb instanceof AndXServerMessageBlock &&
@@ -625,16 +623,16 @@ synchronized( snd_buf ) {
 
                 // default it 1 so that 0 can be used as forever
                 response.wait( response.responseTimeout == 1 ? RESPONSE_TIMEOUT : response.responseTimeout );
-            }
-        } catch( InterruptedException ie ) {
-            tryClose( true );
-        } catch( IOException ioe ) {
-            tryClose( true );
-            throw new SmbException( "An error occured sending the request.", ioe );
-        } finally {
-            synchronized( outLock ) {
+            } catch( InterruptedException ie ) {
+                tryClose( true );
+            } catch( IOException ioe ) {
+                tryClose( true );
+                throw new SmbException( "An error occured sending the request.", ioe );
+            } finally {
                 responseTable.remove( mid );
-                releaseMid( mid );
+                synchronized( outLock ) {
+                    releaseMid( mid );
+                }
             }
         }
 
@@ -694,91 +692,104 @@ synchronized( snd_buf ) {
                 SmbComBlankResponse interimResponse = new SmbComBlankResponse();
 
                 synchronized( interimResponse ) {
-                    synchronized( outLock ) {
-                        mid = aquireMid();
-                        request.mid = mid.mid;
-                        responseTable.put( mid, interimResponse );
-                        ensureOpen();
+                    try {
+                        synchronized( outLock ) {
+                            mid = aquireMid();
+                            request.mid = mid.mid;
+                            responseTable.put( mid, interimResponse );
+                            ensureOpen();
 synchronized(snd_buf) {
-                        request.digest = digest;
-                        request.response = response;
-                        int length = request.writeWireFormat(snd_buf, 4);
-                        out.write(snd_buf, 4, length);
-                        out.flush();
-
-                        if( log.level > 2 ) {
-                            log.println( request );
-                            if( log.level > 5 ) {
-                                Hexdump.hexdump( log, snd_buf, 0, request.length );
+                            request.digest = digest;
+                            request.response = response;
+                            int length = request.writeWireFormat(snd_buf, 4);
+                            out.write(snd_buf, 4, length);
+                            out.flush();
+    
+                            if( log.level > 2 ) {
+                                log.println( request );
+                                if( log.level > 5 ) {
+                                    Hexdump.hexdump( log, snd_buf, 0, request.length );
+                                }
                             }
-                        }
 }
-                    }
-
-                    interimResponse.wait( RESPONSE_TIMEOUT );
-
-                    if( interimResponse.received == false ) {
-                        throw new SmbException( "Timeout waiting for response from server: " + address );
-                    }
-                    interimResponse.errorCode = SmbException.getStatusByCode( interimResponse.errorCode );
-                    switch( interimResponse.errorCode ) {
-                        case NtStatus.NT_STATUS_OK:
-                            break;
-                        case NtStatus.NT_STATUS_ACCESS_DENIED:
-                        case NtStatus.NT_STATUS_WRONG_PASSWORD:
-                        case NtStatus.NT_STATUS_LOGON_FAILURE:
-                        case NtStatus.NT_STATUS_ACCOUNT_RESTRICTION:
-                        case NtStatus.NT_STATUS_INVALID_LOGON_HOURS:
-                        case NtStatus.NT_STATUS_INVALID_WORKSTATION:
-                        case NtStatus.NT_STATUS_PASSWORD_EXPIRED:
-                        case NtStatus.NT_STATUS_ACCOUNT_DISABLED:
-                        case NtStatus.NT_STATUS_ACCOUNT_LOCKED_OUT:
-                            throw new SmbAuthException( interimResponse.errorCode );
-                        case NtStatus.NT_STATUS_PATH_NOT_COVERED:
-                            if( request.auth == null ) {
+                        }
+    
+                        interimResponse.wait( RESPONSE_TIMEOUT );
+    
+                        if( interimResponse.received == false ) {
+                            throw new SmbException( "Timeout waiting for response from server: " + address );
+                        }
+                        interimResponse.errorCode = SmbException.getStatusByCode( interimResponse.errorCode );
+                        switch( interimResponse.errorCode ) {
+                            case NtStatus.NT_STATUS_OK:
+                                break;
+                            case NtStatus.NT_STATUS_ACCESS_DENIED:
+                            case NtStatus.NT_STATUS_WRONG_PASSWORD:
+                            case NtStatus.NT_STATUS_LOGON_FAILURE:
+                            case NtStatus.NT_STATUS_ACCOUNT_RESTRICTION:
+                            case NtStatus.NT_STATUS_INVALID_LOGON_HOURS:
+                            case NtStatus.NT_STATUS_INVALID_WORKSTATION:
+                            case NtStatus.NT_STATUS_PASSWORD_EXPIRED:
+                            case NtStatus.NT_STATUS_ACCOUNT_DISABLED:
+                            case NtStatus.NT_STATUS_ACCOUNT_LOCKED_OUT:
+                                throw new SmbAuthException( interimResponse.errorCode );
+                            case NtStatus.NT_STATUS_PATH_NOT_COVERED:
+                                if( request.auth == null ) {
+                                    throw new SmbException( interimResponse.errorCode, null );
+                                }
+                                DfsReferral dr = getDfsReferral( request.auth, request.path );
+                                referrals.add( dr );
+                                throw dr;
+                            default:
                                 throw new SmbException( interimResponse.errorCode, null );
-                            }
-                            DfsReferral dr = getDfsReferral( request.auth, request.path );
-                            referrals.add( dr );
-                            throw dr;
-                        default:
-                            throw new SmbException( interimResponse.errorCode, null );
+                        }
+                    } finally {
+                        responseTable.remove( mid );
+                        synchronized( outLock ) {
+                            releaseMid( mid );
+                        }
                     }
                 }
+
                 request.nextElement();
             }
 
             synchronized( response ) {
-                synchronized( outLock ) {
-                    mid = aquireMid();
-                    request.mid = mid.mid;
-                    responseTable.put( mid, response );
-                }
-                do {
+                try {
                     synchronized( outLock ) {
-                        ensureOpen();
+                        mid = aquireMid();
+                        request.mid = mid.mid;
+                        responseTable.put( mid, response );
+                        do {
+                            ensureOpen();
 synchronized( snd_buf ) {
-                        request.digest = digest;
-                        request.response = response;
-                        int length = request.writeWireFormat(snd_buf, 4);
-                        out.write(snd_buf, 4, length);
-                        out.flush();
-
-                        if( log.level > 2 ) {
-                            log.println( request );
-                            if( log.level > 5 ) {
-                                Hexdump.hexdump( log, snd_buf, 0, request.length );
+                            request.digest = digest;
+                            request.response = response;
+                            int length = request.writeWireFormat(snd_buf, 4);
+                            out.write(snd_buf, 4, length);
+                            out.flush();
+    
+                            if( log.level > 2 ) {
+                                log.println( request );
+                                if( log.level > 5 ) {
+                                    Hexdump.hexdump( log, snd_buf, 0, request.length );
+                                }
                             }
-                        }
 }
+                        } while( request.hasMoreElements() && request.nextElement() != null );
                     }
-                } while( request.hasMoreElements() && request.nextElement() != null );
 
-                do {
-                    // default it 1 so that 0 can be used as forever
-                    response.received = false;
-                    response.wait( response.responseTimeout == 1 ? RESPONSE_TIMEOUT : response.responseTimeout );
-                } while( response.received && response.hasMoreElements() );
+                    do {
+                        // default it 1 so that 0 can be used as forever
+                        response.received = false;
+                        response.wait( response.responseTimeout == 1 ? RESPONSE_TIMEOUT : response.responseTimeout );
+                    } while( response.received && response.hasMoreElements() );
+                } finally {
+                    responseTable.remove( mid );
+                    synchronized( outLock ) {
+                        releaseMid( mid );
+                    }
+                }
             }
         } catch( InterruptedException ie ) {
             tryClose( true );
@@ -786,10 +797,6 @@ synchronized( snd_buf ) {
             tryClose( true );
             throw new SmbException( "An error occured sending the request.", ioe );
         } finally {
-            synchronized( outLock ) {
-                responseTable.remove( mid );
-                releaseMid( mid );
-            }
             BufferCache.releaseBuffer( request.txn_buf );
             BufferCache.releaseBuffer( response.txn_buf );
         }