Updated CifsMounter to be able to connect from linux to an Alfresco CIFS server that is only running on NetBIOS.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4842 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gary Spencer
2007-01-16 10:15:56 +00:00
parent 32c9b1c7ea
commit 516471381d
3 changed files with 83 additions and 6 deletions

View File

@@ -16,9 +16,15 @@
*/ */
package org.alfresco.filesys.server.config; package org.alfresco.filesys.server.config;
import java.net.InetAddress;
import org.alfresco.filesys.smb.TcpipSMB; import org.alfresco.filesys.smb.TcpipSMB;
import org.alfresco.filesys.util.CifsMounter; import org.alfresco.filesys.util.CifsMounter;
import org.alfresco.filesys.util.Platform; import org.alfresco.filesys.util.Platform;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.sun.star.io.UnknownHostException;
/** /**
* File Server Configuration MBean Class * File Server Configuration MBean Class
@@ -30,6 +36,10 @@ import org.alfresco.filesys.util.Platform;
*/ */
public class FileServerConfig implements FileServerConfigMBean { public class FileServerConfig implements FileServerConfigMBean {
// Debug logging
private static final Log logger = LogFactory.getLog( FileServerConfig.class);
// File server configuration // File server configuration
private ServerConfiguration m_serverConfig; private ServerConfiguration m_serverConfig;
@@ -88,8 +98,7 @@ public class FileServerConfig implements FileServerConfigMBean {
*/ */
public boolean isNFSServerEnabled() public boolean isNFSServerEnabled()
{ {
// return m_serverConfig.isNFSServerEnabled(); return m_serverConfig.isNFSServerEnabled();
return false;
} }
/** /**
@@ -129,6 +138,15 @@ public class FileServerConfig implements FileServerConfigMBean {
CifsMounter cifsMounter = new CifsMounter(); CifsMounter cifsMounter = new CifsMounter();
cifsMounter.setServerName( getCIFSServerName()); cifsMounter.setServerName( getCIFSServerName());
// Set the server address if the global bind address has been set
if ( m_serverConfig.hasSMBBindAddress())
{
// Use the global CIFS server bind address
cifsMounter.setServerAddress( m_serverConfig.getSMBBindAddress().getHostAddress());
}
// Get the local platform type // Get the local platform type
Platform.Type platform = Platform.isPlatformType(); Platform.Type platform = Platform.isPlatformType();
@@ -153,7 +171,32 @@ public class FileServerConfig implements FileServerConfigMBean {
if ( m_serverConfig.hasWin32NetBIOS()) if ( m_serverConfig.hasWin32NetBIOS())
cifsMounter.setProtocolType( CifsMounter.Win32NetBIOS); cifsMounter.setProtocolType( CifsMounter.Win32NetBIOS);
else if ( m_serverConfig.hasNetBIOSSMB()) else if ( m_serverConfig.hasNetBIOSSMB())
{
// Set the protocol type for Java socket based NetBIOS
cifsMounter.setProtocolType( CifsMounter.NetBIOS); cifsMounter.setProtocolType( CifsMounter.NetBIOS);
// Check if the socket NetBIOS is bound to a particular address
if ( m_serverConfig.hasNetBIOSBindAddress())
cifsMounter.setServerAddress( m_serverConfig.getNetBIOSBindAddress().getHostAddress());
}
}
// Check if the CIFS mounter server address has been set, if not then get the local address
if ( cifsMounter.getServerAddress() == null)
{
// Set the CIFS mounter server address
try
{
cifsMounter.setServerAddress( InetAddress.getLocalHost().getHostAddress());
}
catch ( java.net.UnknownHostException ex)
{
logger.error( "Failed to get local IP address", ex);
}
} }
// Return the CIFS mounter // Return the CIFS mounter

View File

@@ -76,7 +76,6 @@ import org.alfresco.filesys.server.core.SharedDeviceList;
import org.alfresco.filesys.server.filesys.DefaultShareMapper; import org.alfresco.filesys.server.filesys.DefaultShareMapper;
import org.alfresco.filesys.server.filesys.DiskInterface; import org.alfresco.filesys.server.filesys.DiskInterface;
import org.alfresco.filesys.server.filesys.DiskSharedDevice; import org.alfresco.filesys.server.filesys.DiskSharedDevice;
import org.alfresco.filesys.server.oncrpc.DefaultRpcAuthenticator;
import org.alfresco.filesys.server.oncrpc.RpcAuthenticator; import org.alfresco.filesys.server.oncrpc.RpcAuthenticator;
import org.alfresco.filesys.smb.ServerType; import org.alfresco.filesys.smb.ServerType;
import org.alfresco.filesys.smb.TcpipSMB; import org.alfresco.filesys.smb.TcpipSMB;

View File

@@ -56,8 +56,9 @@ public class CifsMounter {
private static final String LinuxMountSmbfsCmd = "mount -t smbfs //${srvname}/${sharename} ${mountpoint} -o username=${username},password=${password}"; private static final String LinuxMountSmbfsCmd = "mount -t smbfs //${srvname}/${sharename} ${mountpoint} -o username=${username},password=${password}";
private static final String LinuxMountCifsCmd = "mount -t cifs //${srvname}/${sharename} ${mountpoint} -o username=${username},password=${password}"; private static final String LinuxMountCifsCmd = "mount -t cifs //${srvname}/${sharename} ${mountpoint} -o username=${username},password=${password}";
private static final String LinuxMountCifsNBCmd = "mount.cifs //${srvname}/${sharename} ${mountpoint} -o servern=${srvname},port=139,username=${username},password=${password}";
private static final String LinuxUnMountCmd = "umount ${mountpoint}"; private static final String LinuxUnMountCmd = "umount ${mountpoint}";
// Mac OS X mount/unmount commands // Mac OS X mount/unmount commands
private static final String MacOSXMountCmd = "mount_smbfs -U ${username} //${password}@${srvname}/${sharename} ${mountpoint}"; private static final String MacOSXMountCmd = "mount_smbfs -U ${username} //${password}@${srvname}/${sharename} ${mountpoint}";
@@ -68,6 +69,10 @@ public class CifsMounter {
private String m_srvName; private String m_srvName;
private String m_shareName; private String m_shareName;
// Server address
private String m_srvAddr;
// Access details for remote share // Access details for remote share
private String m_userName; private String m_userName;
@@ -159,9 +164,19 @@ public class CifsMounter {
} }
else else
{ {
// Set the command line to use the older smbfs VFS mounter to connect using NetBIOS // Set the command line to use the CIFS VFS mounter to connect using NetBIOS
commandMap.put( "Linux", LinuxMountSmbfsCmd); StringBuilder cmd = new StringBuilder( LinuxMountCifsNBCmd);
if ( getServerAddress() != null)
{
cmd.append( ",ip=");
cmd.append( getServerAddress());
}
// Set the command line
commandMap.put( "Linux", cmd.toString());
} }
break; break;
@@ -287,6 +302,16 @@ public class CifsMounter {
{ {
return m_srvName; return m_srvName;
} }
/**
* Return hte server address
*
* @return String
*/
public final String getServerAddress()
{
return m_srvAddr;
}
/** /**
* Return the share name * Return the share name
@@ -348,6 +373,16 @@ public class CifsMounter {
m_srvName = name; m_srvName = name;
} }
/**
* Set the server address
*
* @param srvAddr String
*/
public final void setServerAddress(String srvAddr)
{
m_srvAddr = srvAddr;
}
/** /**
* Set the share name * Set the share name
* *