AnsweredAssumed Answered

Starting CIFS server (JLAN) with programmatic (non-XML) config

Question asked by gubby on Oct 22, 2014
Latest reply on Oct 22, 2014 by gubby
Has anybody successfully run the JLAN CIFS server stand-alone, with all configuration done programmatically rather than via .properties, xml, files, etc?

There doesn't seem to be any documentation on this, and various things I have tried yield NullPointerExceptions deep from the bowels of the server.

The closest I got to a working config is below, which allowed connections, but after authenticating gave an error to the effect that there were no valid shares on this server. The code is a bit of a hacked-up mess, but because I couldn't find any documentation, and there isn't much Javadoc, it was the best I could do.


DiskInterface disk = new JavaFileDiskDriver();

ConfigElement configElement = new ConfigElement("", "") {
   @Override
   public ConfigElement getChild(String name) {
      if ("LocalPath".equals(name)) {
         return new ConfigElement("", "/tmp/cifs");
      }
      throw new IllegalArgumentException("Name " + name);
   }
};

DiskDeviceContext context = (DiskDeviceContext) disk.createContext("theContext", configElement);  // Should be static

ServerConfiguration config = new ServerConfiguration("config");

CIFSConfigSection cifs = new CIFSConfigSection(config);
cifs.setHostAnnouncer(false);
cifs.setNetBIOSSMB(false);
cifs.setNetBIOSDebug(true);
cifs.setTcpipSMB(true);
cifs.setTcpipSMBPort(5000);
cifs.setAuthenticator(new DefaultAuthenticator()); // Allows any user
cifs.setServerName("Test Server");
cifs.setDomainName("Test Domain");

FilesystemsConfigSection filesystems = new FilesystemsConfigSection(config);
final DiskSharedDevice dev = new DiskSharedDevice("TheDisk", disk, context);
filesystems.addShare(dev);

GlobalConfigSection global = new GlobalConfigSection(config);

CoreServerConfigSection core = new CoreServerConfigSection(config);
core.setThreadPool(2, 8);
core.setMemoryPool(DefaultMemoryPoolBufSizes, DefaultMemoryPoolInitAlloc, DefaultMemoryPoolMaxAlloc);

SecurityConfigSection security = new SecurityConfigSection(config);
security.setShareMapper(new DefaultShareMapper() {
   @Override
   public SharedDeviceList getShareList(String host, SrvSession sess, boolean allShares) {
      SharedDeviceList list = new SharedDeviceList();
      list.addShare(dev);
      return list;
   }
});

Outcomes