Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Brandys2011-01-12 06:03:49 -0500
committerSzymon Brandys2011-01-12 06:03:49 -0500
commit52749f9b26fbe97b69960df7978291715dab4e7e (patch)
tree894e14616c62ff2e9fbc47fd3980bd453060b6f7
parentce6331139e391c12cf07edc6394b7b0c5537041c (diff)
downloadeclipse.platform.team-52749f9b26fbe97b69960df7978291715dab4e7e.tar.gz
eclipse.platform.team-52749f9b26fbe97b69960df7978291715dab4e7e.tar.xz
eclipse.platform.team-52749f9b26fbe97b69960df7978291715dab4e7e.zip
bug 294925 - Wrong Default SSH Directory
-rw-r--r--bundles/org.eclipse.jsch.core/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/IConstants.java6
-rw-r--r--bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/PreferenceInitializer.java60
3 files changed, 54 insertions, 14 deletions
diff --git a/bundles/org.eclipse.jsch.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.jsch.core/META-INF/MANIFEST.MF
index 0bf9e09f8..3094f8d84 100644
--- a/bundles/org.eclipse.jsch.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.jsch.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jsch.core;singleton:=true
-Bundle-Version: 1.1.200.qualifier
+Bundle-Version: 1.1.300.qualifier
Bundle-Activator: org.eclipse.jsch.internal.core.JSchCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/IConstants.java b/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/IConstants.java
index ce7f29e29..5ec77eb89 100644
--- a/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/IConstants.java
+++ b/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/IConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -39,6 +39,9 @@ public interface IConstants{
public static final String RSA="RSA"; //$NON-NLS-1$
public static final int SSH_DEFAULT_PORT=22;
+ public static final String SSH_DEFAULT_HOME=".ssh"; //$NON-NLS-1$
+ public static final String SSH_OLD_DEFAULT_WIN32_HOME="ssh"; //$NON-NLS-1$
+ public static final String SYSTEM_PROPERTY_USER_HOME="user.home"; //$NON-NLS-1$
public final String PREF_USE_PROXY="proxyEnabled"; //$NON-NLS-1$
public final String PREF_PROXY_TYPE="proxyType"; //$NON-NLS-1$
@@ -47,6 +50,7 @@ public interface IConstants{
public final String PREF_PROXY_AUTH="proxyAuth"; //$NON-NLS-1$
public final String PREF_HAS_MIGRATED_SSH2_PREFS="org.eclipse.jsch.core.hasMigratedSsh2Preferences"; //$NON-NLS-1$
+ public final String PREF_HAS_CHANGED_DEFAULT_WIN32_SSH_HOME="org.eclipse.jsch.core.hasChangedDefaultWin32SshHome"; //$NON-NLS-1$
public static final String PREF_PREFERRED_AUTHENTICATION_METHODS="CVSSSH2PreferencePage.PREF_AUTH_METHODS"; //$NON-NLS-1$
public static final String PREF_PREFERRED_AUTHENTICATION_METHODS_ORDER="CVSSSH2PreferencePage.PREF_AUTH_METHODS_ORDER"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/PreferenceInitializer.java b/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/PreferenceInitializer.java
index 57c990065..e15c37003 100644
--- a/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/PreferenceInitializer.java
+++ b/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/PreferenceInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,30 +11,66 @@
*******************************************************************************/
package org.eclipse.jsch.internal.core;
+import java.io.File;
+
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.preferences.*;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.osgi.service.prefs.BackingStoreException;
public class PreferenceInitializer extends AbstractPreferenceInitializer{
public static String SSH_HOME_DEFAULT=null;
static{
- String ssh_dir_name=".ssh"; //$NON-NLS-1$
-
- // Windows doesn't like files or directories starting with a dot.
- if(Platform.getOS().equals(Platform.OS_WIN32)){
- ssh_dir_name="ssh"; //$NON-NLS-1$
- }
- SSH_HOME_DEFAULT=System.getProperty("user.home"); //$NON-NLS-1$
+ SSH_HOME_DEFAULT=System.getProperty(IConstants.SYSTEM_PROPERTY_USER_HOME);
if(SSH_HOME_DEFAULT!=null){
- SSH_HOME_DEFAULT=SSH_HOME_DEFAULT+java.io.File.separator+ssh_dir_name;
+ SSH_HOME_DEFAULT=SSH_HOME_DEFAULT+File.separator
+ +IConstants.SSH_DEFAULT_HOME;
}
}
-
+
public void initializeDefaultPreferences(){
- IEclipsePreferences defaultNode=new DefaultScope().getNode(JSchCorePlugin.ID);
+ IEclipsePreferences defaultNode=DefaultScope.INSTANCE
+ .getNode(JSchCorePlugin.ID);
defaultNode.put(IConstants.KEY_SSH2HOME, SSH_HOME_DEFAULT);
defaultNode.put(IConstants.KEY_PRIVATEKEY, IConstants.PRIVATE_KEYS_DEFAULT);
Utils.migrateSSH2Preferences();
+ changeDefaultWin32SshHome();
}
+ private void changeDefaultWin32SshHome(){
+ if(!Platform.getOS().equals(Platform.OS_WIN32))
+ return;
+
+ IEclipsePreferences preferences=InstanceScope.INSTANCE
+ .getNode(JSchCorePlugin.ID);
+ boolean verified=preferences.getBoolean(
+ IConstants.PREF_HAS_CHANGED_DEFAULT_WIN32_SSH_HOME, false);
+ if(!verified){
+ if(null==preferences.get(IConstants.KEY_SSH2HOME, null)){
+ String userHome=System
+ .getProperty(IConstants.SYSTEM_PROPERTY_USER_HOME);
+ if(userHome!=null){
+ String oldSshHome=userHome+File.separator
+ +IConstants.SSH_OLD_DEFAULT_WIN32_HOME;
+ File file=new File(oldSshHome);
+ if(file.exists())
+ preferences.put(IConstants.KEY_SSH2HOME, oldSshHome);
+ }
+ preferences.putBoolean(
+ IConstants.PREF_HAS_CHANGED_DEFAULT_WIN32_SSH_HOME, true);
+ try{
+ preferences.flush();
+ }
+ catch(BackingStoreException e){
+ JSchCorePlugin.log(new Status(IStatus.INFO, JSchCorePlugin.ID,
+ "Could not flush preferences.", e)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
}

Back to the top