+Sun Jan 16 17:30:17 EST 2005
+jcifs-1.1.7 released
+
+A bug introduced in a recent release that could cause threads to wait
+indefinately has been fixed. After time many threads could be blocked
+resulting in wasted resources. The DC lookup code has been modified to
+gracefully handle WINS returning an empty list (e.g. due to temporary
+network failure). A simple fix has been applied that premits SMB signatures
+to work without specifying preauthentication credentials. The getAttributes
+method will now return 31 bits of attributes whereas previously it would
+mask off the lower 6 bits that JCIFS actually makes use of. A bug has been
+fixed that under certain conditions prevented copyTo() from copying entire
+shares. A try/catch block has been added to copyTo() to permit the copy to
+continue if an error occurs.
+
Mon Dec 27 17:53:42 EST 2004
jcifs-1.1.6 released
<project name="jcifs" default="usage" basedir=".">
- <property name="version" value="1.1.6"/>
- <property name="reldate" value="Dec 27, 2004"/>
+ <property name="version" value="1.1.7"/>
+ <property name="reldate" value="Jan 16, 2005"/>
<target name="usage">
<echo>
--- /dev/null
+import jcifs.netbios.NbtAddress;
+import jcifs.*;
+import jcifs.smb.*;
+
+public class CheckAllDC {
+
+ public static void main( String argv[] ) throws Exception {
+
+ if( argv.length < 2 ) {
+ System.err.println( "usage: CheckAllDC <domain> <dom;user:pass>" );
+ System.exit(1);
+ }
+
+ NbtAddress[] addrs = NbtAddress.getAllByName( argv[0], 0x1C, null, null );
+
+ for( int i = 0; i < addrs.length; i++ ) {
+ System.out.println( addrs[i] );
+ UniAddress dc = new UniAddress( addrs[i] );
+ NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication( argv[1] );
+ SmbSession.logon( dc, auth );
+ }
+ }
+}
--- /dev/null
+import jcifs.smb.SmbFile;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.net.MalformedURLException;
+import java.io.IOException;
+import jcifs.util.Hexdump;
+
+public class CountPerms {
+
+ int maxDepth;
+ int numFiles;
+ int numDirectories;
+ int numMeta;
+ int numMetaWithArch;
+
+ int[] permissionCounts = new int[16];
+
+ String[] permissionNames = {
+ "Read Only",
+ "Hidden",
+ "System",
+ "Volume ID",
+ "Directory",
+ "Archive",
+ "Device",
+ "Normal",
+ "Temporary",
+ "Sparse",
+ "Reparse Point",
+ "Compressed",
+ "Offline",
+ "Content Indexed",
+ "Encrypted",
+ "Unknown"
+ };
+
+ CountPerms( int maxDepth ) {
+ this.maxDepth = maxDepth;
+ }
+
+ void traverse( SmbFile f, int depth ) throws MalformedURLException, IOException {
+
+ if( depth == 0 ) {
+ return;
+ }
+
+ SmbFile[] l = f.listFiles();
+
+ for(int i = 0; l != null && i < l.length; i++ ) {
+ try {
+ int attrs = l[i].getAttributes();
+
+ if(( attrs & 0x7FEE ) != 0) {
+ if(( attrs & 0x7FCE ) != 0) {
+ numMeta++;
+ }
+ numMetaWithArch++;
+ }
+ for (int b = 0; b < 16; b++) {
+ if(( attrs & (1 << b)) != 0 ) {
+ permissionCounts[b]++;
+ }
+ }
+
+ System.out.print( Hexdump.toHexString( l[i].getAttributes(), 4 ) + ": " );
+ for( int j = maxDepth - depth; j > 0; j-- ) {
+ System.out.print( " " );
+ }
+ System.out.println( l[i].getName() );
+ if( l[i].isDirectory() ) {
+ traverse( l[i], depth - 1 );
+ }
+
+ if(( attrs & SmbFile.ATTR_DIRECTORY ) != 0 ) {
+ numDirectories++;
+ } else {
+ numFiles++;
+ }
+ } catch( IOException ioe ) {
+ System.out.println( l[i] + ": " + ioe.getMessage() );
+ }
+ }
+ }
+
+ void run( String url ) throws Exception {
+ traverse( new SmbFile( url ), maxDepth );
+
+ for (int p = 0; p < 16; p++) {
+ int len = 15 - permissionNames[p].length();
+ while( len > 0 ) {
+ System.out.print( " " );
+ len--;
+ }
+ System.out.println( permissionNames[p] + ": " + permissionCounts[p] );
+ }
+ System.out.println( " num files: " + numFiles );
+ System.out.println( " num directories: " + numDirectories );
+ System.out.println( " num both: " + (numFiles + numDirectories) );
+ System.out.println( " meta req: " + numMeta );
+ System.out.println( "meta (incl. arch) req: " + numMetaWithArch );
+ }
+
+ public static void main(String[] argv) throws Exception {
+
+ if( argv.length < 2 ) {
+ System.err.println( "usage: CountPerms <dir> <maxdepth>" );
+ System.exit(1);
+ }
+
+ int depth = Integer.parseInt( argv[1] );
+ CountPerms cp = new CountPerms( depth );
+ cp.run( argv[0] );
+ }
+}
import jcifs.netbios.NbtAddress;
+import jcifs.*;
+import jcifs.smb.*;
-public class ListDC {
+public class CheckAllDC {
public static void main( String argv[] ) throws Exception {
for( int i = 0; i < addrs.length; i++ ) {
System.out.println( addrs[i] );
+ UniAddress dc = new UniAddress( addrs[i] );
+ NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication( argv[1] );
+ SmbSession.logon( dc, auth );
}
}
}
--- /dev/null
+import jcifs.smb.*;
+
+public class TestCopy {
+
+ public static void main( String[] args ) throws Exception {
+
+ if( args.length < 1 ) {
+ System.err.println( "usage: TestCopy <from1> <to1> [<from2> <to2> [<from3 ...]]");
+ System.exit(1);
+ }
+
+ for( int i = 0; i < args.length; i += 2 ) {
+ try {
+ SmbFile remote = new SmbFile( args[i] );
+ if( remote.exists() ) {
+ SmbFile local = new SmbFile( args[i + 1] );
+ remote.copyTo( local );
+ }
+ } catch( Exception e ) {
+ System.err.println( args[i] + " -> " + args[i + 1] );
+ e.printStackTrace();
+ }
+ }
+ }
+}
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", "");
+ Config.getProperty("jcifs.smb.client.password", BLANK);
private static final Random RANDOM = new Random();
static final int ATTR_NORMAL = 0x080;
static final int ATTR_TEMPORARY = 0x100;
- static final int ATTR_GET_MASK = 0x3F;
+ static final int ATTR_GET_MASK = 0x7FFF;
static final int ATTR_SET_MASK = 0x27;
static final int DEFAULT_ATTR_EXPIRATION_PERIOD = 5000;
SmbFile[] files;
SmbFile ndest;
- try {
- dest.mkdir();
- dest.setPathInformation( attributes, createTime, lastModified );
- } catch( SmbException se ) {
- if( se.getNtStatus() != NtStatus.NT_STATUS_ACCESS_DENIED &&
- se.getNtStatus() != NtStatus.NT_STATUS_OBJECT_NAME_COLLISION ) {
- throw se;
+ String path = dest.getUncPath0();
+ if( path.length() > 1 ) {
+ try {
+ dest.mkdir();
+ dest.setPathInformation( attributes, createTime, lastModified );
+ } catch( SmbException se ) {
+ if( se.getNtStatus() != NtStatus.NT_STATUS_ACCESS_DENIED &&
+ se.getNtStatus() != NtStatus.NT_STATUS_OBJECT_NAME_COLLISION ) {
+ throw se;
+ }
}
}
} else {
int off;
+try {
open( SmbFile.O_RDONLY, ATTR_NORMAL, 0 );
try {
dest.open( SmbFile.O_CREAT | SmbFile.O_WRONLY | SmbFile.O_TRUNC |
new Trans2SetFileInformationResponse() );
dest.close( 0L );
close();
+} catch( Exception ex ) {
+ if( log.level > 1 )
+ ex.printStackTrace( log );
+}
}
}
/**
public InputStream getInputStream() throws IOException {
return new SmbFileInputStream( this );
}
+
+/**
+ * This URLConnection method just returns a new <tt>SmbFileOutputStream</tt> created with this file.
+ *
+ * @throw IOException thrown by <tt>SmbFileOutputStream</tt> constructor
+ */
+ public OutputStream getOutputStream() throws IOException {
+ return new SmbFileOutputStream( this );
+ }
}
}
NbtAddress[] new_dc_list = NbtAddress.getAllByName( DOMAIN, 0x1C, null, null );
- if( new_dc_list != null && new_dc_list.length >= dc_list_range ) {
+ if( new_dc_list == null) {
+ dc_list_expiration = System.currentTimeMillis() + 10000; /* 10sec */
+ throw new UnknownHostException( DOMAIN );
+ } else if( new_dc_list.length >= dc_list_range ) {
dc_list = new_dc_list;
}
if( dc_list_range > 1 ) {
* Only the first SMB_COM_SESSION_SETUP_ANX with creds other than NULL initializes signing.
*/
if( transport.isSignatureSetupRequired( auth )) {
- if( auth.hashesExternal && NtlmPasswordAuthentication.DEFAULT_PASSWORD != null ) {
+ if( auth.hashesExternal && NtlmPasswordAuthentication.DEFAULT_PASSWORD != NtlmPasswordAuthentication.BLANK ) {
/* preauthentication
*/
transport.getSmbSession( NtlmPasswordAuthentication.DEFAULT ).getSmbTree( LOGON_SHARE, null ).treeConnect( null, null );
}
state = ST_NEGOTIATED;
+ notifyAll();
}
public String toString() {
String ret = "SmbTransport[address=" + address;