Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340943 - glogin overwrites blindly org.globus.ip (GLOBUS_HOSTNAME) system property
Summary: glogin overwrites blindly org.globus.ip (GLOBUS_HOSTNAME) system property
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Geclipse (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Thomas Kockerbauer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-25 06:37 EDT by una_ansia CLA
Modified: 2014-01-09 16:01 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description una_ansia CLA 2011-03-25 06:37:02 EDT
Build Identifier: I20080617-2000

I am writing an eclipse plugin which sets the port range and a public ip address as org.globus.ip system property. Supposedly, I can connect to the grid with those settings after that. However, when glogin connection is performed, the glogin code just overwrites the org.globus.ip system property withouth ever reading it or using it. I believe the code should first check the property and if set, use it. Please advise!

Code example from eu.geclipse.glogin.internal.Job:

void gssexec(final String host, final String exec, final int  port,
               final String additionalRsl, final boolean do_staging,
               final boolean do_exec, final boolean forceTTY,
               final boolean disableEncryption, final String command,
               final boolean useHandshakeFileParam, final IProgressMonitor monitor )
               throws InterruptedException, IOException, ProblemException {
    boolean useHandshakeFile = useHandshakeFileParam;
    try {
      InetAddress localAddress = null;
      Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
      while(interfaces.hasMoreElements()){
        NetworkInterface ni = interfaces.nextElement();
        Enumeration<InetAddress> localAddresses = ni.getInetAddresses();
        while (localAddresses.hasMoreElements()) {
          InetAddress address = localAddresses.nextElement();
          if( !address.isSiteLocalAddress() && !address.isLoopbackAddress()
              && address instanceof Inet4Address ){
            localAddress = address;
          }
        }
      }
      if (localAddress == null) {
        if (!useHandshakeFile) {
          Activator.logMessage( IStatus.INFO, Messages.getString( "Job.couldNotDeterminePublicIpAddress" ) ); //$NON-NLS-1$
        }
        useHandshakeFile = true;
        localAddress = InetAddress.getLocalHost(); // just to have any address
      }
      System.setProperty( "org.globus.ip", localAddress.getHostAddress() ); //$NON-NLS-1$
      .......

Reproducible: Always
Comment 1 Thomas Kockerbauer CLA 2011-04-07 17:01:38 EDT
This code was introduced because the globus cog-kit fails to determine the external ip address on linux in case the hostname does not match the DNS entry (and then, if I remember correctly, uses the address of the loopback device which caused the glogin connection attempts to fail). This required to adjust the hostname in order to use glogin in such a case. This code is a workaround that tries to find the ip address of the external interface and sets it using the "org.globus.ip" property in order to avoid the ip-address detection of the cog-kit, and the need to change the hostname (the cog-kit checks for that property and uses the set value if present).

See the following diff:
Job.java - Revision 1.34 - "changed glogin job submission to search the public ip address of the machine in the network interface list (required for submitting glogin from linux without changing the hostname)"
http://savannah.fzk.de/cgi-bin/viewcvs.cgi/fzk/geclipse/geclipse/development/eu.geclipse.glogin/src/eu/geclipse/glogin/internal/Job.java?r1=1.33&r2=1.34

You can safely remove this code if you do not have such a configuration - or if you make sure that this property is set to the external interface. You are right that it might be better to first check if this property was already set and in that case skip the workaround.
Comment 2 una_ansia CLA 2011-05-10 05:07:14 EDT
Hello Thomas,

Can I prupose a change then. It seems to be working. I just added a check whether the property is already set and if set skip the overwriting part. 

void gssexec(final String host, final String exec, final int  port,
               final String additionalRsl, final boolean do_staging,
               final boolean do_exec, final boolean forceTTY,
               final boolean disableEncryption, final String command,
               final boolean useHandshakeFileParam, final IProgressMonitor monitor )
               throws InterruptedException, IOException, ProblemException {
    boolean useHandshakeFile = useHandshakeFileParam;
    try {
      InetAddress localAddress = null;
      localAddress = InetAddress.getByName(System.getProperty("org.globus.ip"));
   
      
      if(localAddress == null || localAddress.isSiteLocalAddress() || localAddress.isLoopbackAddress() 
    		  || localAddress.isLoopbackAddress() || !(localAddress instanceof Inet4Address)){
    	  
	      Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
	      while(interfaces.hasMoreElements()){
	        NetworkInterface ni = interfaces.nextElement();
	        Enumeration<InetAddress> localAddresses = ni.getInetAddresses();
	        while (localAddresses.hasMoreElements()) {
	          InetAddress address = localAddresses.nextElement();
	          if( !address.isSiteLocalAddress() && !address.isLoopbackAddress()
	              && address instanceof Inet4Address ){
	            localAddress = address;
	          }
	        }
	      }
	      if (localAddress == null) {
	        if (!useHandshakeFile) {
	          Activator.logMessage( IStatus.INFO, Messages.getString( "Job.couldNotDeterminePublicIpAddress" ) ); //$NON-NLS-1$
	        }
	        useHandshakeFile = true;
	        localAddress = InetAddress.getLocalHost(); // just to have any address
	      }
	      System.setProperty( "org.globus.ip", localAddress.getHostAddress() ); //$NON-NLS-1$
      }


(In reply to comment #1)
> This code was introduced because the globus cog-kit fails to determine the
> external ip address on linux in case the hostname does not match the DNS entry
> (and then, if I remember correctly, uses the address of the loopback device
> which caused the glogin connection attempts to fail). This required to adjust
> the hostname in order to use glogin in such a case. This code is a workaround
> that tries to find the ip address of the external interface and sets it using
> the "org.globus.ip" property in order to avoid the ip-address detection of the
> cog-kit, and the need to change the hostname (the cog-kit checks for that
> property and uses the set value if present).
> 
> See the following diff:
> Job.java - Revision 1.34 - "changed glogin job submission to search the public
> ip address of the machine in the network interface list (required for
> submitting glogin from linux without changing the hostname)"
> http://savannah.fzk.de/cgi-bin/viewcvs.cgi/fzk/geclipse/geclipse/development/eu.geclipse.glogin/src/eu/geclipse/glogin/internal/Job.java?r1=1.33&r2=1.34
> 
> You can safely remove this code if you do not have such a configuration - or if
> you make sure that this property is set to the external interface. You are
> right that it might be better to first check if this property was already set
> and in that case skip the workaround.
Comment 3 Thomas Kockerbauer CLA 2011-05-12 14:43:48 EDT
Thank you for the patch. I've applied it to the CVS repository.
Comment 4 una_ansia CLA 2011-05-17 04:12:20 EDT
Thank you!

(In reply to comment #3)
> Thank you for the patch. I've applied it to the CVS repository.