}
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 {
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 );
/* 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() );
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 );
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 ));
}
}
request.useUnicode = useUnicode;
if( response == null ) {
- try {
- synchronized( outLock ) {
+ synchronized( outLock ) {
+ try {
mid = aquireMid();
request.mid = mid.mid;
ensureOpen();
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 &&
}
}
}
- }
- } 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 );
}
}
// now for the normal case where response is not null
- try {
- synchronized( response ) {
+ synchronized( response ) {
+ try {
synchronized( outLock ) {
response.received = false;
mid = aquireMid();
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 &&
// 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 );
+ }
}
}
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 );
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 );
}